diff --git a/.clang-format b/.clang-format index fa7abd0654..2f8961f913 100644 --- a/.clang-format +++ b/.clang-format @@ -46,13 +46,17 @@ ConstructorInitializerIndentWidth: 0 # DisableFormat: false # ExperimentalAutoDetectBinPacking: false # ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] -# IncludeCategories: -# - Regex: '^"(llvm|llvm-c|clang|clang-c)/' -# Priority: 2 -# - Regex: '^(<|"(gtest|isl|json)/)' -# Priority: 3 -# - Regex: '.*' -# Priority: 1 +SortIncludes: true +#IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^(<|"(QtCore|QtWidgets|QtGui|QtNetwork)/)' + Priority: 5 + - Regex: '^"(SIMPL|llvm-c|clang|clang-c)/' + Priority: 100 + - Regex: '^"(SIMPLib/SIMPLib)' + Priority: 90 + - Regex: '.*' + Priority: 1000 # IndentCaseLabels: false # IndentWidth: 2 # IndentWrappedFunctionNames: false @@ -72,7 +76,6 @@ ConstructorInitializerIndentWidth: 0 # PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Left # ReflowComments: true -# SortIncludes: true # SpaceAfterCStyleCast: false # SpaceBeforeAssignmentOperators: true SpaceBeforeParens: Never @@ -83,7 +86,7 @@ SpaceBeforeParens: Never # SpacesInCStyleCastParentheses: false # SpacesInParentheses: false # SpacesInSquareBrackets: false -# Standard: Cpp11 +Standard: Cpp11 TabWidth: 2 UseTab: Never ... diff --git a/.clang-tidy b/.clang-tidy index 9ece682801..aec8266d45 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,4 +1,4 @@ -Checks: '-*,modernize-use-nullptr,modernize-deprecated-headers,modernize-shrink-to-fit,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-override,modernize-use-equals-default,readability-avoid-const-params-in-decls,readability-braces-around-statements,readability-container-size-empty,readability-delete-null-pointer,readability-else-after-return,readability-implicit-bool-conversion,readability-redundant-control-flow,readability-redundant-declaration,readability-redundant-function-ptr-dereference,readability-redundant-member-init,readability-redundant-smartptr-get,readability-redundant-string-cstr,readability-redundant-string-init,readability-simplify-boolean-expr,readability-simplify-subscript-expr,readability-static-accessed-through-instance,readability-static-definition-in-anonymous-namespace,readability-string-compare' +Checks: '-*,modernize-use-nullptr,modernize-deprecated-headers,modernize-shrink-to-fit,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-override,modernize-use-equals-default,readability-avoid-const-params-in-decls,readability-braces-around-statements,readability-container-size-empty,readability-delete-null-pointer,readability-else-after-return,readability-implicit-bool-conversion,readability-redundant-control-flow,readability-redundant-declaration,readability-redundant-function-ptr-dereference,readability-redundant-member-init,readability-redundant-smartptr-get,readability-redundant-string-cstr,readability-redundant-string-init,readability-simplify-boolean-expr,readability-simplify-subscript-expr,readability-static-accessed-through-instance,readability-static-definition-in-anonymous-namespace,readability-string-compare,bugprone-unused-return-value' WarningsAsErrors: '' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml new file mode 100644 index 0000000000..59087d88bc --- /dev/null +++ b/.github/workflows/clang-format.yml @@ -0,0 +1,23 @@ +name: clang-format check + +on: + pull_request: + branches: [ develop ] + push: + branches: [ develop ] + +jobs: + clang_format_check: + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - name: Run clang-format on diff + run: ./Support/Scripts/run_clang_format_diff.sh HEAD^ HEAD diff --git a/.gitignore b/.gitignore index 9a2ece8b74..de4437846f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ CMakeLists.txt.* /Build-ninja/ /Build-Xcode/ /zRel/ +/Release/ /CleanBuild/ .cproject .project @@ -27,3 +28,5 @@ Support/Scripts/GMT/gmt.history .vscode /ExternalProjects .DS_Store +**/.mypy_cache/** +**/__pycache__/** diff --git a/CMakeLists.txt b/CMakeLists.txt index 24e7bcd545..b3c32c17ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,17 +24,17 @@ if(NOT "${DREAM3D_SDK}" STREQUAL "") endif() endif() -# Request C++11 standard, using new CMake variables. -set(CMAKE_CXX_STANDARD 14) +# Request C++17 standard, using new CMake variables. +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_EXTENSIONS False) -cmake_minimum_required(VERSION 3.13.0) +cmake_minimum_required(VERSION 3.14.0) #------------------------------------------------------------------------------ # Create the Top level Project # -project(SIMPLProj VERSION 1.2.0.0) +project(SIMPLProj VERSION 2.0.0.0) # ---------- Setup output Directories ------------------------- if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) @@ -82,6 +82,18 @@ if(NOT EXISTS "${CMP_SOURCE_DIR}") message(FATAL_ERROR "CMP_SOURCE_DIR does not exist at '${CMP_SOURCE_DIR}'") endif() +#------------------------------------------------------------------------------ +# If the developer has set another H5Support directory then use that, otherwise look +# for the H5Support directory at the same level as the SIMPL directory +if("${H5Support_SOURCE_DIR}" STREQUAL "") + set(H5Support_SOURCE_DIR ${SIMPL_PARENT}/H5Support) + message(STATUS "H5Support_SOURCE_DIR: ${H5Support_SOURCE_DIR}") +endif() + +if(NOT EXISTS "${H5Support_SOURCE_DIR}") + message(FATAL_ERROR "H5Support_SOURCE_DIR does not exist at '${H5Support_SOURCE_DIR}'") +endif() + #------------------------------------------------------------------------------ # There are several different Release Types that we are going to use. @@ -260,7 +272,8 @@ endif() set(SIMPL_USE_EIGEN "") Find_Package(Eigen3 REQUIRED) if(EIGEN3_FOUND) - message(STATUS "Eigen3: ${EIGEN3_VERSION_STRING}") + message(STATUS "Eigen3 Location: ${EIGEN3_ROOT_DIR}") + message(STATUS "Eigen3 Version: ${EIGEN3_VERSION_STRING}") set(SIMPL_USE_EIGEN "1" CACHE INTERNAL "") else() message(WARNING "The Eigen Library is required for some algorithms to execute. These algorithms will be disabled.") @@ -274,8 +287,7 @@ set(SIMPL_Qt5_COMPONENTS Core Network) if( SIMPL_Group_WIDGETS) set(SIMPL_Qt5_COMPONENTS Core Widgets Network Gui Concurrent Svg Xml OpenGL PrintSupport) endif() -set(USE_QtWebEngine FALSE) -CMP_AddQt5Support( "${SIMPL_Qt5_COMPONENTS}" "${USE_QtWebEngine}" "${SIMPLProj_BINARY_DIR}" "SIMPL") +CMP_AddQt5Support( "${SIMPL_Qt5_COMPONENTS}" "${SIMPLProj_BINARY_DIR}" "SIMPL") # -------------------------------------------------------------------- # Should we use enable NTFS file checking on Windows @@ -300,7 +312,6 @@ if("${DREAM3D_PACKAGE_DEST_PREFIX}" STREQUAL "") set(APPLE_RESOURCES_DIR "share/SIMPL") else () set(APPLE_RESOURCES_DIR "${DREAM3D_PACKAGE_DEST_PREFIX}/Resources") - endif() get_property(DREAM3D_PACKAGE_DEST_PREFIX GLOBAL PROPERTY DREAM3D_PACKAGE_DEST_PREFIX) @@ -318,16 +329,21 @@ configure_file(${PROJECT_RESOURCES_DIR}/SIMPL/SIMPLLicense.txt # -------------------------------------------------------------------- # Generate install rules for the text files +set(license_install_dir "${DREAM3D_PACKAGE_DEST_PREFIX}") + if(APPLE) - install(FILES ${PROJECT_BINARY_DIR}/SIMPL/SIMPLLicense.txt - DESTINATION "${APPLE_RESOURCES_DIR}" - COMPONENT Applications) -else() - install(FILES ${PROJECT_BINARY_DIR}/SIMPL/SIMPLLicense.txt - DESTINATION "${DREAM3D_PACKAGE_DEST_PREFIX}" - COMPONENT Applications) + set(license_install_dir "${APPLE_RESOURCES_DIR}") endif() +if(DREAM3D_ANACONDA) + set(license_install_dir "share/DREAM3D") +endif() + +install(FILES ${PROJECT_BINARY_DIR}/SIMPL/SIMPLLicense.txt + DESTINATION ${license_install_dir} + COMPONENT Applications +) + # ----------------------------------------------------------------------- # Setup a Global property that is used to gather Documentation Information # into a single known location @@ -365,32 +381,23 @@ if(APPLE) set(ConfigPackageLocation ${DREAM3D_PACKAGE_DEST_PREFIX}${ConfigPackageLocation}) endif() -install( - FILES - "${SIMPLProj_SOURCE_DIR}/SIMPLConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/SIMPL/SIMPLTargetsConfigVersion.cmake" - DESTINATION - ${ConfigPackageLocation} - COMPONENT - Devel -) - - -# -------------------------------------------------------------------- -# Use ITK -option(SIMPL_USE_ITK "Use ITK For Image Processing" ON) - -# ----------------------------------------------------------------------- -# Add in the Necessary HDF5 Support Sources into a library -# ----------------------------------------------------------------------- -add_subdirectory( ${SIMPLProj_SOURCE_DIR}/Source/H5Support ${PROJECT_BINARY_DIR}/H5Support) +if(NOT DREAM3D_ANACONDA) + install( + FILES + "${SIMPLProj_SOURCE_DIR}/SIMPLConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/SIMPL/SIMPLTargetsConfigVersion.cmake" + DESTINATION + ${ConfigPackageLocation} + COMPONENT + Devel + ) +endif() # ----------------------------------------------------------------------- # Add in the support to host the documentation over a thin-http server # ----------------------------------------------------------------------- add_subdirectory(${SIMPLProj_SOURCE_DIR}/ThirdParty/QtWebApp ) - # ----------------------------------------------------------------------- # This needs to be set here as we are going to look for files in this directory # ----------------------------------------------------------------------- @@ -398,6 +405,39 @@ if("${FilterWidgetsLib_BINARY_DIR}" STREQUAL "") set(FilterWidgetsLib_BINARY_DIR ${SIMPLProj_BINARY_DIR}/FilterWidgetsLib) endif() + +# -------------------------------------------------------------------- +# Use ITK +option(SIMPL_USE_ITK "Use ITK For Image Processing" ON) +if(SIMPL_USE_ITK) + # -------------------------------------------------------------------- + # find ITK so that we can figure out the version of ITK the user has selected + # Does not register IO factories. It will be done by each plugin that needs it. + set(ITK_NO_IO_FACTORY_REGISTER_MANAGER TRUE) + find_package(ITK REQUIRED) + include(${CMP_SOURCE_DIR}/ITKSupport/IncludeITK.cmake) + + # --- ONLY Mac OS using ITK 5 needs SimpleITKExplicit + get_property(ITK_VERSION_MAJOR GLOBAL PROPERTY ITK_VERSION_MAJOR) + if(APPLE AND "${ITK_VERSION_MAJOR}" STREQUAL "5") + add_subdirectory( ${SIMPLProj_SOURCE_DIR}/Source/SimpleITKExplicit ${PROJECT_BINARY_DIR}/SimpleITKExplicit) + endif() +endif() + +if(NOT DEFINED SIMPL_USE_GHC_FILESYSTEM) + set(SIMPL_USE_GHC_FILESYSTEM OFF) + + if(APPLE OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + set(SIMPL_USE_GHC_FILESYSTEM ON) + elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) + set(SIMPL_USE_GHC_FILESYSTEM ON) + endif() +endif() + +if(SIMPL_USE_GHC_FILESYSTEM) + find_package(ghcFilesystem REQUIRED NAMES ghc_filesystem ghcFilesystem) +endif() + # ----------------------------------------------------------------------- # -- Add in the SIMPL Sources into a library add_subdirectory( ${SIMPLProj_SOURCE_DIR}/Source/SIMPLib ${PROJECT_BINARY_DIR}/SIMPLib) @@ -445,11 +485,152 @@ include(${SIMPLProj_SOURCE_DIR}/Support/Support.cmake) # -------------------------------------------------------------------------- # Find the Pybind11 installation -option(SIMPL_ENABLE_PYTHON "Generate and Compile Python wrapping codes" OFF) -if(SIMPL_ENABLE_PYTHON) +option(SIMPL_WRAP_PYTHON "Generate and Compile Python wrapping codes" OFF) +include(CMakeDependentOption) +cmake_dependent_option(SIMPL_EMBED_PYTHON "Embed the Python interpreter in SIMPL and allow for loading filters from Python" OFF SIMPL_WRAP_PYTHON OFF) +if(SIMPL_EMBED_PYTHON) + if(APPLE) + message(WARNING "Embedding Python is experimental on macOS") + endif() +endif() +if(SIMPL_WRAP_PYTHON) + set(SIMPL_PYTHON_TEST_ENV ${SIMPL_PYTHON_TEST_ENV} CACHE STRING "A semicolon delimited list of environment variables used for Python tests") + + option(SIMPL_USE_ANACONDA_PYTHON "Whether the selected Python executable is part of an Anaconda environment" OFF) + + mark_as_advanced(CLEAR PYTHON_EXECUTABLE) + + if(SIMPL_USE_ANACONDA_PYTHON) + if(NOT ANACONDA_DIR OR NOT ANACONDA_ENVIRONMENT_NAME) + set(ANACONDA_DIR "ANACONDA_DIR-NOTFOUND" CACHE PATH "Path to Anaconda directory") + set(ANACONDA_ENVIRONMENT_NAME "ANACONDA_ENVIRONMENT_NAME-NOTFOUND" CACHE STRING "Anaconda virtual environment to use") + set(ANACONDA_ERROR_MESSAGE "ANACONDA_DIR = ${ANACONDA_DIR}\nANACONDA_ENVIRONMENT_NAME = ${ANACONDA_ENVIRONMENT_NAME}\n") + if(NOT ANACONDA_DIR) + string(APPEND ANACONDA_ERROR_MESSAGE "ANACONDA_DIR is not set.\n") + endif() + if(NOT ANACONDA_ENVIRONMENT_NAME) + string(APPEND ANACONDA_ERROR_MESSAGE "ANACONDA_ENVIRONMENT_NAME is not set.\n") + endif() + message(FATAL_ERROR ${ANACONDA_ERROR_MESSAGE}) + endif() + + if(WIN32) + set(SIMPL_CONDA_EXECUTABLE ${ANACONDA_DIR}/condabin/conda.bat CACHE FILEPATH "Path to conda executable") + else() + set(SIMPL_CONDA_EXECUTABLE ${ANACONDA_DIR}/condabin/conda CACHE FILEPATH "Path to conda executable") + endif() + + mark_as_advanced(SIMPL_CONDA_EXECUTABLE) + endif() - # -------------------------------------------------------------------- - # add the Pybind11 Python Wrapping - add_subdirectory(${SIMPLProj_SOURCE_DIR}/Wrapping/Python/Pybind11 ${PROJECT_BINARY_DIR}/Pybind11) + option(SIMPL_GENERATE_PYI "Generate .pyi files for python bindings" OFF) + + if(SIMPL_GENERATE_PYI) + find_program(MYPY_STUBGEN_EXE stubgen REQUIRED) + endif() + include(${SIMPLProj_SOURCE_DIR}/Wrapping/Python/Binding/CreatePybind11Module.cmake) + + get_target_property(SIMPL_PY_SOURCES SIMPLib SOURCES) + + set(SIMPL_PY_SOURCES_FILE ${SIMPLProj_BINARY_DIR}/SIMPL_py_sources.txt) + + file(WRITE ${SIMPL_PY_SOURCES_FILE} "${SIMPL_PY_SOURCES}") + + set(PY_ALL_MODULES_GENERATOR ${SIMPLProj_SOURCE_DIR}/Wrapping/Python/Binding/generate_all_modules_file.py) + set(PY_ALL_MODULES_FILE ${SIMPLProj_BINARY_DIR}/Wrapping/all_modules.txt) + set_property(GLOBAL PROPERTY PY_ALL_MODULES_FILE ${PY_ALL_MODULES_FILE}) + + file(WRITE ${PY_ALL_MODULES_FILE} "") + + get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + + if(NOT DREAM3D_ANACONDA) + add_custom_target(CreateDream3dModuleFile ALL + COMMAND ${PYTHON_EXECUTABLE} ${PY_ALL_MODULES_GENERATOR} + "${PY_ALL_MODULES_FILE}" + "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}$<${_isMultiConfig}:/$>" + COMMENT "Creating dream3d.py module file" + ) + + set_property(TARGET CreateDream3dModuleFile PROPERTY FOLDER "Python") + endif() + + CreatePybind11Module(MODULE_NAME "simpl" + OUTPUT_DIR "${SIMPLProj_BINARY_DIR}/Wrapping/PythonCore" + FILE_LIST_PATH ${SIMPL_PY_SOURCES_FILE} + SOURCE_DIR "${SIMPLProj_SOURCE_DIR}/Source" + HEADER_PATH "${SIMPLProj_SOURCE_DIR}/Wrapping/Python/Binding/pySIMPLHeader.cpp" + BODY_PATH "${SIMPLProj_SOURCE_DIR}/Wrapping/Python/Binding/pySIMPLBody.cpp" + BODY_TOP_PATH "${SIMPLProj_SOURCE_DIR}/Wrapping/Python/Binding/pySIMPLBodyTop.cpp" + POST_TYPES_PATH "${SIMPLProj_SOURCE_DIR}/Wrapping/Python/Binding/pySIMPLPostTypes.cpp" + PYTHON_OUTPUT_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}$<${_isMultiConfig}:/$>" + LINK_LIBRARIES SIMPLib + INCLUDE_DIRS ${SIMPLProj_SOURCE_DIR}/Wrapping/Python + ) + + if(DREAM3D_ANACONDA) + configure_file(${SIMPLProj_SOURCE_DIR}/Wrapping/Python/SIMPL/simpl_helpers_conda.py ${DREAM3D_PYTHON_PACKAGE_DIR}/simpl_helpers.py) + file(APPEND ${DREAM3D_INIT_PY_FILE} "from . import simpl_helpers\n") + else() + add_custom_target(CopyPythonSupport ALL + COMMAND ${CMAKE_COMMAND} -E copy + ${SIMPLProj_SOURCE_DIR}/Wrapping/Python/SIMPL/simpl_helpers.py + "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}$<${_isMultiConfig}:/$>" + COMMENT "Copying simpl_helpers.py to binary directory" + ) + + add_dependencies(simpl CopyPythonSupport) + + set_property(TARGET CopyPythonSupport PROPERTY FOLDER "ZZ_COPY_FILES") + endif() + + if(SIMPL_BUILD_TESTING) + file(READ ${SIMPLProj_SOURCE_DIR}/Wrapping/Python/SIMPL/simpl_test_dirs.in.py SIMPL_TEST_DIRS_FILE) + + string(REPLACE "\${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" $ SIMPL_TEST_DIRS_FILE ${SIMPL_TEST_DIRS_FILE}) + string(REPLACE "\${SIMPLProj_BINARY_DIR}" ${SIMPLProj_BINARY_DIR} SIMPL_TEST_DIRS_FILE ${SIMPL_TEST_DIRS_FILE}) + string(REPLACE "\${DREAM3D_DATA_DIR}" ${DREAM3D_DATA_DIR} SIMPL_TEST_DIRS_FILE ${SIMPL_TEST_DIRS_FILE}) + + file(GENERATE + OUTPUT "$/simpl_test_dirs.py" + CONTENT ${SIMPL_TEST_DIRS_FILE} + ) + + set(PYTHON_TEST_INPUT_DIR "${SIMPLProj_SOURCE_DIR}/Wrapping/Python/Testing") + + set(SIMPL_PYTHON_TESTS + "AbstractFilterTest" + "AttributeMatrixTest" + "DataArrayTest" + "DataContainerArrayTest" + "DataContainerTest" + "GeometryTest" + "ImageReadTest" + "TestBindings" + + "Create_Edge_Geometry" + "Create_Quad_Geometry" + "Create_RectilinearGrid" + "Create_Triangle_Geometry" + "Create_Vertex_Geometry" + + "Array_Calculator_Test" + "Convert_Attribute_Array_Data_Type" + "Copy_Object_Test" + "Crop_Vertex_Geometry" + "Export_Triangle_Geometry" + "Import_Ascii_Data_Array" + "Import_Hdf5_Dataset" + "Remove_Component_From_Array" + "Rename_Attribute_Array" + "Split_Attribute_Array" + "NumPy_Round_Trip" + ) + + CreatePythonTests(PREFIX "PY_SIMPL" + INPUT_DIR ${PYTHON_TEST_INPUT_DIR} + TEST_NAMES ${SIMPL_PYTHON_TESTS} + ) + endif() endif() diff --git a/Contributing.md b/Contributing.md index 3a58f1f03b..0ecf8e72ed 100644 --- a/Contributing.md +++ b/Contributing.md @@ -1,4 +1,4 @@ -## Contributing to DREAM.3D ## +# Contributing to DREAM.3D # The DREAM.3D project embraces community contributions, and desires to keep the process of contributing changes as easy as possible. There are a few guidelines contributors should follow; adhering to these guidelines will make the contribution process faster and easier. @@ -8,15 +8,15 @@ The DREAM.3D project utilizes the [fork and pull](https://help.github.com/articl + Sign up for a [GitHub account](https://github.com/signup/free) + Create an issue on the DREAM.3D issue tracker for your expected contribution, if one does not already exist - + In the issue, please describe the scope of the intended contribution and apply the proper label - + If the issue is a bug, please include steps necessary to reproduce the bug + + In the issue, please describe the scope of the intended contribution and apply the proper label + + If the issue is a bug, please include steps necessary to reproduce the bug + Fork the DREAM.3D repository into your own GitHub workspace + Create a branch that will encapsulate the work that will address the issue - + The branch should be named with reference to the number of the issue - + For example, for an issue about "Foo" with number "123", the branch should be named "123_foo" + + The branch should be named with reference to the number of the issue + + For example, for an issue about "Foo" with number "123", the branch should be named "123_foo" + Make any commits to this branch to address the issue in logical, atomic units - + Please follow established DREAM.3D style when writing your code for contribution - + Primary DREAM.3D styles include tabs as two spaces, camel case for function naming, and the "m_" naming scheme for instance variables + + Please follow established DREAM.3D style when writing your code for contribution + + Primary DREAM.3D styles include tabs as two spaces, camel case for function naming, and the "m_" naming scheme for instance variables + Format your commit messages to reference the open issue + Add any necessary unit tests for your additions + Ensure that your changes compile on your development platform for the most recent HEAD of the DREAM.3D develop branch @@ -24,13 +24,10 @@ The DREAM.3D project utilizes the [fork and pull](https://help.github.com/articl ## Submitting Contributions ## -+ Sign the [Contributor License Agreement](http://dream3d.bluequartz.net/?page_id=448) + Submit a pull requests from your remote branch to the DREAM.3D project - + If your pull request contains several commits, please squash them into a single commit ++ If your pull request contains several commits, please squash them into a single commit + Update the open issue with a link to the submitted pull request + Pull requests are reviewed bi-weekly by at least two core DREAM.3D developers. The DREAM.3D development team will respond to the pull request with any questions or comments as required by the content of the pull request. If no action is required, the pull request will be merged immediately. + After giving any feedback, the DREAM.3D developers will allow two weeks for response from the contributor. If no further action is taken by the contributor, the DREAM.3D development team may close the pull request as inactive. - ## Submission of Curated Plugins ## - diff --git a/Resources/CPack/PackageProject.cmake b/Resources/CPack/PackageProject.cmake index 907d7e8ef4..2f1e546cbe 100644 --- a/Resources/CPack/PackageProject.cmake +++ b/Resources/CPack/PackageProject.cmake @@ -15,8 +15,10 @@ if(MSVC) SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP 1) #SET(CMAKE_INSTALL_DEBUG_LIBRARIES OFF) - # Gather the list of system level runtime libraries - INCLUDE (InstallRequiredSystemLibraries) + if(NOT DREAM3D_DISABLE_DEPENDENCY_COPY_INSTALL_RULES) + # Gather the list of system level runtime libraries + include(InstallRequiredSystemLibraries) + endif() # Our own Install rule for Release builds of the MSVC runtime libs if(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS) diff --git a/Resources/DocConfigFiles/CMake/Macros.cmake b/Resources/DocConfigFiles/CMake/Macros.cmake index 4912900654..7cb7a5c7e3 100644 --- a/Resources/DocConfigFiles/CMake/Macros.cmake +++ b/Resources/DocConfigFiles/CMake/Macros.cmake @@ -26,7 +26,7 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -# The code contained herein was partially funded by the followig contracts: +# The code contained herein was partially funded by the following contracts: # United States Air Force Prime Contract FA8650-07-D-5800 # United States Air Force Prime Contract FA8650-10-D-5210 # United States Prime Contract Navy N00173-07-C-2068 diff --git a/Resources/SIMPL.qrc b/Resources/SIMPL.qrc index e5a67385db..e25acd621b 100644 --- a/Resources/SIMPL.qrc +++ b/Resources/SIMPL.qrc @@ -26,7 +26,14 @@ SIMPL/StyleSheets/Default.css SIMPL/StyleSheets/Default.json + SIMPL/StyleSheets/Default_DarkMode.css + SIMPL/StyleSheets/Default_DarkMode.json + + SIMPL/icons/images/expand_all.png + SIMPL/icons/images/expand_all@2x.png + SIMPL/icons/images/collapse_all.png + SIMPL/icons/images/collapse_all@2x.png SIMPL/icons/images/add.png SIMPL/icons/images/add@2x.png SIMPL/icons/images/arrow_down.png diff --git a/Resources/SIMPL/SIMPL_Code_License_Template.txt b/Resources/SIMPL/SIMPL_Code_License_Template.txt index 1c45b3963b..89f3df89e8 100644 --- a/Resources/SIMPL/SIMPL_Code_License_Template.txt +++ b/Resources/SIMPL/SIMPL_Code_License_Template.txt @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 diff --git a/Resources/SIMPL/StyleSheets/Default.css b/Resources/SIMPL/StyleSheets/Default.css index d78f07270d..1e6d59f378 100644 --- a/Resources/SIMPL/StyleSheets/Default.css +++ b/Resources/SIMPL/StyleSheets/Default.css @@ -114,6 +114,25 @@ DataArrayPathSelectionWidget > QToolTip { color: #000000; } +DataPathLabel { + font-family: "Lato-Bold"; + font-weight: bold; + font-size: Font_Size_Small; + border-radius: 4px; +} +DataPathLabel:disabled { + color: DataPathLabel_Disabled_color; +} +DataPathLabel:enabled[DataTypei="0"] { + color: DataArrayPath_DataContainer_color; +} +DataPathLabel:enabled[DataTypei="1"] { + color: DataArrayPath_AttributeMatrix_color; +} +DataPathLabel:enabled[DataTypei="2"] { + color: DataArrayPath_DataArray_color; +} + /* ---------------------------------------------------------------------------- * SVPushButton Section * ----------------------------------------------------------------------------*/ diff --git a/Resources/SIMPL/StyleSheets/Default.json b/Resources/SIMPL/StyleSheets/Default.json index 82e18eb4ff..53e7f2f750 100644 --- a/Resources/SIMPL/StyleSheets/Default.json +++ b/Resources/SIMPL/StyleSheets/Default.json @@ -63,10 +63,12 @@ "DataArrayPath_DataContainer_color": "#056d00", "DataArrayPath_AttributeMatrix_color": "#6400b7", "DataArrayPath_DataArray_color": "#004dad", + "DataArrayPath_Invalid_color": "#dddddd", "DataArrayPath_DataContainer_background_color": "#a0ff9b", "DataArrayPath_AttributeMatrix_background_color": "#d9adff", "DataArrayPath_DataArray_background_color": "#afd3ff", + "DataArrayPath_Invalid_background_color": "#ffffff", "DataArrayPath_border_normal": "#8f8f91", "DataArrayPath_border_not_found": "#BC0000", diff --git a/Resources/SIMPL/StyleSheets/Default_DarkMode.css b/Resources/SIMPL/StyleSheets/Default_DarkMode.css new file mode 100644 index 0000000000..459c1f8134 --- /dev/null +++ b/Resources/SIMPL/StyleSheets/Default_DarkMode.css @@ -0,0 +1,334 @@ +/* STYLESHEET=DEFAULT */ + +/* ---------------------------------------------------------------------------- +* QGroupBox Section +* ----------------------------------------------------------------------------*/ +QGroupBox::title +{ + /* height: 185px; */ + subcontrol-origin: margin; + subcontrol-position: top left; + padding: 0 0px; +} + +QGroupBox +{ + font-family: "Lato-Bold"; + font-weight: bold; + font-size: 16px; +} + + +/* ---------------------------------------------------------------------------- +* Section +* ----------------------------------------------------------------------------*/ +SVSmallLabel +{ + font-style:italic; + font-size: Font_Size_Small; +} + +DataArrayPathSelectionWidget +{ + /* font-family: "Lato"; + font-weight: normal; */ + font-size: Font_Size_Small; + border: 1px solid QLineEdit_border_color; + border-radius: 5px; + background-color: QToolButton_background_color; + padding-left: 0px; + padding-right: 4px; + padding-top: 2px; + padding-bottom: 2px; +} + +DataArrayPathSelectionWidget:disabled +{ + background-color: QToolButtonDisabled_background_color; +} + +/* + * State: { Normal, Active, NotFound, DragEnabled, DragDisabled } + * PathType: { DataContainer, AttributeMatrix, DataArray, None } + */ +DataArrayPathSelectionWidget[State="0"] +{ + border-color: DataArrayPath_border_normal; +} +DataArrayPathSelectionWidget[State="1"][PathType="0"] +{ + border-color: DataArrayPath_DataContainer_color; +} +DataArrayPathSelectionWidget[State="1"][PathType="1"] +{ + border-color: DataArrayPath_AttributeMatrix_color; +} +DataArrayPathSelectionWidget[State="1"][PathType="2"] +{ + border-color: DataArrayPath_DataArray_color; +} +DataArrayPathSelectionWidget[State="2"] +{ + border-color : DataArrayPath_border_not_found; +} +DataArrayPathSelectionWidget[State="3"] +{ + border-color: DataArrayPath_border_drag_enabled; +} +DataArrayPathSelectionWidget[State="4"] +{ + border-color: DataArrayPath_border_drag_disabled; +} + +DataArrayPathSelectionWidget:checked[PathType="0"] +{ + background-color: DataArrayPath_DataContainer_background_color; +} +DataArrayPathSelectionWidget:checked[PathType="1"] +{ + background-color: DataArrayPath_AttributeMatrix_background_color; +} +DataArrayPathSelectionWidget:checked[PathType="2"] +{ + background-color: DataArrayPath_DataArray_background_color; +} + +DataArrayPathSelectionWidget::menu-indicator { + subcontrol-origin: content; + subcontrol-position: right; /* */ +} +DataArrayPathSelectionWidget::menu-indicator:pressed, DataArrayPathSelectionWidget::menu-indicator:open { + position: relative; +} +DataArrayPathSelectionWidget:flat { + border: none; +} + +DataArrayPathSelectionWidget > QToolTip { + border: 2px solid #434343; + padding: 2px; + border-radius: 3px; + opacity: 255; + background-color: #FFFCEA; + color: #000000; + } + +DataPathLabel { + font-family: "Lato-Bold"; + font-weight: bold; + font-size: Font_Size_Small; + border-radius: 4px; +} +DataPathLabel:disabled { + color: DataPathLabel_Disabled_color; +} +DataPathLabel:enabled[DataTypei="0"] { + color: DataArrayPath_DataContainer_color; +} +DataPathLabel:enabled[DataTypei="1"] { + color: DataArrayPath_AttributeMatrix_color; +} +DataPathLabel:enabled[DataTypei="2"] { + color: DataArrayPath_DataArray_color; +} + +/* ---------------------------------------------------------------------------- +* SVPushButton Section +* ----------------------------------------------------------------------------*/ +SVIconPushButton +{ + background-repeat: no-repeat; + background-position: center center; + padding-left: 0px; + padding-top: 0px; +} + +SVIconPushButton:hover +{ + border: 1px solid; + border-radius: 5px; + border-color: rgb(190, 190, 190); + background-color: rgb(190, 190, 190); +} + +SVIconPushButton:pressed +{ + border: 1px solid; + border-radius: 5px; + border-color: rgb(170, 170, 170); + background-color: rgb(170, 170, 170); + padding-left: 2px; + padding-top: 2px; +} + +SVIconPushButton:disabled +{ + border: 1px solid; + border-radius: 5px; + border-color: rgb(130, 130, 130); + background-color: rgb(130, 130, 130); + padding-left: 0px; + padding-top: 0px; +} + +FilterParameterWidget +{ + margin: 2px; + background-position: top left; + background-origin: content; + background-clip: margin; +} + +/* This is here for the search box at the top of the FilterLibrary */ +QtSLineEdit#filterSearch +{ + border-radius: 0; + min-height: 24; +} + +/* **************************************************************************** +* +******************************************************************************/ +QwtPlot +{ + background-color: white; + border: 1px solid #6b6b6b; + border-radius: 5px; +} + +QwtPlotCanvas +{ + background-color: white; +} + +QwtPlotGLCanvas +{ + border: 1px solid white; + background-color: #616d7e; +} + +QwtScaleWidget +{ + color: black; +} + +QwtTextLabel#QwtPlotTitle +{ + color: black; + padding: 0px; + margin: 0px; +} + +QwtTextLabel#QwtPlotFooter +{ + color: black; +} + +QwtLegend +{ + border: 1px solid black; + border-radius: 0px; + padding: 2px; + background: #616d7e; +} + +QwtLegendLabel +{ + color: black; +} + +/* ---------------------------------------------------------------------------- +* QTableView Section +* ----------------------------------------------------------------------------*/ +QTableView +{ + font-family: "Lato"; + color: #b1b1b1; + font-size: Font_Size_Small; + background: rgb-primary-2; + outline: none; /* removes the "focus rect" */ + border: 1px solid rgb( 68, 89, 100); +} +QTableView::item +{ + padding: 2 0 2 0px; + border-top-color: transparent; + border-bottom-color: transparent; + border: 0px solid transparent; + color: #b1b1b1; +} + +QTableView::item:selected +{ + background: rgb-primary-2; + color: rgb-primary-0; +} + +/* ---------------------------------------------------------------------------- +* QTableWidget Section +* ----------------------------------------------------------------------------*/ + +/* See QHeaderView on how to style the QTableWidget header */ +QTableWidget +{ + font-family: "Lato"; + color: #b1b1b1; + font-size: Font_Size_Small; + background: rgb-primary-2; + outline: none; /* removes the "focus rect" */ + border: 1px solid rgb-primary-3; +} + +QTableWidget::item:selected +{ + background: rgb-primary-3; + color: #F1F1F1; +} + +QTableWidget::item +{ +} + +QTableWidget::item:hover +{ + background: rgb-primary-3; + border: 0px; +} + +QTableWidget::item:selected:hover +{ + background: rgb-primary-3; + color: #F1F1F1; +} + +QTableView QTableCornerButton::section +{ + background-color: QHeaderView_background_color; +} + +/* ---------------------------------------------------------------------------- +* QTextEdit Section +* ----------------------------------------------------------------------------*/ +QTextEdit +{ + background-color: QLineEdit_background_color; + color: QLineEdit_color; +} + +QTextEdit:focus +{ + /* border: 1px solid rgb-primary-0; + background-color: #3F3F3F; */ +} + +QTextEdit:disabled +{ + color: QLineEdit_color; + background-color: QLineEditDisabled_background_color; +} + +StandardOutputWidget +{ + background-color: QLineEdit_background_color; + color: QLineEdit_color; +} \ No newline at end of file diff --git a/Resources/SIMPL/StyleSheets/Default_DarkMode.json b/Resources/SIMPL/StyleSheets/Default_DarkMode.json new file mode 100644 index 0000000000..3dd9841f1b --- /dev/null +++ b/Resources/SIMPL/StyleSheets/Default_DarkMode.json @@ -0,0 +1,202 @@ +{ + "Theme_Name": "Default Dark", + "CSS_File_Name": "Default_DarkMode.css", + + "_comment1": "The next set of colors MUST be in HEX notation as they are being converted to a QColor", + "FilterBackgroundColor" : "#5b337a", + "FilterSelectionColor" : "#A788Be", + "FilterFontColor" : "#DDDDDD", + + "Named_Variables": + { + "white" : "rgb(255,255,255)", + "black" : "rgb(0,0,0)", + "light_gray": "rgb(239,239,239)", + "light_yellow": "rgb(255,252,225)", + "light_yellow_disabled": "rgb(141,141,140)", + + "rgb-primary-0" : "#1e1e1e", + "rgb-primary-1" : "#252526", + "rgb-primary-2" : "#333333", + "rgb-primary-3" : "#444444", + + "rgb-complement-0" : "#d7801a", + "rgb-complement-1" : "#d77300", + "rgb-complement-2" : "#b1b1b1", + "rgb-complement-3" : "#F6F6F6", + "rgb-complement-4" : "#ACACAC", + "rgb-complement-5" : "#C0C0C0", + "rgb-complement-6" : "#75450e" + }, + + "Font_Replacements": + { + "macOS": + { + "Font_Size_Very_Small": "10pt", + "Font_Size_Small": "12pt", + "Font_Size_Medium": "13pt", + "Font_Size_Large": "14pt", + "Font_Size_Very_Large": "16pt" + }, + "Windows": + { + "Font_Size_Very_Small": "8pt", + "Font_Size_Small": "9pt", + "Font_Size_Medium": "10pt", + "Font_Size_Large": "11pt", + "Font_Size_Very_Large": "14pt" + }, + "Linux": + { + "Font_Size_Very_Small": "9pt", + "Font_Size_Small": "10pt", + "Font_Size_Medium": "11pt", + "Font_Size_Large": "12pt", + "Font_Size_Very_Large": "14pt" + } + }, + + "CSS_Replacements": { + "_comment2" : "These colors can be in any standard CSS notation.", + "rgb-primary-0" : "rgb-primary-0", + "rgb-primary-1" : "rgb-primary-1", + "rgb-primary-2" : "rgb-primary-2", + "rgb-primary-3" : "rgb-primary-3", + + "rgb-complement-0" : "rgb-complement-0", + "rgb-complement-1" : "rgb-complement-1", + "rgb-complement-2" : "rgb-complement-2", + "rgb-complement-3" : "rgb-complement-3", + "rgb-complement-4" : "rgb-complement-4", + "rgb-complement-5" : "rgb-complement-5", + "rgb-complement-6" : "rgb-complement-6", + + "Fader_color" : "rgb-complement-2", + "QLabel_color" : "rgb-complement-4", + "Widget_Error_color": "rgb(25,0,0)", + "QLineEditError_background_color": "rgb(100, 50, 50)", + "Text_Error_color": "rgb(200, 65, 65)", + + "CentralWidget_background_color" : "rgb-primary-0", + "FilterInputWidget_background_color": "rgb-primary-0", + "QScrollArea_background_color": "rgb-primary-0", + "VariablesTabContents_background_color": "rgb-primary-0", + + "FilterParameterWidget_background_color": "rgb-primary-0", + "FilterParameterWidget_border_color": "rgb-primary-2", + + "QDockWidget_border_color" : "rgb-primary-2", + "QDockWidget_color": "rgb-complement-0", + "QDockWidgetTitle_background_color": "rgb-primary-0", + "QDockWidgetTitle_color": "white", + + "SIMPLViewPipelineDockWidgetTitle_inactive_background_color": "rgb-complement-3", + "SIMPLViewPipelineDockWidgetTitle_inactive_text_color": "rgb-complement-4", + + "QListView_background_color": "rgb-primary-0", + "QListView_color": "rgb-complement-5", + "QListViewItemHover_background_color": "rgb-primary-1", + "QListViewItemHover_color": "rgb-complement-1", + "QListViewItemSelected_background_color": "rgb-primary-2", + "QListViewItemSelected_color": "rgb-complement-5", + + "QMainWindowSeparator_background_color" : "rgb-primary-0", + + "QMenuBar_background_color": "rgb-primary-0", + "QMenuBarItem_color" : "white", + "QMenuBarItemPressed_color" : "rgb-complement-2", + "QMenuBarItemSelected_background_color" : "rgb( 93, 114, 126)", + "QMenuBarItemSelected_color": "rgb-complement-5", + + "QMenu_background_color": "rgb-primary-2", + "QMenu_color": "rgb-complement-5", + "QMenuItemSelected_background_color": "#4F4F4F", + "QMenuItemDisabled_background_color": "rgb-primary-2", + "QMenuItemSelected_color": "white", + + "QPushButtonPressed_background_color": "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #505050, stop:1 #808080)", + "QPushButton_border_color": "rgb-primary-1", + "QPushButtonHover_background_color": "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #808080, stop:1 #505050)", + "QPushButton_background_color": "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #808080, stop:1 #505050)", + + "QSplitter_handle_start_color": "rgb-primary-0", + "QSplitter_handle_end_color": "rgb-primary-1", + + "QToolButton_background_color": "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #333333, stop:1 #1e1e1e)", + "QToolButton_color": "rgb-complement-1", + "QToolButton_border_color": "rgb-complement-4", + "QToolButtonChecked_background_color": "rgb(200,236,255)", + "QToolButtonDisabled_background_color": "disabled_color", + "QToolButtonDisabled_color": "disabled_text_color", + + "QStatusBar_border_color": "rgb-primary-2", + + "QTableWidget_color": "rgb-complement-2", + "QTableWidget_selected_background_color": "rgb-complement-2", + "QHeaderView_background_color": "rgb-primary-0", + "QHeaderView_border_color": "rgb-complement-4", + "QHeaderView_color": "rgb-complement-2", + "QHeaderViewDisabled_background_color": "disabled_color", + "QHeaderViewDisabled_border_color": "disabled_text_color", + "QHeaderViewDisabled_color": "disabled_text_color", + + "QTabWidgetPane_border_color": "rgb-complement-2", + "QTabWidgetPane_background_color": "rgb-primary-0", + "QTabBarTab_border_color": "rgb-complement-2", + "QTabBarTabSelected_background_color": "#413930", + "QTabBarTabSelected_color":"rgb-complement-0", + "QTabBarTabNotSelected_background_color": "rgb-primary-1", + "QTabBarTabNotSelectedHover_background_color": "rgb-primary-2", + + "QTextEdit_background_color": "black", + "QTextEdit_color": "white", + + "QLineEdit_color": "rgb-complement-2", + "QLineEdit_background_color": "#2e2e2e", + "QLineEdit_border_color": "rgb-complement-2", + "QLineEditDisabled_background_color": "disabled_color", + + "QSpinBoxArrow_background_color": "rgb(70,124,214)", + "QSpinBoxArrow_hover_background_color": "rgb(98,145,224)", + + "QToolBar_background_color": "rgb(240,248,253)", + "QToolBar_border_color": "rgb(64,119,149)", + + "QTreeView_background_color": "rgb-primary-1", + "QTreeViewItem_background_color": "rgb-primary-1", + "QTreeViewItem_color": "rgb-complement-5", + "QTreeViewBranch_background_color": "rgb-primary-1", + "QTreeViewBranchSelectedActive_background_color": "rgb-primary-1", + "QTreeViewBranchSelectedNotActive_background_color": "rgb-primary-2", + "QTreeViewItemHover_background_color": "rgb-primary-2", + "QTreeViewItemHover_color": "rgb-complement-5", + "QTreeViewBranchHover_background_color": "rgb-primary-2", + "QTreeViewBranchHover_color": "rgb-complement-5", + "QTreeViewItemSelectedActive_background_color": "rgb-primary-1", + "QTreeViewItemSelectedActive_color": "rgb-complement-2", + "QTreeViewItemSelectedNotActive_background_color": "rgb-primary-2", + "QTreeViewItemSelectedNotActive_color": "rgb-complement-1", + "QTreeViewItem_error_color": "#FF0000", + "QTreeViewItem_error_background_color": "#00FFFFFF", + + "DataArrayPath_DataContainer_color": "#56c551", + "DataArrayPath_AttributeMatrix_color": "#a96bdb", + "DataArrayPath_DataArray_color": "#3a89e9", + "DataArrayPath_Invalid_color": "#dddddd", + + "DataArrayPath_DataContainer_background_color": "#507F4E", + "DataArrayPath_AttributeMatrix_background_color": "#886CA0", + "DataArrayPath_DataArray_background_color": "#2E527F", + "DataArrayPath_Invalid_background_color": "#FFFFFF", + + "DataArrayPath_border_normal": "#8f8f91", + "DataArrayPath_border_not_found": "#AA4444", + "DataArrayPath_border_drag_enabled": "#009104", + "DataArrayPath_border_drag_disabled": "#BC0000", + + "DataPathLabel_color": "rgb-complement-5", + "DataPathLabel_Disabled_color": "disabled_text_color" + } + +} diff --git a/Resources/SIMPL/StyleSheets/Example.css b/Resources/SIMPL/StyleSheets/Example.css index 32055fdbe3..d51b77f790 100644 --- a/Resources/SIMPL/StyleSheets/Example.css +++ b/Resources/SIMPL/StyleSheets/Example.css @@ -267,7 +267,26 @@ DataArrayPathSelectionWidget:flat { /* Style all DataArrayPathSelectionWidgets' flat menu indicators */ } +DataPathLabel +{ + /* Style DataPathLabel */ +} +DataPathLabel:disabled +{ +} +DataPathLabel:enabled[DataTypei="0"] +{ + /* DataContainer Style */ +} +DataPathLabel:enabled[DataTypei="1"] +{ + /* AttributeMatrix Style */ +} +DataPathLabel:enabled[DataTypei="2"] +{ + /* DataArray Style */ +} /* ---------------------------------------------------------------------------- * QStatusBar Section diff --git a/Resources/SIMPL/StyleSheets/Example.json b/Resources/SIMPL/StyleSheets/Example.json index 96f00971fa..c3dd3e929e 100644 --- a/Resources/SIMPL/StyleSheets/Example.json +++ b/Resources/SIMPL/StyleSheets/Example.json @@ -93,10 +93,12 @@ "DataArrayPath_DataContainer_color": "#056d00", "DataArrayPath_AttributeMatrix_color": "#6400b7", "DataArrayPath_DataArray_color": "#004dad", + "DataArrayPath_Invalid_color": "#dddddd", "DataArrayPath_DataContainer_background_color": "#a0ff9b", "DataArrayPath_AttributeMatrix_background_color": "#d9adff", "DataArrayPath_DataArray_background_color": "#afd3ff", + "DataArrayPath_Invalid_background_color": "#FFFFFF", "DataArrayPath_border_normal": "#8f8f91", "DataArrayPath_border_not_found": "#BC0000", diff --git a/Resources/SIMPL/icons/images/collapse_all.png b/Resources/SIMPL/icons/images/collapse_all.png new file mode 100644 index 0000000000..a2a4da0c57 Binary files /dev/null and b/Resources/SIMPL/icons/images/collapse_all.png differ diff --git a/Resources/SIMPL/icons/images/collapse_all@2x.png b/Resources/SIMPL/icons/images/collapse_all@2x.png new file mode 100644 index 0000000000..5051e61d8a Binary files /dev/null and b/Resources/SIMPL/icons/images/collapse_all@2x.png differ diff --git a/Resources/SIMPL/icons/images/expand_all.png b/Resources/SIMPL/icons/images/expand_all.png new file mode 100644 index 0000000000..da6842ea5e Binary files /dev/null and b/Resources/SIMPL/icons/images/expand_all.png differ diff --git a/Resources/SIMPL/icons/images/expand_all@2x.png b/Resources/SIMPL/icons/images/expand_all@2x.png new file mode 100644 index 0000000000..34e031ef33 Binary files /dev/null and b/Resources/SIMPL/icons/images/expand_all@2x.png differ diff --git a/Resources/SIMPL/icons/svg/collapse_all.svg b/Resources/SIMPL/icons/svg/collapse_all.svg new file mode 100644 index 0000000000..ff3f05a539 --- /dev/null +++ b/Resources/SIMPL/icons/svg/collapse_all.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Resources/SIMPL/icons/svg/expand_all.svg b/Resources/SIMPL/icons/svg/expand_all.svg new file mode 100644 index 0000000000..27ad8095e8 --- /dev/null +++ b/Resources/SIMPL/icons/svg/expand_all.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Resources/SIMPL_API.doxyfile.in b/Resources/SIMPL_API.doxyfile.in index aa58be626d..2bbf470ea4 100644 --- a/Resources/SIMPL_API.doxyfile.in +++ b/Resources/SIMPL_API.doxyfile.in @@ -274,22 +274,22 @@ PREDEFINED = "EBSD_INSTANCE_PROPERTY(type, prpty)= \ "DREAM3D_TYPE_MACRO(class)=\ virtual const char* getNameOfClass() const \ {return "CrossCorrelationData";}" \ - "MXA_INSTANCE_PROPERTY(type, prpty)= \ + "SIMPL_INSTANCE_PROPERTY(type, prpty)= \ /** Sets the prpty instance variable */ \ void set##prpty (type); \ /** Gets the prpty instance variable */ \ type get##prpty (type);" \ - "MXA_INSTANCE_PROPERTY(type, prpty, name)= \ + "SIMPL_INSTANCE_PROPERTY(type, prpty, name)= \ /** Sets the prpty instance variable */ \ void set##prpty (type); \ /** Gets the prpty instance variable */ \ type get##prpty (type);" \ - "MXA_INSTANCE_STRING_PROPERTY(prpty)=\ + "SIMPL_INSTANCE_STRING_PROPERTY(prpty)=\ /** Sets the prpty instance variable */ \ void set##prpty (std::string); \ /** Gets the prpty instance variable */ \ std::string get##prpty (std::string);" \ - "MXA_SHARED_POINTERS(class)=\ + "SIMPL_SHARED_POINTERS(class)=\ typedef CrossCorrelation Self;\ typedef boost::shared_ptr< Self > Pointer;\ typedef boost::shared_ptr ConstPointer;\ @@ -297,13 +297,13 @@ PREDEFINED = "EBSD_INSTANCE_PROPERTY(type, prpty)= \ { \ return Pointer(static_cast(0));\ }"\ - "MXA_STATIC_NEW_MACRO(class)=\ + "SIMPL_STATIC_NEW_MACRO(class)=\ static Pointer New(void) \ { \ Pointer sharedPtr (new CrossCorrelationData); \ return sharedPtr; \ }"\ - "MXA_TYPE_MACRO(class)=\ + "SIMPL_TYPE_MACRO(class)=\ virtual const char* getNameOfClass() const \ {return "CrossCorrelationData";}" #--------------------------------------------------------------------------- diff --git a/Resources/ThirdParty.qrc b/Resources/ThirdParty.qrc index 7c3962178e..8ec4e1a86e 100644 --- a/Resources/ThirdParty.qrc +++ b/Resources/ThirdParty.qrc @@ -1,7 +1,6 @@ -ThirdParty/Boost.txt ThirdParty/ctk.txt ThirdParty/HDF5.txt ThirdParty/Qt.txt diff --git a/Resources/ThirdParty/Boost.txt b/Resources/ThirdParty/Boost.txt deleted file mode 100644 index 0ee3eecc87..0000000000 --- a/Resources/ThirdParty/Boost.txt +++ /dev/null @@ -1,37 +0,0 @@ - - -
-Boost from http://www.boost.org - A subset of the complete boost open-source
-project is being used by the project. The license to use and distribute boost
-related source and binaries is as follows:
-
-  Boost Software License - Version 1.0 - August 17th, 2003
-
-  Permission is hereby granted, free of charge, to any person or organization
-  obtaining a copy of the software and accompanying documentation covered by
-  this license (the "Software") to use, reproduce, display, distribute,
-  execute, and transmit the Software, and to prepare derivative works of the
-  Software, and to permit third-parties to whom the Software is furnished to
-  do so, all subject to the following:
-
-  The copyright notices in the Software and this entire statement, including
-  the above license grant, this restriction and the following disclaimer,
-  must be included in all copies of the Software, in whole or in part, and
-  all derivative works of the Software, unless such copies or derivative
-  works are solely in the form of machine-executable object code generated by
-  a source language processor.
-
-  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-  FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-  SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-  FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-  DEALINGS IN THE SOFTWARE.
-
-The complete sub-set of boost is included in this release of the project. The source
-is compressed as a GZip file and can be found as the file "MXABoost.tar.gz".
-
-
- - \ No newline at end of file diff --git a/Resources/UnitTestSupport.hpp b/Resources/UnitTestSupport.hpp old mode 100755 new mode 100644 index 46ca33aef7..ba006e33aa --- a/Resources/UnitTestSupport.hpp +++ b/Resources/UnitTestSupport.hpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once @@ -49,6 +49,8 @@ #include #include +#include "SIMPLib/DataContainers/DataArrayPath.h" + namespace SIMPL { namespace unittest @@ -63,7 +65,16 @@ static const char Passed[6] = {'P', 'A', 'S', 'S', 'E', 'D'}; static const char Failed[6] = {'F', 'A', 'I', 'L', 'E', 'D'}; static int SizeOfPassed = 6; static int SizeOfFailed = 6; -} +} // namespace unittest +} // namespace SIMPL + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QTextStream& operator<<(QTextStream& out, const DataArrayPath& v) +{ + out << v.getDataContainerName() << "|" << v.getAttributeMatrixName() << "|" << v.getDataArrayName(); + return out; } // ----------------------------------------------------------------------------- @@ -73,11 +84,11 @@ class TestException : public std::exception { public: /** - * @brief - * @param what - * @param file - * @param lineNumber - */ + * @brief + * @param what + * @param file + * @param lineNumber + */ TestException(const std::string& what, const std::string& filename, int lineNumber) : m_Message(what) , m_FileName(filename) @@ -87,8 +98,8 @@ class TestException : public std::exception } /** - * @brief Copy Constructor - */ + * @brief Copy Constructor + */ TestException(const TestException& te) { m_Message = (&te)->getMessage(); @@ -272,10 +283,10 @@ inline int Sign(float* A) bool AlmostEqualUlpsFinal(float* A, float* B, int maxUlps) { -// There are several optional checks that you can do, depending -// on what behavior you want from your floating point comparisons. -// These checks should not be necessary and they are included -// mainly for completeness. + // There are several optional checks that you can do, depending + // on what behavior you want from your floating point comparisons. + // These checks should not be necessary and they are included + // mainly for completeness. #ifdef INFINITYCHECK // If A or B are infinity (positive or negative) then @@ -417,8 +428,8 @@ bool AlmostEqualUlpsFinal(float* A, float* B, int maxUlps) QString buf; \ QTextStream ss(&buf); \ ss << "Your test required the following\n '"; \ - ss << "AlmostEqualUlpsFinal(" << #L << ", " << #R << ", " << #Ulps << "'\n but this condition was not met with MaxUlps=" << Ulps << "\n"; \ - ss << " " << L << "==" << R; \ + ss << "AlmostEqualUlpsFinal(" << #L << ", " << #R << ", " << #Ulps << ")'\n but this condition was not met with MaxUlps=" << Ulps << "\n"; \ + ss << " " << *L << "==" << *R; \ DREAM3D_TEST_THROW_EXCEPTION(buf.toStdString()) \ } @@ -522,7 +533,8 @@ bool AlmostEqualUlpsFinal(float* A, float* B, int maxUlps) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void require_equal(T l, const QString& L, K r, const QString& R, const QString file = "", int line = 0) +template +void require_equal(T l, const QString& L, K r, const QString& R, const QString file = "", int line = 0) { if(l != r) { @@ -539,7 +551,8 @@ template void require_equal(T l, const QString& L, K r, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void require_less_than(T l, const QString& L, K r, const QString& R, const QString file = "", int line = 0) +template +void require_less_than(T l, const QString& L, K r, const QString& R, const QString file = "", int line = 0) { if(l >= r) { @@ -555,7 +568,8 @@ template void require_less_than(T l, const QString& L, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void require_greater_than(T l, const QString& L, K r, const QString& R, const QString file = "", int line = 0) +template +void require_greater_than(T l, const QString& L, K r, const QString& R, const QString file = "", int line = 0) { if(l <= r) { @@ -567,4 +581,3 @@ template void require_greater_than(T l, const QString& throw TestException(buf.toStdString(), file.toStdString(), line); } } - diff --git a/Source/Experimental/FilterCallback/FilterParameter.cpp b/Source/Experimental/FilterCallback/FilterParameter.cpp index b9d65b5731..71816bf124 100644 --- a/Source/Experimental/FilterCallback/FilterParameter.cpp +++ b/Source/Experimental/FilterCallback/FilterParameter.cpp @@ -1,36 +1,24 @@ #include "FilterParameter.h" - - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- IFilterParameter::IFilterParameter(const std::string& humanLabel, const std::string& propertyName, IFilterParameter::Category category, int groupIndex) - : m_HumanLabel(humanLabel) - , m_PropertyName(propertyName) - , m_Category(category) - , m_GroupIndex(groupIndex) +: m_HumanLabel(humanLabel) +, m_PropertyName(propertyName) +, m_Category(category) +, m_GroupIndex(groupIndex) { } IFilterParameter::~IFilterParameter() = default; - - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - - - -Int32Parameter::Pointer Int32Parameter::New(const std::string& humanLabel, - const std::string& propertyName, - const int& defaultValue, - Category category, - Int32Parameter::SetterCallbackType setterCallback, - Int32Parameter::GetterCallbackType getterCallback, - int groupIndex) +Int32Parameter::Pointer Int32Parameter::New(const std::string& humanLabel, const std::string& propertyName, int defaultValue, Category category, Int32Parameter::SetterCallbackType setterCallback, + Int32Parameter::GetterCallbackType getterCallback, int groupIndex) { Pointer sharedPtr(new Int32Parameter(humanLabel, propertyName, defaultValue, category, setterCallback, getterCallback, groupIndex)); return sharedPtr; @@ -61,24 +49,20 @@ void Int32Parameter::writeJson(QJsonObject& json) const json[QString::fromStdString(getPropertyName())] = m_GetterCallback(); } -Int32Parameter::Int32Parameter(const std::string& humanLabel, const std::string& propertyName, int defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) - : IFilterParameter(humanLabel, propertyName, category, groupIndex) - , m_DefaultValue(defaultValue) - , m_SetterCallback(setterCallback) - , m_GetterCallback(getterCallback) +Int32Parameter::Int32Parameter(const std::string& humanLabel, const std::string& propertyName, int defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex) +: IFilterParameter(humanLabel, propertyName, category, groupIndex) +, m_DefaultValue(defaultValue) +, m_SetterCallback(setterCallback) +, m_GetterCallback(getterCallback) { } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DoubleParameter::Pointer DoubleParameter::New(const std::string& humanLabel, - const std::string& propertyName, - const double& defaultValue, - Category category, - DoubleParameter::SetterCallbackType setterCallback, - DoubleParameter::GetterCallbackType getterCallback, - int groupIndex) +DoubleParameter::Pointer DoubleParameter::New(const std::string& humanLabel, const std::string& propertyName, double defaultValue, Category category, + DoubleParameter::SetterCallbackType setterCallback, DoubleParameter::GetterCallbackType getterCallback, int groupIndex) { Pointer sharedPtr(new DoubleParameter(humanLabel, propertyName, defaultValue, category, setterCallback, getterCallback, groupIndex)); return sharedPtr; @@ -109,27 +93,20 @@ void DoubleParameter::writeJson(QJsonObject& json) const json[QString::fromStdString(getPropertyName())] = m_GetterCallback(); } - -DoubleParameter::DoubleParameter(const std::string& humanLabel, const std::string& propertyName, double defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) - : IFilterParameter(humanLabel, propertyName, category, groupIndex) - , m_DefaultValue(defaultValue) - , m_SetterCallback(setterCallback) - , m_GetterCallback(getterCallback) +DoubleParameter::DoubleParameter(const std::string& humanLabel, const std::string& propertyName, double defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex) +: IFilterParameter(humanLabel, propertyName, category, groupIndex) +, m_DefaultValue(defaultValue) +, m_SetterCallback(setterCallback) +, m_GetterCallback(getterCallback) { } - - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataArrayPathParameter::Pointer DataArrayPathParameter::New(const std::string& humanLabel, - const std::string& propertyName, - const DataArrayPath& defaultValue, - Category category, - SetterCallbackType setterCallback, - GetterCallbackType getterCallback, - int groupIndex) +DataArrayPathParameter::Pointer DataArrayPathParameter::New(const std::string& humanLabel, const std::string& propertyName, const DataArrayPath& defaultValue, Category category, + SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) { DataArrayPathParameter::Pointer sharedPtr(new DataArrayPathParameter(humanLabel, propertyName, defaultValue, category, setterCallback, getterCallback, groupIndex)); return sharedPtr; @@ -154,7 +131,7 @@ void DataArrayPathParameter::readJson(const QJsonObject& json) DataArrayPath dap; QJsonObject obj = jsonValue.toObject(); dap.readJson(obj); - if( m_SetterCallback) + if(m_SetterCallback) { m_SetterCallback(dap); } @@ -169,10 +146,119 @@ void DataArrayPathParameter::writeJson(QJsonObject& json) const } } -DataArrayPathParameter::DataArrayPathParameter(const std::string& humanLabel, const std::string& propertyName, const DataArrayPath &defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) - : IFilterParameter(humanLabel, propertyName, category, groupIndex) - , m_DefaultValue(defaultValue) - , m_SetterCallback(setterCallback) - , m_GetterCallback(getterCallback) +DataArrayPathParameter::DataArrayPathParameter(const std::string& humanLabel, const std::string& propertyName, const DataArrayPath& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) +: IFilterParameter(humanLabel, propertyName, category, groupIndex) +, m_DefaultValue(defaultValue) +, m_SetterCallback(setterCallback) +, m_GetterCallback(getterCallback) +{ +} + +// ----------------------------------------------------------------------------- +FilterParameter::Pointer FilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +void FilterParameter::setHumanLabel(const std::string& value) +{ + m_HumanLabel = value; +} + +// ----------------------------------------------------------------------------- +std::string FilterParameter::getHumanLabel() const +{ + return m_HumanLabel; +} + +// ----------------------------------------------------------------------------- +void FilterParameter::setPropertyName(const std::string& value) +{ + m_PropertyName = value; +} + +// ----------------------------------------------------------------------------- +std::string FilterParameter::getPropertyName() const +{ + return m_PropertyName; +} + +// ----------------------------------------------------------------------------- +void FilterParameter::setCategory(const Category& value) +{ + m_Category = value; +} + +// ----------------------------------------------------------------------------- +Category FilterParameter::getCategory() const +{ + return m_Category; +} + +// ----------------------------------------------------------------------------- +void FilterParameter::setGroupIndex(int value) +{ + m_GroupIndex = value; +} + +// ----------------------------------------------------------------------------- +int FilterParameter::getGroupIndex() const +{ + return m_GroupIndex; +} + +// ----------------------------------------------------------------------------- +FilterParameter::Pointer FilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +void FilterParameter::setDefaultValue(int value) +{ + m_DefaultValue = value; +} + +// ----------------------------------------------------------------------------- +int FilterParameter::getDefaultValue() const +{ + return m_DefaultValue; +} + +// ----------------------------------------------------------------------------- +FilterParameter::Pointer FilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +void FilterParameter::setDefaultValue(double value) +{ + m_DefaultValue = value; +} + +// ----------------------------------------------------------------------------- +double FilterParameter::getDefaultValue() const +{ + return m_DefaultValue; +} + +// ----------------------------------------------------------------------------- +FilterParameter::Pointer FilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +void FilterParameter::setDefaultValue(const DataArrayPath& value) +{ + m_DefaultValue = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath FilterParameter::getDefaultValue() const { + return m_DefaultValue; } diff --git a/Source/Experimental/FilterCallback/FilterParameter.h b/Source/Experimental/FilterCallback/FilterParameter.h index c2514d2f10..25be4d58fb 100644 --- a/Source/Experimental/FilterCallback/FilterParameter.h +++ b/Source/Experimental/FilterCallback/FilterParameter.h @@ -1,21 +1,15 @@ #pragma once - - - +#include #include #include #include - #include -#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataContainers/DataArrayPath.h" - // ----------------------------------------------------------------------------- // This section of Macros allows each FilterParameter subclass to create a macro // or set of macros that can lessen the amout of code that needs to be written @@ -24,166 +18,186 @@ // __VA__ARGS__ // ----------------------------------------------------------------------------- -#define SIMPL_BIND_SETTER(Class, Type, Prop)\ - Class::SetterCallbackType _##Prop##_ParamSetter = [this](Type i) { return this->set##Prop(i); }; \ - -#define SIMPL_BIND_GETTER(Class, Type, Prop)\ - Class::GetterCallbackType _##Prop##_ParamGetter = [this] { return this->get##Prop(); }; \ - +#define SIMPL_BIND_SETTER(Class, Type, Prop) Class::SetterCallbackType _##Prop##_ParamSetter = [this](Type i) { return this->set##Prop(i); }; + +#define SIMPL_BIND_GETTER(Class, Type, Prop) Class::GetterCallbackType _##Prop##_ParamGetter = [this] { return this->get##Prop(); }; + // Define overrides that can be used by the expansion of our main macro. // Each subclass can define a macro that takes up to nine (9) arguments // to the constructor. These macros support a minimum of 4 arguments. -#define SIMPL_NEW_FP_9(Class, Type, Desc, Prop, Category, Index, A, B, C, D, E)\ - Class::New(Desc, #Prop, get##Prop(), Category, \ - [this](Type i) { return this->set##Prop(i); }, \ - [this] { return this->get##Prop(); },\ - Index, A, B, C, D, E) - -#define SIMPL_NEW_FP_8(Class, Type, Desc, Prop, Category, Index, A, B, C, D)\ - Class::New(Desc, #Prop, get##Prop(), Category, \ - [this](Type i) { return this->set##Prop(i); }, \ - [this] { return this->get##Prop(); },\ - Index, A, B, C, D) - -#define SIMPL_NEW_FP_7(Class, Type, Desc, Prop, Category, Index, A, B, C)\ - Class::New(Desc, #Prop, get##Prop(), Category, \ - [this](Type i) { return this->set##Prop(i); }, \ - [this] { return this->get##Prop(); },\ - Index, A, B, C) - -#define SIMPL_NEW_FP_6(Class, Type, Desc, Prop, Category, Index, A, B)\ - Class::New(Desc, #Prop, get##Prop(), Category, \ - [this](Type i) { return this->set##Prop(i); }, \ - [this] { return this->get##Prop(); },\ - Index, A, B) - -#define SIMPL_NEW_FP_5(Class, Type, Desc, Prop, Category, Index, A)\ - Class::New(Desc, #Prop, get##Prop(), Category, \ - [this](Type i) { return this->set##Prop(i); }, \ - [this] { return this->get##Prop(); },\ - Index, A) - -#define SIMPL_NEW_FP_4(Class, Type, Desc, Prop, Category, Index)\ - Class::New(Desc, #Prop, get##Prop(), Category, \ - [this](Type i) { return this->set##Prop(i); }, \ - [this] { return this->get##Prop(); },\ - Index) - -#define SIMPL_NEW_FP_3(Class, Type, Desc, Prop, Category)\ - Class::New(Desc, #Prop, get##Prop(), Category, \ - [this](Type i) { return this->set##Prop(i); }, \ - [this] { return this->get##Prop(); }\ - ) +#define SIMPL_NEW_FP_9(Class, Type, Desc, Prop, Category, Index, A, B, C, D, E) \ + Class::New( \ + Desc, #Prop, get##Prop(), Category, [this](Type i) { return this->set##Prop(i); }, [this] { return this->get##Prop(); }, Index, A, B, C, D, E) + +#define SIMPL_NEW_FP_8(Class, Type, Desc, Prop, Category, Index, A, B, C, D) \ + Class::New( \ + Desc, #Prop, get##Prop(), Category, [this](Type i) { return this->set##Prop(i); }, [this] { return this->get##Prop(); }, Index, A, B, C, D) +#define SIMPL_NEW_FP_7(Class, Type, Desc, Prop, Category, Index, A, B, C) \ + Class::New( \ + Desc, #Prop, get##Prop(), Category, [this](Type i) { return this->set##Prop(i); }, [this] { return this->get##Prop(); }, Index, A, B, C) + +#define SIMPL_NEW_FP_6(Class, Type, Desc, Prop, Category, Index, A, B) \ + Class::New( \ + Desc, #Prop, get##Prop(), Category, [this](Type i) { return this->set##Prop(i); }, [this] { return this->get##Prop(); }, Index, A, B) + +#define SIMPL_NEW_FP_5(Class, Type, Desc, Prop, Category, Index, A) \ + Class::New( \ + Desc, #Prop, get##Prop(), Category, [this](Type i) { return this->set##Prop(i); }, [this] { return this->get##Prop(); }, Index, A) + +#define SIMPL_NEW_FP_4(Class, Type, Desc, Prop, Category, Index) \ + Class::New( \ + Desc, #Prop, get##Prop(), Category, [this](Type i) { return this->set##Prop(i); }, [this] { return this->get##Prop(); }, Index) + +#define SIMPL_NEW_FP_3(Class, Type, Desc, Prop, Category) \ + Class::New( \ + Desc, #Prop, get##Prop(), Category, [this](Type i) { return this->set##Prop(i); }, [this] { return this->get##Prop(); }) /** * @brief This macro is needed for Visual Studio due to differences of VAR_ARGS when * passed to another macro that results in a new macro that needs expansion. */ -#define SIMPL_EXPAND( x ) x +#define SIMPL_EXPAND(x) x // ----------------------------------------------------------------------------- // Define a macro that uses the "paired, sliding arg list" // technique to select the appropriate override. #define _FP_GET_OVERRIDE(A, B, C, D, E, F, G, H, I, NAME, ...) NAME +#define SIMPL_NEW_INT32_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4, SIMPL_NEW_FP_3)(Int32Parameter, int, __VA_ARGS__)) -#define SIMPL_NEW_INT32_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4, SIMPL_NEW_FP_3)\ - (Int32Parameter, int, __VA_ARGS__)) - - -#define SIMPL_NEW_DOUBLE_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4, SIMPL_NEW_FP_3)\ - (DoubleParameter, double, __VA_ARGS__)) - - -#define SIMPL_NEW_DATA_ARRAY_PATH_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4, SIMPL_NEW_FP_3)\ - (DataArrayPathParameter, DataArrayPath, __VA_ARGS__)) - +#define SIMPL_NEW_DOUBLE_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4, SIMPL_NEW_FP_3)(DoubleParameter, double, __VA_ARGS__)) +#define SIMPL_NEW_DATA_ARRAY_PATH_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4, SIMPL_NEW_FP_3)(DataArrayPathParameter, DataArrayPath, \ + __VA_ARGS__)) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- class IFilterParameter { - public: - SIMPL_SHARED_POINTERS(IFilterParameter) - - using EnumType = unsigned int; - - enum class Category : EnumType - { - Parameter = 0, - RequiredArray = 1, - CreatedArray = 2, - Uncategorized = 3 - }; - - IFilterParameter(const std::string& humanLabel, const std::string& propertyName, Category category, int groupIndex); - - virtual ~IFilterParameter(); - - SIMPL_INSTANCE_PROPERTY(std::string, HumanLabel) - SIMPL_INSTANCE_PROPERTY(std::string, PropertyName) - SIMPL_INSTANCE_PROPERTY(Category, Category) - SIMPL_INSTANCE_PROPERTY(int, GroupIndex) - - virtual void readJson(const QJsonObject& json) = 0; - virtual void writeJson(QJsonObject& json) const = 0; - - private: - IFilterParameter(const IFilterParameter&) = delete; // Copy Constructor Not Implemented - void operator=(const IFilterParameter&) = delete; // Move assignment Not Implemented +public: + using Self = IFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + using EnumType = unsigned int; + + enum class Category : EnumType + { + Parameter = 0, + RequiredArray = 1, + CreatedArray = 2, + Uncategorized = 3 + }; + + IFilterParameter(const std::string& humanLabel, const std::string& propertyName, Category category, int groupIndex); + + virtual ~IFilterParameter(); + + /** + * @brief Setter property for HumanLabel + */ + void setHumanLabel(const std::string& value); + /** + * @brief Getter property for HumanLabel + * @return Value of HumanLabel + */ + std::string getHumanLabel() const; + + /** + * @brief Setter property for PropertyName + */ + void setPropertyName(const std::string& value); + /** + * @brief Getter property for PropertyName + * @return Value of PropertyName + */ + std::string getPropertyName() const; + + /** + * @brief Setter property for Category + */ + void setCategory(const Category& value); + /** + * @brief Getter property for Category + * @return Value of Category + */ + Category getCategory() const; + + /** + * @brief Setter property for GroupIndex + */ + void setGroupIndex(int value); + /** + * @brief Getter property for GroupIndex + * @return Value of GroupIndex + */ + int getGroupIndex() const; + + virtual void readJson(const QJsonObject& json) = 0; + virtual void writeJson(QJsonObject& json) const = 0; + +private: + IFilterParameter(const IFilterParameter&) = delete; // Copy Constructor Not Implemented + void operator=(const IFilterParameter&) = delete; // Move assignment Not Implemented }; - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- class Int32Parameter : public IFilterParameter { - - public: - SIMPL_SHARED_POINTERS(Int32Parameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - - static Pointer New(const std::string& humanLabel, - const std::string& propertyName, - const int& defaultValue, - Category category, - SetterCallbackType setterCallback, - GetterCallbackType getterCallback, - int groupIndex = -1); - virtual ~Int32Parameter(); - - SIMPL_INSTANCE_PROPERTY(int, DefaultValue) - - SetterCallbackType getSetterCallback(); - GetterCallbackType getGetterCallback(); - - void readJson(const QJsonObject& json) override; - - void writeJson(QJsonObject& json) const override; - - protected: - Int32Parameter(const std::string& humanLabel, const std::string& propertyName, int defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex); - - private: - Int32Parameter(const Int32Parameter&) = delete; // Copy Constructor Not Implemented - void operator=(const Int32Parameter&) = delete; // Move assignment Not Implemented - - SetterCallbackType m_SetterCallback; - GetterCallbackType m_GetterCallback; + +public: + using Self = Int32Parameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + static Pointer New(const std::string& humanLabel, const std::string& propertyName, int defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + virtual ~Int32Parameter(); + + /** + * @brief Setter property for DefaultValue + */ + void setDefaultValue(int value); + /** + * @brief Getter property for DefaultValue + * @return Value of DefaultValue + */ + int getDefaultValue() const; + + SetterCallbackType getSetterCallback(); + GetterCallbackType getGetterCallback(); + + void readJson(const QJsonObject& json) override; + + void writeJson(QJsonObject& json) const override; + +protected: + Int32Parameter(const std::string& humanLabel, const std::string& propertyName, int defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex); + +private: + Int32Parameter(const Int32Parameter&) = delete; // Copy Constructor Not Implemented + void operator=(const Int32Parameter&) = delete; // Move assignment Not Implemented + + SetterCallbackType m_SetterCallback; + GetterCallbackType m_GetterCallback; }; // ----------------------------------------------------------------------------- @@ -191,40 +205,48 @@ class Int32Parameter : public IFilterParameter // ----------------------------------------------------------------------------- class DoubleParameter : public IFilterParameter { - public: - SIMPL_SHARED_POINTERS(DoubleParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - static Pointer New(const std::string& humanLabel, - const std::string& propertyName, - const double& defaultValue, - Category category, - SetterCallbackType setterCallback, - GetterCallbackType getterCallback, - int groupIndex = -1); - virtual ~DoubleParameter(); - - SIMPL_INSTANCE_PROPERTY(double, DefaultValue) - - - SetterCallbackType getSetterCallback(); - GetterCallbackType getGetterCallback(); - - void readJson(const QJsonObject& json) override; - - void writeJson(QJsonObject& json) const override; - - protected: - DoubleParameter(const std::string& humanLabel, const std::string& propertyName, double defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex); - - private: - DoubleParameter(const DoubleParameter&) = delete; // Copy Constructor Not Implemented - void operator=(const DoubleParameter&) = delete; // Move assignment Not Implemented - - SetterCallbackType m_SetterCallback; - GetterCallbackType m_GetterCallback; +public: + using Self = DoubleParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + static Pointer New(const std::string& humanLabel, const std::string& propertyName, double defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + virtual ~DoubleParameter(); + + /** + * @brief Setter property for DefaultValue + */ + void setDefaultValue(double value); + /** + * @brief Getter property for DefaultValue + * @return Value of DefaultValue + */ + double getDefaultValue() const; + + SetterCallbackType getSetterCallback(); + GetterCallbackType getGetterCallback(); + + void readJson(const QJsonObject& json) override; + + void writeJson(QJsonObject& json) const override; + +protected: + DoubleParameter(const std::string& humanLabel, const std::string& propertyName, double defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex); + +private: + DoubleParameter(const DoubleParameter&) = delete; // Copy Constructor Not Implemented + void operator=(const DoubleParameter&) = delete; // Move assignment Not Implemented + + SetterCallbackType m_SetterCallback; + GetterCallbackType m_GetterCallback; }; // ----------------------------------------------------------------------------- @@ -232,40 +254,55 @@ class DoubleParameter : public IFilterParameter // ----------------------------------------------------------------------------- class DataArrayPathParameter : public IFilterParameter { - public: - SIMPL_SHARED_POINTERS(DataArrayPathParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - static Pointer New(const std::string& humanLabel, - const std::string& propertyName, - const DataArrayPath& defaultValue, - Category category, - SetterCallbackType setterCallback, - GetterCallbackType getterCallback, - int groupIndex = -1); - - virtual ~DataArrayPathParameter(); - - SIMPL_INSTANCE_PROPERTY(DataArrayPath, DefaultValue) - - - SetterCallbackType getSetterCallback(); - GetterCallbackType getGetterCallback(); - - void readJson(const QJsonObject& json) override; - - void writeJson(QJsonObject& json) const override; - - protected: - DataArrayPathParameter(const std::string& humanLabel, const std::string& propertyName, const DataArrayPath &defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex); - - private: - DataArrayPathParameter(const DataArrayPathParameter&) = delete; // Copy Constructor Not Implemented - void operator=(const DataArrayPathParameter&) = delete; // Move assignment Not Implemented - - SetterCallbackType m_SetterCallback; - GetterCallbackType m_GetterCallback; +public: + using Self = DataArrayPathParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + static Pointer New(const std::string& humanLabel, const std::string& propertyName, const DataArrayPath& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + virtual ~DataArrayPathParameter(); + + /** + * @brief Setter property for DefaultValue + */ + void setDefaultValue(const DataArrayPath& value); + /** + * @brief Getter property for DefaultValue + * @return Value of DefaultValue + */ + DataArrayPath getDefaultValue() const; + + SetterCallbackType getSetterCallback(); + GetterCallbackType getGetterCallback(); + + void readJson(const QJsonObject& json) override; + + void writeJson(QJsonObject& json) const override; + +protected: + DataArrayPathParameter(const std::string& humanLabel, const std::string& propertyName, const DataArrayPath& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex); + +private: + std::string m_HumanLabel = {}; + std::string m_PropertyName = {}; + Category m_Category = {}; + int m_GroupIndex = {}; + int m_DefaultInt = {}; + double m_DefaultDouble = {}; + DataArrayPath m_DefaultDAP = {}; + + DataArrayPathParameter(const DataArrayPathParameter&) = delete; // Copy Constructor Not Implemented + void operator=(const DataArrayPathParameter&) = delete; // Move assignment Not Implemented + + SetterCallbackType m_SetterCallback; + GetterCallbackType m_GetterCallback; }; - diff --git a/Source/Experimental/FilterCallback/FilterParameterCallbackExample.cpp b/Source/Experimental/FilterCallback/FilterParameterCallbackExample.cpp index 9451426f63..8f946be4ec 100644 --- a/Source/Experimental/FilterCallback/FilterParameterCallbackExample.cpp +++ b/Source/Experimental/FilterCallback/FilterParameterCallbackExample.cpp @@ -4,14 +4,13 @@ #include #include -#include #include #include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataContainers/DataArrayPath.h" -#include "IFilter.h" #include "FilterWidget.h" +#include "IFilter.h" //#define ADD_NEW_FILTER_PARAMETER(Params, Class, Desc, Prop, Category, Type) \ // Class::SetterCallbackType _##Prop##_ParamSetter = [this](Type i) { return this->set##Prop(i); }; \ @@ -27,7 +26,6 @@ //#define ADD_DATAARRAYPATH_PARAMETER(Params, Desc, Prop) \ // ADD_NEW_FILTER_PARAMETER(Params, DataArrayPathParameter, Desc, Prop, DataArrayPath) - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -36,7 +34,6 @@ namespace Detail const QString FilterName("FilterName"); } - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -63,12 +60,14 @@ int main(int argc, char* argv[]) { dblParam->getSetterCallback()(6.66666); } - + DataArrayPathParameter::Pointer dapParam = std::dynamic_pointer_cast(params.at(3)); - if(dapParam) { + if(dapParam) + { std::function dapCallback = dapParam->getSetterCallback(); - if(dapCallback) { - dapCallback(DataArrayPath("Image","CellAM","FeatureIds")); + if(dapCallback) + { + dapCallback(DataArrayPath("Image", "CellAM", "FeatureIds")); } } @@ -82,7 +81,6 @@ int main(int argc, char* argv[]) int32Widget_B.parametersUpdated(); filter.printValues(std::cout); - QJsonObject root; filter.writeParameters(root); diff --git a/Source/Experimental/FilterCallback/FilterWidget.cpp b/Source/Experimental/FilterCallback/FilterWidget.cpp index 36c47f1fe1..9e29cfb419 100644 --- a/Source/Experimental/FilterCallback/FilterWidget.cpp +++ b/Source/Experimental/FilterCallback/FilterWidget.cpp @@ -60,7 +60,6 @@ void IntFilterParameterWidget::parametersUpdated() } else { - std::cout << "Filter Parameter is NOT Int32Parameter" << std::endl; + std::cout << "Filter Parameter is NOT Int32Parameter" << std::endl; } } - diff --git a/Source/Experimental/FilterCallback/FilterWidget.h b/Source/Experimental/FilterCallback/FilterWidget.h index e900411e50..bbc98ae613 100644 --- a/Source/Experimental/FilterCallback/FilterWidget.h +++ b/Source/Experimental/FilterCallback/FilterWidget.h @@ -1,35 +1,26 @@ #pragma once - - - - class IFilter; class Int32Parameter; class IFilterParameter; - class IntFilterParameterWidget /* : Normally be a QWidget class */ { public: IntFilterParameterWidget(IFilter* filter, Int32Parameter* parameter); - + IntFilterParameterWidget(IFilter* filter, IFilterParameter* parameter); - + virtual ~IntFilterParameterWidget(); - + void parametersUpdated(); - -private: +private: IFilter* m_Filter = nullptr; Int32Parameter* m_FilterParameter = nullptr; IntFilterParameterWidget(const IntFilterParameterWidget&) = delete; // Copy Constructor Not Implemented void operator=(const IntFilterParameterWidget&) = delete; // Move assignment Not Implemented }; - - - diff --git a/Source/Experimental/FilterCallback/IFilter.cpp b/Source/Experimental/FilterCallback/IFilter.cpp index e12862b5ea..0ab816f408 100644 --- a/Source/Experimental/FilterCallback/IFilter.cpp +++ b/Source/Experimental/FilterCallback/IFilter.cpp @@ -1,18 +1,15 @@ #include "IFilter.h" - - - #include "FilterParameter.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- IFilter::IFilter() - : m_Index(0) - , m_Parameter1(std::numeric_limits::max()) - , m_Parameter2(std::numeric_limits::max()) - , m_FeatureIdsPath("Foo", "Bar", "FeatureIds") +: m_Index(0) +, m_Parameter1(std::numeric_limits::max()) +, m_Parameter2(std::numeric_limits::max()) +, m_FeatureIdsPath("Foo", "Bar", "FeatureIds") { setupParameters(); } @@ -29,12 +26,12 @@ void IFilter::setupParameters() { std::vector params; int groupIndex = -1; - - params.push_back( SIMPL_NEW_INT32_FP("Parameter 1", Parameter1, IFilterParameter::Category::Parameter) ); - params.push_back( SIMPL_NEW_DOUBLE_FP("Parameter 2", Parameter2, IFilterParameter::Category::Parameter) ); - params.push_back( SIMPL_NEW_INT32_FP("Index", Index, IFilterParameter::Category::Parameter, groupIndex) ); - params.push_back( SIMPL_NEW_DATA_ARRAY_PATH_FP("FeatureIdsPath", FeatureIdsPath, IFilterParameter::Category::Parameter, groupIndex) ); - + + params.push_back(SIMPL_NEW_INT32_FP("Parameter 1", Parameter1, IFilterParameter::Category::Parameter)); + params.push_back(SIMPL_NEW_DOUBLE_FP("Parameter 2", Parameter2, IFilterParameter::Category::Parameter)); + params.push_back(SIMPL_NEW_INT32_FP("Index", Index, IFilterParameter::Category::Parameter, groupIndex)); + params.push_back(SIMPL_NEW_DATA_ARRAY_PATH_FP("FeatureIdsPath", FeatureIdsPath, IFilterParameter::Category::Parameter, groupIndex)); + m_FilterParameters = params; } @@ -107,10 +104,70 @@ void IFilter::dataCheck() // ----------------------------------------------------------------------------- void IFilter::preflight() { -// setInPreflight(true); -// emit preflightAboutToExecute(); -// emit updateFilterParameters(this); -// dataCheck(); -// emit preflightExecuted(); -// setInPreflight(false); + // setInPreflight(true); + // Q_EMIT preflightAboutToExecute(); + // Q_EMIT updateFilterParameters(this); + // dataCheck(); + // Q_EMIT preflightExecuted(); + // setInPreflight(false); +} + +// ----------------------------------------------------------------------------- +void IFilter::setIndex(int value) +{ + m_Index = value; +} + +// ----------------------------------------------------------------------------- +int IFilter::getIndex() const +{ + return m_Index; +} + +// ----------------------------------------------------------------------------- +void IFilter::setParameter1(int value) +{ + m_Parameter1 = value; +} + +// ----------------------------------------------------------------------------- +int IFilter::getParameter1() const +{ + return m_Parameter1; +} + +// ----------------------------------------------------------------------------- +void IFilter::setParameter2(double value) +{ + m_Parameter2 = value; +} + +// ----------------------------------------------------------------------------- +double IFilter::getParameter2() const +{ + return m_Parameter2; +} + +// ----------------------------------------------------------------------------- +void IFilter::setFeatureIdsPath(const DataArrayPath& value) +{ + m_FeatureIdsPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath IFilter::getFeatureIdsPath() const +{ + return m_FeatureIdsPath; +} + +// ----------------------------------------------------------------------------- +void IFilter::setInPreflight(bool value) +{ + m_InPreflight = value; +} + +// ----------------------------------------------------------------------------- +bool IFilter::getInPreflight() const +{ + return m_InPreflight; } diff --git a/Source/Experimental/FilterCallback/IFilter.h b/Source/Experimental/FilterCallback/IFilter.h index adbb2050cd..db21b052df 100644 --- a/Source/Experimental/FilterCallback/IFilter.h +++ b/Source/Experimental/FilterCallback/IFilter.h @@ -1,14 +1,10 @@ #pragma once - - #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataContainers/DataArrayPath.h" - #include "FilterParameter.h" // ----------------------------------------------------------------------------- @@ -16,32 +12,75 @@ // ----------------------------------------------------------------------------- class IFilter { - public: - IFilter(); - - virtual ~IFilter(); - - void setupParameters(); - - SIMPL_FILTER_PARAMETER(int, Index) - SIMPL_FILTER_PARAMETER(int, Parameter1) - SIMPL_FILTER_PARAMETER(double, Parameter2) - SIMPL_FILTER_PARAMETER(DataArrayPath, FeatureIdsPath) - - void readFilterParameters(QJsonObject& root); - - void writeParameters(QJsonObject& root); - - void printValues(std::ostream& out); - - std::string getName(); - - SIMPL_INSTANCE_PROPERTY(bool, InPreflight) - - std::vector getFilterParameters(); - - virtual void preflight(); - #if 0 +public: + IFilter(); + + virtual ~IFilter(); + + void setupParameters(); + + /** + * @brief Setter property for Index + */ + void setIndex(int value); + /** + * @brief Getter property for Index + * @return Value of Index + */ + int getIndex() const; + + /** + * @brief Setter property for Parameter1 + */ + void setParameter1(int value); + /** + * @brief Getter property for Parameter1 + * @return Value of Parameter1 + */ + int getParameter1() const; + + /** + * @brief Setter property for Parameter2 + */ + void setParameter2(double value); + /** + * @brief Getter property for Parameter2 + * @return Value of Parameter2 + */ + double getParameter2() const; + + /** + * @brief Setter property for FeatureIdsPath + */ + void setFeatureIdsPath(const DataArrayPath& value); + /** + * @brief Getter property for FeatureIdsPath + * @return Value of FeatureIdsPath + */ + DataArrayPath getFeatureIdsPath() const; + + void readFilterParameters(QJsonObject& root); + + void writeParameters(QJsonObject& root); + + void printValues(std::ostream& out); + + std::string getName(); + + /** + * @brief Setter property for InPreflight + */ + void setInPreflight(bool value); + /** + * @brief Getter property for InPreflight + * @return Value of InPreflight + */ + bool getInPreflight() const; + + std::vector getFilterParameters(); + + virtual void preflight(); +#if 0 // These are slots virtual void setCancel(bool value); @@ -73,20 +112,23 @@ class IFilter * @brief preflightExecuted Emitted just after calling dataCheck() */ void preflightExecuted(); - #endif - - protected: - void dataCheck(); - - private: - std::vector m_FilterParameters; - - public: - IFilter(const IFilter&) = delete; // Copy Constructor Not Implemented - IFilter(IFilter&&) = delete; // Move Constructor Not Implemented - IFilter& operator=(const IFilter&) = delete; // Copy Assignment Not Implemented - IFilter& operator=(IFilter&&) = delete; // Move Assignment Not Implemented -}; +#endif + +protected: + void dataCheck(); +private: + int m_Index = {}; + int m_Parameter1 = {}; + double m_Parameter2 = {}; + DataArrayPath m_FeatureIdsPath = {}; + bool m_InPreflight = {}; + std::vector m_FilterParameters; +public: + IFilter(const IFilter&) = delete; // Copy Constructor Not Implemented + IFilter(IFilter&&) = delete; // Move Constructor Not Implemented + IFilter& operator=(const IFilter&) = delete; // Copy Assignment Not Implemented + IFilter& operator=(IFilter&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/H5Support/CMakeLists.txt b/Source/H5Support/CMakeLists.txt deleted file mode 100755 index 46c9f85f8f..0000000000 --- a/Source/H5Support/CMakeLists.txt +++ /dev/null @@ -1,240 +0,0 @@ -# ============================================================================ -# Copyright (c) 2009-2015 BlueQuartz Software, LLC -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, this -# list of conditions and the following disclaimer in the documentation and/or -# other materials provided with the distribution. -# -# Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -# contributors may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The code contained herein was partially funded by the followig contracts: -# United States Air Force Prime Contract FA8650-07-D-5800 -# United States Air Force Prime Contract FA8650-10-D-5210 -# United States Prime Contract Navy N00173-07-C-2068 -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -# set project's name -PROJECT( H5Support VERSION ${SIMPLProj_VERSION_MAJOR}.${SIMPLProj_VERSION_MINOR}) - -set(PROJECT_CODE_DIR ${PROJECT_SOURCE_DIR}/Source) -if(NOT PROJECT_RESOURCES_DIR) - set(PROJECT_RESOURCES_DIR ${H5Support_SOURCE_DIR}/Resources) -endif() -if(NOT DEFINED CMP_SOURCE_DIR) - set(CMP_SOURCE_DIR ${H5Support_SOURCE_DIR}/Support/cmp) -endif() - -set(PROJECT_PREFIX "H5Support" CACHE STRING "The Prefix to be used for Preprocessor definitions") -set(H5Support_INSTALL_FILES 0) -# ----------------------------------------------------------------------- -# The project generally does NOT want to install headers. See if another -# project has over ridden that property -get_property(CMP_PROJECT_INSTALL_HEADERS GLOBAL PROPERTY CMP_PROJECT_INSTALL_HEADERS) -if("${CMP_PROJECT_INSTALL_HEADERS}" STREQUAL "") - set_property(GLOBAL PROPERTY CMP_PROJECT_INSTALL_HEADERS "0") - get_property(CMP_PROJECT_INSTALL_HEADERS GLOBAL PROPERTY CMP_PROJECT_INSTALL_HEADERS) -endif() -set(H5Support_INSTALL_FILES "${CMP_PROJECT_INSTALL_HEADERS}") - -set(H5Support_BUILT_AS_DYNAMIC_LIB) -if(BUILD_SHARED_LIBS) - set(H5Support_BUILT_AS_DYNAMIC_LIB 1) -endif(BUILD_SHARED_LIBS) - -#------------------------------------------------------------------------------- -# Include the cmp project to perform all the basic configuration tests for the -# project. -#------------------------------------------------------------------------------- -set(CMP_HEADER_DIR ${${PROJECT_NAME}_BINARY_DIR}) -set(CMP_CONFIGURATION_FILE_NAME "${PROJECT_NAME}Configuration.h") -set(CMP_EXPORT_FILE_NAME "${PROJECT_NAME}DLLExport.h") -set(CMP_TYPES_FILE_NAME "${PROJECT_NAME}Types.h") -set(CMP_VERSION_HEADER_FILE_NAME "${PROJECT_NAME}Version.h") -set(CMP_VERSION_SOURCE_FILE_NAME "${PROJECT_NAME}Version.cpp") -set(CMP_TOP_HEADER_FILE "${PROJECT_NAME}.h") -set(CMP_PROJECT_NAMESPACE "${PROJECT_NAME}") -set(CMP_PROJECT_NAME "${PROJECT_NAME}") -set(CMP_ENABLE_PLUGINS "0") -set(CMP_LIB_SEARCH_DIRS "") -set(CMP_GENERATE_VERSION_STRING 1) -set(PROJECT_INSTALL_HEADERS "${CMP_PROJECT_INSTALL_HEADERS}") - -INCLUDE (${CMP_SOURCE_DIR}/cmpProject.cmake) - -#------------------------------------------------------------------------------- -# Set our H5Lite codes to also compile the Qt API version of H5Lite -#------------------------------------------------------------------------------- -set(H5Support_USE_QT 0) -option(H5Support_INCLUDE_QT_API "Include support for using Qt classes with H5Lite" ON) -if(H5Support_INCLUDE_QT_API) - set(H5Support_USE_QT 1) -endif() -MARK_AS_ADVANCED(H5Support_INCLUDE_QT_API) -MARK_AS_ADVANCED(H5Support_USE_QT) - -set(H5Support_SRCS - ${H5Support_SOURCE_DIR}/H5Lite.cpp - ${H5Support_SOURCE_DIR}/H5Utilities.cpp - ${H5Support_SOURCE_DIR}/H5ScopedSentinel.cpp - ${H5Support_SOURCE_DIR}/H5ScopedErrorHandler.cpp - ) - -set(H5Support_HDRS - ${H5Support_SOURCE_DIR}/H5Lite.h - ${H5Support_SOURCE_DIR}/H5Utilities.h - ${H5Support_SOURCE_DIR}/H5ScopedSentinel.h - ${H5Support_SOURCE_DIR}/H5ScopedErrorHandler.h - ${H5Support_SOURCE_DIR}/H5Macros.h - ${H5Support_SOURCE_DIR}/H5SupportDLLExport.h -) - -if(H5Support_USE_QT) - set(H5Support_SRCS - ${H5Support_SRCS} - ${H5Support_SOURCE_DIR}/QH5Lite.cpp - ${H5Support_SOURCE_DIR}/QH5Utilities.cpp - ) - set(H5Support_HDRS - ${H5Support_HDRS} - ${H5Support_SOURCE_DIR}/QH5Lite.h - ${H5Support_SOURCE_DIR}/QH5Utilities.h - ) -endif() - - -#--------------------------------- -# Now configure the main header file. -configure_file(${H5Support_SOURCE_DIR}/H5SupportConfiguration.h.in - ${H5Support_BINARY_DIR}/${CMP_TOP_HEADER_FILE}) - -cmp_IDE_SOURCE_PROPERTIES( "" "${H5Support_HDRS}" "${H5Support_SRCS}" ${PROJECT_INSTALL_HEADERS}) - -# -------------------------------------------------------------------- -# Generate a Header file with Compile Version variables -# -------------------------------------------------------------------- -# set(VERSION_GEN_NAME "H5Support") -# set(VERSION_GEN_NAMESPACE "H5Support") -# set(PROJECT_PREFIX "H5Support") -# set(VERSION_GEN_COMPLETE "1.0.0") -# set(VERSION_GEN_VER_MAJOR "1") -# set(VERSION_GEN_VER_MINOR "0") -# set(VERSION_GEN_VER_PATCH "0") -# set(VERSION_GEN_HEADER_FILE_NAME "H5SupportVersion.h") - -# configure_file(${CMP_CONFIGURED_FILES_SOURCE_DIR}/cmpVersion.h.in -# ${H5Support_BINARY_DIR}/${PROJECT_NAME}/H5SupportVersion.h ) -# configure_file(${CMP_CONFIGURED_FILES_SOURCE_DIR}/cmpVersion.cpp.in -# ${H5Support_BINARY_DIR}/${PROJECT_NAME}/H5SupportVersion.cpp ) - - -set(PROJECT_SRCS - ${H5Support_SRCS} - ${H5Support_HDRS} - ${H5Support_BINARY_DIR}/${CMP_VERSION_SOURCE_FILE_NAME} -) - -add_library(${PROJECT_NAME} ${LIB_TYPE} ${PROJECT_SRCS}) -CMP_AddDefinitions(TARGET ${PROJECT_NAME}) -LibraryProperties( ${PROJECT_NAME} ${EXE_DEBUG_EXTENSION} ) -CMP_MODULE_INCLUDE_DIRS (TARGET ${PROJECT_NAME} LIBVARS HDF5 Qt5Core) - -get_filename_component(TARGET_BINARY_DIR_PARENT ${H5Support_BINARY_DIR} PATH) -get_filename_component(TARGET_SOURCE_DIR_PARENT ${H5Support_SOURCE_DIR} PATH) - - -TARGET_INCLUDE_DIRECTORIES( ${PROJECT_NAME} PUBLIC - $ - $ - $ - ) - -if(BUILD_SHARED_LIBS) - if(WIN32) - target_compile_definitions(${PROJECT_NAME} PUBLIC "-DH5Support_BUILT_AS_DYNAMIC_LIB") - endif(WIN32) -endif(BUILD_SHARED_LIBS) -target_link_libraries(${PROJECT_NAME} ${HDF5_C_TARGET_NAME} Qt5::Core ) - - -set(install_dir "bin") -set(lib_install_dir "lib") - -if(APPLE) - get_property(DREAM3D_PACKAGE_DEST_PREFIX GLOBAL PROPERTY DREAM3D_PACKAGE_DEST_PREFIX) - set(install_dir "${DREAM3D_PACKAGE_DEST_PREFIX}bin") - set(lib_install_dir "${DREAM3D_PACKAGE_DEST_PREFIX}lib") -elseif(WIN32) - set(install_dir ".") - set(lib_install_dir ".") -endif() - - -INSTALL(TARGETS ${PROJECT_NAME} - EXPORT H5SupportTargets - COMPONENT Applications - RUNTIME DESTINATION ${install_dir} - LIBRARY DESTINATION ${lib_install_dir} - ARCHIVE DESTINATION lib - BUNDLE DESTINATION "." -) - - -# -------------------------------------------------------------------- -# Allow the generation and installation of a CMake configuration file -# which makes using SIMPL from another project easier. -# -------------------------------------------------------------------- -export(EXPORT H5SupportTargets - FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake" - NAMESPACE H5Support:: -) - -if (H5Support_INSTALL_FILES) - install(EXPORT H5SupportTargets - FILE - ${PROJECT_NAME}Targets.cmake - NAMESPACE - ${PROJECT_NAME}:: - DESTINATION - ${ConfigPackageLocation} - ) - - install(FILES - ${CMP_HEADER_DIR}/${CMP_TOP_HEADER_FILE} - ${CMP_HEADER_DIR}/${CMP_TYPES_FILE_NAME} - ${CMP_HEADER_DIR}/${CMP_CONFIGURATION_FILE_NAME} - ${CMP_HEADER_DIR}/${CMP_VERSION_HEADER_FILE_NAME} - DESTINATION - include/${PROJECT_NAME} - ) - -endif() - - -# ------- Enable the CTest testing. --------------- -# -------------------------------------------------------------------- -# If Testing is enabled, turn on the Unit Tests -if(SIMPL_BUILD_TESTING) - include(${H5Support_SOURCE_DIR}/Test/CMakeLists.txt) -endif() - - diff --git a/Source/H5Support/H5Functions.cpp b/Source/H5Support/H5Functions.cpp deleted file mode 100644 index daee2a72e6..0000000000 --- a/Source/H5Support/H5Functions.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include diff --git a/Source/H5Support/H5Lite.cpp b/Source/H5Support/H5Lite.cpp deleted file mode 100644 index 2753b7a8e3..0000000000 --- a/Source/H5Support/H5Lite.cpp +++ /dev/null @@ -1,1395 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include - -#include - -#if defined(H5Support_NAMESPACE) -using namespace H5Support_NAMESPACE; -#endif - -/*------------------------------------------------------------------------- - * Function: find_dataset - * - * Purpose: operator function used by H5LTfind_dataset - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: June 21, 2001 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t find_dataset(hid_t /*loc_id*/, const char* name, void* op_data) -{ - H5SUPPORT_MUTEX_LOCK() - /* Define a default zero value for return. This will cause the iterator to continue if - * the dataset is not found yet. - */ - - int32_t ret = 0; - - char* dset_name = reinterpret_cast(op_data); - - /* Shut the compiler up */ - // loc_id=loc_id; - - /* Define a positive value for return value if the dataset was found. This will - * cause the iterator to immediately return that positive value, - * indicating short-circuit success - */ - - if(strcmp(name, dset_name) == 0) - { - ret = 1; - } - - return ret; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t find_attr(hid_t /*loc_id*/, const char* name, const H5A_info_t* /*info*/, void* op_data) -{ - H5SUPPORT_MUTEX_LOCK() - /* Define a default zero value for return. This will cause the iterator to continue if - * the palette attribute is not found yet. - */ - - int32_t ret = 0; - - char* attr_name = reinterpret_cast(op_data); - - /* Shut the compiler up */ - // loc_id=loc_id; - - /* Define a positive value for return value if the attribute was found. This will - * cause the iterator to immediately return that positive value, - * indicating short-circuit success - */ - - if(strcmp(name, attr_name) == 0) - { - ret = 1; - } - - return ret; -} - -// ----------------------------------------------------------------------------- -// Protected Constructor -// ----------------------------------------------------------------------------- -H5Lite::H5Lite() -= default; - -// ----------------------------------------------------------------------------- -// Protected Destructor -// ----------------------------------------------------------------------------- -H5Lite::~H5Lite() -= default; - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void H5Lite::disableErrorHandlers() -{ - H5SUPPORT_MUTEX_LOCK() - - HDF_ERROR_HANDLER_OFF; -} - -// ----------------------------------------------------------------------------- -// Opens an ID for HDF5 operations -// ----------------------------------------------------------------------------- -hid_t H5Lite::openId(hid_t loc_id, const std::string& obj_name, H5O_type_t obj_type) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t obj_id = -1; - - switch(obj_type) - { - case H5O_TYPE_DATASET: - - /* Open the dataset. */ - if((obj_id = H5Dopen(loc_id, obj_name.c_str(), H5P_DEFAULT)) < 0) - { - return -1; - } - break; - - case H5O_TYPE_GROUP: - - /* Open the group. */ - if((obj_id = H5Gopen(loc_id, obj_name.c_str(), H5P_DEFAULT)) < 0) - { - return -1; - } - break; - - default: - return -1; - } - - return obj_id; -} - -// ----------------------------------------------------------------------------- -// Closes the given ID -// ----------------------------------------------------------------------------- -herr_t H5Lite::closeId(hid_t obj_id, int32_t obj_type) -{ - H5SUPPORT_MUTEX_LOCK() - - switch(obj_type) - { - case H5O_TYPE_DATASET: - /* Close the dataset. */ - if(H5Dclose(obj_id) < 0) - { - return -1; - } - break; - - case H5O_TYPE_GROUP: - /* Close the group. */ - if(H5Gclose(obj_id) < 0) - { - return -1; - } - break; - - default: - return -1; - } - - return 1; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -std::string H5Lite::StringForHDFClassType(H5T_class_t classType) -{ - if(classType == H5T_NO_CLASS) - { - return "H5T_NO_CLASS"; - } - if(classType == H5T_INTEGER) - { - return "H5T_INTEGER"; - } - if(classType == H5T_FLOAT) - { - return "H5T_FLOAT"; - } - if(classType == H5T_TIME) - { - return "H5T_TIME"; - } - if(classType == H5T_STRING) - { - return "H5T_STRING"; - } - if(classType == H5T_BITFIELD) - { - return "H5T_BITFIELD"; - } - if(classType == H5T_OPAQUE) - { - return "H5T_OPAQUE"; - } - if(classType == H5T_COMPOUND) - { - return "H5T_COMPOUND"; - } - if(classType == H5T_REFERENCE) - { - return "H5T_REFERENCE"; - } - if(classType == H5T_ENUM) - { - return "H5T_ENUM"; - } - if(classType == H5T_VLEN) - { - return "H5T_VLEN"; - } - if(classType == H5T_ARRAY) - { - return "H5T_ARRAY"; - } - - return "UNKNOWN"; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -hid_t H5Lite::HDFTypeFromString(const std::string& value) -{ - H5SUPPORT_MUTEX_LOCK() - - if(value == "H5T_STRING") - { - return H5T_STRING; - } - - if(value == "H5T_NATIVE_INT8") - { - return H5T_NATIVE_INT8; - } - if(value == "H5T_NATIVE_UINT8") - { - return H5T_NATIVE_UINT8; - } - - if(value == "H5T_NATIVE_INT16") - { - return H5T_NATIVE_INT16; - } - if(value == "H5T_NATIVE_UINT16") - { - return H5T_NATIVE_UINT16; - } - - if(value == "H5T_NATIVE_INT32") - { - return H5T_NATIVE_INT32; - } - if(value == "H5T_NATIVE_UINT32") - { - return H5T_NATIVE_UINT32; - } - - if(value == "H5T_NATIVE_INT64") - { - return H5T_NATIVE_INT64; - } - if(value == "H5T_NATIVE_UINT64") - { - return H5T_NATIVE_UINT64; - } - - if(value == "H5T_NATIVE_FLOAT") - { - return H5T_NATIVE_FLOAT; - } - if(value == "H5T_NATIVE_DOUBLE") - { - return H5T_NATIVE_DOUBLE; - } - - std::cout << "Error: HDFTypeFromString - Unknown Type: " << value << std::endl; - return -1; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -std::string H5Lite::StringForHDFType(hid_t dataTypeIdentifier) -{ - H5SUPPORT_MUTEX_LOCK() - - if(dataTypeIdentifier == H5T_STRING) - { - return "H5T_STRING"; - } - - if(H5Tequal(dataTypeIdentifier, H5T_NATIVE_INT8) != 0) - { - return "H5T_NATIVE_INT8"; - } - if(H5Tequal(dataTypeIdentifier, H5T_NATIVE_UINT8) != 0) - { - return "H5T_NATIVE_UINT8"; - } - - if(H5Tequal(dataTypeIdentifier, H5T_NATIVE_INT16) != 0) - { - return "H5T_NATIVE_INT16"; - } - if(H5Tequal(dataTypeIdentifier, H5T_NATIVE_UINT16) != 0) - { - return "H5T_NATIVE_UINT16"; - } - - if(H5Tequal(dataTypeIdentifier, H5T_NATIVE_INT32) != 0) - { - return "H5T_NATIVE_INT32"; - } - if(H5Tequal(dataTypeIdentifier, H5T_NATIVE_UINT32) != 0) - { - return "H5T_NATIVE_UINT32"; - } - - if(H5Tequal(dataTypeIdentifier, H5T_NATIVE_INT64) != 0) - { - return "H5T_NATIVE_INT64"; - } - if(H5Tequal(dataTypeIdentifier, H5T_NATIVE_UINT64) != 0) - { - return "H5T_NATIVE_UINT64"; - } - - if(H5Tequal(dataTypeIdentifier, H5T_NATIVE_FLOAT) != 0) - { - return "H5T_NATIVE_FLOAT"; - } - if(H5Tequal(dataTypeIdentifier, H5T_NATIVE_DOUBLE) != 0) - { - return "H5T_NATIVE_DOUBLE"; - } - - std::cout << "Error: HDFTypeForPrimitiveAsStr - Unknown Type: " << dataTypeIdentifier << std::endl; - return "Unknown"; -} - -// ----------------------------------------------------------------------------- -// Finds an Attribute given an object to look in -// ----------------------------------------------------------------------------- -herr_t H5Lite::findAttribute(hid_t loc_id, const std::string& attrName) -{ - H5SUPPORT_MUTEX_LOCK() - - hsize_t attr_num; - herr_t ret = 0; - - attr_num = 0; - ret = H5Aiterate(loc_id, H5_INDEX_NAME, H5_ITER_INC, &attr_num, find_attr, (void*)(attrName.c_str())); - - return ret; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -bool H5Lite::datasetExists(hid_t loc_id, const std::string& dsetName) -{ - H5SUPPORT_MUTEX_LOCK() - - H5O_info_t ginfo{}; - HDF_ERROR_HANDLER_OFF - herr_t err = H5Oget_info_by_name(loc_id, dsetName.c_str(), &ginfo, H5P_DEFAULT); - HDF_ERROR_HANDLER_ON - return err >= 0; -} - -// ----------------------------------------------------------------------------- -// We assume a null terminated string -// ----------------------------------------------------------------------------- -herr_t H5Lite::writeStringDataset(hid_t loc_id, const std::string& dsetName, size_t size, const char* data) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t did = -1; - hid_t sid = -1; - hid_t tid = -1; - // size_t size = 0; - herr_t err = -1; - herr_t retErr = 0; - - /* create a string data type */ - if((tid = H5Tcopy(H5T_C_S1)) >= 0) - { - if(H5Tset_size(tid, size) >= 0) - { - if(H5Tset_strpad(tid, H5T_STR_NULLTERM) >= 0) - { - /* Create the data space for the dataset. */ - if((sid = H5Screate(H5S_SCALAR)) >= 0) - { - /* Create the dataset. */ - if((did = H5Dcreate(loc_id, dsetName.c_str(), tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) - { - if(nullptr != data) - { - err = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - if(err < 0) - { - std::cout << "Error Writing String Data" << std::endl; - retErr = err; - } - } - } - else - { - //retErr = did; - retErr = 0; - } - CloseH5D(did, err, retErr); - } - CloseH5S(sid, err, retErr); - } - } - CloseH5T(tid, err, retErr); - } - return retErr; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t H5Lite::writeVectorOfStringsDataset(hid_t loc_id, const std::string& dsetName, const std::vector& data) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t sid = -1; - hid_t memspace = -1; - hid_t datatype = -1; - hid_t did = -1; - herr_t err = -1; - herr_t retErr = 0; - - hsize_t dims[1] = {data.size()}; - if((sid = H5Screate_simple(sizeof(dims) / sizeof(*dims), dims, nullptr)) >= 0) - { - dims[0] = 1; - - if((memspace = H5Screate_simple(sizeof(dims) / sizeof(*dims), dims, nullptr)) >= 0) - { - - datatype = H5Tcopy(H5T_C_S1); - H5Tset_size(datatype, H5T_VARIABLE); - - if((did = H5Dcreate(loc_id, dsetName.c_str(), datatype, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) - { - - // - // Select the "memory" to be written out - just 1 record. - hsize_t offset[] = {0}; - hsize_t count[] = {1}; - H5Sselect_hyperslab(memspace, H5S_SELECT_SET, offset, nullptr, count, nullptr); - hsize_t m_pos = 0; - for(auto v : data) - { - // Select the file position, 1 record at position 'pos' - hsize_t count[] = {1}; - hsize_t offset[] = {m_pos++}; - H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, nullptr, count, nullptr); - const char* s = v.c_str(); - err = H5Dwrite(did, datatype, memspace, sid, H5P_DEFAULT, &s); - if(err < 0) - { - std::cout << "Error Writing String Data: " __FILE__ << "(" << __LINE__ << ")" << std::endl; - retErr = err; - } - } - CloseH5D(did, err, retErr); - } - H5Tclose(datatype); - CloseH5S(memspace, err, retErr); - } - - CloseH5S(sid, err, retErr); - } - return retErr; -} - -// ----------------------------------------------------------------------------- -// Writes a string to a HDF5 dataset -// ----------------------------------------------------------------------------- -herr_t H5Lite::writeStringDataset(hid_t loc_id, const std::string& dsetName, const std::string& data) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t did = -1; - hid_t sid = -1; - hid_t tid = -1; - size_t size = 0; - herr_t err = -1; - herr_t retErr = 0; - - /* create a string data type */ - if((tid = H5Tcopy(H5T_C_S1)) >= 0) - { - size = data.size() + 1; - if(H5Tset_size(tid, size) >= 0) - { - if(H5Tset_strpad(tid, H5T_STR_NULLTERM) >= 0) - { - /* Create the data space for the dataset. */ - if((sid = H5Screate(H5S_SCALAR)) >= 0) - { - /* Create or open the dataset. */ - HDF_ERROR_HANDLER_OFF - did = H5Dopen(loc_id, dsetName.c_str(), H5P_DEFAULT); - HDF_ERROR_HANDLER_ON - if(did < 0) // dataset does not exist so create it - { - did = H5Dcreate(loc_id, dsetName.c_str(), tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } - - if(did >= 0) - { - if(!data.empty()) - { - err = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data.c_str()); - if(err < 0) - { - std::cout << "Error Writing String Data" << std::endl; - retErr = err; - } - } - } - else - { - //retErr = did; - retErr = 0; - } - CloseH5D(did, err, retErr); - // err = H5Dclose(did); - // if (err < 0) { - // std::cout << "Error Closing Dataset." << std::endl; - // retErr = err; - // } - } - CloseH5S(sid, err, retErr); - // err = H5Sclose(sid); - // if ( err < 0) { - // std::cout << "Error closing Dataspace." << std::endl; - // retErr = err; - // } - } - } - CloseH5T(tid, err, retErr); - // err = H5Tclose(tid); - // if (err < 0 ) { - // std::cout << "Error closing DataType" << std::endl; - // retErr = err; - // } - } - return retErr; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t H5Lite::writeStringAttributes(hid_t loc_id, const std::string& objName, const std::map& attributes) -{ - H5SUPPORT_MUTEX_LOCK() - - herr_t err = 0; - for(const auto & attribute : attributes) - { - err = H5Lite::writeStringAttribute(loc_id, objName, attribute.first, attribute.second); - if(err < 0) - { - return err; - } - } - return err; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -hsize_t H5Lite::getNumberOfElements(hid_t loc_id, const std::string& dsetName) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t did; - herr_t err = 0; - herr_t retErr = 0; - hid_t spaceId; - hsize_t numElements = 0; - did = H5Dopen(loc_id, dsetName.c_str(), H5P_DEFAULT); - if(did < 0) - { - std::cout << "H5Lite.cpp::getNumberOfElements(" << __LINE__ << ") Error opening Dataset at loc_id (" << loc_id << ") with object name (" << dsetName << ")" << std::endl; - return -1; - } - if(did >= 0) - { - spaceId = H5Dget_space(did); - if(spaceId > 0) - { - int32_t rank = H5Sget_simple_extent_ndims(spaceId); - if(rank > 0) - { - std::vector dims; - dims.resize(rank); // Allocate enough room for the dims - err = H5Sget_simple_extent_dims(spaceId, &(dims.front()), nullptr); - numElements = 1; - for(auto iter = dims.begin(); iter < dims.end(); ++iter) - { - numElements = numElements * (*iter); - } - } - err = H5Sclose(spaceId); - if(err < 0) - { - std::cout << "Error Closing Data Space" << std::endl; - retErr = err; - } - } - else - { - std::cout << "Error Opening SpaceID" << std::endl; - //retErr = spaceId; - } - err = H5Dclose(did); - if(err < 0) - { - std::cout << "Error Closing Dataset" << std::endl; - retErr = err; - } - } - return numElements; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t H5Lite::writeStringAttribute(hid_t loc_id, const std::string& objName, const std::string& attrName, hsize_t size, const char* data) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t attr_type; - hid_t attr_space_id; - hid_t attr_id; - hid_t obj_id; - int32_t has_attr; - H5O_info_t statbuf{}; - size_t attr_size; - herr_t err = 0; - herr_t retErr = 0; - - /* Get the type of object */ - retErr = H5Oget_info_by_name(loc_id, objName.c_str(), &statbuf, H5P_DEFAULT); - if(retErr >= 0) - { - /* Open the object */ - obj_id = H5Lite::openId(loc_id, objName, statbuf.type); - if(obj_id >= 0) - { - /* Create the attribute */ - attr_type = H5Tcopy(H5T_C_S1); - if(attr_type >= 0) - { - attr_size = size; /* extra null term */ - err = H5Tset_size(attr_type, attr_size); - if(err < 0) - { - std::cout << "Error Setting H5T Size" << std::endl; - retErr = err; - } - if(err >= 0) - { - err = H5Tset_strpad(attr_type, H5T_STR_NULLTERM); - if(err < 0) - { - std::cout << "Error adding a null terminator." << std::endl; - retErr = err; - } - if(err >= 0) - { - attr_space_id = H5Screate(H5S_SCALAR); - if(attr_space_id >= 0) - { - /* Verify if the attribute already exists */ - has_attr = H5Lite::findAttribute(obj_id, attrName); - /* The attribute already exists, delete it */ - if(has_attr == 1) - { - err = H5Adelete(obj_id, attrName.c_str()); - if(err < 0) - { - std::cout << "Error Deleting Attribute '" << attrName << "' from Object '" << objName << "'" << std::endl; - retErr = err; - } - } - if(err >= 0) - { - /* Create and write the attribute */ - attr_id = H5Acreate(obj_id, attrName.c_str(), attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT); - if(attr_id >= 0) - { - err = H5Awrite(attr_id, attr_type, data); - if(err < 0) - { - std::cout << "Error Writing String attribute." << std::endl; - - retErr = err; - } - } - CloseH5A(attr_id, err, retErr); - } - CloseH5S(attr_space_id, err, retErr); - } - } - } - CloseH5T(attr_type, err, retErr); - } - else - { - //retErr = attr_type; - } - /* Close the object */ - err = H5Lite::closeId(obj_id, statbuf.type); - if(err < 0) - { - std::cout << "Error Closing Object Id" << std::endl; - retErr = err; - } - } - } - return retErr; -} - -// ----------------------------------------------------------------------------- -// Writes a string to an HDF5 Attribute -// ----------------------------------------------------------------------------- -herr_t H5Lite::writeStringAttribute(hid_t loc_id, const std::string& objName, const std::string& attrName, const std::string& data) -{ - return H5Lite::writeStringAttribute(loc_id, objName, attrName, data.size() + 1, data.data()); -} - -// ----------------------------------------------------------------------------- -// Reads a String dataset into a std::string -// ----------------------------------------------------------------------------- -herr_t H5Lite::readStringDataset(hid_t loc_id, const std::string& dsetName, std::string& data) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t did; // dataset id - hid_t tid; // type id - herr_t err = 0; - herr_t retErr = 0; - hsize_t size; - data.clear(); - did = H5Dopen(loc_id, dsetName.c_str(), H5P_DEFAULT); - if(did < 0) - { - std::cout << "H5Lite.cpp::readStringDataset(" << __LINE__ << ") Error opening Dataset at loc_id (" << loc_id << ") with object name (" << dsetName << ")" << std::endl; - return -1; - } - /* - * Get the datatype. - */ - tid = H5Dget_type(did); - if(tid >= 0) - { - htri_t isVariableString = H5Tis_variable_str(tid); // Test if the string is variable length - - if(isVariableString == 1) - { - std::vector strings; - err = readVectorOfStringDataset(loc_id, dsetName, strings); // Read the string - if(err < 0 || (strings.size() > 1 && !strings.empty())) - { - std::cout << "Error Reading string dataset. There were multiple Strings and the program asked for a single string." << std::endl; - retErr = err; - } - else - { - data.assign(strings[0]); - } - } - else - { - size = H5Dget_storage_size(did); - std::vector buf(static_cast(size + 1), 0x00); // Allocate and Zero and array - err = H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &(buf.front())); - if(err < 0) - { - std::cout << "Error Reading string dataset." << std::endl; - retErr = err; - } - else - { - data.append(&(buf.front())); // Append the string to the given string - } - } - } - CloseH5D(did, err, retErr); - CloseH5T(tid, err, retErr); - return retErr; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t H5Lite::readStringDataset(hid_t loc_id, const std::string& dsetName, char* data) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t did; // dataset id - hid_t tid; // type id - herr_t err = 0; - herr_t retErr = 0; - - did = H5Dopen(loc_id, dsetName.c_str(), H5P_DEFAULT); - if(did < 0) - { - std::cout << "H5Lite.cpp::readStringDataset(" << __LINE__ << ") Error opening Dataset at loc_id (" << loc_id << ") with object name (" << dsetName << ")" << std::endl; - return -1; - } - tid = H5Dget_type(did); - if(tid >= 0) - { - err = H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - if(err < 0) - { - std::cout << "Error Reading string dataset." << std::endl; - retErr = err; - } - CloseH5T(tid, err, retErr); - } - CloseH5D(did, err, retErr); - return retErr; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t H5Lite::readVectorOfStringDataset(hid_t loc_id, const std::string& dsetName, std::vector& data) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t did; // dataset id - hid_t tid; // type id - herr_t err = 0; - herr_t retErr = 0; - - did = H5Dopen(loc_id, dsetName.c_str(), H5P_DEFAULT); - if(did < 0) - { - std::cout << "H5Lite.cpp::readVectorOfStringDataset(" << __LINE__ << ") Error opening Dataset at loc_id (" << loc_id << ") with object name (" << dsetName << ")" << std::endl; - return -1; - } - /* - * Get the datatype. - */ - tid = H5Dget_type(did); - if(tid >= 0) - { - hsize_t dims[1] = {0}; - /* - * Get dataspace and allocate memory for read buffer. - */ - hid_t sid = H5Dget_space(did); - int ndims = H5Sget_simple_extent_dims(sid, dims, nullptr); - if(ndims != 1) - { - CloseH5S(sid, err, retErr); - CloseH5T(tid, err, retErr); - std::cout << "H5Lite.cpp::readVectorOfStringDataset(" << __LINE__ << ") Number of dims should be 1 but it was " << ndims << ". Returning early. Is your data file correct?" << std::endl; - return -2; - } - std::vector rdata(dims[0]); - for(int i = 0; i < dims[0]; i++) - { - rdata[i] = nullptr; - } - - /* - * Create the memory datatype. - */ - hid_t memtype = H5Tcopy(H5T_C_S1); - herr_t status = H5Tset_size(memtype, H5T_VARIABLE); - - /* - * Read the data. - */ - status = H5Dread(did, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, &(rdata.front())); - if(status < 0) - { - status = H5Dvlen_reclaim(memtype, sid, H5P_DEFAULT, &(rdata.front())); - CloseH5S(sid, err, retErr); - CloseH5T(tid, err, retErr); - CloseH5T(memtype, err, retErr); - std::cout << "H5Lite.cpp::readVectorOfStringDataset(" << __LINE__ << ") Error reading Dataset at loc_id (" << loc_id << ") with object name (" << dsetName << ")" << std::endl; - return -3; - } - /* - * copy the data into the vector of strings - */ - data.resize(dims[0]); - for(int i = 0; i < dims[0]; i++) - { - // printf("%s[%d]: %s\n", "VlenStrings", i, rdata[i].p); - std::string str = std::string(rdata[i]); - data[i] = str; - } - /* - * Close and release resources. Note that H5Dvlen_reclaim works - * for variable-length strings as well as variable-length arrays. - * Also note that we must still free the array of pointers stored - * in rdata, as H5Tvlen_reclaim only frees the data these point to. - */ - status = H5Dvlen_reclaim(memtype, sid, H5P_DEFAULT, &(rdata.front())); - CloseH5S(sid, err, retErr); - CloseH5T(tid, err, retErr); - CloseH5T(memtype, err, retErr); - } - - CloseH5D(did, err, retErr); - - return retErr; -} - -// ----------------------------------------------------------------------------- -// Reads a string Attribute from the HDF file -// ----------------------------------------------------------------------------- -herr_t H5Lite::readStringAttribute(hid_t loc_id, const std::string& objName, const std::string& attrName, std::string& data) -{ - H5SUPPORT_MUTEX_LOCK() - - /* identifiers */ - hid_t obj_id; - H5O_info_t statbuf{}; - hid_t attr_id; - hid_t attr_type; - std::vector attr_out; - hsize_t size; - herr_t err = 0; - herr_t retErr = 0; - data.clear(); - HDF_ERROR_HANDLER_OFF; - - /* Get the type of object */ - err = H5Oget_info_by_name(loc_id, objName.c_str(), &statbuf, H5P_DEFAULT); - if(err < 0) - { - return err; - } - - /* Open the object */ - obj_id = H5Lite::openId(loc_id, objName, statbuf.type); - if(obj_id >= 0) - { - attr_id = H5Aopen_by_name(loc_id, objName.c_str(), attrName.c_str(), H5P_DEFAULT, H5P_DEFAULT); - hid_t attrTypeId = H5Aget_type(attr_id); - htri_t isVariableString = H5Tis_variable_str(attrTypeId); // Test if the string is variable length - H5Tclose(attrTypeId); - if(isVariableString == 1) - { - data.clear(); - retErr = -1; - CloseH5A(attr_id, err, retErr); - return retErr; - } - if(attr_id >= 0) - { - size = H5Aget_storage_size(attr_id); - attr_out.resize(static_cast(size)); // Resize the vector to the proper length - attr_type = H5Aget_type(attr_id); - if(attr_type >= 0) - { - err = H5Aread(attr_id, attr_type, &(attr_out.front())); - if(err < 0) - { - std::cout << "Error Reading Attribute." << std::endl; - retErr = err; - } - else - { - if(attr_out[size - 1] == 0) // nullptr Terminated string - { - size = size - 1; - } - data.append(&(attr_out.front()), size); // Append the data to the passed in string - } - CloseH5T(attr_type, err, retErr); - } - CloseH5A(attr_id, err, retErr); - } - else - { - //retErr = attr_id; - } - err = H5Lite::closeId(obj_id, statbuf.type); - if(err < 0) - { - std::cout << "Error Closing Object ID" << std::endl; - retErr = err; - } - } - HDF_ERROR_HANDLER_ON; - return retErr; -} - -// ----------------------------------------------------------------------------- -// Reads a string Attribute from the HDF file -// ----------------------------------------------------------------------------- -herr_t H5Lite::readStringAttribute(hid_t loc_id, const std::string& objName, const std::string& attrName, char* data) -{ - H5SUPPORT_MUTEX_LOCK() - - /* identifiers */ - hid_t obj_id; - H5O_info_t statbuf{}; - hid_t attr_id; - hid_t attr_type; - herr_t err = 0; - herr_t retErr = 0; - - HDF_ERROR_HANDLER_OFF; - - /* Get the type of object */ - err = H5Oget_info_by_name(loc_id, objName.c_str(), &statbuf, H5P_DEFAULT); - if(err < 0) - { - return err; - } - - /* Open the object */ - obj_id = H5Lite::openId(loc_id, objName, statbuf.type); - if(obj_id >= 0) - { - attr_id = H5Aopen_by_name(loc_id, objName.c_str(), attrName.c_str(), H5P_DEFAULT, H5P_DEFAULT); - if(attr_id >= 0) - { - attr_type = H5Aget_type(attr_id); - if(attr_type >= 0) - { - err = H5Aread(attr_id, attr_type, data); - if(err < 0) - { - std::cout << "Error Reading Attribute." << std::endl; - retErr = err; - } - CloseH5T(attr_type, err, retErr); - } - CloseH5A(attr_id, err, retErr); - } - else - { - //retErr = attr_id; - } - err = H5Lite::closeId(obj_id, statbuf.type); - if(err < 0) - { - std::cout << "Error Closing Object ID" << std::endl; - retErr = err; - } - } - HDF_ERROR_HANDLER_ON; - return retErr; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t H5Lite::getDatasetNDims(hid_t loc_id, const std::string& dsetName, hid_t& rank) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t did; - hid_t sid; - herr_t err = 0; - herr_t retErr = 0; - rank = 0; - - /* Open the dataset. */ - if((did = H5Dopen(loc_id, dsetName.c_str(), H5P_DEFAULT)) < 0) - { - return -1; - } - - /* Get the dataspace handle */ - sid = H5Dget_space(did); - if(sid >= 0) - { - - /* Get rank */ - rank = H5Sget_simple_extent_ndims(sid); - if(rank < 0) - { - //retErr = rank; - rank = 0; - std::cout << "Error Getting the rank of the dataset:" << std::endl; - } - - /* Terminate access to the dataspace */ - CloseH5S(sid, err, retErr); - } - - /* End access to the dataset */ - err = H5Dclose(did); - if(err < 0) - { - retErr = err; - rank = 0; - } - return retErr; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t H5Lite::getAttributeNDims(hid_t loc_id, const std::string& objName, const std::string& attrName, hid_t& rank) -{ - H5SUPPORT_MUTEX_LOCK() - - /* identifiers */ - hid_t obj_id; - H5O_info_t statbuf{}; - hid_t attr_id; - herr_t err = 0; - herr_t retErr = 0; - hid_t sid; - rank = -1; - /* Get the type of object */ - err = H5Oget_info_by_name(loc_id, objName.c_str(), &statbuf, H5P_DEFAULT); - if(err < 0) - { - return err; - } - /* Open the object */ - obj_id = H5Lite::openId(loc_id, objName, statbuf.type); - if(obj_id >= 0) - { - attr_id = H5Aopen_by_name(loc_id, objName.c_str(), attrName.c_str(), H5P_DEFAULT, H5P_DEFAULT); - if(attr_id >= 0) - { - sid = H5Aget_space(attr_id); - if(sid >= 0) - { - rank = H5Sget_simple_extent_ndims(sid); - CloseH5S(sid, err, retErr); - } - CloseH5A(attr_id, err, retErr); - } - else - { - //retErr = attr_id; - } - err = H5Lite::closeId(obj_id, statbuf.type); - if(err < 0) - { - std::cout << "Error Closing Object ID" << std::endl; - retErr = err; - } - } - - return retErr; -} - -// ----------------------------------------------------------------------------- -// Returns the type of data stored in the dataset. You MUST use H5Tclose(tid) -// on the returned value or resource leaks will occur. -// ----------------------------------------------------------------------------- -hid_t H5Lite::getDatasetType(hid_t loc_id, const std::string& dsetName) -{ - H5SUPPORT_MUTEX_LOCK() - - herr_t err = 0; - herr_t retErr = 0; - hid_t did = -1; - /* Open the dataset. */ - if((did = H5Dopen(loc_id, dsetName.c_str(), H5P_DEFAULT)) < 0) - { - return -1; - } - /* Get an identifier for the datatype. */ - hid_t tid = H5Dget_type(did); - CloseH5D(did, err, retErr); - if(retErr < 0) - { - return static_cast(retErr); - } - return tid; -} - -// ----------------------------------------------------------------------------- -// Get the dataset information -// ----------------------------------------------------------------------------- -herr_t H5Lite::getDatasetInfo(hid_t loc_id, const std::string& dsetName, std::vector& dims, H5T_class_t& classType, size_t& sizeType) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t did; - hid_t tid; - hid_t sid; - herr_t err = 0; - herr_t retErr = 0; - hid_t rank = 0; - - /* Open the dataset. */ - if((did = H5Dopen(loc_id, dsetName.c_str(), H5P_DEFAULT)) < 0) - { - return -1; - } - - /* Get an identifier for the datatype. */ - tid = H5Dget_type(did); - if(tid >= 0) - { - /* Get the class. */ - classType = H5Tget_class(tid); - /* Get the size. */ - sizeType = H5Tget_size(tid); - /* Release the datatype. */ - err = H5Tclose(tid); - if(err < 0) - { - std::cout << "Error Closing H5Type" << std::endl; - retErr = err; - } - } - /* Get the dataspace handle */ - sid = H5Dget_space(did); - if(sid >= 0) - { - /* Get the Number of Dimensions */ - rank = H5Sget_simple_extent_ndims(sid); - if(rank > 0) - { - // hsize_t _dims[rank]; // allocate space for the dimensions - std::vector _dims(rank, 0); - /* Get dimensions */ - err = H5Sget_simple_extent_dims(sid, &(_dims.front()), nullptr); - if(err < 0) - { - std::cout << "Error Getting Simple Extents for dataset" << std::endl; - retErr = err; - } - // Copy the dimensions into the dims vector - dims.clear(); // Erase everything in the Vector - dims.resize(rank); - for(hid_t i = 0; i < rank; ++i) - { - dims[i] = static_cast(_dims[i]); - } - } - else if(classType == H5T_STRING) - { - dims.clear(); // Erase everything in the Vector - dims.resize(1); - dims[0] = sizeType; - } - /* Terminate access to the dataspace */ - CloseH5S(sid, err, retErr); - } - - /* End access to the dataset */ - CloseH5D(did, err, retErr); - return retErr; -} - -// ----------------------------------------------------------------------------- -// You must close the attributeType argument or resource leaks will occur. Use -// H5Tclose(tid); after your call to this method if you do not need the id for -// anything. -// ----------------------------------------------------------------------------- -herr_t H5Lite::getAttributeInfo(hid_t loc_id, const std::string& objName, const std::string& attrName, std::vector& dims, H5T_class_t& type_class, size_t& type_size, hid_t& tid) -{ - H5SUPPORT_MUTEX_LOCK() - - /* identifiers */ - hid_t obj_id; - H5O_info_t statbuf{}; - hid_t attr_id; - herr_t err = 0; - herr_t retErr = 0; - hid_t sid; - hid_t rank = -1; - - err = H5Oget_info_by_name(loc_id, objName.c_str(), &statbuf, H5P_DEFAULT); - if(err < 0) - { - return err; - } - - /* Open the object */ - obj_id = H5Lite::openId(loc_id, objName, statbuf.type); - if(obj_id >= 0) - { - attr_id = H5Aopen_by_name(loc_id, objName.c_str(), attrName.c_str(), H5P_DEFAULT, H5P_DEFAULT); - if(attr_id >= 0) - { - /* Get an identifier for the datatype. */ - tid = H5Aget_type(attr_id); - if(tid > 0) - { - /* Get the class. */ - type_class = H5Tget_class(tid); - /* Get the size. */ - type_size = H5Tget_size(tid); - sid = H5Aget_space(attr_id); - if(sid >= 0) - { - if(type_class == H5T_STRING) - { - rank = 1; - dims.resize(1); - dims[0] = type_size; - } - else - { - rank = H5Sget_simple_extent_ndims(sid); - std::vector _dims(rank, 0); - /* Get dimensions */ - err = H5Sget_simple_extent_dims(sid, &(_dims.front()), nullptr); - if(err < 0) - { - std::cout << "Error Getting Attribute dims" << std::endl; - retErr = err; - } - // Copy the dimensions into the dims vector - dims.clear(); // Erase everything in the Vector - dims.resize(rank); - for(hid_t i = 0; i < rank; ++i) - { - dims[i] = static_cast(_dims[i]); - } - } - CloseH5S(sid, err, retErr); - sid = 0; - } - } - CloseH5A(attr_id, err, retErr); - attr_id = 0; - } - else - { - retErr = -1; - } - err = H5Lite::closeId(obj_id, statbuf.type); - if(err < 0) - { - std::cout << "Error Closing Object ID" << std::endl; - retErr = err; - } - } - return retErr; -} diff --git a/Source/H5Support/H5Lite.h b/Source/H5Support/H5Lite.h deleted file mode 100644 index 4a716b3e49..0000000000 --- a/Source/H5Support/H5Lite.h +++ /dev/null @@ -1,1631 +0,0 @@ - -// -// Copyright (c) 2007, 2010 Michael A. Jackson for BlueQuartz Software -// All rights reserved. -// BSD License: http://www.opensource.org/licenses/bsd-license.html -// -// This code was written under United States Air Force Contract number -// FA8650-04-C-5229 -// - -#pragma once - -//--C++ Headers -#include - -//-- STL Headers -#include -#include -#include -#include -#include - -//-- HDF Headers -#include - -//-- H5Support Headers -#include "H5Support/H5Support.h" -#include "H5Support/H5Macros.h" - -#ifdef H5Support_USE_MUTEX -#define H5SUPPORT_MUTEX_LOCK()\ - static std::mutex mutex;\ - std::lock_guard lock(mutex); -#else -#define H5SUPPORT_MUTEX_LOCK() - -#endif -#ifdef __cplusplus -extern "C" { -#endif -herr_t H5Support_EXPORT find_attr( hid_t loc_id, const char* name, void* op_data); - -herr_t H5Support_EXPORT find_dataset( hid_t loc_id, const char* name, void* op_data); - -#ifdef __cplusplus -} -#endif - -#if defined (H5Support_NAMESPACE) -namespace H5Support_NAMESPACE -{ -#endif - - /** - * @brief Class to bring together some high level methods to read/write data to HDF5 files. - * @class H5Lite - * @author Mike Jackson - * @date April 2007 - * @version $Revision: 1.3 $ - */ - class H5Lite - { - public: - /** - * @brief Turns off the global error handler/reporting objects. Note that once - * they are turned off using this method they CAN NOT be turned back on. If you - * would like to turn them off for a piece of code then surround your code with - * the HDF_ERROR_HANDLER_OFF and HDF_ERROR_HANDLER_ON macros defined in - * H5Lite.h - */ - static H5Support_EXPORT void disableErrorHandlers(); - - /** - * @brief Opens an object for HDF5 operations - * @param loc_id The parent object that holds the true object we want to open - * @param objName The string name of the object - * @param obj_type The HDF5_TYPE of object - * @return Standard HDF5 Error Conditions - */ - static H5Support_EXPORT hid_t openId( hid_t loc_id, const std::string& obj_name, H5O_type_t obj_type); - - /** - * @brief Opens an HDF5 Object - * @param obj_id The Object id - * @param obj_type Basic Object Type - * @return Standard HDF5 Error Conditions - */ - static H5Support_EXPORT herr_t closeId( hid_t obj_id, int32_t obj_type ); - - /** - * @brief StringForHDFClassType - * @param classType - * @return - */ - static H5Support_EXPORT std::string StringForHDFClassType(H5T_class_t classType); - - /** - * @brief Given one of the HDF Types as a string, this will return the HDF Type - * as an hid_t value. - * @param value The HDF_Type as a string - * @return the hid_t value for the given type. -1 if the string does not match a type. - */ - static H5Support_EXPORT hid_t HDFTypeFromString(const std::string& value); - - /** - * @brief Returns a string version of the HDF Type - * @param type The HDF5 Type to query - * @return - */ - static H5Support_EXPORT std::string StringForHDFType(hid_t dataTypeIdentifier); - - /** - * @brief Returns the HDF Type for a given primitive value. - * @param value A value to use. Can be anything. Just used to get the type info - * from - * @return A std::string representing the HDF5 Type - */ - template - static std::string HDFTypeForPrimitiveAsStr(T value) - { - H5SUPPORT_MUTEX_LOCK() - - if (typeid(value) == typeid(int8_t)) { return "H5T_NATIVE_INT8"; } - if (typeid(value) == typeid(uint8_t)) { return "H5T_NATIVE_UINT8"; } - - if (typeid(value) == typeid(int16_t)) { return "H5T_NATIVE_INT16"; } - if (typeid(value) == typeid(uint16_t)) { return "H5T_NATIVE_UINT16"; } - - if (typeid(value) == typeid(int32_t)) { return "H5T_NATIVE_INT32"; } - if (typeid(value) == typeid(uint32_t)) { return "H5T_NATIVE_UINT32"; } - - if (typeid(value) == typeid(int64_t)) { return "H5T_NATIVE_INT64"; } - if (typeid(value) == typeid(uint64_t)) { return "H5T_NATIVE_UINT64"; } - - if (typeid(value) == typeid(float)) { return "H5T_NATIVE_FLOAT"; } - if (typeid(value) == typeid(double)) { return "H5T_NATIVE_DOUBLE"; } - - //if (typeid(value) == typeid(bool)) return "H5T_NATIVE_UINT8"; - - std::cout << "Error: HDFTypeForPrimitiveAsStr - Unknown Type: " << typeid(value).name() << std::endl; - return ""; - } - - /** - * @brief Returns the HDF Type for a given primitive value. - * @param value A value to use. Can be anything. Just used to get the type info - * from - * @return The HDF5 native type for the value - */ - template - static hid_t HDFTypeForPrimitive(T value) - { - H5SUPPORT_MUTEX_LOCK() - - if (typeid(value) == typeid(float)) { return H5T_NATIVE_FLOAT; } - if (typeid(value) == typeid(double)) { return H5T_NATIVE_DOUBLE; } - - if (typeid(value) == typeid(int8_t)) { return H5T_NATIVE_INT8; } - if (typeid(value) == typeid(uint8_t)) { return H5T_NATIVE_UINT8; } -# if CMP_TYPE_CHAR_IS_SIGNED - if (typeid(value) == typeid(char)) { return H5T_NATIVE_INT8; } -#else - if (typeid(value) == typeid(char)) { return H5T_NATIVE_UINT8; } -#endif - if (typeid(value) == typeid(signed char)) { return H5T_NATIVE_INT8; } - if (typeid(value) == typeid(unsigned char)) { return H5T_NATIVE_UINT8; } - - - if (typeid(value) == typeid(int16_t)) { return H5T_NATIVE_INT16; } - if (typeid(value) == typeid(short)) { return H5T_NATIVE_INT16; } - if (typeid(value) == typeid(signed short)) { return H5T_NATIVE_INT16; } - if (typeid(value) == typeid(uint16_t)) { return H5T_NATIVE_UINT16; } - if (typeid(value) == typeid(unsigned short)) { return H5T_NATIVE_UINT16; } - - - if (typeid(value) == typeid(int32_t)) { return H5T_NATIVE_INT32; } - if (typeid(value) == typeid(uint32_t)) { return H5T_NATIVE_UINT32; } -#if (CMP_SIZEOF_INT == 4) - if (typeid(value) == typeid(int)) { return H5T_NATIVE_INT32; } - if (typeid(value) == typeid(signed int)) { return H5T_NATIVE_INT32; } - if (typeid(value) == typeid(unsigned int)) { return H5T_NATIVE_UINT32; } -#endif - - -#if (CMP_SIZEOF_LONG == 4) - if (typeid(value) == typeid(long int)) { return H5T_NATIVE_INT32; } - if (typeid(value) == typeid(signed long int)) { return H5T_NATIVE_INT32; } - if (typeid(value) == typeid(unsigned long int)) { return H5T_NATIVE_UINT32; } -#elif (CMP_SIZEOF_LONG == 8) - if (typeid(value) == typeid(long int)) { return H5T_NATIVE_INT64; } - if (typeid(value) == typeid(signed long int)) { return H5T_NATIVE_INT64; } - if (typeid(value) == typeid(unsigned long int)) { return H5T_NATIVE_UINT64; } -#endif - - -#if (CMP_SIZEOF_LONG_LONG == 8) - if (typeid(value) == typeid(long long int)) { return H5T_NATIVE_INT64; } - if (typeid(value) == typeid(signed long long int)) { return H5T_NATIVE_INT64; } - if (typeid(value) == typeid(unsigned long long int)) { return H5T_NATIVE_UINT64; } -#endif - if (typeid(value) == typeid(int64_t)) { return H5T_NATIVE_INT64; } - if (typeid(value) == typeid(uint64_t)) { return H5T_NATIVE_UINT64; } - - if (typeid(value) == typeid(bool)) { return H5T_NATIVE_UINT8; } - - std::cout << "Error: HDFTypeForPrimitive - Unknown Type: " << (typeid(value).name()) << std::endl; - const char* name = typeid(value).name(); - if (nullptr != name && name[0] == 'l' ) - { - std::cout << "You are using 'long int' as a type which is not 32/64 bit safe. Suggest you use one of the H5SupportTypes defined in such as int32_t or uint32_t." << std::endl; - } - return -1; - } - - - - /** - * @brief Inquires if an attribute named attr_name exists attached to the object loc_id. - * @param loc_id The location to search - * @param attrName The attribute to search for - * @return Standard HDF5 Error condition - */ - static H5Support_EXPORT herr_t findAttribute( hid_t loc_id, const std::string& attrName ); - - /** - * @brief Finds a Data set given a data set name - * @param loc_id The location to search - * @param name The dataset to search for - * @return Standard HDF5 Error condition. Negative=DataSet - */ - static H5Support_EXPORT bool datasetExists( hid_t loc_id, const std::string& dsetName ); - - /** - * @brief Creates a Dataset with the given name at the location defined by loc_id - * - * - * @param loc_id The Parent location to store the data - * @param dsetName The name of the dataset - * @param dims The dimensions of the dataset - * @param data The data to write to the file - * @return Standard HDF5 error conditions - * - * The dimensions of the data sets are usually passed as both a "rank" and - * dimensions array. By using a std::vector that stores the values of - * each of the dimensions we can reduce the number of arguments to this method as - * the value of the "rank" simply becomes dims.length(). So to create a Dims variable - * for a 3D data space of size(x,y,z) = {10,20,30} I would use the following code: - * - * std::vector dims; - * dims.push_back(10); - * dims.push_back(20); - * dims.push_back(30); - * - * - * Also when passing data BE SURE that the type of data and the data type match. - * For example if I create some data in a std::vector I would need to - * pass H5T_NATIVE_UINT8 as the dataType. - */ - template - static herr_t writeVectorDataset (hid_t loc_id, - const std::string& dsetName, - std::vector& dims, - std::vector& data) - { - H5SUPPORT_MUTEX_LOCK() - - herr_t err = -1; - hid_t did = -1; - hid_t sid = -1; - herr_t retErr = 0; - if(data.size() == 0) { return 0; } - hid_t dataType = H5Lite::HDFTypeForPrimitive(data.front()); - if(dataType == -1) - { - return -100; - } - //Create the DataSpace - std::vector::size_type size = dims.size(); - //std::vector _dims(size, 0); - std::vector _dims(size, 0); - for (std::vector::size_type i = 0; i < size; ++i) - { - _dims[i] = static_cast(dims[i]); - } - sid = H5Screate_simple( static_cast(size), &(_dims.front()), nullptr ); - if (sid < 0) - { - return -101; - } - // Create the Dataset - did = H5Dcreate (loc_id, dsetName.c_str(), dataType, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if ( did >= 0 ) - { - err = H5Dwrite( did, dataType, H5S_ALL, H5S_ALL, H5P_DEFAULT, &(data.front()) ); - if (err < 0 ) - { - std::cout << "Error Writing Data" << std::endl; - retErr = -102; - } - err = H5Dclose( did ); - if (err < 0) - { - std::cout << "Error Closing Dataset." << std::endl; - retErr = -103; - } - } - else - { - retErr = -104; - } - /* Terminate access to the data space. */ - err = H5Sclose( sid ); - if (err < 0) - { - std::cout << "Error Closing Dataspace" << std::endl; - retErr = -105; - } - return retErr; - } - - /** - * @brief Writes the data of a pointer to an HDF5 file - * @param loc_id The hdf5 object id of the parent - * @param dsetName The name of the dataset to write to. This can be a name of Path - * @param rank The number of dimensions - * @param dims The sizes of each dimension - * @param data The data to be written. - * @return Standard hdf5 error condition. - */ - template - static herr_t writePointerDataset (hid_t loc_id, - const std::string& dsetName, - int32_t rank, - hsize_t* dims, - T* data) - { - H5SUPPORT_MUTEX_LOCK() - - herr_t err = -1; - hid_t did = -1; - hid_t sid = -1; - herr_t retErr = 0; - - if(nullptr == data) { return -2;} - hid_t dataType = H5Lite::HDFTypeForPrimitive(data[0]); - if(dataType == -1) - { - return -1; - } - //Create the DataSpace - std::vector::size_type size = static_cast::size_type>(rank); - - std::vector _dims(size, 0); - for (int32_t i = 0; i < rank; ++i) - { - _dims[i] = static_cast(dims[i]); - } -// sid = H5Screate_simple( size, &(_dims.front()), nullptr ); - sid = H5Screate_simple( rank, dims, nullptr); - if (sid < 0) - { - return sid; - } - // Create the Dataset - // This will fail if dsetName contains a "/"! - did = H5Dcreate (loc_id, dsetName.c_str(), dataType, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if ( did >= 0 ) - { - err = H5Dwrite( did, dataType, H5S_ALL, H5S_ALL, H5P_DEFAULT, data ); - if (err < 0 ) - { - std::cout << "Error Writing Data '" << dsetName << "'" << std::endl; - std::cout << " rank=" << rank << std::endl; - uint64_t totalSize = 1; - for(size_t i = 0; i < _dims.size(); ++i) - { - std::cout << " dim[" << i << "]=" << _dims[i] << std::endl; - totalSize = totalSize * _dims[i]; - } - std::cout << " TotalElements=" << totalSize << std::endl; - std::cout << " Size of Type (Bytes):" << sizeof(T) << std::endl; - std::cout << " TotalBytes to Write: " << (sizeof(T) * totalSize) << std::endl; - retErr = err; - } - err = H5Dclose( did ); - if (err < 0) - { - std::cout << "Error Closing Dataset." << std::endl; - retErr = err; - } - } - else - { - retErr = did; - } - /* Terminate access to the data space. */ - err = H5Sclose( sid ); - if (err < 0) - { - std::cout << "Error Closing Dataspace" << std::endl; - retErr = err; - } - return retErr; - } - - /** - * @brief replacePointerDataset - * @param loc_id - * @param dsetName - * @param rank - * @param dims - * @param data - * @return - */ - template - static herr_t replacePointerDataset (hid_t loc_id, - const std::string& dsetName, - int32_t rank, - hsize_t* dims, - T* data) - { - H5SUPPORT_MUTEX_LOCK() - - herr_t err = -1; - hid_t did = -1; - hid_t sid = -1; - herr_t retErr = 0; - - hid_t dataType = H5Lite::HDFTypeForPrimitive(data[0]); - if(dataType == -1) - { - return -1; - } - //Create the DataSpace - std::vector::size_type size = static_cast::size_type>(rank); - - std::vector _dims(size, 0); - for (int32_t i = 0; i < rank; ++i) - { - _dims[i] = static_cast(dims[i]); - } -// sid = H5Screate_simple( size, &(_dims.front()), nullptr ); - sid = H5Screate_simple( rank, dims, nullptr); - if (sid < 0) - { - return sid; - } - - HDF_ERROR_HANDLER_OFF - did = H5Dopen(loc_id, dsetName.c_str(), H5P_DEFAULT ); - HDF_ERROR_HANDLER_ON - if ( did < 0 ) // dataset does not exist so create it - { - did = H5Dcreate (loc_id, dsetName.c_str(), dataType, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } - if ( did >= 0 ) - { - err = H5Dwrite( did, dataType, H5S_ALL, H5S_ALL, H5P_DEFAULT, data ); - if (err < 0 ) - { - std::cout << "Error Writing Data" << std::endl; - retErr = err; - } - err = H5Dclose( did ); - if (err < 0) - { - std::cout << "Error Closing Dataset." << std::endl; - retErr = err; - } - } - else - { - retErr = did; - } - /* Terminate access to the data space. */ - err = H5Sclose( sid ); - if (err < 0) - { - std::cout << "Error Closing Dataspace" << std::endl; - retErr = err; - } - return retErr; - } - - - /** - * @brief Creates a Dataset with the given name at the location defined by loc_id - * - * @param loc_id The Parent location to store the data - * @param dsetName The name of the dataset - * @param dims The dimensions of the dataset - * @param rank The number of dimensions to the dataset - * @param data The data to write to the file - * @return Standard HDF5 error conditions - * - * The dimensions of the data sets are usually passed as both a "rank" and - * dimensions array. By using a std::vector that stores the values of - * each of the dimensions we can reduce the number of arguments to this method as - * the value of the "rank" simply becomes dims.length(). So to create a Dims variable - * for a 3D data space of size(x,y,z) = {10,20,30} I would use the following code: - * - * std::vector dims; - * dims.push_back(10); - * dims.push_back(20); - * dims.push_back(30); - * - * - */ - template - static herr_t writeDataset(hid_t loc_id, - const std::string& dsetName, - int32_t& rank, - hsize_t* dims, - T* data) - { - H5SUPPORT_MUTEX_LOCK() - - herr_t err = -1; - hid_t did = -1; - hid_t sid = -1; - herr_t retErr = 0; - hid_t dataType = H5Lite::HDFTypeForPrimitive(data[0]); - if (dataType == -1) - { - return -1; - } - //Create the DataSpace - sid = H5Screate_simple( rank, dims, nullptr ); - if (sid < 0) - { - return sid; - } - // Create the Dataset - did = H5Dcreate (loc_id, dsetName.c_str(), dataType, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if ( did >= 0 ) - { - err = H5Dwrite( did, dataType, H5S_ALL, H5S_ALL, H5P_DEFAULT, data ); - if (err < 0 ) - { - std::cout << "Error Writing Data" << std::endl; - retErr = err; - } - err = H5Dclose( did ); - if (err < 0) - { - std::cout << "Error Closing Dataset." << std::endl; - retErr = err; - } - } - else - { - retErr = did; - } - /* Terminate access to the data space. */ - err = H5Sclose( sid ); - if (err < 0) - { - std::cout << "Error Closing Dataspace" << std::endl; - retErr = err; - } - return retErr; - } - - - /** - * @brief Creates a Dataset with the given name at the location defined by loc_id. - * This version of writeDataset should be used with a single scalar value. If you - * need to write an array of values, use the form that takes an std::vector<> - * - * @param loc_id The Parent location to store the data - * @param dsetName The name of the dataset - * @param value The value to write to the HDF5 dataset - * @return Standard HDF5 error conditions - */ - template - static herr_t writeScalarDataset (hid_t loc_id, - const std::string& dsetName, - T& value) - { - H5SUPPORT_MUTEX_LOCK() - - herr_t err = -1; - hid_t did = -1; - hid_t sid = -1; - herr_t retErr = 0; - hsize_t dims = 1; - hid_t rank = 1; - hid_t dataType = H5Lite::HDFTypeForPrimitive(value); - if (dataType == -1) - { - return -1; - } - //Create the DataSpace - sid = H5Screate_simple( rank, &(dims), nullptr ); - if (sid < 0) - { - return sid; - } - // Create the Dataset - did = H5Dcreate (loc_id, dsetName.c_str(), dataType, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if ( did >= 0 ) - { - err = H5Dwrite( did, dataType, H5S_ALL, H5S_ALL, H5P_DEFAULT, &value ); - if (err < 0 ) - { - std::cout << "Error Writing Data" << std::endl; - retErr = err; - } - err = H5Dclose( did ); - if (err < 0) - { - std::cout << "Error Closing Dataset." << std::endl; - retErr = err; - } - } - else - { - retErr = did; - } - /* Terminate access to the data space. */ - err = H5Sclose( sid ); - if (err < 0) - { - std::cout << "Error Closing Dataspace" << std::endl; - retErr = err; - } - return retErr; - } - - /** - * @brief Writes a std::string as a HDF Dataset. - * @param loc_id The Parent location to write the dataset - * @param dsetName The Name to use for the dataset - * @param data The actual data to write as a null terminated string - * @return Standard HDF5 error conditions - */ - static H5Support_EXPORT herr_t writeStringDataset (hid_t loc_id, - const std::string& dsetName, - const std::string& data); - - /** - * @brief Writes a null terminated 'C String' to an HDF Dataset. - * @param loc_id The Parent location to write the dataset - * @param dsetName The Name to use for the dataset - * @param data const char pointer to write as a null terminated string - * @param size The number of characters in the string - * @return Standard HDF5 error conditions - */ - static H5Support_EXPORT herr_t writeStringDataset (hid_t loc_id, - const std::string& dsetName, - size_t size, - const char* data); - - /** - * @brief - * @param loc_id - * @param dsetName - * @param size - * @param data - * @return - */ - static H5Support_EXPORT herr_t writeVectorOfStringsDataset(hid_t loc_id, - const std::string& dsetName, - const std::vector& data); - /** - * @brief Writes an Attribute to an HDF5 Object - * @param loc_id The Parent Location of the HDFobject that is getting the attribute - * @param objName The Name of Object to write the attribute into. - * @param attrName The Name of the Attribute - * @param rank The number of dimensions in the attribute data - * @param dims The Dimensions of the attribute data - * @param data The Attribute Data to write as a pointer - * @return Standard HDF Error Condition - */ - template - static herr_t writePointerAttribute(hid_t loc_id, - const std::string& objName, - const std::string& attrName, - int32_t rank, - hsize_t* dims, - T* data) - { - H5SUPPORT_MUTEX_LOCK() - - hid_t obj_id, sid, attr_id; - int32_t has_attr; - H5O_info_t statbuf; - herr_t err = 0; - herr_t retErr = 0; - T test = 0x00; - hid_t dataType = H5Lite::HDFTypeForPrimitive(test); - if (dataType == -1) - { - std::cout << "dataType was unknown" << std::endl; - return -1; - } - /* Get the type of object */ - - if (H5Oget_info_by_name(loc_id, objName.c_str(), &statbuf, H5P_DEFAULT) < 0) - { - std::cout << "Error getting object info at loc_id (" << loc_id << ") with object name (" << objName << ")" << std::endl; - return -1; - } - /* Open the object */ - obj_id = H5Lite::openId( loc_id, objName, statbuf.type ); - if ( obj_id < 0) - { - std::cout << "Error opening Object for Attribute operations." << std::endl; - return -1; - } - - /* Create the data space for the attribute. */ - hsize_t* dimsPtr = nullptr; -// size mismatch between hsize_t and size_t - std::vector _dims(rank, 0); - for (int32_t i = 0; i < rank; ++i) - { - _dims[i] = static_cast(dims[i]); - } - dimsPtr = &(_dims.front() ); - - sid = H5Screate_simple( rank, dimsPtr, nullptr ); - if ( sid >= 0 ) - { - /* Verify if the attribute already exists */ - has_attr = H5Lite::findAttribute( obj_id, attrName ); - - /* The attribute already exists, delete it */ - if ( has_attr == 1 ) - { - err = H5Adelete( obj_id, attrName.c_str() ); - if (err < 0) - { - std::cout << "Error Deleting Existing Attribute" << std::endl; - retErr = err; - } - } - - if ( err >= 0 ) - { - /* Create the attribute. */ - attr_id = H5Acreate( obj_id, attrName.c_str() , dataType, sid, H5P_DEFAULT, H5P_DEFAULT ); - if ( attr_id >= 0 ) - { - /* Write the attribute data. */ - err = H5Awrite( attr_id, dataType, data ); - if ( err < 0 ) - { - std::cout << "Error Writing Attribute" << std::endl; - retErr = err; - } - } - /* Close the attribute. */ - err = H5Aclose( attr_id ); - if (err < 0) - { - std::cout << "Error Closing Attribute" << std::endl; - retErr = err; - } - } - /* Close the dataspace. */ - err = H5Sclose( sid ); - if ( err < 0 ) - { - std::cout << "Error Closing Dataspace" << std::endl; - retErr = err; - } - } - else - { - retErr = sid; - } - /* Close the object */ - err = H5Lite::closeId( obj_id, statbuf.type ); - if ( err < 0 ) - { - std::cout << "Error Closing HDF5 Object ID" << std::endl; - retErr = err; - } - return retErr; - } - - - /** - * @brief Writes an Attribute to an HDF5 Object - * @param loc_id The Parent Location of the HDFobject that is getting the attribute - * @param objName The Name of Object to write the attribute into. - * @param attrName The Name of the Attribute - * @param dims The Dimensions of the data set - * @param data The Attribute Data to write - * @return Standard HDF Error Condition - * - */ - template - static herr_t writeVectorAttribute(hid_t loc_id, - const std::string& objName, - const std::string& attrName, - std::vector& dims, - std::vector& data ) - { - H5SUPPORT_MUTEX_LOCK() - - hid_t obj_id, sid, attr_id; - //hsize_t dim_size = data.size(); - int32_t has_attr; - H5O_info_t statbuf; - herr_t err = 0; - herr_t retErr = 0; - hid_t dataType = H5Lite::HDFTypeForPrimitive(data.front()); - if (dataType == -1) - { - return -1; - } - /* Get the type of object */ - if (H5Oget_info_by_name(loc_id, objName.c_str(), &statbuf, H5P_DEFAULT) < 0) - { - std::cout << "Error getting object info at loc_id (" << loc_id << ") with object name (" << objName << ")" << std::endl; - return -1; - } - /* Open the object */ - obj_id = H5Lite::openId( loc_id, objName, statbuf.type ); - if ( obj_id < 0) - { - std::cout << "Error opening Object for Attribute operations." << std::endl; - return -1; - } - - /* Create the data space for the attribute. */ - hsize_t* dimsPtr = nullptr; - //size mismatch between hsize_t and size_t - std::vector::size_type _size = dims.size(); - //hsize_t _dims[ _size ]; - std::vector _dims(_size, 0); - for (std::vector::size_type i = 0; i < _size; ++i) - { - _dims[i] = static_cast(dims[i]); - } - dimsPtr = &(_dims.front() ); - - sid = H5Screate_simple( static_cast(dims.size()), dimsPtr, nullptr ); - if ( sid >= 0 ) - { - /* Verify if the attribute already exists */ - has_attr = H5Lite::findAttribute( obj_id, attrName ); - - /* The attribute already exists, delete it */ - if ( has_attr == 1 ) - { - err = H5Adelete( obj_id, attrName.c_str() ); - if (err < 0) - { - std::cout << "Error Deleting Existing Attribute" << std::endl; - retErr = err; - } - } - - if ( err >= 0 ) - { - /* Create the attribute. */ - attr_id = H5Acreate( obj_id, attrName.c_str() , dataType, sid, H5P_DEFAULT, H5P_DEFAULT ); - if ( attr_id >= 0 ) - { - /* Write the attribute data. */ - err = H5Awrite( attr_id, dataType, &(data.front()) ); - if ( err < 0 ) - { - std::cout << "Error Writing Attribute" << std::endl; - retErr = err; - } - } - /* Close the attribute. */ - err = H5Aclose( attr_id ); - if (err < 0) - { - std::cout << "Error Closing Attribute" << std::endl; - retErr = err; - } - } - /* Close the dataspace. */ - err = H5Sclose( sid ); - if ( err < 0 ) - { - std::cout << "Error Closing Dataspace" << std::endl; - retErr = err; - } - } - else - { - retErr = sid; - } - /* Close the object */ - err = H5Lite::closeId( obj_id, statbuf.type ); - if ( err < 0 ) - { - std::cout << "Error Closing HDF5 Object ID" << std::endl; - retErr = err; - } - return retErr; - } - - /** - * @brief Writes a string as a null terminated attribute. - * @param loc_id The location to look for objName - * @param objName The Object to write the attribute to - * @param attrName The name of the Attribute - * @param data The string to write as the attribute - * @return Standard HDF error conditions - */ - static H5Support_EXPORT herr_t writeStringAttribute(hid_t loc_id, - const std::string& objName, - const std::string& attrName, - const std::string& data); - /** - * @brief Writes a null terminated string as an attribute - * @param loc_id The location to look for objName - * @param objName The Object to write the attribute to - * @param attrName The name of the Attribute - * @param size The number of characters in the string - * @param data pointer to a const char array - * @return Standard HDF error conditions - */ - static H5Support_EXPORT herr_t writeStringAttribute(hid_t loc_id, - const std::string& objName, - const std::string& attrName, - hsize_t size, - const char* data); - - - /** - * @brief Writes attributes that all have a data type of STRING. The first value - * in each set is the key, the second is the actual value of the attribute. - * @param loc_id The location to look for objName - * @param objName The Object to write the attribute to - * @param attributes The attributes to be written where the first value is the name - * of the attribute, and the second is the actual value of the attribute. - * @return Standard HDF error condition - */ - static H5Support_EXPORT herr_t writeStringAttributes(hid_t loc_id, - const std::string& objName, - const std::map& attributes); - - /** - * @brief Returns the total number of elements in the supplied dataset - * @param loc_id The parent location that contains the dataset to read - * @param dsetName The name of the dataset to read - * @param data A std::vector. Note the vector WILL be resized to fit the data. - * The best idea is to just allocate the vector but not to size it. The method - * will size it for you. - * @return Number of elements in dataset - */ - static H5Support_EXPORT hsize_t getNumberOfElements(hid_t loc_id, - const std::string& dsetName); - - /** - * @brief Writes an attribute to the given object. This method is designed with - * a Template parameter that represents a primitive value. If you need to write - * an array, please use the other over loaded method that takes a vector. - * @param loc_id The location to look for objName - * @param objName The Object to write the attribute to - * @param attrName The name of the attribute - * @param data The data to be written as the attribute - * @return Standard HDF error condition - */ - template - static herr_t writeScalarAttribute(hid_t loc_id, - const std::string& objName, - const std::string& attrName, - T data ) - { - H5SUPPORT_MUTEX_LOCK() - - hid_t obj_id, sid, attr_id; - int32_t has_attr; - H5O_info_t statbuf; - herr_t err = 0; - herr_t retErr = 0; - hsize_t dims = 1; - hid_t rank = 1; - hid_t dataType = H5Lite::HDFTypeForPrimitive(data); - if (dataType == -1) - { - return -1; - } - /* Get the type of object */ - err = H5Oget_info_by_name(loc_id, objName.c_str(), &statbuf, H5P_DEFAULT); - if (err < 0) - { - std::cout << "Error getting object info at loc_id (" << loc_id << ") with object name (" << objName << ")" << std::endl; - return err; - } - /* Open the object */ - obj_id = H5Lite::openId( loc_id, objName, statbuf.type ); - if ( obj_id < 0) - { - std::cout << "Error opening Object for Attribute operations." << std::endl; - return obj_id; - } - - /* Create the data space for the attribute. */ - sid = H5Screate_simple( rank, &dims, nullptr ); - if ( sid >= 0 ) - { - /* Verify if the attribute already exists */ - has_attr = H5Lite::findAttribute( obj_id, attrName ); - - /* The attribute already exists, delete it */ - if ( has_attr == 1 ) - { - err = H5Adelete( obj_id, attrName.c_str() ); - if (err < 0) - { - std::cout << "Error Deleting Existing Attribute" << std::endl; - retErr = err; - } - } - - if ( err >= 0 ) - { - /* Create the attribute. */ - attr_id = H5Acreate( obj_id, attrName.c_str() , dataType, sid, H5P_DEFAULT, H5P_DEFAULT ); - if ( attr_id >= 0 ) - { - /* Write the attribute data. */ - err = H5Awrite( attr_id, dataType, &data ); - if ( err < 0 ) - { - std::cout << "Error Writing Attribute" << std::endl; - retErr = err; - } - } - /* Close the attribute. */ - err = H5Aclose( attr_id ); - if (err < 0) - { - std::cout << "Error Closing Attribute" << std::endl; - retErr = err; - } - } - /* Close the dataspace. */ - err = H5Sclose( sid ); - if ( err < 0 ) - { - std::cout << "Error Closing Dataspace" << std::endl; - retErr = err; - } - } - else - { - retErr = sid; - } - - /* Close the object */ - err = H5Lite::closeId( obj_id, statbuf.type ); - if ( err < 0 ) - { - std::cout << "Error Closing HDF5 Object ID" << std::endl; - retErr = err; - } - return retErr; - } - - /** - * @brief Reads data from the HDF5 File into a preallocated array. - * @param loc_id The parent location that contains the dataset to read - * @param dsetName The name of the dataset to read - * @param data A Pointer to the PreAllocated Array of Data - * @return Standard HDF error condition - */ - template - static herr_t readPointerDataset(hid_t loc_id, - const std::string& dsetName, - T* data) - { - H5SUPPORT_MUTEX_LOCK() - - hid_t did; - herr_t err = 0; - herr_t retErr = 0; - hid_t dataType = 0; - T test = 0x00; - dataType = H5Lite::HDFTypeForPrimitive(test); - if (dataType == -1) - { - std::cout << "dataType was not supported." << std::endl; - return -10; - } - if (loc_id < 0) - { - std::cout << "loc_id was Negative: This is not allowed." << std::endl; - return -2; - } - if (nullptr == data) - { - std::cout << "The Pointer to hold the data is nullptr. This is NOT allowed." << std::endl; - return -3; - } - did = H5Dopen( loc_id, dsetName.c_str(), H5P_DEFAULT ); - if ( did < 0 ) - { - std::cout << " Error opening Dataset: " << did << std::endl; - return -1; - } - if ( did >= 0 ) - { - err = H5Dread(did, dataType, H5S_ALL, H5S_ALL, H5P_DEFAULT, data ); - if (err < 0) - { - std::cout << "Error Reading Data." << std::endl; - retErr = err; - } - err = H5Dclose( did ); - if (err < 0 ) - { - std::cout << "Error Closing Dataset id" << std::endl; - retErr = err; - } - } - return retErr; - } - - /** - * @brief Reads data from the HDF5 File into an std::vector object. If the dataset - * is very large this can be an expensive method to use. It is here for convenience - * using STL with hdf5. - * @param loc_id The parent location that contains the dataset to read - * @param dsetName The name of the dataset to read - * @param data A std::vector. Note the vector WILL be resized to fit the data. - * The best idea is to just allocate the vector but not to size it. The method - * will size it for you. - * @return Standard HDF error condition - */ - template - static herr_t readVectorDataset(hid_t loc_id, - const std::string& dsetName, - std::vector& data) - { - H5SUPPORT_MUTEX_LOCK() - - hid_t did; - herr_t err = 0; - herr_t retErr = 0; - hid_t spaceId; - hid_t dataType; - T test = static_cast(0x00); - dataType = H5Lite::HDFTypeForPrimitive(test); - if (dataType == -1) - { - return -1; - } - did = H5Dopen( loc_id, dsetName.c_str(), H5P_DEFAULT); - if ( did < 0 ) - { - std::cout << "H5Lite.h::readVectorDataset(" << __LINE__ << ") Error opening Dataset at loc_id (" << loc_id << ") with object name (" << dsetName << ")" << std::endl; - return -1; - } - if ( did >= 0 ) - { - spaceId = H5Dget_space(did); - if ( spaceId > 0 ) - { - int32_t rank = H5Sget_simple_extent_ndims(spaceId); - if (rank > 0) - { - std::vector dims; - dims.resize(rank);// Allocate enough room for the dims - err = H5Sget_simple_extent_dims(spaceId, &(dims.front()), nullptr); - hsize_t numElements = 1; - for (std::vector::iterator iter = dims.begin(); iter < dims.end(); ++iter ) - { - numElements = numElements * (*iter); - } - // std::cout << "NumElements: " << numElements << std::endl; - //Resize the vector - data.resize( static_cast(numElements) ); - // for (uint32_t i = 0; i - static herr_t readScalarDataset(hid_t loc_id, - const std::string& dsetName, - T& data) - { - H5SUPPORT_MUTEX_LOCK() - - hid_t did = 0; - herr_t err = 0; - herr_t retErr = 0; - hid_t spaceId = 0; - - hid_t dataType = H5Lite::HDFTypeForPrimitive(data); - if (dataType == -1) - { - return -1; - } - /* Open the dataset. */ - did = H5Dopen( loc_id, dsetName.c_str(), H5P_DEFAULT ); - if ( did < 0 ) - { - std::cout << "H5Lite.h::readScalarDataset(" << __LINE__ << ") Error opening Dataset at loc_id (" << loc_id << ") with object name (" << dsetName << ")" << std::endl; - return -1; - } - if ( did >= 0 ) - { - spaceId = H5Dget_space(did); - if ( spaceId > 0 ) - { - err = H5Dread(did, dataType, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data ); - if (err < 0) - { - std::cout << "Error Reading Data at loc_id (" << loc_id << ") with object name (" << dsetName << ")" << std::endl; - retErr = err; - } - - err = H5Sclose(spaceId); - if (err < 0 ) - { - std::cout << "Error Closing Data Space at loc_id (" << loc_id << ") with object name (" << dsetName << ")" << std::endl; - retErr = err; - } - } - else - { - retErr = spaceId; - } - err = H5Dclose( did ); - if (err < 0 ) - { - std::cout << "Error Closing Dataset at loc_id (" << loc_id << ") with object name (" << dsetName << ")" << std::endl; - retErr = err; - } - } - return retErr; - } - - - /** - * @brief Reads a string dataset into the supplied string. Any data currently in the 'data' variable - * is cleared first before the new data is read into the string. - * @param loc_id The parent group that holds the data object to read - * @param dsetName The name of the dataset. - * @param data The std::string to hold the data - * @return Standard HDF error condition - */ - static H5Support_EXPORT herr_t readStringDataset(hid_t loc_id, - const std::string& dsetName, - std::string& data); - - - - /** - * @brief reads a null terminated string dataset into the supplied buffer. The buffer - * should be already preallocated. - * @param loc_id The parent group that holds the data object to read - * @param dsetName The name of the dataset. - * @param data pointer to the buffer - * @return Standard HDF error condition - */ - static H5Support_EXPORT herr_t readStringDataset(hid_t loc_id, - const std::string& dsetName, - char* data); - /** - * @brief - * @param loc_id - * @param dsetName - * @param data - * @return - */ - static H5Support_EXPORT herr_t readVectorOfStringDataset(hid_t loc_id, - const std::string& dsetName, - std::vector& data); - /** - * @brief Reads an Attribute from an HDF5 Object. - * - * Use this method if you already know the datatype of the attribute. If you do - * not know this already then use another form of this method. - * - * @param loc_id The Parent object that holds the object to which you want to read an attribute - * @param objName The name of the object to which the attribute is to be read - * @param attrName The name of the Attribute to read - * @param data The memory to store the data - * @return Standard HDF Error condition - */ - template - static herr_t readVectorAttribute(hid_t loc_id, - const std::string& objName, - const std::string& attrName, - std::vector& data) - { - H5SUPPORT_MUTEX_LOCK() - - /* identifiers */ - hid_t obj_id; - H5O_info_t statbuf; - herr_t err = 0; - herr_t retErr = 0; - hid_t attr_id; - hid_t tid; - T test = 0x00; - hid_t dataType = H5Lite::HDFTypeForPrimitive(test); - if (dataType == -1) - { - return -1; - } - //std::cout << " Reading Vector Attribute at Path '" << objName << "' with Key: '" << attrName << "'" << std::endl; - /* Get the type of object */ - err = H5Oget_info_by_name(loc_id, objName.c_str(), &statbuf, H5P_DEFAULT); - if (err < 0) - { return err; } - /* Open the object */ - obj_id = H5Lite::openId( loc_id, objName, statbuf.type); - if ( obj_id >= 0) - { - attr_id = H5Aopen_by_name( loc_id, objName.c_str(), attrName.c_str(), H5P_DEFAULT, H5P_DEFAULT ); - if ( attr_id >= 0 ) - { - //Need to allocate the array size - H5T_class_t type_class; - size_t type_size; - std::vector dims; - err = H5Lite::getAttributeInfo(loc_id, objName, attrName, dims, type_class, type_size, tid); - hsize_t numElements = 1; - for (std::vector::iterator iter = dims.begin(); iter < dims.end(); ++iter ) - { - numElements *= *(iter); - } - //std::cout << " Vector Attribute has " << numElements << " elements." << std::endl; - data.resize( static_cast(numElements) ); - err = H5Aread( attr_id, dataType, &(data.front()) ); - if ( err < 0 ) - { - std::cout << "Error Reading Attribute." << err << std::endl; - retErr = err; - } - err = H5Aclose( attr_id ); - if ( err < 0 ) - { - std::cout << "Error Closing Attribute" << std::endl; - retErr = err; - } - } - else - { - retErr = attr_id; - } - err = H5Lite::closeId( obj_id, statbuf.type ); - if ( err < 0 ) - { - std::cout << "Error Closing Object" << std::endl; - retErr = err; - } - } - return retErr; - } - - /** - * @brief Reads a scalar attribute value from a dataset - * @param loc_id - * @param objName The name of the dataset - * @param attrName The name of the Attribute - * @param data The preallocated memory for the variable to be stored into - * @return Standard HDF5 error condition - */ - template - static herr_t readScalarAttribute(hid_t loc_id, - const std::string& objName, - const std::string& attrName, - T& data) - { - H5SUPPORT_MUTEX_LOCK() - - /* identifiers */ - hid_t obj_id; - H5O_info_t statbuf; - herr_t err = 0; - herr_t retErr = 0; - hid_t attr_id; - T test = 0x00; - hid_t dataType = H5Lite::HDFTypeForPrimitive(test); - if (dataType == -1) - { - return -1; - } - //std::cout << "Reading Scalar style Attribute at Path '" << objName << "' with Key: '" << attrName << "'" << std::endl; - /* Get the type of object */ - err = H5Oget_info_by_name(loc_id, objName.c_str(), &statbuf, H5P_DEFAULT); - if (err < 0) - { return err; } - /* Open the object */ - obj_id = H5Lite::openId( loc_id, objName, statbuf.type); - if ( obj_id >= 0) - { - attr_id = H5Aopen_by_name( loc_id, objName.c_str(), attrName.c_str(), H5P_DEFAULT, H5P_DEFAULT ); - if ( attr_id >= 0 ) - { - err = H5Aread( attr_id, dataType, &data ); - if ( err < 0 ) - { - std::cout << "Error Reading Attribute." << std::endl; - retErr = err; - } - err = H5Aclose( attr_id ); - if ( err < 0 ) - { - std::cout << "Error Closing Attribute" << std::endl; - retErr = err; - } - } - else - { - retErr = attr_id; - } - err = H5Lite::closeId( obj_id, statbuf.type ); - if ( err < 0 ) - { - std::cout << "Error Closing Object" << std::endl; - retErr = err; - } - } - return retErr; - } - - /** - * @brief Reads the Attribute into a pre-allocated pointer - * @param loc_id - * @param objName The name of the dataset - * @param attrName The name of the Attribute - * @param data The preallocated memory for the variable to be stored into - * @return Standard HDF5 error condition - */ - template - static herr_t readPointerAttribute(hid_t loc_id, - const std::string& objName, - const std::string& attrName, - T* data) - { - H5SUPPORT_MUTEX_LOCK() - - /* identifiers */ - hid_t obj_id; - H5O_info_t statbuf; - herr_t err = 0; - herr_t retErr = 0; - hid_t attr_id; - T test = 0x00; - hid_t dataType = H5Lite::HDFTypeForPrimitive(test); - if (dataType == -1) - { - return -1; - } - //std::cout << " Reading Vector Attribute at Path '" << objName << "' with Key: '" << attrName << "'" << std::endl; - /* Get the type of object */ - err = H5Oget_info_by_name(loc_id, objName.c_str(), &statbuf, H5P_DEFAULT); - if (err < 0) - { return err; } - /* Open the object */ - obj_id = H5Lite::openId( loc_id, objName, statbuf.type); - if ( obj_id >= 0) - { - attr_id = H5Aopen_by_name( loc_id, objName.c_str(), attrName.c_str(), H5P_DEFAULT, H5P_DEFAULT ); - if ( attr_id >= 0 ) - { - err = H5Aread( attr_id, dataType, data); - if ( err < 0 ) - { - std::cout << "Error Reading Attribute." << err << std::endl; - retErr = err; - } - err = H5Aclose( attr_id ); - if ( err < 0 ) - { - std::cout << "Error Closing Attribute" << std::endl; - retErr = err; - } - } - else - { - retErr = attr_id; - } - err = H5Lite::closeId( obj_id, statbuf.type ); - if ( err < 0 ) - { - std::cout << "Error Closing Object" << std::endl; - retErr = err; - } - } - return retErr; - } - - /** - * @brief Reads a string attribute from an HDF object - * @param loc_id The Parent object that holds the object to which you want to read an attribute - * @param objName The name of the object to which the attribute is to be read - * @param attrName The name of the Attribute to read - * @param data The memory to store the data - * @return Standard HDF Error condition - */ - static H5Support_EXPORT herr_t readStringAttribute(hid_t loc_id, - const std::string& objName, - const std::string& attrName, - std::string& data); - - /** - * @brief Reads a string attribute from an HDF object into a precallocated buffer - * @param loc_id The Parent object that holds the object to which you want to read an attribute - * @param objName The name of the object to which the attribute is to be read - * @param attrName The name of the Attribute to read - * @param data The memory to store the data into - * @return Standard HDF Error condition - */ - static H5Support_EXPORT herr_t readStringAttribute(hid_t loc_id, - const std::string& objName, - const std::string& attrName, - char* data); - /** - * @brief Returns the number of dimensions for a given attribute - * @param loc_id The HDF5 id of the parent group/file for the objName - * @param objName The name of the dataset - * @param attrName The name of the attribute - * @param rank (out) Number of dimensions is store into this variable - */ - static H5Support_EXPORT herr_t getAttributeNDims(hid_t loc_id, const std::string& objName, const std::string& attrName, hid_t& rank); - - /** - * @brief Returns the number of dimensions for a given dataset - * @param loc_id The HDF5 id of the parent group/file for the objName - * @param objName The name of the dataset - * @param rank (out) Number of dimensions is store into this variable - */ - static H5Support_EXPORT herr_t getDatasetNDims(hid_t loc_id, const std::string& objName, hid_t& rank); - - /** - * @brief Returns the H5T value for a given dataset. - * - * Returns the type of data stored in the dataset. You MUST use H5Tclose(tid) - * on the returned value or resource leaks will occur. - * @param loc_id A Valid HDF5 file or group id. - * @param dsetName Path to the dataset - * @return - */ - static H5Support_EXPORT hid_t getDatasetType(hid_t loc_id, const std::string& dsetName); - - /** - * @brief Get the information about a dataset. - * - * @param loc_id The parent location of the Dataset - * @param dsetName The name of the dataset - * @param dims A std::vector that will hold the sizes of the dimensions - * @param type_class The HDF5 class type - * @param type_size THe HDF5 size of the data - * @return Negative value is Failure. Zero or Positive is success; - */ - static H5Support_EXPORT herr_t getDatasetInfo( hid_t loc_id, - const std::string& dsetName, - std::vector& dims, - H5T_class_t& classType, - size_t& sizeType ); - - /** - * @brief Returns the information about an attribute. - * You must close the attributeType argument or resource leaks will occur. Use - * H5Tclose(attr_type); after your call to this method if you do not need the id for - * anything. - * @param loc_id The parent location of the Dataset - * @param objName The name of the dataset - * @param attr_name The name of the attribute - * @param dims A std::vector that will hold the sizes of the dimensions - * @param type_class The HDF5 class type - * @param type_size THe HDF5 size of the data - * @param attr_type The Attribute ID - which needs to be closed after you are finished with the data - * @return - */ - static H5Support_EXPORT herr_t getAttributeInfo(hid_t loc_id, - const std::string& objName, - const std::string& attrName, - std::vector& dims, - H5T_class_t& type_class, - size_t& type_size, - hid_t& tid); - - - - -// ----------------------------------------------------------------------------- - protected: - H5Lite(); - ~H5Lite(); - - - private: - - }; - - -#if defined (H5Support_NAMESPACE) -} -#endif - diff --git a/Source/H5Support/H5Macros.h b/Source/H5Support/H5Macros.h deleted file mode 100755 index 3f1c7d5d27..0000000000 --- a/Source/H5Support/H5Macros.h +++ /dev/null @@ -1,94 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#pragma once - - -//-- HDF Headers -#include - -#include "H5Support/H5Support.h" -#include "H5Support/H5SupportDLLExport.h" - - -#define CloseH5A(aid, err, retError)\ - err = H5Aclose( attr_id );\ - if (err<0) {std::cout << "File: " << __FILE__ << "(" << __LINE__ << "): " << "Error Closing Attribute." << std::endl;retErr = err;} - -#define CloseH5D(did, err, retError)\ - err = H5Dclose(did);\ - if (err < 0) { std::cout << "File: " << __FILE__ << "(" << __LINE__ << "): "<< "Error Closing Dataset: " << dsetName << " did=" << did << " retError=" << retError << std::endl; retError = err;} - -#define CloseH5S(sid, err, retError)\ - err = H5Sclose(sid); \ - if ( err < 0) {std::cout << "File: " << __FILE__ << "(" << __LINE__ << "): "<< "Error closing Dataspace." << std::endl;retErr = err;} - -#define CloseH5T(tid, err, re)\ - err = H5Tclose(tid);\ - if (err < 0 ) {std::cout << "File: " << __FILE__ << "(" << __LINE__ << "): "<< "Error closing DataType" << std::endl; re = err;} - -#define HDF_ERROR_HANDLER_OFF\ - herr_t (*_oldHDF_error_func)(hid_t, void *);\ - void *_oldHDF_error_client_data;\ - H5Eget_auto(H5E_DEFAULT, &_oldHDF_error_func, &_oldHDF_error_client_data);\ - H5Eset_auto(H5E_DEFAULT, nullptr, nullptr); - -#define HDF_ERROR_HANDLER_ON H5Eset_auto(H5E_DEFAULT, _oldHDF_error_func, _oldHDF_error_client_data); - - -#define UNUSED(x) ((void)(x)); - - -#define QCloseH5A(aid, err, retError)\ - err = H5Aclose( attr_id );\ - if (err<0) {qDebug() << "File: " << __FILE__ << "(" << __LINE__ << "): " << "Error Closing Attribute.";retErr = err;} - -#define QCloseH5D(did, err, retError)\ - err = H5Dclose(did);\ - if (err < 0) { qDebug() << "File: " << __FILE__ << "(" << __LINE__ << "): "<< "Error Closing Dataset: " << dsetName << " did=" << did << " retError=" << retError; retError = err;} - -#define QCloseH5S(sid, err, retError)\ - err = H5Sclose(sid); \ - if ( err < 0) {qDebug() << "File: " << __FILE__ << "(" << __LINE__ << "): "<< "Error closing Dataspace.";retErr = err;} - -#define QCloseH5T(tid, err, re)\ - err = H5Tclose(tid);\ - if (err < 0 ) {qDebug() << "File: " << __FILE__ << "(" << __LINE__ << "): "<< "Error closing DataType"; re = err;} - - - - - - diff --git a/Source/H5Support/H5ScopedErrorHandler.cpp b/Source/H5Support/H5ScopedErrorHandler.cpp deleted file mode 100644 index 71e11219fe..0000000000 --- a/Source/H5Support/H5ScopedErrorHandler.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2018 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include "H5ScopedErrorHandler.h" - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -H5ScopedErrorHandler::H5ScopedErrorHandler() -{ - H5Eget_auto(H5E_DEFAULT, &_oldHDF_error_func, &_oldHDF_error_client_data); - H5Eset_auto(H5E_DEFAULT, nullptr, nullptr); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -H5ScopedErrorHandler::~H5ScopedErrorHandler() -{ - H5Eset_auto(H5E_DEFAULT, _oldHDF_error_func, _oldHDF_error_client_data); -} \ No newline at end of file diff --git a/Source/H5Support/H5ScopedErrorHandler.h b/Source/H5Support/H5ScopedErrorHandler.h deleted file mode 100644 index 18a0413bd1..0000000000 --- a/Source/H5Support/H5ScopedErrorHandler.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include - -#include "H5Support/H5Support.h" - -#if defined (H5Support_NAMESPACE) -namespace H5Support_NAMESPACE -{ -#endif - -/** -* @brief This class is meant to disable the normal HDF5 error handlers until the -* instance goes out of scope the original error handlers will be put back in -* place -*/ -class H5Support_EXPORT H5ScopedErrorHandler -{ - - public: - - H5ScopedErrorHandler(); - - ~H5ScopedErrorHandler(); - - private: - herr_t (*_oldHDF_error_func)(hid_t, void *); - void *_oldHDF_error_client_data; - - public: - H5ScopedErrorHandler(const H5ScopedErrorHandler&) = delete; // Copy Constructor Not Implemented - H5ScopedErrorHandler(H5ScopedErrorHandler&&) = delete; // Move Constructor Not Implemented - H5ScopedErrorHandler& operator=(const H5ScopedErrorHandler&) = delete; // Copy Assignment Not Implemented - H5ScopedErrorHandler& operator=(H5ScopedErrorHandler&&) = delete; // Move Assignment Not Implemented -}; - - -#if defined (H5Support_NAMESPACE) -} -#endif - diff --git a/Source/H5Support/H5ScopedSentinel.cpp b/Source/H5Support/H5ScopedSentinel.cpp deleted file mode 100644 index 2405d49390..0000000000 --- a/Source/H5Support/H5ScopedSentinel.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include "H5ScopedSentinel.h" - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -H5ScopedFileSentinel::H5ScopedFileSentinel(hid_t* fileId, bool turnOffErrors) -: m_FileId(fileId) -, m_TurnOffErrors(turnOffErrors) -{ - if(m_TurnOffErrors) - { - H5Eget_auto(H5E_DEFAULT, &_oldHDF_error_func, &_oldHDF_error_client_data); - H5Eset_auto(H5E_DEFAULT, nullptr, nullptr); - } -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -H5ScopedFileSentinel::~H5ScopedFileSentinel() -{ - if(m_TurnOffErrors) - { - H5Eset_auto(H5E_DEFAULT, _oldHDF_error_func, _oldHDF_error_client_data); - } - for(auto temp : m_Groups) - { - if(*temp > 0) - { - H5Gclose(*temp); - *temp = -1; - } - } - - if(*m_FileId > 0) - { - H5Utilities::closeFile(*m_FileId); - *m_FileId = -1; - } -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void H5ScopedFileSentinel::setFileId(hid_t* fileId) -{ - m_FileId = fileId; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -hid_t* H5ScopedFileSentinel::getFileId() -{ - return m_FileId; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void H5ScopedFileSentinel::addGroupId(hid_t* gid) -{ - m_Groups.push_back(gid); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -H5ScopedGroupSentinel::H5ScopedGroupSentinel(hid_t* gid, bool turnOffErrors) -: m_TurnOffErrors(turnOffErrors) -{ - m_Groups.push_back(gid); - if(m_TurnOffErrors) - { - H5Eget_auto(H5E_DEFAULT, &_oldHDF_error_func, &_oldHDF_error_client_data); - H5Eset_auto(H5E_DEFAULT, nullptr, nullptr); - } -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -H5ScopedGroupSentinel::~H5ScopedGroupSentinel() -{ - if(m_TurnOffErrors) - { - H5Eset_auto(H5E_DEFAULT, _oldHDF_error_func, _oldHDF_error_client_data); - } - for(auto temp : m_Groups) - { - if(*temp > 0) - { - H5Gclose(*temp); - *temp = -1; - } - } -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void H5ScopedGroupSentinel::addGroupId(hid_t* gid) -{ - m_Groups.push_back(gid); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -H5ScopedObjectSentinel::H5ScopedObjectSentinel(hid_t* gid, bool turnOffErrors) -: m_TurnOffErrors(turnOffErrors) -{ - m_Groups.push_back(gid); - if(m_TurnOffErrors) - { - H5Eget_auto(H5E_DEFAULT, &_oldHDF_error_func, &_oldHDF_error_client_data); - H5Eset_auto(H5E_DEFAULT, nullptr, nullptr); - } -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -H5ScopedObjectSentinel::~H5ScopedObjectSentinel() -{ - if(m_TurnOffErrors) - { - H5Eset_auto(H5E_DEFAULT, _oldHDF_error_func, _oldHDF_error_client_data); - } - for(auto temp : m_Groups) - { - if(*temp > 0) - { - H5Utilities::closeHDF5Object(*temp); - *temp = -1; - } - } -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void H5ScopedObjectSentinel::addGroupId(hid_t* gid) -{ - m_Groups.push_back(gid); -} - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -H5GroupAutoCloser::H5GroupAutoCloser(hid_t* groupId) -: gid(groupId) -{ -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -H5GroupAutoCloser::~H5GroupAutoCloser() -{ - if(*gid > 0) - { - H5Gclose(*gid); - } -} - diff --git a/Source/H5Support/H5ScopedSentinel.h b/Source/H5Support/H5ScopedSentinel.h deleted file mode 100644 index 10c50d2cf0..0000000000 --- a/Source/H5Support/H5ScopedSentinel.h +++ /dev/null @@ -1,121 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#pragma once - - -#include "H5Support/H5Utilities.h" -#include "H5Support/H5Lite.h" - -#include "H5Support/H5Support.h" - -#if defined (H5Support_NAMESPACE) -namespace H5Support_NAMESPACE -{ -#endif - - -/** - * @brief The HDF5FileSentinel class ensures the HDF5 file that is currently open - * is closed when the variable goes out of Scope - */ -class H5Support_EXPORT H5ScopedFileSentinel -{ - public: - H5ScopedFileSentinel(hid_t* fileId, bool turnOffErrors); - virtual ~H5ScopedFileSentinel(); - - void setFileId(hid_t* fileId); - hid_t* getFileId(); - void addGroupId(hid_t* gid); - - private: - hid_t* m_FileId; - bool m_TurnOffErrors; - std::vector m_Groups; - - herr_t (*_oldHDF_error_func)(hid_t, void*){}; - void* _oldHDF_error_client_data{}; -}; - -class H5Support_EXPORT H5ScopedGroupSentinel -{ - public: - H5ScopedGroupSentinel(hid_t* gid, bool turnOffErrors); - virtual ~H5ScopedGroupSentinel(); - void addGroupId(hid_t* gid); - - private: - bool m_TurnOffErrors; - std::vector m_Groups; - - herr_t (*_oldHDF_error_func)(hid_t, void*){}; - void* _oldHDF_error_client_data{}; -}; - - -class H5Support_EXPORT H5ScopedObjectSentinel -{ - public: - H5ScopedObjectSentinel(hid_t* gid, bool turnOffErrors); - virtual ~H5ScopedObjectSentinel(); - void addGroupId(hid_t* gid); - - private: - bool m_TurnOffErrors; - std::vector m_Groups; - - herr_t (*_oldHDF_error_func)(hid_t, void*){}; - void* _oldHDF_error_client_data{}; -}; - -class H5Support_EXPORT H5GroupAutoCloser -{ -public: - H5GroupAutoCloser(hid_t* groupId); - - virtual ~H5GroupAutoCloser(); -private: - hid_t* gid = nullptr; -}; - - -#if defined (H5Support_NAMESPACE) -} -#endif - - - - diff --git a/Source/H5Support/H5SupportConfiguration.h.in b/Source/H5Support/H5SupportConfiguration.h.in deleted file mode 100755 index 8ec9439a61..0000000000 --- a/Source/H5Support/H5SupportConfiguration.h.in +++ /dev/null @@ -1,46 +0,0 @@ -/* This file is auto generated. DO NOT EDIT THIS FILE. Edit the original template file and then rerun CMake -* again to regenerate this file. -*/ - -#ifndef _H5SUPPORT_H_ -#define _H5SUPPORT_H_ - - -/* Define to 1 if H5Support was built as a dynamic library */ -#cmakedefine H5Support_BUILT_AS_DYNAMIC_LIB @H5Support_BUILT_AS_DYNAMIC_LIB@ - -/* Define the namespace we are going to use for the H5Support Codes */ -#cmakedefine H5Support_NAMESPACE @H5Support_NAMESPACE@ - -/* Define if H5Support is using Qt classes in addition to STL classes */ -#cmakedefine H5Support_USE_QT @H5Support_USE_QT@ - -/* Include the Overall Configuration header file */ -#include "@PROJECT_NAME@/@CMP_CONFIGURATION_FILE_NAME@" - -/* Include the Typedefs Header */ -#include "@PROJECT_NAME@/@CMP_TYPES_FILE_NAME@" - -/* Include the DLL export preprocessor defines */ -#include "@PROJECT_NAME@/@PROJECT_NAME@DLLExport.h" - -/* We are going to disable some warnings just to get a grip on all the warnings that get produced -* during an MSVC build */ -#cmakedefine DREAM3D_DISABLE_MSVC_WARNINGS - -#define H5Support_USE_MUTEX - -#if (_MSC_VER >= 1) - - #pragma warning (error: 4715) /* Not all control points return a value */ - - #ifdef DREAM3D_DISABLE_MSVC_WARNINGS - #pragma warning(disable:4244) - #pragma warning(disable:4267) - #pragma warning(disable:4305) - #endif - -#endif - - -#endif diff --git a/Source/H5Support/H5SupportDLLExport.h b/Source/H5Support/H5SupportDLLExport.h deleted file mode 100755 index 0afa357c92..0000000000 --- a/Source/H5Support/H5SupportDLLExport.h +++ /dev/null @@ -1,105 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - - - - - -#pragma once - - -#if defined (_MSC_VER) -#pragma warning(disable: 4251) -#pragma warning(disable: 4710) -#pragma warning(disable: 4820) -#pragma warning(disable: 4668) -#pragma warning(disable: 4265) -#pragma warning(disable: 4189) -#pragma warning(disable: 4640) -#pragma warning(disable: 4996) -#pragma warning(disable: 4548) -#endif - -/* Cmake will define H5Support_EXPORTS on Windows when it -configures to build a shared library. If you are going to use -another build system on windows or create the visual studio -projects by hand you need to define H5Support_EXPORTS when -building the H5SupportDatModel DLL on windows. -*/ - -#if defined (H5Support_BUILT_AS_DYNAMIC_LIB) - -#if defined (H5Support_EXPORTS) /* Compiling the H5Support DLL/Dylib */ -#if defined (_MSC_VER) /* MSVC Compiler Case */ -#define H5Support_EXPORT __declspec(dllexport) -#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ -#define H5Support_EXPORT __attribute__ ((visibility("default"))) -#endif -#else /* Importing the DLL into another project */ -#if defined (_MSC_VER) /* MSVC Compiler Case */ -#define H5Support_EXPORT __declspec(dllimport) -#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ -#define H5Support_EXPORT __attribute__ ((visibility("default"))) -#endif -#endif -#endif - -/* If H5Support_EXPORT was never defined, define it here */ -#ifndef _h5supportdllexport_h_ -#define _h5supportdllexport_h_ -#endif - -#if 0 -#if defined (_WIN32) || defined __CYGWIN__ - -#if defined (H5Support_BUILT_AS_DYNAMIC_LIB) -#if defined(H5Support_EXPORTS) -#define H5Support_EXPORT __declspec(dllexport) -#else -#define H5Support_EXPORT __declspec(dllimport) -#endif /* H5Support_EXPORTS */ - -#else -#define H5Support_EXPORT -#endif -#elif __GNUC__ >= 4 -#define FLOW_DLL __attribute__ ((visibility("default"))) -#define DLL_LOCAL __attribute__ ((visibility("hidden") -#else /* defined (_WIN32) && defined (H5Support_BUILD_SHARED_LIBS) */ -#define H5Support_EXPORT -#endif -#endif - - diff --git a/Source/H5Support/H5Utilities.cpp b/Source/H5Support/H5Utilities.cpp deleted file mode 100644 index 4b9767f3aa..0000000000 --- a/Source/H5Support/H5Utilities.cpp +++ /dev/null @@ -1,842 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include - -#include "H5Fpublic.h" - -// C Includes -#include - -// C++ Includes -#include - -#define CheckValidLocId(locId) \ - if((locId) < 0) \ - { \ - std::cout << "Invalid HDF Location ID: " << (locId) << std::endl; \ - return -1; \ - } - -#if defined(H5Support_NAMESPACE) -using namespace H5Support_NAMESPACE; -#endif - - -/** - * Define the libraries features and file compatibility that will be used when opening - * or creating a file - */ -#if (H5_VERS_MINOR == 8) -#define HDF5_VERSION_LIB_LOWER_BOUNDS H5F_LIBVER_18 -#define HDF5_VERSION_LIB_UPPER_BOUNDS H5F_LIBVER_LATEST -#endif - -#if (H5_VERS_MINOR == 10) -#define HDF5_VERSION_LIB_LOWER_BOUNDS H5F_LIBVER_V18 -#define HDF5_VERSION_LIB_UPPER_BOUNDS H5F_LIBVER_V18 -#endif - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -hid_t H5Utilities::createFile(const std::string& filename) -{ - H5SUPPORT_MUTEX_LOCK() - - /* Create a file access property list */ - hid_t fapl = H5Pcreate(H5P_FILE_ACCESS); - - /* Set the fapl */ - H5Pset_libver_bounds(fapl, HDF5_VERSION_LIB_LOWER_BOUNDS, HDF5_VERSION_LIB_UPPER_BOUNDS); - - /* Create a file with this fapl */ - hid_t fileId = H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - - /* Close the apl object */ - H5Pclose(fapl); - - return fileId; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -hid_t H5Utilities::openFile(const std::string& filename, bool readOnly) -{ - H5SUPPORT_MUTEX_LOCK() - - HDF_ERROR_HANDLER_OFF - hid_t fileId = -1; - if(readOnly) - { - fileId = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); - } - else - { - /* Create a file access property list */ - hid_t fapl = H5Pcreate(H5P_FILE_ACCESS); - - /* Set the fapl */ - H5Pset_libver_bounds(fapl, HDF5_VERSION_LIB_LOWER_BOUNDS, HDF5_VERSION_LIB_UPPER_BOUNDS); - fileId = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT); - - /* Close the apl object */ - H5Pclose(fapl); - } - - HDF_ERROR_HANDLER_ON - return fileId; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t H5Utilities::closeFile(hid_t& fileId) -{ - H5SUPPORT_MUTEX_LOCK() - - herr_t err = 1; - if(fileId < 0) // fileId isn't open - { - return 1; - } - - // Get the number of open identifiers of all types - // except files - ssize_t num_open = H5Fget_obj_count(fileId, H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_DATATYPE | H5F_OBJ_ATTR | H5F_OBJ_LOCAL); - if(num_open > 0) - { - std::cout << "WARNING: Some IDs weren't closed. Closing them." << std::endl; - std::vector attr_ids(num_open, 0); - H5Fget_obj_ids(fileId, H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_DATATYPE | H5F_OBJ_ATTR, num_open, &(attr_ids.front())); - for(int i = 0; i < num_open; i++) - { - char name[1024]; - ::memset(name, 0, 1024); - // hid_t obj_type = H5Iget_type(attr_ids[i]); - ssize_t charsRead = H5Iget_name(attr_ids[i], name, 1024); - if(charsRead < 0) - { - std::cout << "Error Trying to get the name of an hdf object that was not closed. This is probably pretty bad. " << __FILE__ << "(" << __LINE__ << ")" << std::endl; - return -1; - } - std::cout << "H5 Object left open. Id=" << attr_ids[i] << " Name='" << name << "'" << std::endl; - H5Utilities::closeHDF5Object(attr_ids[i]); - } - } - - err = H5Fclose(fileId); - if(err < 0) - { - std::cout << "Error Closing HDF5 File. " << err << std::endl; - } - fileId = -1; - return err; -} - -// ----------------------------------------------------------------------------- -// Returns the full path to the object referred to by the -// ----------------------------------------------------------------------------- -std::string H5Utilities::getObjectPath(hid_t loc_id, bool /*trim*/) -{ - H5SUPPORT_MUTEX_LOCK() - - // char *obj_name; - size_t name_size; - name_size = 1 + H5Iget_name(loc_id, nullptr, 0); - std::vector obj_name(name_size, 0); - H5Iget_name(loc_id, &(obj_name.front()), name_size); - std::string objPath(&(obj_name.front())); - - if((objPath != "/") && (objPath.at(0) == '/')) - { - objPath.erase(0, 1); - } - - return objPath; -} - -// ----------------------------------------------------------------------------- -// @brief Retrieves the HDF object type for obj_name at loc_id and stores -// it in the parameter obj_type passed in. -// ----------------------------------------------------------------------------- -herr_t H5Utilities::getObjectType(hid_t objId, const std::string& objName, int32_t* objType) -{ - H5SUPPORT_MUTEX_LOCK() - - herr_t err = 1; - H5O_info_t obj_info{}; - - err = H5Oget_info_by_name(objId, objName.c_str(), &obj_info, H5P_DEFAULT); - if(err < 0) - { - return err; - } - - (*objType) = obj_info.type; - - return err; -} - -// Opens and returns the HDF object (since the HDF api requires -// different open and close methods for different types of objects -hid_t H5Utilities::openHDF5Object(hid_t loc_id, const std::string& objName) -{ - H5SUPPORT_MUTEX_LOCK() - - int32_t obj_type; - hid_t obj_id; - herr_t err = 0; - HDF_ERROR_HANDLER_OFF; - err = getObjectType(loc_id, objName, &obj_type); - if(err < 0) - { - // std::cout << "Error: Unable to get object type for object: " << objName << std::endl; - HDF_ERROR_HANDLER_ON; - return -1; - } - - switch(obj_type) - { - case H5O_TYPE_GROUP: - obj_id = H5Gopen(loc_id, objName.c_str(), H5P_DEFAULT); - break; - case H5O_TYPE_DATASET: - obj_id = H5Dopen(loc_id, objName.c_str(), H5P_DEFAULT); - break; - default: - std::cout << "Unknonwn HDF Type: " << obj_type << std::endl; - obj_id = -1; - } - HDF_ERROR_HANDLER_ON; - return obj_id; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -std::string H5Utilities::getParentPath(hid_t objId) -{ - std::string objPath = getObjectPath(objId); - return getParentPath(objPath); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -std::string H5Utilities::getParentPath(const std::string& objectPath) -{ - std::string parentPath = objectPath; - size_t start = parentPath.find_last_of('/'); - parentPath.erase(start, parentPath.size() - start); - return parentPath; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -std::string H5Utilities::getObjectNameFromPath(const std::string& objectPath) -{ - std::string str = objectPath; - size_t end = str.find_last_of('/'); - str.erase(0, end+1); - return str; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t H5Utilities::closeHDF5Object(hid_t obj_id) -{ - H5SUPPORT_MUTEX_LOCK() - - if(obj_id < 0) // Object was not valid. - { - return 0; - } - H5I_type_t obj_type; - herr_t err = -1; // default to an error - char name[1024]; - ::memset(name, 0, 1024); - obj_type = H5Iget_type(obj_id); - ssize_t charsRead = H5Iget_name(obj_id, name, 1024); - if(charsRead < 0) - { - std::cout << "Error Trying to get the name of an hdf object that was not closed. This is probably pretty bad. " << __FILE__ << "(" << __LINE__ << ")" << std::endl; - return -1; - } - - switch(obj_type) - { - case H5I_FILE: - err = H5Fclose(obj_id); - break; - case H5I_GROUP: - // std::cout << "H5 Group Object left open. Id=" << obj_id << " Name='" << name << "'" << std::endl; - err = H5Gclose(obj_id); - break; - case H5I_DATASET: - // std::cout << "H5 Dataset Object left open. Id=" << obj_id << " Name='" << name << "'" << std::endl; - err = H5Dclose(obj_id); - break; - case H5I_ATTR: - // std::cout << "H5 Attribute Object left open. Id=" << obj_id << " Name='" << name << "'" << std::endl; - err = H5Aclose(obj_id); - break; - case H5I_DATATYPE: - // std::cout << "H5 DataType Object left open. Id=" << obj_id << " Name='" << name << "'" << std::endl; - err = H5Tclose(obj_id); - break; - case H5I_DATASPACE: - // std::cout << "H5 Data Space Object left open. Id=" << obj_id << " Name='" << name << "'" << std::endl; - err = H5Sclose(obj_id); - break; - default: - // std::cout << "Error unknown HDF object for closing: " << " Name='" << name << "'" << " Object Type=" << obj_type << std::endl; - err = -1; - } - - return err; -} - -//--------------------------------------------------------------------// -// HDF Group Methods -//--------------------------------------------------------------------// - -/*! @brief Returns a std::list of std::strings containing the names - * of all objects attached to the group referred to by loc_id - * - * @parameter typeFilter is one of H5Support_GROUP, H5Support_DATASET, HDF5_TYPE, - * or HDF5_LINK or any combination of these using the bitwise or | - * command. Or you can pass in HDF5_ANY to not filter at all - */ -herr_t H5Utilities::getGroupObjects(hid_t loc_id, int32_t typeFilter, std::list& names) -{ - H5SUPPORT_MUTEX_LOCK() - - herr_t err = 0; - hsize_t numObjs = 0; - H5G_info_t group_info{}; - err = H5Gget_info(loc_id, &group_info); - if(err < 0) - { - // std::cout << "Error getting number of objects for group: " << loc_id << std::endl; - return err; - } - numObjs = group_info.nlinks; - - if(numObjs <= 0) - { - return 0; // no objects in group - } - - size_t size = 0; - H5O_type_t type = H5O_TYPE_NTYPES; - - for(hsize_t i = 0; i < numObjs; i++) - { - size = 1 + H5Lget_name_by_idx(loc_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, nullptr, 0, H5P_DEFAULT); - - std::vector name(size * sizeof(char), 0); - - H5Lget_name_by_idx(loc_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, &(name.front()), size, H5P_DEFAULT); - if(typeFilter == H5Support_ANY) - { - std::string objName(&(name.front())); - names.push_back(objName); - } - else - { - H5O_info_t object_info{}; - err = H5Oget_info_by_name(loc_id, &(name.front()), &object_info, H5P_DEFAULT); - if(err >= 0) - { - type = object_info.type; - if(((type == H5O_TYPE_GROUP) && ((H5Support_GROUP & typeFilter) != 0)) || ((type == H5O_TYPE_DATASET) && ((H5Support_DATASET & typeFilter) != 0))) - { - std::string objName(&(name.front())); - names.push_back(objName); - } - } - } - } - - return err; -} - -// ----------------------------------------------------------------------------- -// HDF Creation/Modification Methods -// ----------------------------------------------------------------------------- -hid_t H5Utilities::createGroup(hid_t loc_id, const std::string& group) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t grp_id = -1; - herr_t err = -1; - H5O_info_t obj_info{}; - HDF_ERROR_HANDLER_OFF - - err = H5Oget_info_by_name(loc_id, group.c_str(), &obj_info, H5P_DEFAULT); - // std::cout << "H5Gget_objinfo = " << err << " for " << group << std::endl; - if(err == 0) - { - grp_id = H5Gopen(loc_id, group.c_str(), H5P_DEFAULT); - } - else - { - grp_id = H5Gcreate(loc_id, group.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - } - // Turn the HDF Error handlers back on - HDF_ERROR_HANDLER_ON - - return grp_id; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -hid_t H5Utilities::createGroupsForDataset(const std::string& datasetPath, hid_t parent) -{ - H5SUPPORT_MUTEX_LOCK() - - // Generate the internal HDF dataset path and create all the groups necessary to write the dataset - std::string::size_type pos = 0; - pos = datasetPath.find_last_of('/'); - // std::string parentPath; - if(pos != 0 && pos != std::string::npos) - { - std::string parentPath(datasetPath.substr(0, pos)); - return H5Utilities::createGroupsFromPath(parentPath, parent); - } - // Make sure all the intermediary groups are in place in the HDF5 File - return 1; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -hid_t H5Utilities::createGroupsFromPath(const std::string& pathToCheck, hid_t parent) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t gid = 1; - herr_t err = -1; - std::string first; - std::string second; - std::string path(pathToCheck); // make a copy of the input - - if(parent <= 0) - { - std::cout << "Bad parent Id. Returning from createGroupsFromPath" << std::endl; - return -1; - } - // remove any front slash - std::string::size_type pos = path.find_first_of('/', 0); - if(0 == pos) - { - path = path.substr(1, path.size()); - } - else if(pos == std::string::npos) // Path contains only one element - { - gid = H5Utilities::createGroup(parent, path); - if(gid < 0) - { - std::cout << "Error creating group: " << path << " err:" << gid << std::endl; - return gid; - } - err = H5Gclose(gid); - if(err < 0) - { - std::cout << "Error closing group during group creation." << std::endl; - return err; - } - return err; // Now return here as this was a special case. - } - - // Remove any trailing slash - pos = path.find_last_of('/'); - if(pos == (path.size() - 1)) // slash was in the last position - { - path = path.substr(0, pos); - } - - if(path.empty()) - { - return -1; // The path that was passed in was only a slash.. - } - - pos = path.find_first_of('/', 0); - if(pos == std::string::npos) // Only one element in the path - { - gid = H5Utilities::createGroup(parent, path); - if(gid < 0) - { - std::cout << "Error creating group '" << path << "' for group id " << gid << std::endl; - return gid; - } - err = H5Gclose(gid); - return err; - } - - while(pos != std::string::npos) - { - first = path.substr(0, pos); - second = path.substr(pos + 1, path.length()); - gid = H5Utilities::createGroup(parent, first); - if(gid < 0) - { - std::cout << "Error creating group:" << gid << std::endl; - return gid; - } - err = H5Gclose(gid); - pos = path.find_first_of('/', pos + 1); - if(pos == std::string::npos) - { - first += "/" + second; - gid = createGroup(parent, first); - if(gid < 0) - { - std::cout << "Error creating group:" << gid << std::endl; - return gid; - } - err = H5Gclose(gid); - } - } - return err; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -std::string H5Utilities::extractObjectName(const std::string& path) -{ - std::string::size_type pos; - pos = path.find_last_of('/'); - if(pos == std::string::npos || path == "/") - { - return path; - } - return path.substr(pos+1); -} - -//--------------------------------------------------------------------// -// HDF Attribute Methods -//--------------------------------------------------------------------// -bool H5Utilities::probeForAttribute(hid_t loc_id, const std::string& obj_name, const std::string& attr_name) -{ - H5SUPPORT_MUTEX_LOCK() - - herr_t err = 0; - hid_t rank; - HDF_ERROR_HANDLER_OFF - err = H5Lite::getAttributeNDims(loc_id, obj_name, attr_name, rank); - HDF_ERROR_HANDLER_ON - return err >= 0; -} - -//--------------------------------------------------------------------// -// Returns a std::list of all attribute names attached to the object -// referred to by obj_id -//--------------------------------------------------------------------// -herr_t H5Utilities::getAllAttributeNames(hid_t obj_id, std::list& results) -{ - H5SUPPORT_MUTEX_LOCK() - - if(obj_id < 0) - { - return -1; - } - herr_t err = -1; - hsize_t num_attrs; - hid_t attr_id; - size_t name_size; - H5O_info_t object_info{}; - err = H5Oget_info(obj_id, &object_info); - num_attrs = object_info.num_attrs; - - for(hsize_t i = 0; i < num_attrs; i++) - { - attr_id = H5Aopen_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, H5P_DEFAULT, H5P_DEFAULT); - name_size = 1 + H5Aget_name(attr_id, 0, nullptr); - std::vector attr_name(name_size * sizeof(char), 0); - H5Aget_name(attr_id, name_size, &(attr_name.front())); - results.emplace_back(&(attr_name.front())); - err = H5Aclose(attr_id); - } - - return err; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t H5Utilities::getAllAttributeNames(hid_t loc_id, const std::string& obj_name, std::list& names) -{ - - hid_t obj_id = -1; - herr_t err = -1; - names.clear(); - - obj_id = openHDF5Object(loc_id, obj_name); - if(obj_id < 0) - { - return static_cast(obj_id); - } - err = getAllAttributeNames(obj_id, names); - err = closeHDF5Object(obj_id); - - return err; -} - -#if 0 -// Returns a std::map with all of the attributes for obj_name -// and their attribute values in a std::string std::map -herr_t H5Utilities::getAttributesMap(hid_t loc_id, - const std::string& obj_name, - std::map& attributes) -{ - //std::map attributes; - herr_t err = 0; - H5T_class_t attr_type; - size_t attr_size; - std::string res; - hid_t tid; - MXATypes::Int32Vector ires; - MXATypes::Float32Vector fres; - std::vector dims; //Reusable for the loop - std::list names; - err = getAllAttributeNames(loc_id, obj_name, names); - if (err < 0) { return err; } - std::list::iterator iter; - for (iter = names.begin(); iter != names.end(); iter++) - { - err = H5Lite::getAttributeInfo(loc_id, obj_name, (*iter), dims, attr_type, attr_size, tid); - if (err < 0) - { - std::cout << "Error getting all attributes" << std::endl; - return err; - } - else - { - switch(attr_type) - { - case H5T_STRING: - err = H5Lite::readStringAttribute(loc_id, obj_name, (*iter), res ); - if (err >= 0) - { - attributes[(*iter)] = res; - } - else { return err; } - break; - case H5T_INTEGER: - err = H5Lite::readVectorAttribute(loc_id, obj_name, (*iter), ires); - if (err >= 0) - { - attributes[(*iter)] = QString::number(ires[0]); - } - else { return err; } - break; - case H5T_FLOAT: - err = H5Lite::readVectorAttribute(loc_id, obj_name, (*iter), fres); - if (err >= 0) - { - attributes[(*iter)] = QString::number(fres[0]); - } - else { return err; } - break; - default: - std::cout << "Unknown attribute type: " << attr_type << ": "; - printHDFClassType(attr_type); - } - } - } - - return err; -} -#endif - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -std::string H5Utilities::HDFClassTypeAsStr(hid_t class_type) -{ - switch(class_type) - { - case H5T_INTEGER: - return "H5T_INTEGER"; - break; - case H5T_FLOAT: - return "H5T_FLOAT"; - break; - case H5T_STRING: - return "H5T_STRING"; - break; - case H5T_TIME: - return "H5T_TIME"; - break; - case H5T_BITFIELD: - return "H5T_BITFIELD"; - break; - case H5T_OPAQUE: - return "H5T_OPAQUE"; - break; - case H5T_COMPOUND: - return "H5T_COMPOUND"; - break; - case H5T_REFERENCE: - return "H5T_REFERENCE"; - break; - case H5T_ENUM: - return "H5T_ENUM"; - break; - case H5T_VLEN: - return "H5T_VLEN"; - break; - case H5T_ARRAY: - return "H5T_ARRAY"; - break; - default: - return "OTHER"; - } -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void H5Utilities::printHDFClassType(H5T_class_t class_type) -{ - switch(class_type) - { - case H5T_INTEGER: - std::cout << "H5T_INTEGER" << std::endl; - break; - case H5T_FLOAT: - std::cout << "H5T_FLOAT" << std::endl; - break; - case H5T_STRING: - std::cout << "H5T_STRING" << std::endl; - break; - case H5T_TIME: - std::cout << "H5T_TIME" << std::endl; - break; - case H5T_BITFIELD: - std::cout << "H5T_BITFIELD" << std::endl; - break; - case H5T_OPAQUE: - std::cout << "H5T_OPAQUE" << std::endl; - break; - case H5T_COMPOUND: - std::cout << "H5T_COMPOUND" << std::endl; - break; - case H5T_REFERENCE: - std::cout << "H5T_REFERENCE" << std::endl; - break; - case H5T_ENUM: - std::cout << "H5T_ENUM" << std::endl; - break; - case H5T_VLEN: - std::cout << "H5T_VLEN" << std::endl; - break; - case H5T_ARRAY: - std::cout << "H5T_ARRAY" << std::endl; - break; - default: - std::cout << "OTHER" << std::endl; - } -} - -// ----------------------------------------------------------------------------- -// Returns a std::string that is the name of the object at the given index -// ----------------------------------------------------------------------------- -herr_t H5Utilities::objectNameAtIndex(hid_t fileId, int32_t idx, std::string& name) -{ - H5SUPPORT_MUTEX_LOCK() - - ssize_t err = -1; - // call H5Gget_objname_by_idx with name as nullptr to get its length - ssize_t name_len = H5Lget_name_by_idx(fileId, ".", H5_INDEX_NAME, H5_ITER_NATIVE, static_cast(idx), nullptr, 0, H5P_DEFAULT); - if(name_len < 0) - { - name.clear(); - return -1; - } - - std::vector buf(name_len + 1, 0); - err = H5Lget_name_by_idx(fileId, ".", H5_INDEX_NAME, H5_ITER_NATIVE, static_cast(idx), &(buf.front()), name_len + 1, H5P_DEFAULT); - if(err < 0) - { - std::cout << "Error Trying to get the dataset name for index " << idx << std::endl; - name.clear(); // Make an empty string if this fails - } - else - { - name.append(&(buf.front())); // Append the string to the given string - } - return static_cast(err); -} - -// ----------------------------------------------------------------------------- -// Checks the given name object to see what type of HDF5 object it is. -// ----------------------------------------------------------------------------- -bool H5Utilities::isGroup(hid_t nodeId, const std::string& objName) -{ - H5SUPPORT_MUTEX_LOCK() - - bool isGroup = true; - herr_t err = -1; - H5O_info_t statbuf{}; - err = H5Oget_info_by_name(nodeId, objName.c_str(), &statbuf, H5P_DEFAULT); - if(err < 0) - { - std::cout << "Error in methd H5Gget_objinfo" << std::endl; - return false; - } - switch(statbuf.type) - { - case H5O_TYPE_GROUP: - isGroup = true; - break; - case H5O_TYPE_DATASET: - isGroup = false; - break; - case H5O_TYPE_NAMED_DATATYPE: - isGroup = false; - break; - default: - isGroup = false; - } - return isGroup; -} diff --git a/Source/H5Support/H5Utilities.h b/Source/H5Support/H5Utilities.h deleted file mode 100644 index ccbb0624c6..0000000000 --- a/Source/H5Support/H5Utilities.h +++ /dev/null @@ -1,235 +0,0 @@ - -// -// Copyright (c) 2007, 2010 Michael A. Jackson for BlueQuartz Software -// All rights reserved. -// BSD License: http://www.opensource.org/licenses/bsd-license.html -// -// This code was written under United States Air Force Contract number -// FA8650-04-C-5229 -// - -#pragma once - - -// C++ Includes -#include -#include -#include - -//-- HDF Headers -#include - -#include "H5Support/H5Support.h" -#include "H5Support/H5Lite.h" - -/* H5LITE_USE_H5Support_CONSTRUCTS is used to include H5SupportDataModel Specific classes in - * this class. If this is being compiled as part of H5SupportDataModel this should - * _always_ be defined. If this code is being used as part of another project - * then this should probably NOT be defined. - */ - -#if defined (H5Support_NAMESPACE) -namespace H5Support_NAMESPACE -{ -#endif - - /** - * @brief General Utilities for working with the HDF5 data files and API - */ - class H5Utilities - { - - public: - - virtual ~H5Utilities(); - - enum CustomHDFDataTypes - { - H5Support_GROUP = 1, - H5Support_DATASET = 2, - H5Support_TYPE = 4, - H5Support_LINK = 8, - H5Support_ANY = 15 - }; - - // -----------HDF5 File Operations - static H5Support_EXPORT hid_t openFile(const std::string& filename, bool readOnly = false); - - static H5Support_EXPORT hid_t createFile(const std::string& filename); - - static H5Support_EXPORT herr_t closeFile(hid_t& fileId); - - // -------------- HDF Indentifier Methods ---------------------------- - /** - * @brief Retuirns the path to an object - * @param objId The HDF5 id of the object - * @param trim set to False to trim the path - * @return The path to the object relative to the objId - */ - static H5Support_EXPORT std::string getObjectPath(hid_t loc_id, bool trim = false); - - /** - * @brief Returns the hdf object type - * @param objId The hdf5 object id - * @param objName The path to the data set - * @param objType The type of the object - * @return Negative value on error - */ - static H5Support_EXPORT herr_t getObjectType(hid_t objId, const std::string& objName, int32_t* objType); - - /** - * @brief Retrieves the object name for a given index - * @param fileId The hdf5 object id - * @param idx The index to retrieve the name for - * @param name The variable to store the name - * @return Negative value is error - */ - static H5Support_EXPORT herr_t objectNameAtIndex(hid_t fileId, int32_t idx, std::string& name); - - /** - * @brief Returns the path to an object's parent - * @param objId The HDF5 id of the object - * @param trim set to False to trim the path - * @return The path to the object relative to the objId - */ - static H5Support_EXPORT std::string getParentPath(hid_t objId); - - /** - * @brief Returns the path to an object's parent - * @param objectPath The HDF5 path to the object - * @param trim set to False to trim the path - * @return The path to the object relative to the objId - */ - static H5Support_EXPORT std::string getParentPath(const std::string& objectPath); - - /** - * @brief Returns the object's name from object path - * @param objectPath The HDF5 path to the object - * @return The object name - */ - static H5Support_EXPORT std::string getObjectNameFromPath(const std::string& objectPath); - - /** - * @brief Returns if a given hdf5 object is a group - * @param objId The hdf5 object that contains an object with name objName - * @param objName The name of the object to check - * @return True if the given hdf5 object id is a group - */ - static H5Support_EXPORT bool isGroup(hid_t nodeId, const std::string& objName); - - - /** - * @brief Opens an HDF5 object for hdf5 operations - * @param locId the Object id of the parent - * @param objectPath The path of the object to open - * @return The hdf5 id of the opened object. Negative value is error. - */ - static H5Support_EXPORT hid_t openHDF5Object(hid_t loc_id, const std::string& objName); - - /** - * @brief Closes the object id - * @param locId The object id to close - * @return Negative value is error. - */ - static H5Support_EXPORT herr_t closeHDF5Object(hid_t obj_id); - - - static H5Support_EXPORT std::string HDFClassTypeAsStr(hid_t class_type); - - /** - * @brief prints the class type of the given class - * @param classT The Class Type to print - */ - static H5Support_EXPORT void printHDFClassType(H5T_class_t class_type); - - // -------------- HDF Group Methods ---------------------------- - /** - * @brief Returns a list of child hdf5 objects for a given object id - * @param loc_id The parent hdf5 id - * @param typeFilter A filter to apply to the list - * @param names Variable to store the list - * @return - */ - static H5Support_EXPORT herr_t getGroupObjects(hid_t loc_id, int32_t typeFilter, std::list& names); - - /** - * @brief Creates a HDF Group by checking if the group already exists. If the - * group already exists then that group is returned otherwise a new group is - * created. - * @param loc_id The HDF unique id given to files or groups - * @param group The name of the group to create. Note that this group name should - * not be any sort of 'path'. It should be a single group. - */ - static H5Support_EXPORT hid_t createGroup(hid_t loc_id, const std::string& group); - - /** - * @brief Given a path relative to the Parent ID, this method will create all - * the intermediate groups if necessary. - * @param pathToCheck The path to either create or ensure exists. - * @param parent The HDF unique id for the parent - * @return Error Condition: Negative is error. Positive is success. - */ - static H5Support_EXPORT hid_t createGroupsFromPath(const std::string& pathToCheck, hid_t parent); - - /** - * @brief Given a path relative to the Parent ID, this method will create all - * the intermediate groups if necessary. - * @param datasetPath The path to the dataset that you want to make all the intermediate groups for - * @param parent The HDF unique id for the parent - * @return Error Condition: Negative is error. Positive is success. - */ - static H5Support_EXPORT hid_t createGroupsForDataset(const std::string& datasetPath, hid_t parent); - - /** - * @brief Extracts the object name from a given path - * @param path The path which to extract the object name - * @return The name of the object - */ - static H5Support_EXPORT std::string extractObjectName(const std::string& path); - - // -------------- HDF Attribute Methods ---------------------------- - /** - * @brief Looks for an attribute with a given name - * @param loc_id The objects Parent id - * @param obj_name The name of the object - * @param attr_name The attribute to look for (by name) - * @return True if the attribute exists. - */ - static H5Support_EXPORT bool probeForAttribute(hid_t loc_id, - const std::string& obj_name, - const std::string& attr_name); - - - /** - * @brief Returns a list of all the attribute names - * @param objId The parent object - * @param names Variable to hold the list of attribute names - * @return Negate value is error - */ - static H5Support_EXPORT herr_t getAllAttributeNames(hid_t obj_id, std::list& results); - - /** - * @brief Returns a list of all the attribute names - * @param objId The parent object - * @param obj_name The name of the object whose attribute names you want a list - * @param names Variable to hold the list of attribute names - * @return Negative value is error - */ - static H5Support_EXPORT herr_t getAllAttributeNames(hid_t loc_id, const std::string& obj_name, - std::list& names); - - - protected: - H5Utilities() = default; // This is just a bunch of Static methods - - private: - H5Utilities(const H5Utilities&); //Copy Constructor Not Implemented - void operator=(const H5Utilities&); //Copy Assignment Not Implemented - }; - -#if defined (H5Support_NAMESPACE) -} -#endif - - - diff --git a/Source/H5Support/QH5Lite.cpp b/Source/H5Support/QH5Lite.cpp deleted file mode 100644 index db12545cab..0000000000 --- a/Source/H5Support/QH5Lite.cpp +++ /dev/null @@ -1,399 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include - -#include -#include - -#if defined(H5Support_NAMESPACE) -using namespace H5Support_NAMESPACE; -#endif - -// ----------------------------------------------------------------------------- -// Protected Constructor -// ----------------------------------------------------------------------------- -QH5Lite::QH5Lite() -= default; - -// ----------------------------------------------------------------------------- -// Protected Destructor -// ----------------------------------------------------------------------------- -QH5Lite::~QH5Lite() -= default; - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void QH5Lite::disableErrorHandlers() -{ - HDF_ERROR_HANDLER_OFF; -} - -// ----------------------------------------------------------------------------- -// Opens an ID for HDF5 operations -// ----------------------------------------------------------------------------- -hid_t QH5Lite::openId(hid_t loc_id, const QString& obj_name, H5O_type_t obj_type) -{ - return H5Lite::openId(loc_id, obj_name.toStdString(), obj_type); -} - -// ----------------------------------------------------------------------------- -// Closes the given ID -// ----------------------------------------------------------------------------- -herr_t QH5Lite::closeId(hid_t obj_id, int32_t obj_type) -{ - return H5Lite::closeId(obj_id, obj_type); -} - -// ----------------------------------------------------------------------------- -// Finds an Attribute given an object to look in -// ----------------------------------------------------------------------------- -herr_t QH5Lite::findAttribute(hid_t loc_id, const QString& attrName) -{ - return H5Lite::findAttribute(loc_id, attrName.toStdString()); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -bool QH5Lite::datasetExists(hid_t loc_id, const QString& name) -{ - return H5Lite::datasetExists(loc_id, name.toStdString()); -} - -// ----------------------------------------------------------------------------- -// We assume a null terminated string -// ----------------------------------------------------------------------------- -herr_t QH5Lite::writeStringDataset(hid_t loc_id, const QString& dsetName, size_t size, const char* data) -{ - return H5Lite::writeStringDataset(loc_id, dsetName.toStdString(), size, data); -} - -// ----------------------------------------------------------------------------- -// Writes a string to a HDF5 dataset -// ----------------------------------------------------------------------------- -herr_t QH5Lite::writeStringDataset(hid_t loc_id, const QString& dsetName, const QString& data) -{ - return H5Lite::writeStringDataset(loc_id, dsetName.toStdString(), data.toStdString()); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t QH5Lite::writeVectorOfStringsDataset(hid_t loc_id, const QString& dsetName, const QVector& data) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t sid = -1; - hid_t memspace = -1; - hid_t datatype = -1; - hid_t did = -1; - herr_t err = -1; - herr_t retErr = 0; - - hsize_t dims[1] = {static_cast(data.size())}; - if((sid = H5Screate_simple(sizeof(dims) / sizeof(*dims), dims, nullptr)) >= 0) - { - dims[0] = 1; - - if((memspace = H5Screate_simple(sizeof(dims) / sizeof(*dims), dims, nullptr)) >= 0) - { - - datatype = H5Tcopy(H5T_C_S1); - H5Tset_size(datatype, H5T_VARIABLE); - - if((did = H5Dcreate(loc_id, dsetName.toLocal8Bit().constData(), datatype, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) >= 0) - { - - // - // Select the "memory" to be written out - just 1 record. - hsize_t offset_[] = {0}; - hsize_t count_[] = {1}; - H5Sselect_hyperslab(memspace, H5S_SELECT_SET, offset_, nullptr, count_, nullptr); - hsize_t m_pos = 0; - for(const auto & i : data) - { - // Select the file position, 1 record at position 'pos' - hsize_t count[] = {1}; - hsize_t offset[] = {m_pos++}; - H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, nullptr, count, nullptr); - std::string v = i.toStdString(); // MUST be a C String, i.e., null terminated - const char* s = v.c_str(); - err = H5Dwrite(did, datatype, memspace, sid, H5P_DEFAULT, s); - if(err < 0) - { - qDebug() << "Error Writing String Data: " __FILE__ << "(" << __LINE__ << ")"; - retErr = err; - } - } - QCloseH5D(did, err, retErr); - } - H5Tclose(datatype); - QCloseH5S(memspace, err, retErr); - } - - QCloseH5S(sid, err, retErr); - } - return retErr; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t QH5Lite::writeStringAttributes(hid_t loc_id, const QString& objName, const QMap& attributes) -{ - herr_t err = 0; - QMapIterator i(attributes); - while(i.hasNext()) - { - i.next(); - err = H5Lite::writeStringAttribute(loc_id, objName.toStdString(), i.key().toStdString(), i.value().toStdString()); - if(err < 0) - { - return err; - } - } - return err; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -hsize_t QH5Lite::getNumberOfElements(hid_t loc_id, const QString& dsetName) -{ - return H5Lite::getNumberOfElements(loc_id, dsetName.toStdString()); -} - -// ----------------------------------------------------------------------------- -// Writes a string to an HDF5 Attribute -// ----------------------------------------------------------------------------- -herr_t QH5Lite::writeStringAttribute(hid_t loc_id, const QString& objName, const QString& attrName, hsize_t size, const char* data) -{ - return H5Lite::writeStringAttribute(loc_id, objName.toStdString(), attrName.toStdString(), size, data); -} - -// ----------------------------------------------------------------------------- -// Writes a string to an HDF5 Attribute -// ----------------------------------------------------------------------------- -herr_t QH5Lite::writeStringAttribute(hid_t loc_id, const QString& objName, const QString& attrName, const QString& data) -{ - return H5Lite::writeStringAttribute(loc_id, objName.toStdString(), attrName.toStdString(), data.size() + 1, data.toLatin1().data()); -} - -// ----------------------------------------------------------------------------- -// Reads a String dataset into a QString -// ----------------------------------------------------------------------------- -herr_t QH5Lite::readStringDataset(hid_t loc_id, const QString& dsetName, QString& data) -{ - std::string readValue; - herr_t err = H5Lite::readStringDataset(loc_id, dsetName.toStdString(), readValue); - data = QString::fromStdString(readValue); - return err; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t QH5Lite::readStringDataset(hid_t loc_id, const QString& dsetName, char* data) -{ - return H5Lite::readStringDataset(loc_id, dsetName.toStdString(), data); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t QH5Lite::readVectorOfStringDataset(hid_t loc_id, const QString& dsetName, QVector& data) -{ - H5SUPPORT_MUTEX_LOCK() - - hid_t did; // dataset id - hid_t tid; // type id - herr_t err = 0; - herr_t retErr = 0; - - did = H5Dopen(loc_id, dsetName.toLocal8Bit().constData(), H5P_DEFAULT); - if(did < 0) - { - qDebug() << "H5Lite.cpp::readVectorOfStringDataset(" << __LINE__ << ") Error opening Dataset at loc_id (" << loc_id << ") with object name (" << dsetName << ")"; - return -1; - } - /* - * Get the datatype. - */ - tid = H5Dget_type(did); - if(tid >= 0) - { - hsize_t dims[1] = {0}; - /* - * Get dataspace and allocate memory for read buffer. - */ - hid_t sid = H5Dget_space(did); - int ndims = H5Sget_simple_extent_dims(sid, dims, nullptr); - if(ndims != 1) - { - CloseH5S(sid, err, retErr); - CloseH5T(tid, err, retErr); - std::cout << "H5Lite.cpp::readVectorOfStringDataset(" << __LINE__ << ") Number of dims should be 1 but it was " << ndims << ". Returning early. Is your data file correct?" << std::endl; - return -2; - } - std::vector rdata(dims[0]); - for(int i = 0; i < dims[0]; i++) - { - rdata[i] = nullptr; - } - - /* - * Create the memory datatype. - */ - hid_t memtype = H5Tcopy(H5T_C_S1); - herr_t status = H5Tset_size(memtype, H5T_VARIABLE); - - /* - * Read the data. - */ - status = H5Dread(did, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, &(rdata.front())); - if(status < 0) - { - status = H5Dvlen_reclaim(memtype, sid, H5P_DEFAULT, &(rdata.front())); - CloseH5S(sid, err, retErr); - CloseH5T(tid, err, retErr); - CloseH5T(memtype, err, retErr); - std::cout << "H5Lite.cpp::readVectorOfStringDataset(" << __LINE__ << ") Error reading Dataset at loc_id (" << loc_id << ") with object name (" << dsetName.toStdString() << ")" << std::endl; - return -3; - } - data.resize(dims[0]); - /* - * copy the data into the vector of strings - */ - for(int i = 0; i < dims[0]; i++) - { - // printf("%s[%d]: %s\n", "VlenStrings", i, rdata[i].p); - QString str = QString::fromLatin1(rdata[i]); - data[i] = str; - } - /* - * Close and release resources. Note that H5Dvlen_reclaim works - * for variable-length strings as well as variable-length arrays. - * Also note that we must still free the array of pointers stored - * in rdata, as H5Tvlen_reclaim only frees the data these point to. - */ - status = H5Dvlen_reclaim(memtype, sid, H5P_DEFAULT, &(rdata.front())); - QCloseH5S(sid, err, retErr); - QCloseH5T(tid, err, retErr); - QCloseH5T(memtype, err, retErr); - } - - QCloseH5D(did, err, retErr); - - return retErr; -} - -// ----------------------------------------------------------------------------- -// Reads a string Attribute from the HDF file -// ----------------------------------------------------------------------------- -herr_t QH5Lite::readStringAttribute(hid_t loc_id, const QString& objName, const QString& attrName, QString& data) -{ - std::string sValue; - herr_t err = H5Lite::readStringAttribute(loc_id, objName.toStdString(), attrName.toStdString(), sValue); - data = QString::fromStdString(sValue); - return err; -} - -// ----------------------------------------------------------------------------- -// Reads a string Attribute from the HDF file -// ----------------------------------------------------------------------------- -herr_t QH5Lite::readStringAttribute(hid_t loc_id, const QString& objName, const QString& attrName, char* data) -{ - return H5Lite::readStringAttribute(loc_id, objName.toStdString(), attrName.toStdString(), data); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t QH5Lite::getDatasetNDims(hid_t loc_id, const QString& dsetName, hid_t& rank) -{ - return H5Lite::getDatasetNDims(loc_id, dsetName.toStdString(), rank); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t QH5Lite::getAttributeNDims(hid_t loc_id, const QString& objName, const QString& attrName, hid_t& rank) -{ - return H5Lite::getAttributeNDims(loc_id, objName.toStdString(), attrName.toStdString(), rank); -} - -// ----------------------------------------------------------------------------- -// Returns the type of data stored in the dataset. You MUST use H5Tclose(tid) -// on the returned value or resource leaks will occur. -// ----------------------------------------------------------------------------- -hid_t QH5Lite::getDatasetType(hid_t loc_id, const QString& dsetName) -{ - return H5Lite::getDatasetType(loc_id, dsetName.toStdString()); -} - -// ----------------------------------------------------------------------------- -// Get the dataset information -// ----------------------------------------------------------------------------- -herr_t QH5Lite::getDatasetInfo(hid_t loc_id, const QString& dsetName, QVector& dims, H5T_class_t& classType, size_t& sizeType) -{ - // Since this is a wrapper we need to pass a std::vector() then copy the values from that into our 'dims' argument - std::vector rDims; - herr_t err = H5Lite::getDatasetInfo(loc_id, dsetName.toStdString(), rDims, classType, sizeType); - dims.resize(static_cast(rDims.size())); - for(std::vector::size_type i = 0; i < rDims.size(); ++i) - { - dims[static_cast(i)] = rDims[i]; - } - return err; -} - -// ----------------------------------------------------------------------------- -// You must close the attributeType argument or resource leaks will occur. Use -// H5Tclose(tid); after your call to this method if you do not need the id for -// anything. -// ----------------------------------------------------------------------------- -herr_t QH5Lite::getAttributeInfo(hid_t loc_id, const QString& objName, const QString& attrName, QVector& dims, H5T_class_t& type_class, size_t& type_size, hid_t& tid) -{ - std::vector rDims = dims.toStdVector(); - herr_t err = H5Lite::getAttributeInfo(loc_id, objName.toStdString(), attrName.toStdString(), rDims, type_class, type_size, tid); - dims.resize(static_cast(rDims.size())); - for(std::vector::size_type i = 0; i < rDims.size(); ++i) - { - dims[static_cast(i)] = rDims[i]; - } - return err; -} diff --git a/Source/H5Support/QH5Lite.h b/Source/H5Support/QH5Lite.h deleted file mode 100644 index c054f4b7f0..0000000000 --- a/Source/H5Support/QH5Lite.h +++ /dev/null @@ -1,887 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#pragma once - - -//--C++ Headers -#include - -//-- HDF Headers -#include -#include - -#include -#include - -#include "H5Support/H5Support.h" -#include "H5Support/H5SupportDLLExport.h" -#include "H5Support/H5Lite.h" - -#if !defined (H5Support_USE_QT) -#error THIS FILE SHOULD NOT BE INCLUDED UNLESS THE H5Support_USE_QT is also defined -#endif - - -#include -#include -#include -#include - - -#if defined (H5Support_NAMESPACE) -namespace H5Support_NAMESPACE -{ -#endif - - /** - * @brief Class to bring together some high level methods to read/write data to HDF5 files. - * @class QH5Lite - * @author Mike Jackson - * @date April 2007 - * @version $Revision: 1.3 $ - */ - class QH5Lite - { - public: - /** - * @brief Turns off the global error handler/reporting objects. Note that once - * they are turned off using this method they CAN NOT be turned back on. If you - * would like to turn them off for a piece of code then surround your code with - * the HDF_ERROR_HANDLER_OFF and HDF_ERROR_HANDLER_ON macros defined in - * QH5Lite.h - */ - static H5Support_EXPORT void disableErrorHandlers(); - - /** - * @brief Opens an object for HDF5 operations - * @param loc_id The parent object that holds the true object we want to open - * @param objName The string name of the object - * @param obj_type The HDF5_TYPE of object - * @return Standard HDF5 Error Conditions - */ - static H5Support_EXPORT hid_t openId(hid_t loc_id, const QString& obj_name, H5O_type_t obj_type); - - /** - * @brief Opens an HDF5 Object - * @param obj_id The Object id - * @param obj_type Basic Object Type - * @return Standard HDF5 Error Conditions - */ - static H5Support_EXPORT herr_t closeId( hid_t obj_id, int32_t obj_type ); - - /** - * @brief Given one of the HDF Types as a string, this will return the HDF Type - * as an hid_t value. - * @param value The HDF_Type as a string - * @return the hid_t value for the given type. -1 if the string does not match a type. - */ - static hid_t HDFTypeFromString(const QString& value) - { - return H5Lite::HDFTypeFromString(value.toStdString()); - } - - - /** - * @brief Returns a string version of the HDF Type - * @param type The HDF5 Type to query - * @return - */ - static QString StringForHDFType(hid_t type) - { - return QString::fromStdString(H5Lite::StringForHDFType(type)); - } - - /** - * @brief Returns the HDF Type for a given primitive value. - * @param value A value to use. Can be anything. Just used to get the type info - * from - * @return A QString representing the HDF5 Type - */ - template - static QString HDFTypeForPrimitiveAsStr(T value) - { - return QString::fromStdString(H5Lite::HDFTypeForPrimitiveAsStr(value)); - } - - /** - * @brief Returns the HDF Type for a given primitive value. - * @param value A value to use. Can be anything. Just used to get the type info - * from - * @return The HDF5 native type for the value - */ - template - static hid_t HDFTypeForPrimitive(T value) - { - return H5Lite::HDFTypeForPrimitive(value); - } - - - - /** - * @brief Inquires if an attribute named attr_name exists attached to the object loc_id. - * @param loc_id The location to search - * @param attrName The attribute to search for - * @return Standard HDF5 Error condition - */ - static H5Support_EXPORT herr_t findAttribute( hid_t loc_id, const QString& attrName ); - - /** - * @brief Finds a Data set given a data set name - * @param loc_id The location to search - * @param name The dataset to search for - * @return Standard HDF5 Error condition. Negative=DataSet - */ - static H5Support_EXPORT bool datasetExists( hid_t loc_id, const QString& name ); - - /** - * @brief Creates a Dataset with the given name at the location defined by loc_id - * - * - * @param loc_id The Parent location to store the data - * @param dsetName The name of the dataset - * @param dims The dimensions of the dataset - * @param data The data to write to the file - * @return Standard HDF5 error conditions - * - * The dimensions of the data sets are usually passed as both a "rank" and - * dimensions array. By using a QVector that stores the values of - * each of the dimensions we can reduce the number of arguments to this method as - * the value of the "rank" simply becomes dims.length(). So to create a Dims variable - * for a 3D data space of size(x,y,z) = {10,20,30} I would use the following code: - * - * QVector dims; - * dims.push_back(10); - * dims.push_back(20); - * dims.push_back(30); - * - * - * Also when passing data BE SURE that the type of data and the data type match. - * For example if I create some data in a QVector you would need to - * pass H5T_NATIVE_UINT8 as the dataType. - * - * Also note that QVector is 32 bit limited in that the most data that it can hold is 2^31 elements. If you - * are trying to write a data set that has more than 2^31 elements then use the H5Lite::writeVectorDataset() - * instead which takes a std::vector() and is probably more suited for large data. - */ - template - static herr_t writeVectorDataset (hid_t loc_id, - const QString& dsetName, - QVector& dims, - QVector& data) - { - return H5Lite::writePointerDataset(loc_id, dsetName.toStdString(), dims.size(), dims.data(), data.data()); - } - - /** - * @brief Writes the data of a pointer to an HDF5 file - * @param loc_id The hdf5 object id of the parent - * @param dsetName The name of the dataset to write to. This can be a name of Path - * @param rank The number of dimensions - * @param dims The sizes of each dimension - * @param data The data to be written. - * @return Standard hdf5 error condition. - */ - template - static herr_t writePointerDataset (hid_t loc_id, - const QString& dsetName, - int32_t rank, - hsize_t* dims, - T* data) - { - return H5Lite::writePointerDataset(loc_id, dsetName.toStdString(), rank, dims, data); - } - - /** - * @brief replacePointerDataset - * @param loc_id - * @param dsetName - * @param rank - * @param dims - * @param data - * @return - */ - template - static herr_t replacePointerDataset (hid_t loc_id, - const QString& dsetName, - int32_t rank, - hsize_t* dims, - T* data) - { - return H5Lite::replacePointerDataset(loc_id, dsetName.toStdString(), rank, dims, data); - } - - - /** - * @brief Creates a Dataset with the given name at the location defined by loc_id - * - * @param loc_id The Parent location to store the data - * @param dsetName The name of the dataset - * @param dims The dimensions of the dataset - * @param rank The number of dimensions to the dataset - * @param data The data to write to the file - * @return Standard HDF5 error conditions - * - * The dimensions of the data sets are usually passed as both a "rank" and - * dimensions array. By using a QVector that stores the values of - * each of the dimensions we can reduce the number of arguments to this method as - * the value of the "rank" simply becomes dims.length(). So to create a Dims variable - * for a 3D data space of size(x,y,z) = {10,20,30} I would use the following code: - * - * QVector dims; - * dims.push_back(10); - * dims.push_back(20); - * dims.push_back(30); - * - * - */ - template - static herr_t writeDataset(hid_t loc_id, - const QString& dsetName, - int32_t& rank, - hsize_t* dims, - T* data) - { - return H5Lite::writeDataset(loc_id, dsetName.toStdString(), rank, dims, data); - } - - - /** - * @brief Creates a Dataset with the given name at the location defined by loc_id. - * This version of writeDataset should be used with a single scalar value. If you - * need to write an array of values, use the form that takes an QVector<> - * - * @param loc_id The Parent location to store the data - * @param dsetName The name of the dataset - * @param value The value to write to the HDF5 dataset - * @return Standard HDF5 error conditions - */ - template - static herr_t writeScalarDataset (hid_t loc_id, - const QString& dsetName, - T& value) - { - return H5Lite::writeScalarDataset(loc_id, dsetName.toStdString(), value); - } - - /** - * @brief Writes a QString as a HDF Dataset. - * @param loc_id The Parent location to write the dataset - * @param dsetName The Name to use for the dataset - * @param data The actual data to write as a null terminated string - * @return Standard HDF5 error conditions - */ - static H5Support_EXPORT herr_t writeStringDataset (hid_t loc_id, - const QString& dsetName, - const QString& data); - - /** - * @brief Writes a null terminated 'C String' to an HDF Dataset. - * @param loc_id The Parent location to write the dataset - * @param dsetName The Name to use for the dataset - * @param data const char pointer to write as a null terminated string - * @param size The number of characters in the string - * @return Standard HDF5 error conditions - */ - static H5Support_EXPORT herr_t writeStringDataset (hid_t loc_id, - const QString& dsetName, - size_t size, - const char* data); - - /** - * @brief - * @param loc_id - * @param dsetName - * @param size - * @param data - * @return - */ - static H5Support_EXPORT herr_t writeVectorOfStringsDataset(hid_t loc_id, - const QString& dsetName, - const QVector& data); - /** - * @brief Writes an Attribute to an HDF5 Object - * @param loc_id The Parent Location of the HDFobject that is getting the attribute - * @param objName The Name of Object to write the attribute into. - * @param attrName The Name of the Attribute - * @param rank The number of dimensions in the attribute data - * @param dims The Dimensions of the attribute data - * @param data The Attribute Data to write as a pointer - * @return Standard HDF Error Condition - */ - template - static herr_t writePointerAttribute(hid_t loc_id, - const QString& objName, - const QString& attrName, - int32_t rank, - hsize_t* dims, - T* data) - { - return H5Lite::writePointerAttribute(loc_id, objName.toStdString(), attrName.toStdString(), rank, dims, data); - } - - - /** - * @brief Writes an Attribute to an HDF5 Object - * @param loc_id The Parent Location of the HDFobject that is getting the attribute - * @param objName The Name of Object to write the attribute into. - * @param attrName The Name of the Attribute - * @param dims The Dimensions of the data set - * @param data The Attribute Data to write - * @return Standard HDF Error Condition - * - */ - template - static herr_t writeVectorAttribute(hid_t loc_id, - const QString& objName, - const QString& attrName, - QVector& dims, - QVector& data ) - { - return H5Lite::writePointerAttribute(loc_id, objName.toStdString(), attrName.toStdString(), dims.size(), dims.data(), data.data()); - } - - /** - * @brief Writes a string as a null terminated attribute. - * @param loc_id The location to look for objName - * @param objName The Object to write the attribute to - * @param attrName The name of the Attribute - * @param data The string to write as the attribute - * @return Standard HDF error conditions - */ - static H5Support_EXPORT herr_t writeStringAttribute(hid_t loc_id, - const QString& objName, - const QString& attrName, - const QString& data); - /** - * @brief Writes a null terminated string as an attribute - * @param loc_id The location to look for objName - * @param objName The Object to write the attribute to - * @param attrName The name of the Attribute - * @param size The number of characters in the string - * @param data pointer to a const char array - * @return Standard HDF error conditions - */ - static H5Support_EXPORT herr_t writeStringAttribute(hid_t loc_id, - const QString& objName, - const QString& attrName, - hsize_t size, - const char* data); - - - /** - * @brief Writes attributes that all have a data type of STRING. The first value - * in each set is the key, the second is the actual value of the attribute. - * @param loc_id The location to look for objName - * @param objName The Object to write the attribute to - * @param attributes The attributes to be written where the first value is the name - * of the attribute, and the second is the actual value of the attribute. - * @return Standard HDF error condition - */ - static H5Support_EXPORT herr_t writeStringAttributes(hid_t loc_id, - const QString& objName, - const QMap& attributes); - - /** - * @brief Returns the total number of elements in the supplied dataset - * @param loc_id The parent location that contains the dataset to read - * @param dsetName The name of the dataset to read - * @param data A std::vector. Note the vector WILL be resized to fit the data. - * The best idea is to just allocate the vector but not to size it. The method - * will size it for you. - * @return Number of elements in dataset - */ - static H5Support_EXPORT hsize_t getNumberOfElements(hid_t loc_id, - const QString& dsetName); - - /** - * @brief Writes an attribute to the given object. This method is designed with - * a Template parameter that represents a primitive value. If you need to write - * an array, please use the other over loaded method that takes a vector. - * @param loc_id The location to look for objName - * @param objName The Object to write the attribute to - * @param attrName The name of the attribute - * @param data The data to be written as the attribute - * @return Standard HDF error condition - */ - template - static herr_t writeScalarAttribute(hid_t loc_id, - const QString& objName, - const QString& attrName, - T data ) - { - return H5Lite::writeScalarAttribute(loc_id, objName.toStdString(), attrName.toStdString(), data); - } - - /** - * @brief Reads data from the HDF5 File into a preallocated array. - * @param loc_id The parent location that contains the dataset to read - * @param dsetName The name of the dataset to read - * @param data A Pointer to the PreAllocated Array of Data - * @return Standard HDF error condition - */ - template - static herr_t readPointerDataset(hid_t loc_id, - const QString& dsetName, - T* data) - { - return H5Lite::readPointerDataset(loc_id, dsetName.toStdString(), data); - } - - - /** - * @brief Reads data from the HDF5 File into an QVector object. If the dataset - * is very large this can be an expensive method to use. It is here for convenience - * using STL with hdf5. - * @param loc_id The parent location that contains the dataset to read - * @param dsetName The name of the dataset to read - * @param data A QVector. Note the vector WILL be resized to fit the data. - * The best idea is to just allocate the vector but not to size it. The method - * will size it for you. - * @return Standard HDF error condition - */ - template - static herr_t readVectorDataset(hid_t loc_id, - const QString& dsetName, - std::vector& data) - { - std::string dsetNameStr = dsetName.toStdString(); - herr_t err = H5Lite::readVectorDataset(loc_id, dsetNameStr, data); - return err; - } - - - /** - * @brief Reads a dataset that consists of a single scalar value - * @param loc_id The HDF5 file or group id - * @param dsetName The name or path to the dataset to read - * @param data The variable to store the data into - * @return HDF error condition. - */ - template - static herr_t readScalarDataset(hid_t loc_id, - const QString& dsetName, - T& data) - { - std::string dsetNameStr = dsetName.toStdString(); - herr_t err = H5Lite::readScalarDataset(loc_id, dsetNameStr, data); - return err; - } - - - /** - * @brief Reads a string dataset into the supplied string. Any data currently in the 'data' variable - * is cleared first before the new data is read into the string. - * @param loc_id The parent group that holds the data object to read - * @param dsetName The name of the dataset. - * @param data The QString to hold the data - * @return Standard HDF error condition - */ - static H5Support_EXPORT herr_t readStringDataset(hid_t loc_id, - const QString& dsetName, - QString& data); - - - /** - * @brief - * @param loc_id - * @param dsetName - * @param data - * @return - */ - static H5Support_EXPORT herr_t readVectorOfStringDataset(hid_t loc_id, - const QString& dsetName, - QVector& data); - /** - * @brief reads a null terminated string dataset into the supplied buffer. The buffer - * should be already preallocated. - * @param loc_id The parent group that holds the data object to read - * @param dsetName The name of the dataset. - * @param data pointer to the buffer - * @return Standard HDF error condition - */ - static H5Support_EXPORT herr_t readStringDataset(hid_t loc_id, - const QString& dsetName, - char* data); - - /** - * @brief Reads an Attribute from an HDF5 Object. - * - * Use this method if you already know the datatype of the attribute. If you do - * not know this already then use another form of this method. - * - * @param loc_id The Parent object that holds the object to which you want to read an attribute - * @param objName The name of the object to which the attribute is to be read - * @param attrName The name of the Attribute to read - * @param data The memory to store the data - * @return Standard HDF Error condition - */ - template - static herr_t readVectorAttribute(hid_t loc_id, - const QString& objName, - const QString& attrName, - QVector& data) - { - - std::string objNameStr = objName.toStdString(); - std::string attrNameStr = attrName.toStdString(); - std::vector dataV; - herr_t err = H5Lite::readVectorAttribute(loc_id, objNameStr, attrNameStr, dataV); - data.resize(dataV.size()); - std::copy(dataV.begin(), dataV.end(), data.begin()); - return err; -#if 0 - /* identifiers */ - hid_t obj_id; - H5O_info_t statbuf; - herr_t err = 0; - herr_t retErr = 0; - hid_t attr_id; - hid_t tid; - T test = 0x00; - hid_t dataType = QH5Lite::HDFTypeForPrimitive(test); - if (dataType == -1) - { - return -1; - } - //qDebug() << " Reading Vector Attribute at Path '" << objName << "' with Key: '" << attrName << "'"; - /* Get the type of object */ - err = H5Oget_info_by_name(loc_id, objName.toLatin1().data(), &statbuf, H5P_DEFAULT); - if (err < 0) - { return err; } - /* Open the object */ - obj_id = QH5Lite::openId( loc_id, objName, statbuf.type); - if ( obj_id >= 0) - { - attr_id = H5Aopen_by_name( loc_id, objName.toLatin1().data(), attrName.toLatin1().data(), H5P_DEFAULT, H5P_DEFAULT ); - if ( attr_id >= 0 ) - { - //Need to allocate the array size - H5T_class_t type_class; - size_t type_size; - QVector dims; - err = QH5Lite::getAttributeInfo(loc_id, objName, attrName, dims, type_class, type_size, tid); - hsize_t numElements = 1; - for (QVector::iterator iter = dims.begin(); iter < dims.end(); ++iter ) - { - numElements *= *(iter); - } - //qDebug() << " Vector Attribute has " << numElements << " elements."; - if (numElements > static_cast(std::numeric_limits::max() ) ) - { - qDebug() << "Number of Elements in Array is larger than QVector can handle. Suggest using a std::vector<> instead"; - err = -1000; - } - else - { - data.resize( static_cast(numElements) ); - err = H5Aread( attr_id, dataType, &(data.front()) ); - } - if ( err < 0 ) - { - qDebug() << "Error Reading Attribute." << err; - retErr = err; - } - err = H5Aclose( attr_id ); - if ( err < 0 ) - { - qDebug() << "Error Closing Attribute"; - retErr = err; - } - } - else - { - retErr = attr_id; - } - err = QH5Lite::closeId( obj_id, statbuf.type ); - if ( err < 0 ) - { - qDebug() << "Error Closing Object"; - retErr = err; - } - } - return retErr; -#endif - } - - /** - * @brief Reads a scalar attribute value from a dataset - * @param loc_id - * @param objName The name of the dataset - * @param attrName The name of the Attribute - * @param data The preallocated memory for the variable to be stored into - * @return Standard HDF5 error condition - */ - template - static herr_t readScalarAttribute(hid_t loc_id, - const QString& objName, - const QString& attrName, - T& data) - { - std::string objNameStr = objName.toStdString(); - std::string attrNameStr = attrName.toStdString(); - herr_t err = H5Lite::readScalarAttribute(loc_id, objNameStr, attrNameStr, data); - return err; -#if 0 - /* identifiers */ - hid_t obj_id; - H5O_info_t statbuf; - herr_t err = 0; - herr_t retErr = 0; - hid_t attr_id; - T test = static_cast(0x00); - hid_t dataType = QH5Lite::HDFTypeForPrimitive(test); - if (dataType == -1) - { - return -1; - } - //qDebug() << "Reading Scalar style Attribute at Path '" << objName << "' with Key: '" << attrName << "'"; - /* Get the type of object */ - err = H5Oget_info_by_name(loc_id, objName.toLatin1().data(), &statbuf, H5P_DEFAULT); - if (err < 0) - { return err; } - /* Open the object */ - obj_id = QH5Lite::openId( loc_id, objName, statbuf.type); - if ( obj_id >= 0) - { - attr_id = H5Aopen_by_name( loc_id, objName.toLatin1().data(), attrName.toLatin1().data(), H5P_DEFAULT, H5P_DEFAULT ); - if ( attr_id >= 0 ) - { - err = H5Aread( attr_id, dataType, &data ); - if ( err < 0 ) - { - qDebug() << "Error Reading Attribute."; - retErr = err; - } - err = H5Aclose( attr_id ); - if ( err < 0 ) - { - qDebug() << "Error Closing Attribute"; - retErr = err; - } - } - else - { - retErr = attr_id; - } - err = QH5Lite::closeId( obj_id, statbuf.type ); - if ( err < 0 ) - { - qDebug() << "Error Closing Object"; - retErr = err; - } - } - return retErr; -#endif - } - - /** - * @brief Reads the Attribute into a pre-allocated pointer - * @param loc_id - * @param objName The name of the dataset - * @param attrName The name of the Attribute - * @param data The preallocated memory for the variable to be stored into - * @return Standard HDF5 error condition - */ - template - static herr_t readPointerAttribute(hid_t loc_id, - const QString& objName, - const QString& attrName, - T* data) - { - std::string objNameStr = objName.toStdString(); - std::string attrNameStr = attrName.toStdString(); - herr_t err = H5Lite::readPointerAttribute(loc_id, objNameStr, attrNameStr, data); - return err; -#if 0 - /* identifiers */ - hid_t obj_id; - H5O_info_t statbuf; - herr_t err = 0; - herr_t retErr = 0; - hid_t attr_id; - T test = 0x00; - hid_t dataType = QH5Lite::HDFTypeForPrimitive(test); - if (dataType == -1) - { - return -1; - } - //qDebug() << " Reading Vector Attribute at Path '" << objName << "' with Key: '" << attrName << "'"; - /* Get the type of object */ - err = H5Oget_info_by_name(loc_id, objName.toLatin1().data(), &statbuf, H5P_DEFAULT); - if (err < 0) - { return err; } - /* Open the object */ - obj_id = QH5Lite::openId( loc_id, objName, statbuf.type); - if ( obj_id >= 0) - { - attr_id = H5Aopen_by_name( loc_id, objName.toLatin1().data(), attrName.toLatin1().data(), H5P_DEFAULT, H5P_DEFAULT ); - if ( attr_id >= 0 ) - { - err = H5Aread( attr_id, dataType, data); - if ( err < 0 ) - { - qDebug() << "Error Reading Attribute." << err; - retErr = err; - } - err = H5Aclose( attr_id ); - if ( err < 0 ) - { - qDebug() << "Error Closing Attribute"; - retErr = err; - } - } - else - { - //retErr = attr_id; - } - err = QH5Lite::closeId( obj_id, statbuf.type ); - if ( err < 0 ) - { - qDebug() << "Error Closing Object"; - retErr = err; - } - } - return retErr; -#endif - } - - /** - * @brief Reads a string attribute from an HDF object - * @param loc_id The Parent object that holds the object to which you want to read an attribute - * @param objName The name of the object to which the attribute is to be read - * @param attrName The name of the Attribute to read - * @param data The memory to store the data - * @return Standard HDF Error condition - */ - static H5Support_EXPORT herr_t readStringAttribute(hid_t loc_id, - const QString& objName, - const QString& attrName, - QString& data); - - /** - * @brief Reads a string attribute from an HDF object into a precallocated buffer - * @param loc_id The Parent object that holds the object to which you want to read an attribute - * @param objName The name of the object to which the attribute is to be read - * @param attrName The name of the Attribute to read - * @param data The memory to store the data into - * @return Standard HDF Error condition - */ - static H5Support_EXPORT herr_t readStringAttribute(hid_t loc_id, - const QString& objName, - const QString& attrName, - char* data); - /** - * @brief Returns the number of dimensions for a given attribute - * @param loc_id The HDF5 id of the parent group/file for the objName - * @param objName The name of the dataset - * @param attrName The name of the attribute - * @param rank (out) Number of dimensions is store into this variable - */ - static H5Support_EXPORT herr_t getAttributeNDims(hid_t loc_id, const QString& objName, const QString& attrName, hid_t& rank); - - /** - * @brief Returns the number of dimensions for a given dataset - * @param loc_id The HDF5 id of the parent group/file for the objName - * @param objName The name of the dataset - * @param rank (out) Number of dimensions is store into this variable - */ - static H5Support_EXPORT herr_t getDatasetNDims(hid_t loc_id, const QString& dsetName, hid_t& rank); - - /** - * @brief Returns the H5T value for a given dataset. - * - * Returns the type of data stored in the dataset. You MUST use H5Tclose(tid) - * on the returned value or resource leaks will occur. - * @param loc_id A Valid HDF5 file or group id. - * @param dsetName Path to the dataset - * @return - */ - static H5Support_EXPORT hid_t getDatasetType(hid_t loc_id, const QString& dsetName); - - /** - * @brief Get the information about a dataset. - * - * @param loc_id The parent location of the Dataset - * @param dsetName The name of the dataset - * @param dims A QVector that will hold the sizes of the dimensions - * @param type_class The HDF5 class type - * @param type_size THe HDF5 size of the data - * @return Negative value is Failure. Zero or Positive is success; - */ - static H5Support_EXPORT herr_t getDatasetInfo( hid_t loc_id, - const QString& dsetName, - QVector& dims, - H5T_class_t& classType, - size_t& sizeType ); - - /** - * @brief Returns the information about an attribute. - * You must close the attributeType argument or resource leaks will occur. Use - * H5Tclose(attr_type); after your call to this method if you do not need the id for - * anything. - * @param loc_id The parent location of the Dataset - * @param objName The name of the dataset - * @param attr_name The name of the attribute - * @param dims A QVector that will hold the sizes of the dimensions - * @param type_class The HDF5 class type - * @param type_size THe HDF5 size of the data - * @param attr_type The Attribute ID - which needs to be closed after you are finished with the data - * @return - */ - static H5Support_EXPORT herr_t getAttributeInfo(hid_t loc_id, - const QString& objName, - const QString& attrName, - QVector& dims, - H5T_class_t& type_class, - size_t& type_size, - hid_t& tid); - - -// ----------------------------------------------------------------------------- - protected: - QH5Lite(); - ~QH5Lite(); - - - private: - - }; - - -#if defined (H5Support_NAMESPACE) -} -#endif - diff --git a/Source/H5Support/QH5Utilities.cpp b/Source/H5Support/QH5Utilities.cpp deleted file mode 100644 index 701606c6f5..0000000000 --- a/Source/H5Support/QH5Utilities.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include - -#include -#include - -#define CheckValidLocId(locId) \ - if((locId) < 0) \ - { \ - qDebug() << "Invalid HDF Location ID: " << (locId); \ - return -1; \ - } - -#if defined(H5Support_NAMESPACE) -using namespace H5Support_NAMESPACE; -#endif - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -hid_t QH5Utilities::createFile(const QString& filename) -{ - return H5Utilities::createFile(filename.toStdString()); -} -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -hid_t QH5Utilities::openFile(const QString& filename, bool readOnly) -{ - return H5Utilities::openFile(filename.toStdString(), readOnly); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t QH5Utilities::closeFile(hid_t& fileId) -{ - return H5Utilities::closeFile(fileId); -} - -// ----------------------------------------------------------------------------- -// Returns the full path to the object referred to by the -// ----------------------------------------------------------------------------- -QString QH5Utilities::getObjectPath(hid_t loc_id, bool trim) -{ - return QString::fromStdString(H5Utilities::getObjectPath(loc_id, trim)); -} - -// ----------------------------------------------------------------------------- -// @brief Retrieves the HDF object type for obj_name at loc_id and stores -// it in the parameter obj_type passed in. -// ----------------------------------------------------------------------------- -herr_t QH5Utilities::getObjectType(hid_t objId, const QString& objName, int32_t* objType) -{ - return H5Utilities::getObjectType(objId, objName.toStdString(), objType); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString QH5Utilities::getParentPath(hid_t objId) -{ - return QString::fromStdString(H5Utilities::getParentPath(objId)); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString QH5Utilities::getParentPath(const QString& objectPath) -{ - return QString::fromStdString(H5Utilities::getParentPath(objectPath.toStdString())); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString QH5Utilities::getObjectNameFromPath(const QString& objectPath) -{ - return QString::fromStdString(H5Utilities::getObjectNameFromPath(objectPath.toStdString())); -} - -// Opens and returns the HDF object (since the HDF api requires -// different open and close methods for different types of objects -hid_t QH5Utilities::openHDF5Object(hid_t loc_id, const QString& objName) -{ - return H5Utilities::openHDF5Object(loc_id, objName.toStdString()); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t QH5Utilities::closeHDF5Object(hid_t obj_id) -{ - return H5Utilities::closeHDF5Object(obj_id); -} - -//--------------------------------------------------------------------// -// HDF Group Methods -//--------------------------------------------------------------------// -herr_t QH5Utilities::getGroupObjects(hid_t loc_id, int32_t typeFilter, QList& names) -{ - - std::list sNames; - herr_t err = H5Utilities::getGroupObjects(loc_id, typeFilter, sNames); - - names.clear(); - for(auto & sName : sNames) - { - names.push_back(QString::fromStdString(sName)); - } - - return err; -} - -// ----------------------------------------------------------------------------- -// HDF Creation/Modification Methods -// ----------------------------------------------------------------------------- -hid_t QH5Utilities::createGroup(hid_t loc_id, const QString& group) -{ - return H5Utilities::createGroup(loc_id, group.toStdString()); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -int32_t QH5Utilities::createGroupsForDataset(const QString& datasetPath, hid_t parent) -{ - return H5Utilities::createGroupsForDataset(datasetPath.toStdString(), parent); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -int32_t QH5Utilities::createGroupsFromPath(const QString& pathToCheck, hid_t parent) -{ - return H5Utilities::createGroupsFromPath(pathToCheck.toStdString(), parent); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString QH5Utilities::extractObjectName(const QString& path) -{ - return QString::fromStdString(H5Utilities::extractObjectName(path.toStdString())); -} - -//--------------------------------------------------------------------// -// HDF Attribute Methods -//--------------------------------------------------------------------// -bool QH5Utilities::probeForAttribute(hid_t loc_id, const QString& obj_name, const QString& attr_name) -{ - return H5Utilities::probeForAttribute(loc_id, obj_name.toStdString(), attr_name.toStdString()); -} - -//--------------------------------------------------------------------// -// Returns a QList of all attribute names attached to the object -// referred to by obj_id -//--------------------------------------------------------------------// -herr_t QH5Utilities::getAllAttributeNames(hid_t obj_id, QList& names) -{ - names.clear(); - std::list sResults; - herr_t err = H5Utilities::getAllAttributeNames(obj_id, sResults); - for(auto & sResult : sResults) - { - names.push_back(QString::fromStdString(sResult)); - } - return err; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t QH5Utilities::getAllAttributeNames(hid_t loc_id, const QString& obj_name, QList& names) -{ - names.clear(); - std::list sResults; - herr_t err = H5Utilities::getAllAttributeNames(loc_id, obj_name.toStdString(), sResults); - for(auto & sResult : sResults) - { - names.push_back(QString::fromStdString(sResult)); - } - return err; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString QH5Utilities::HDFClassTypeAsStr(hid_t class_type) -{ - return QString::fromStdString(H5Utilities::HDFClassTypeAsStr(class_type)); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void QH5Utilities::printHDFClassType(H5T_class_t class_type) -{ - std::string hType = H5Utilities::HDFClassTypeAsStr(class_type); - qDebug() << QString::fromStdString(hType); -} - -// ----------------------------------------------------------------------------- -// Returns a QString that is the name of the object at the given index -// ----------------------------------------------------------------------------- -herr_t QH5Utilities::objectNameAtIndex(hid_t fileId, int32_t idx, QString& name) -{ - std::string sName; - herr_t err = H5Utilities::objectNameAtIndex(fileId, idx, sName); - name = QString::fromStdString(sName); - return err; -} - -// ----------------------------------------------------------------------------- -// Checks the given name object to see what type of HDF5 object it is. -// ----------------------------------------------------------------------------- -bool QH5Utilities::isGroup(hid_t nodeId, const QString& objName) -{ - return H5Utilities::isGroup(nodeId, objName.toStdString()); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString QH5Utilities::fileNameFromFileId(hid_t fileId) -{ - H5SUPPORT_MUTEX_LOCK() - - // Get the name of the .dream3d file that we are writing to: - ssize_t nameSize = H5Fget_name(fileId, nullptr, 0) + 1; - QByteArray nameBuffer(nameSize, 0); - nameSize = H5Fget_name(fileId, nameBuffer.data(), nameSize); - - QString hdfFileName(nameBuffer); - QFileInfo fi(hdfFileName); - hdfFileName = fi.fileName(); - return hdfFileName; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString QH5Utilities::absoluteFilePathFromFileId(hid_t fileId) -{ - H5SUPPORT_MUTEX_LOCK() - - // Get the name of the .dream3d file that we are writing to: - ssize_t nameSize = H5Fget_name(fileId, nullptr, 0) + 1; - QByteArray nameBuffer(nameSize, 0); - nameSize = H5Fget_name(fileId, nameBuffer.data(), nameSize); - - QString hdfFileName(nameBuffer); - QFileInfo fi(hdfFileName); - return fi.absoluteFilePath(); -} diff --git a/Source/H5Support/QH5Utilities.h b/Source/H5Support/QH5Utilities.h deleted file mode 100644 index 7a198a6696..0000000000 --- a/Source/H5Support/QH5Utilities.h +++ /dev/null @@ -1,242 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#pragma once - - -#include "H5Support/H5Support.h" -#include "H5Support/H5Utilities.h" - -#if !defined (H5Support_USE_QT) -#error THIS FILE SHOULD NOT BE INCLUDED UNLESS THE H5Support_USE_QT is also defined -#endif - - -#include -#include -#include - - -/** - * @brief General Utilities for working with the HDF5 data files and API - */ -class QH5Utilities -{ - - public: - - virtual ~QH5Utilities(); - - - static H5Support_EXPORT hid_t openFile(const QString& filename, bool readOnly = false); - - static H5Support_EXPORT hid_t createFile(const QString& filename); - - - static H5Support_EXPORT herr_t closeFile(hid_t& fileId); - - // -------------- HDF Indentifier Methods ---------------------------- - /** - * @brief Retuirns the path to an object - * @param objId The HDF5 id of the object - * @param trim set to False to trim the path - * @return The path to the object relative to the objId - */ - static H5Support_EXPORT QString getObjectPath(hid_t loc_id, bool trim = false); - - /** - * @brief Returns the hdf object type - * @param objId The hdf5 object id - * @param objName The path to the data set - * @param objType The type of the object - * @return Negative value on error - */ - static H5Support_EXPORT herr_t getObjectType(hid_t objId, const QString& objName, int32_t* objType); - - /** - * @brief Retrieves the object name for a given index - * @param fileId The hdf5 object id - * @param idx The index to retrieve the name for - * @param name The variable to store the name - * @return Negative value is error - */ - static H5Support_EXPORT herr_t objectNameAtIndex(hid_t fileId, int32_t idx, QString& name); - - /** - * @brief Returns the path to an object's parent - * @param objId The HDF5 id of the object - * @param trim set to False to trim the path - * @return The path to the object relative to the objId - */ - static H5Support_EXPORT QString getParentPath(hid_t objId); - - /** - * @brief Returns the path to an object's parent - * @param objectPath The HDF5 path to the object - * @param trim set to False to trim the path - * @return The path to the object relative to the objId - */ - static H5Support_EXPORT QString getParentPath(const QString& objectPath); - - /** - * @brief Returns the object name from the object's path - * @param objectPath The HDF5 path to the object - * @return The object name - */ - static H5Support_EXPORT QString getObjectNameFromPath(const QString& objectPath); - - /** - * @brief Returns if a given hdf5 object is a group - * @param objId The hdf5 object that contains an object with name objName - * @param objName The name of the object to check - * @return True if the given hdf5 object id is a group - */ - static H5Support_EXPORT bool isGroup(hid_t nodeId, const QString& objName); - - - /** - * @brief Opens an HDF5 object for hdf5 operations - * @param locId the Object id of the parent - * @param objectPath The path of the object to open - * @return The hdf5 id of the opened object. Negative value is error. - */ - static H5Support_EXPORT hid_t openHDF5Object(hid_t loc_id, const QString& objName); - - /** - * @brief Closes the object id - * @param locId The object id to close - * @return Negative value is error. - */ - static H5Support_EXPORT herr_t closeHDF5Object(hid_t obj_id); - - - static H5Support_EXPORT QString HDFClassTypeAsStr(hid_t class_type); - - /** - * @brief prints the class type of the given class - * @param classT The Class Type to print - */ - static H5Support_EXPORT void printHDFClassType(H5T_class_t class_type); - - // -------------- HDF Group Methods ---------------------------- - /** - * @brief Returns a list of child hdf5 objects for a given object id - * @param loc_id The parent hdf5 id - * @param typeFilter A filter to apply to the list - * @param names Variable to store the list - * @return - */ - static H5Support_EXPORT herr_t getGroupObjects(hid_t loc_id, int32_t typeFilter, QList& names); - - /** - * @brief Creates a HDF Group by checking if the group already exists. If the - * group already exists then that group is returned otherwise a new group is - * created. - * @param loc_id The HDF unique id given to files or groups - * @param group The name of the group to create. Note that this group name should - * not be any sort of 'path'. It should be a single group. - */ - static H5Support_EXPORT hid_t createGroup(hid_t loc_id, const QString& group); - - /** - * @brief Given a path relative to the Parent ID, this method will create all - * the intermediate groups if necessary. - * @param pathToCheck The path to either create or ensure exists. - * @param parent The HDF unique id for the parent - * @return Error Condition: Negative is error. Positive is success. - */ - static H5Support_EXPORT herr_t createGroupsFromPath(const QString& pathToCheck, hid_t parent); - - /** - * @brief Given a path relative to the Parent ID, this method will create all - * the intermediate groups if necessary. - * @param datasetPath The path to the dataset that you want to make all the intermediate groups for - * @param parent The HDF unique id for the parent - * @return Error Condition: Negative is error. Positive is success. - */ - static H5Support_EXPORT herr_t createGroupsForDataset(const QString& datasetPath, hid_t parent); - - /** - * @brief Extracts the object name from a given path - * @param path The path which to extract the object name - * @return The name of the object - */ - static H5Support_EXPORT QString extractObjectName(const QString& path); - - // -------------- HDF Attribute Methods ---------------------------- - /** - * @brief Looks for an attribute with a given name - * @param loc_id The objects Parent id - * @param obj_name The name of the object - * @param attr_name The attribute to look for (by name) - * @return True if the attribute exists. - */ - static H5Support_EXPORT bool probeForAttribute(hid_t loc_id, - const QString& obj_name, - const QString& attr_name); - - - /** - * @brief Returns a list of all the attribute names - * @param objId The parent object - * @param names Variable to hold the list of attribute names - * @return Negate value is error - */ - static H5Support_EXPORT herr_t getAllAttributeNames(hid_t obj_id, QList& names); - - /** - * @brief Returns a list of all the attribute names - * @param objId The parent object - * @param obj_name The name of the object whose attribute names you want a list - * @param names Variable to hold the list of attribute names - * @return Negative value is error - */ - static H5Support_EXPORT herr_t getAllAttributeNames(hid_t loc_id, const QString& obj_name, - QList& names); - - - static H5Support_EXPORT QString fileNameFromFileId(hid_t fileId); - static H5Support_EXPORT QString absoluteFilePathFromFileId(hid_t fileId); - - - protected: - QH5Utilities() = default; // This is just a bunch of Static methods - - private: - QH5Utilities(const QH5Utilities&); //Copy Constructor Not Implemented - void operator=(const QH5Utilities&); //Copy Assignment Not Implemented -}; - - diff --git a/Source/H5Support/Test/BigHDF5DatasetTest.cpp b/Source/H5Support/Test/BigHDF5DatasetTest.cpp deleted file mode 100644 index 7d97c7d766..0000000000 --- a/Source/H5Support/Test/BigHDF5DatasetTest.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include - -#include "H5Support/H5Lite.h" -#include "H5Support/H5Utilities.h" - -int main(int argc, char** argv) -{ - std::cout << "Test starting" << std::endl; - hsize_t size = 5294967296ull; - unsigned char* data = reinterpret_cast(malloc(size)); - - hid_t fileId = H5Utilities::createFile("/tmp/BIG_HDF5_DATASET.h5"); - hid_t groupId = H5Utilities::createGroup(fileId, "big_data"); - if(groupId < 0) - { - std::cout << "Error creating Group" << std::endl; - return EXIT_FAILURE; - } - - hsize_t dims[2] = {size, 0}; - herr_t err = H5Lite::writePointerDataset(groupId, "TEST", 1, dims, data); - if(err < 0) - { - return EXIT_FAILURE; - } - H5Utilities::closeHDF5Object(groupId); - H5Utilities::closeFile(fileId); - return EXIT_SUCCESS; -} diff --git a/Source/H5Support/Test/CMakeLists.txt b/Source/H5Support/Test/CMakeLists.txt deleted file mode 100755 index 990e1bb40c..0000000000 --- a/Source/H5Support/Test/CMakeLists.txt +++ /dev/null @@ -1,105 +0,0 @@ -#--//////////////////////////////////////////////////////////////////////////// -#-- -#-- Copyright (c) 2015, BlueQuartz Software -#-- All rights reserved. -#-- BSD License: http://www.opensource.org/licenses/bsd-license.html -#-- -#-- This code was partly written under US Air Force Contract FA8650-07-D-5800 -#-- -#--//////////////////////////////////////////////////////////////////////////// - -# project(H5SupportTest) -set(PLUGIN_NAME "H5Support") -set(${PLUGIN_NAME}Test_SOURCE_DIR ${${PLUGIN_NAME}_SOURCE_DIR}/Test) -set(${PLUGIN_NAME}Test_BINARY_DIR ${${PLUGIN_NAME}_BINARY_DIR}/Test) - -include(${CMP_SOURCE_DIR}/cmpCMakeMacros.cmake) - - - - -set(TEST_TEMP_DIR ${${PLUGIN_NAME}Test_BINARY_DIR}/Test/Temp) -# Make sure the directory is created during CMake time -file(MAKE_DIRECTORY ${TEST_TEMP_DIR}) - -configure_file(${${PLUGIN_NAME}_SOURCE_DIR}/Test/TestFileLocations.h.in - ${${PLUGIN_NAME}_BINARY_DIR}/Test/${PLUGIN_NAME}TestFileLocations.h @ONLY IMMEDIATE) - -configure_file(${SIMPLProj_SOURCE_DIR}/Resources/UnitTestSupport.hpp - ${${PLUGIN_NAME}_BINARY_DIR}/Test/UnitTestSupport.hpp COPYONLY IMMEDIATE) - -set(TEST_NAMES - H5LiteTest - H5UtilitiesTest - ) - - -set( ${PLUGIN_NAME}_TEST_SRCS ) -set(FilterTestIncludes "") -set(TestMainFunctors "") - -foreach(name ${TEST_NAMES}) - set( ${PLUGIN_NAME}_TEST_SRCS - ${${PLUGIN_NAME}_TEST_SRCS} - "${${PLUGIN_NAME}_SOURCE_DIR}/Test/${name}.cpp" - ) - string(CONCAT - FilterTestIncludes - ${FilterTestIncludes} - "#include \"${${PLUGIN_NAME}_SOURCE_DIR}/Test/${name}.cpp\"\n" - ) - - string(CONCAT - TestMainFunctors - ${TestMainFunctors} - " ${name}()()|\n") -endforeach() - -STRING(REPLACE "|" ";" TestMainFunctors ${TestMainFunctors} ) - -configure_file(${${PLUGIN_NAME}_SOURCE_DIR}/Test/${PLUGIN_NAME}TestMain.cpp.in - ${${PLUGIN_NAME}Test_BINARY_DIR}/${PLUGIN_NAME}UnitTest.cpp @ONLY) - -# Set the source files properties on each source file. -foreach(f ${${PLUGIN_NAME}_TEST_SRCS}) - set_source_files_properties( ${f} PROPERTIES HEADER_FILE_ONLY TRUE) -endforeach() - -get_filename_component(TARGET_SOURCE_DIR_PARENT ${${PLUGIN_NAME}_SOURCE_DIR} PATH) -get_filename_component(TARGET_BINARY_DIR_PARENT ${${PLUGIN_NAME}_BINARY_DIR} PATH) - - -AddSIMPLUnitTest(TESTNAME H5SupportUnitTest - SOURCES - ${${PLUGIN_NAME}Test_BINARY_DIR}/${PLUGIN_NAME}UnitTest.cpp - ${${PLUGIN_NAME}_TEST_SRCS} - FOLDER - "H5SupportProj/Test" - LINK_LIBRARIES - Qt5::Core - H5Support - SIMPLib - INCLUDE_DIRS - ${TARGET_SOURCE_DIR_PARENT} - ${TARGET_BINARY_DIR_PARENT} - ${${PLUGIN_NAME}_SOURCE_DIR}/Test - ${${PLUGIN_NAME}_BINARY_DIR}/Test - ${${PLUGIN_NAME}Test_BINARY_DIR} - ${SIMPLProj_SOURCE_DIR}/Source - ) - -if(MSVC) - set_source_files_properties( ${${PLUGIN_NAME}Test_BINARY_DIR}/${PLUGIN_NAME}UnitTest.cpp PROPERTIES COMPILE_FLAGS /bigobj) -endif() - - -if(0) - # This is just a quick test to make sure that the latest HDF5 can actually write data - # sets that are larger than 4GB in size - add_executable(BigHDF5DatasetTest ${DREAM3DTest_SOURCE_DIR}/BigHDF5DatasetTest.cpp) - target_link_libraries(BigHDF5DatasetTest Qt5::Core H5Support ) - set_target_properties(BigHDF5DatasetTest PROPERTIES FOLDER Test) - add_test(BigHDF5DatasetTest ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/BigHDF5DatasetTest) - - -endif() diff --git a/Source/H5Support/Test/H5LiteTest.cpp b/Source/H5Support/Test/H5LiteTest.cpp deleted file mode 100644 index a87108fee5..0000000000 --- a/Source/H5Support/Test/H5LiteTest.cpp +++ /dev/null @@ -1,1459 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, 2010 Michael A. Jackson for BlueQuartz Software -// All rights reserved. -// BSD License: http://www.opensource.org/licenses/bsd-license.html -// -// This code was written under United States Air Force Contract number -// FA8650-04-C-5229 -// -/////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include - -#include -#include -#include -#include - -#include "H5Support/H5Lite.h" -#include "H5Support/H5Utilities.h" -#include "H5Support/QH5Lite.h" -#include "H5Support/QH5Utilities.h" - -// THIS IS REALLY DANGEROUS AS IT COULD SETUP A CIRCULAR REFERENCE WITH LIBRARY DEPENDECIES. -#include "UnitTestSupport.hpp" - -#include "H5SupportTestFileLocations.h" - -#define DSET0_NAME "2D int32_t array" -#define DSET1_NAME "dataset char" -#define DSET2_NAME "dataset short" -#define DSET3_NAME "dataset int" -#define DSET4_NAME "dataset long" -#define DSET5_NAME "dataset float" -#define DSET6_NAME "dataset double" -#define DSET7_NAME "dataset string" - -#define DIM 6 -#define DIM0 4 -#define DIM1 3 -#define DIM2 2 - -#define RANK_1D 1 -#define RANK_2D 2 -#define RANK_3D 3 - -#define H5ATTRIBUTE_INSTANCE(m_msgType, Suffix, key) \ - Suffix##H5Attribute::Pointer m_msgType##_attr = Suffix##H5Attribute::New(); \ - m_msgType##_attr->setKey(key); - -/* Methods to test - * - * HDFTypeFromString - * HDFTypeForPrimitiveAsStr - * HDFTypeForPrimitive - * writeVectorDataset - DONE - * writePointerDataset - DONE - * writeScalarDataset - DONE - * writeStringDataset - DONE - * writeStringDataset - DONE - * writePointerAttribute - DONE - * writeVectorAttribute - DONE - * writeStringAttribute - DONE - * writeStringAttribute - DONE - * writeStringAttributes - DONE - * writeScalarAttribute - DONE - * readPointerDataset - DONE - * readVectorDataset - DONE - * readScalarDataset - DONE - * readStringDataset - DONE - * readStringDataset - DONE - * readVectorAttribute - DONE - * readScalarAttribute - DONE - * readPointerAttribute - DONE - * readStringAttribute - DONE - * readStringAttribute - DONE - * getAttributeNDims - DONE - * getDatasetNDims - DONE - * getDatasetType - * getDatasetInfo - DONE - * getAttributeInfo - DONE - */ - -herr_t testMakeStringDataset(hid_t file_id); -herr_t testMakeStringAttribute(hid_t file_id); -void QH5LiteTest(); -// MXADataModel::Pointer createModelTemplate(); -template herr_t testWritePointer1DArrayAttribute(hid_t file_id, const QString& dsetName); - -class H5LiteTest -{ -public: - H5LiteTest() = default; - virtual ~H5LiteTest() = default; - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void RemoveTestFiles() - { -#if REMOVE_TEST_FILES - QFile::remove(UnitTest::H5LiteTest::FileName); - QFile::remove(UnitTest::H5LiteTest::LargeFile); -#endif - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testWritePointer1DArrayAttribute(hid_t file_id, const QString& dsetName) - { - T value = 0x0; - herr_t err = -1; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - attributeKey = "1DArrayAttribute<" + attributeKey + ">"; - int32_t rank = 1; - T data[DIM0]; - for(int i = 0; i < DIM0; ++i) - { - data[i] = (T)(i); - } - hsize_t dims[1]; - dims[0] = DIM0; - - err = QH5Lite::writePointerAttribute(file_id, dsetName, attributeKey, rank, dims, (T*)data); - DREAM3D_REQUIRE(err >= 0); - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testReadPointer1DArrayAttribute(hid_t file_id, const QString& dsetName) - { - T value = 0x0; - herr_t err = -1; - herr_t retErr = err; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - attributeKey = "1DArrayAttribute<" + attributeKey + ">"; - QVector referenceData(DIM0, 0); - for(int i = 0; i < DIM0; ++i) - { - referenceData[i] = (T)(i); - } - - H5T_class_t attr_type; - size_t attr_size; - hid_t typeId = -1; - QVector dims; // Reusable for the loop - err = QH5Lite::getAttributeInfo(file_id, dsetName, attributeKey, dims, attr_type, attr_size, typeId); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(dims.size() == 1); - DREAM3D_REQUIRE(attr_size == sizeof(T)); - hid_t rank = 0; - err = QH5Lite::getAttributeNDims(file_id, dsetName, attributeKey, rank); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(rank == 1); - CloseH5T(typeId, err, retErr); // Close the H5A type Id that was retrieved during the loop - typename QVector::size_type numElements = 1; - for(QVector::size_type i = 0; i < dims.size(); ++i) - { - numElements = numElements * dims[i]; - } - QVector data(numElements, 0); - err = QH5Lite::readPointerAttribute(file_id, dsetName, attributeKey, data.data()); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(data == referenceData); - - return retErr; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testWritePointer2DArrayAttribute(hid_t file_id, const QString& dsetName) - { - // qDebug() << DEBUG_OUT(logTime) << "testWritePointer2DArrayAttribute" << "\n"; - T value = 0x0; - herr_t err = -1; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - - attributeKey = "2DArrayAttribute<" + attributeKey + ">"; - int32_t rank = RANK_2D; - T data[DIM0][DIM1]; - for(int i = 0; i < DIM0; ++i) - { - for(int j = 0; j < DIM1; ++j) - { - data[i][j] = (T)(i * j); - } - } - hsize_t dims[RANK_2D]; - dims[0] = DIM0; - dims[1] = DIM1; - err = QH5Lite::writePointerAttribute(file_id, dsetName, attributeKey, rank, dims, (T*)data); - DREAM3D_REQUIRE(err >= 0); - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testReadPointer2DArrayAttribute(hid_t file_id, const QString& dsetName) - { - T value = 0x0; - herr_t err = -1; - herr_t retErr = err; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - attributeKey = "2DArrayAttribute<" + attributeKey + ">"; - T referenceData[DIM0][DIM1]; - for(int i = 0; i < DIM0; ++i) - { - for(int j = 0; j < DIM1; ++j) - { - referenceData[i][j] = (T)(i * j); - } - } - H5T_class_t attr_type; - size_t attr_size; - hid_t typeId = -1; - QVector dims; // Reusable for the loop - err = QH5Lite::getAttributeInfo(file_id, dsetName, attributeKey, dims, attr_type, attr_size, typeId); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(dims.size() == 2); - DREAM3D_REQUIRE(attr_size == sizeof(T)); - hid_t rank = 0; - err = QH5Lite::getAttributeNDims(file_id, dsetName, attributeKey, rank); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(rank == 2); - - CloseH5T(typeId, err, retErr); // Close the H5A type Id that was retrieved during the loop - typename QVector::size_type numElements = 1; - for(QVector::size_type i = 0; i < dims.size(); ++i) - { - numElements = numElements * dims[i]; - } - QVector data(numElements, 0); - err = QH5Lite::readPointerAttribute(file_id, dsetName, attributeKey, data.data()); - DREAM3D_REQUIRE(err >= 0); - - DREAM3D_REQUIRE(::memcmp(data.data(), referenceData, sizeof(T) * numElements) == 0); - return retErr; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testWritePointer3DArrayAttribute(hid_t file_id, const QString& dsetName) - { - T value = 0x0; - herr_t err = -1; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - attributeKey = "3DArrayAttribute<" + attributeKey + ">"; - int32_t rank = RANK_3D; - T data[DIM0][DIM1][DIM2]; - for(int i = 0; i < DIM0; ++i) - { - for(int j = 0; j < DIM1; ++j) - { - for(int k = 0; k < DIM2; ++k) - { - data[i][j][k] = (T)(i * j * k); - } - } - } - hsize_t dims[RANK_3D]; - dims[0] = DIM0; - dims[1] = DIM1; - dims[2] = DIM2; - err = QH5Lite::writePointerAttribute(file_id, dsetName, attributeKey, rank, dims, (T*)data); - DREAM3D_REQUIRE(err >= 0); - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testReadPointer3DArrayAttribute(hid_t file_id, const QString& dsetName) - { - T value = 0x0; - herr_t err = -1; - herr_t retErr = err; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - attributeKey = "3DArrayAttribute<" + attributeKey + ">"; - T referenceData[DIM0][DIM1][DIM2]; - for(int i = 0; i < DIM0; ++i) - { - for(int j = 0; j < DIM1; ++j) - { - for(int k = 0; k < DIM2; ++k) - { - referenceData[i][j][k] = (T)(i * j * k); - } - } - } - H5T_class_t attr_type; - size_t attr_size; - hid_t typeId = -1; - QVector dims; // Reusable for the loop - err = QH5Lite::getAttributeInfo(file_id, dsetName, attributeKey, dims, attr_type, attr_size, typeId); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(dims.size() == 3); - DREAM3D_REQUIRE(attr_size == sizeof(T)); - hid_t rank = 0; - err = QH5Lite::getAttributeNDims(file_id, dsetName, attributeKey, rank); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(rank == 3); - CloseH5T(typeId, err, retErr); // Close the H5A type Id that was retrieved during the loop - typename QVector::size_type numElements = 1; - for(QVector::size_type i = 0; i < dims.size(); ++i) - { - numElements = numElements * dims[i]; - } - QVector data(numElements, 0); - err = QH5Lite::readPointerAttribute(file_id, dsetName, attributeKey, data.data()); - DREAM3D_REQUIRE(err >= 0); - - DREAM3D_REQUIRE(::memcmp(data.data(), referenceData, sizeof(T) * numElements) == 0); - return retErr; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testWriteVectorAttribute(hid_t file_id, QString dsetName) - { - T value = 0x0; - herr_t err = -1; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - attributeKey = "VectorAttribute<" + attributeKey + ">"; - - int32_t numElements = DIM0; - QVector dims(1, DIM0); - - /* Make dataset */ - QVector data(DIM0, 0); - for(int i = 0; i < numElements; ++i) - { - data[i] = (T)(i); - } - // qDebug() << "Attribute->Write: " << objName; - err = QH5Lite::writeVectorAttribute(file_id, dsetName, attributeKey, dims, data); - DREAM3D_REQUIRE(err >= 0); - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testReadVectorAttribute(hid_t file_id, QString dsetName) - { - T value = 0x0; - herr_t err = -1; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - attributeKey = "VectorAttribute<" + attributeKey + ">"; - - int32_t numElements = DIM0; - QVector dims(1, DIM0); - - QVector data(DIM0, 0); - for(int i = 0; i < numElements; ++i) - { - data[i] = (T)(i); - } - QVector rData(numElements, 0); // allocate and zero out the memory - err = QH5Lite::readVectorAttribute(file_id, dsetName, attributeKey, rData); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(data == rData); - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testWriteScalarAttribute(hid_t file_id, const QString& dsetName) - { - T value = 0x0F; - herr_t err = -1; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - attributeKey = "ScalarAttribute<" + attributeKey + ">"; - err = QH5Lite::writeScalarAttribute(file_id, dsetName, attributeKey, value); - DREAM3D_REQUIRE(err >= 0); - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testReadScalarAttribute(hid_t file_id, const QString& dsetName) - { - T value = 0x0F; - T refValue = value; - herr_t err = -1; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - attributeKey = "ScalarAttribute<" + attributeKey + ">"; - - err = QH5Lite::readScalarAttribute(file_id, dsetName, attributeKey, value); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(refValue == value); - return err; - } - - // ----------------------------------------------------------------------------- - // Uses Raw Pointers to save data to the data file - // ----------------------------------------------------------------------------- - template herr_t testWritePointer2DArrayDataset(hid_t file_id) - { - - T value = 0x0; - herr_t err = 1; - int32_t rank = 2; - // Create the Dimensions - hsize_t dims[2]; - dims[0] = DIM0; - dims[1] = DIM1; - - /* Make dataset char */ - int32_t tSize = dims[0] * dims[1]; - // T data[dimx*dimy]; - QVector data(tSize); - for(int32_t i = 0; i < tSize; ++i) - { - data[i] = static_cast(i * 5); - } - - QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(value); - dsetName = "Pointer2DArrayDataset<" + dsetName + ">"; - qDebug() << "Running " << dsetName << " ... "; - err = QH5Lite::writePointerDataset(file_id, dsetName, rank, dims, &(data.front())); - DREAM3D_REQUIRE(err >= 0); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - - qDebug() << " Passed" - << "\n"; - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testWriteVectorDataset(hid_t file_id) - { - T value = 0x0; - herr_t err = 1; - - QVector dims(RANK_1D, DIM0); - /* Make dataset char */ - QVector data(DIM0, 0); - for(int32_t i = 0; i < DIM0; ++i) - { - data[i] = static_cast(i * 5); - } - - QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(value); - dsetName = "VectorDataset<" + dsetName + ">"; - qDebug() << "Running " << dsetName << " ... "; - err = QH5Lite::writeVectorDataset(file_id, dsetName, dims, data); - DREAM3D_REQUIRE(err >= 0); - - qDebug() << " Passed" - << "\n"; - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testReadVectorDataset(hid_t file_id) - { - T value = 0x0; - herr_t err = 1; - - std::vector dims(RANK_1D, DIM0); - std::vector referenceData(DIM0, 0); - for(int32_t i = 0; i < DIM0; ++i) - { - referenceData[i] = static_cast(i * 5); - } - - QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(value); - qDebug() << "Running testReadVectorDataset <" + dsetName + "> ... "; - dsetName = "VectorDataset<" + dsetName + ">"; - - std::vector data; - err = QH5Lite::readVectorDataset(file_id, dsetName, data); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(data == referenceData); - - qDebug() << " Passed" - << "\n"; - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testWriteScalarDataset(hid_t file_id) - { - T value = 0x0F; - herr_t err = 1; - - QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(value); - dsetName = "ScalarDataset<" + dsetName + ">"; - qDebug() << "Running " << dsetName << " ... "; - err = QH5Lite::writeScalarDataset(file_id, dsetName, value); - DREAM3D_REQUIRE(err >= 0); - - bool exists = QH5Lite::datasetExists(file_id, dsetName); - DREAM3D_REQUIRE_EQUAL(exists, true); - - exists = QH5Lite::datasetExists(file_id, QString("DOES_NOT_EXIST")); - DREAM3D_REQUIRE_EQUAL(exists, false); - - qDebug() << " Passed" - << "\n"; - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testReadScalarDataset(hid_t file_id) - { - T value = 0x0F; - T refValue = value; - herr_t err = 1; - - QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(value); - qDebug() << "Running testReadScalarDataset <" + dsetName + "> ... "; - dsetName = "ScalarDataset<" + dsetName + ">"; - - err = QH5Lite::readScalarDataset(file_id, dsetName, value); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(refValue == value); - - qDebug() << " Passed" - << "\n"; - return err; - } - -#if 0 - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - herr_t testMXAAttribute(hid_t file_id, const QString& dsetName) - { - T value = 0x0F; - herr_t err = -1; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - attributeKey = "MXAAttribute<" + attributeKey + ">"; - IMXAArray* array = MXAArrayTemplate::New(10); - IMXAArray::Pointer arrayPtr (array); - T* p = static_cast(array->getVoidPointer(0)); - for (int var = 0; var < 10; ++var) - { - p[var] = static_cast(var + 65); - } - err = QH5Lite::writeMXAAttribute(file_id, dsetName, attributeKey, array); - DREAM3D_REQUIRE(err >= 0); - - // Now Read the Attribute back into an MXAArray object and test against the previous for equality - IMXAArray* rArray = QH5Lite::readMXAAttribute(file_id, dsetName, attributeKey); - DREAM3D_REQUIRE (rArray != nullptr); - //hid_t t = rArray->getDataType(); - IMXAArray::Pointer rArrayPtr(rArray); // Let boost clean up the pointer - T* r = static_cast(rArrayPtr->getVoidPointer(0)); - // for (int var = 0; var < 10; ++var) { - // qDebug() << "p=" << p[var] << " r=" << (r[var]) << "\n"; - // } - DREAM3D_REQUIRE( ::memcmp(r, p, sizeof(T) * 10) == 0); - - - - AbstractH5Attribute::Pointer ptr = H5Attribute::ReadH5Attribute(file_id, dsetName, attributeKey); - DREAM3D_REQUIRE(ptr.get() != nullptr); - r = static_cast(ptr->getAttributeValue()->getVoidPointer(0)); - DREAM3D_REQUIRE( ::memcmp(r, p, sizeof(T) * 10) == 0); - - return err; - } - - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - herr_t testWriteMXAArray(hid_t file_id) - { - herr_t err = 1; - T value = 0x0F; - - QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(value); - dsetName = "MXAArrayDataset<" + dsetName + ">"; - qDebug() << "Running " << dsetName << " ... "; - - IMXAArray* array = MXAArrayTemplate::New(10); - IMXAArray::Pointer arrayPtr (array); - T* p = static_cast(array->getVoidPointer(0)); - for (int var = 0; var < 10; ++var) - { - p[var] = static_cast(var); - } - err = QH5Lite::writeMXAArray(file_id, dsetName, array); - DREAM3D_REQUIRE(err >= 0); - - DREAM3D_REQUIRE ( testMXAAttribute(file_id, dsetName) >= 0 ); - DREAM3D_REQUIRE ( testMXAAttribute(file_id, dsetName) >= 0 ); - DREAM3D_REQUIRE ( testMXAAttribute(file_id, dsetName) >= 0 ); - DREAM3D_REQUIRE ( testMXAAttribute(file_id, dsetName) >= 0 ); - DREAM3D_REQUIRE ( testMXAAttribute(file_id, dsetName) >= 0 ); - DREAM3D_REQUIRE ( testMXAAttribute(file_id, dsetName) >= 0 ); - DREAM3D_REQUIRE ( testMXAAttribute(file_id, dsetName) >= 0 ); - DREAM3D_REQUIRE ( testMXAAttribute(file_id, dsetName) >= 0 ); - DREAM3D_REQUIRE ( testMXAAttribute(file_id, dsetName) >= 0 ); - DREAM3D_REQUIRE ( testMXAAttribute(file_id, dsetName) >= 0 ); - - // Now Read the Attribute back into an MXAArray object and test against the previous for equality - IMXAArray* rArray = QH5Lite::readMXAArray(file_id, dsetName); - DREAM3D_REQUIRE (rArray != nullptr); - IMXAArray::Pointer rArrayPtr(rArray); // Let boost clean up the pointer - T* r = static_cast(rArrayPtr->getVoidPointer(0)); - // for (int var = 0; var < 10; ++var) { - // qDebug() << "p=" << p[var] << " r=" << (r[var]) << "\n"; - // } - DREAM3D_REQUIRE( ::memcmp(r, p, sizeof(T) * 10) == 0); - - qDebug() << " Passed" << "\n"; - return err; - } -#endif - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - herr_t testWriteStringDatasetAndAttributes(hid_t file_id) - { - qDebug() << "Running testWriteStringDatasetAndAttributes ......"; - herr_t err = 0; - QString dsetName("QString"); - QString dsetNameBytes("c_string"); - QString attributeKey("QString"); - - QString strData("THIS IS THE DATA"); - QByteArray strDataBytes("THIS IS THE DATA AS BYTES"); - QString attrData("THIS IS THE ATTRIBUTE DATA"); - QByteArray attrDataBytes("THIS IS THE ATTRIBUTE DATA AS BYTES"); - - // Write a String Data set using a QString as the data source - err = QH5Lite::writeStringDataset(file_id, dsetName, strData); - DREAM3D_REQUIRE(err >= 0); - - // Over Write the data from Above but with different values - strData = "THIS IS XXX DATA"; - err = QH5Lite::writeStringDataset(file_id, dsetName, strData); - DREAM3D_REQUIRE(err >= 0); - - // Over Write the data from Above but with longer string - strData = "THIS IS LONGER DATA"; - err = QH5Lite::writeStringDataset(file_id, dsetName, strData); - DREAM3D_REQUIRE(err >= 0); - - // Over Write the data from Above but with shorter string - strData = "THIS IS LESS DATA"; - err = QH5Lite::writeStringDataset(file_id, dsetName, strData); - DREAM3D_REQUIRE(err >= 0); - - // Over Write the data from Above but with even shorter string - strData = "Even LESS DATA"; - err = QH5Lite::writeStringDataset(file_id, dsetName, strData); - DREAM3D_REQUIRE(err >= 0); - - // Over Write the data from Above but with even shorter string - strData = "THIS IS THE DATA"; - err = QH5Lite::writeStringDataset(file_id, dsetName, strData); - DREAM3D_REQUIRE(err >= 0); - - // Write a String attribute using a QString as the data source - err = QH5Lite::writeStringAttribute(file_id, dsetName, attributeKey, attrData); - DREAM3D_REQUIRE(err >= 0); - - attributeKey = "c_string"; - err = QH5Lite::writeStringAttribute(file_id, dsetName, attributeKey, attrDataBytes.size() + 1, attrDataBytes.data()); - - // Write a String data set using char* as data source - err = QH5Lite::writeStringDataset(file_id, dsetNameBytes, strDataBytes.size() + 1, strDataBytes.data()); - DREAM3D_REQUIRE(err >= 0); - - // Write a bunch of Attributes using a Map structure. - QMap attrMap; - attrMap[attributeKey] = attrData; - attributeKey = "QString"; - attrMap[attributeKey] = attrData; - - err = QH5Lite::writeStringAttributes(file_id, dsetNameBytes, attrMap); - DREAM3D_REQUIRE(err >= 0); - - qDebug() << " Passed"; - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - herr_t HDF5Dump_datatype(hid_t dataset_id, std::ostream& iostr) - { - herr_t status = 0; - - hid_t type_id = H5Dget_type(dataset_id); - - iostr << " "; - iostr << "DATATYPE \""; - - switch(H5Tget_class(type_id)) - { - case H5T_INTEGER: - iostr << "Integer"; - break; - - case H5T_FLOAT: - if(H5Tequal(type_id, H5T_IEEE_F32BE) || H5Tequal(type_id, H5T_IEEE_F32LE) || H5Tequal(type_id, H5T_NATIVE_FLOAT)) - { - // Float - iostr << "Float"; - } - else if(H5Tequal(type_id, H5T_IEEE_F64BE) || H5Tequal(type_id, H5T_IEEE_F64LE) || H5Tequal(type_id, H5T_NATIVE_DOUBLE) || H5Tequal(type_id, H5T_NATIVE_LDOUBLE)) - { - // Double - iostr << "Double"; - } - else - { - iostr << "Undefined HDF5 float."; - } - break; - - case H5T_STRING: - iostr << "String - Unsupported"; - break; - - case H5T_COMPOUND: - iostr << "Compound - Unsupported"; - break; - - default: - iostr << "Unsupported or unknown data type"; - break; - } - - iostr << "\"" - << "\n"; - - status = H5Tclose(type_id); - - return status; - } - - // ----------------------------------------------------------------------------- - // Uses Raw Pointers to read data from the data file - // ----------------------------------------------------------------------------- - template herr_t testReadPointer2DArrayDataset(hid_t file_id) - { - // Create the reference data - T value = 0x0; - herr_t err = 1; - QVector dims(2, 0); - dims[0] = DIM0; - dims[1] = DIM1; - - int32_t tSize = dims[0] * dims[1]; - QVector referenceData(tSize); - for(int32_t i = 0; i < tSize; ++i) - { - referenceData[i] = static_cast(i * 5); - } - // Generate the data set name - QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(value); - qDebug() << "Running testReadPointer2DArrayDataset<" << dsetName << "> ... "; - dsetName = "Pointer2DArrayDataset<" + dsetName + ">"; - - H5T_class_t attr_type; - size_t attr_size; - - err = QH5Lite::getDatasetInfo(file_id, "FOOBAR", dims, attr_type, attr_size); - DREAM3D_REQUIRE(err < 0); - - err = QH5Lite::getDatasetInfo(file_id, dsetName, dims, attr_type, attr_size); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(dims.size() == 2); - DREAM3D_REQUIRE(attr_size == sizeof(T)); - hid_t rank = 0; - err = QH5Lite::getDatasetNDims(file_id, dsetName, rank); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(rank == 2); - typename QVector::size_type numElements = 1; - for(QVector::size_type i = 0; i < dims.size(); ++i) - { - numElements = numElements * dims[i]; - } - - herr_t retErr = 0; - hid_t did = -1; - /* Open the dataset. */ - if((did = H5Dopen(file_id, dsetName.toLatin1().data(), H5P_DEFAULT)) < 0) - { - return -2; - } - /* Get an identifier for the datatype. */ - hid_t tid = H5Dget_type(did); - - err = H5Dclose(did); - if(err < 0) - { - qDebug() << "File: " << __FILE__ << "(" << __LINE__ << "): " - << "Error Closing Dataset." - << "\n"; - retErr = err; - } - if(retErr < 0) - { - return retErr; - } - - DREAM3D_REQUIRE(tid > 0); - // qDebug() << QH5Lite::StringForHDFType(tid) << "\n"; - err = H5Tclose(tid); - DREAM3D_REQUIRE(err >= 0); - - hid_t dsType = QH5Lite::getDatasetType(file_id, dsetName); - DREAM3D_REQUIRE(dsType > 0); - // qDebug() << QH5Lite::StringForHDFType(dsType) << "\n"; - - err = H5Tclose(dsType); - DREAM3D_REQUIRE(err >= 0); - - QVector data(numElements, 0); - err = QH5Lite::readPointerDataset(file_id, dsetName, data.data()); - DREAM3D_REQUIRE(err >= 0); - // Compare the data... - DREAM3D_REQUIRE(data == referenceData); - - // Read all the attributes - err = testReadPointer1DArrayAttribute(file_id, dsetName); - err = testReadPointer1DArrayAttribute(file_id, dsetName); - err = testReadPointer1DArrayAttribute(file_id, dsetName); - err = testReadPointer1DArrayAttribute(file_id, dsetName); - err = testReadPointer1DArrayAttribute(file_id, dsetName); - err = testReadPointer1DArrayAttribute(file_id, dsetName); - err = testReadPointer1DArrayAttribute(file_id, dsetName); - err = testReadPointer1DArrayAttribute(file_id, dsetName); - err = testReadPointer1DArrayAttribute(file_id, dsetName); - err = testReadPointer1DArrayAttribute(file_id, dsetName); - - err = testReadPointer2DArrayAttribute(file_id, dsetName); - err = testReadPointer2DArrayAttribute(file_id, dsetName); - err = testReadPointer2DArrayAttribute(file_id, dsetName); - err = testReadPointer2DArrayAttribute(file_id, dsetName); - err = testReadPointer2DArrayAttribute(file_id, dsetName); - err = testReadPointer2DArrayAttribute(file_id, dsetName); - err = testReadPointer2DArrayAttribute(file_id, dsetName); - err = testReadPointer2DArrayAttribute(file_id, dsetName); - err = testReadPointer2DArrayAttribute(file_id, dsetName); - err = testReadPointer2DArrayAttribute(file_id, dsetName); - - err = testReadPointer3DArrayAttribute(file_id, dsetName); - err = testReadPointer3DArrayAttribute(file_id, dsetName); - err = testReadPointer3DArrayAttribute(file_id, dsetName); - err = testReadPointer3DArrayAttribute(file_id, dsetName); - err = testReadPointer3DArrayAttribute(file_id, dsetName); - err = testReadPointer3DArrayAttribute(file_id, dsetName); - err = testReadPointer3DArrayAttribute(file_id, dsetName); - err = testReadPointer3DArrayAttribute(file_id, dsetName); - err = testReadPointer3DArrayAttribute(file_id, dsetName); - err = testReadPointer3DArrayAttribute(file_id, dsetName); - // - err = testReadVectorAttribute(file_id, dsetName); - err = testReadVectorAttribute(file_id, dsetName); - err = testReadVectorAttribute(file_id, dsetName); - err = testReadVectorAttribute(file_id, dsetName); - err = testReadVectorAttribute(file_id, dsetName); - err = testReadVectorAttribute(file_id, dsetName); - err = testReadVectorAttribute(file_id, dsetName); - err = testReadVectorAttribute(file_id, dsetName); - err = testReadVectorAttribute(file_id, dsetName); - err = testReadVectorAttribute(file_id, dsetName); - - err = testReadScalarAttribute(file_id, dsetName); - err = testReadScalarAttribute(file_id, dsetName); - err = testReadScalarAttribute(file_id, dsetName); - err = testReadScalarAttribute(file_id, dsetName); - err = testReadScalarAttribute(file_id, dsetName); - err = testReadScalarAttribute(file_id, dsetName); - err = testReadScalarAttribute(file_id, dsetName); - err = testReadScalarAttribute(file_id, dsetName); - err = testReadScalarAttribute(file_id, dsetName); - err = testReadScalarAttribute(file_id, dsetName); - - qDebug() << " Passed" - << "\n"; - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template void printData(QVector& data, QVector& rData) - { - // qDebug() << "Wrote/Read" << "\n"; - for(typename QVector::iterator iter = data.begin(); iter < data.end(); ++iter) - { - qDebug() << *iter << " "; - } - qDebug() << "\n"; - - for(typename QVector::iterator iter = rData.begin(); iter < rData.end(); ++iter) - { - qDebug() << *iter << " "; - } - - qDebug() << "\n"; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - herr_t testReadStringDatasetAndAttributes(hid_t file_id) - { - qDebug() << "Running testReadStringDatasetAndAttributes ......"; - herr_t err = 0; - - QString dsetName("QString"); - QString dsetNameBytes("c_string"); - QString attributeKey("QString"); - - QString refData("THIS IS THE DATA"); - QByteArray refDataBytes("THIS IS THE DATA AS BYTES"); - QString refAttrData("THIS IS THE ATTRIBUTE DATA"); - QByteArray refAttrDataBytes("THIS IS THE ATTRIBUTE DATA AS BYTES"); - - QString strData(""); - // Read the string as a QString from the file - err = QH5Lite::readStringDataset(file_id, dsetName, strData); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(refData.compare(strData) == 0); - - // Read the string again this time passing in a QString that has data in it which should get cleared - strData = "FooBarJunk"; - err = QH5Lite::readStringDataset(file_id, dsetName, strData); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(refData.compare(strData) == 0); - - // Read the Attributes - QString attrData(""); - // Read the Attribute as a QString and compare to the reference - err = QH5Lite::readStringAttribute(file_id, dsetName, attributeKey, attrData); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(refAttrData.compare(attrData) == 0); - - // Read the attribute as a byte array (US ASCII nullptr TERM) - QByteArray attrDataPtr(refAttrDataBytes.size(), 0); // Create a null terminated string initialized to all zeros - attributeKey = "c_string"; - err = QH5Lite::readStringAttribute(file_id, dsetName, attributeKey, attrDataPtr.data()); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(::memcmp(attrDataPtr.data(), refAttrDataBytes.data(), refAttrDataBytes.size()) == 0); - - // Read a string data set which was written as a QByteArray into a QByteArray - QByteArray strDataBytes(refDataBytes.size(), 0); - err = QH5Lite::readStringDataset(file_id, dsetNameBytes, strDataBytes.data()); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(strDataBytes == refDataBytes); - - QString mapString; - err = QH5Lite::readStringAttribute(file_id, dsetNameBytes, dsetNameBytes, mapString); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(refAttrData.compare(mapString) == 0); - - err = QH5Lite::readStringAttribute(file_id, dsetNameBytes, attributeKey, mapString); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(refAttrData.compare(mapString) == 0); - - qDebug() << " Passed" - << "\n"; - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void QH5LiteTest() - { - // herr_t err = -1; - hid_t file_id = 0; - /* Create a new file using default properties. */ - file_id = H5Fcreate(UnitTest::H5LiteTest::FileName.toLatin1().data(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - DREAM3D_REQUIRE(file_id > 0); - // Create the Extra Groups - hid_t sintGid = H5Gcreate(file_id, "Signed Int", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - hid_t uintGid = H5Gcreate(file_id, "Unsigned Int", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - hid_t pointer = H5Gcreate(file_id, "Pointer", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - herr_t err = H5Gclose(sintGid); - if(err < 0) - { - qDebug() << "Error closing Group sintGid" - << "\n"; - return; - } - err = H5Gclose(uintGid); - if(err < 0) - { - qDebug() << "Error closing Group uintGid" - << "\n"; - return; - } - err = H5Gclose(pointer); - if(err < 0) - { - qDebug() << "Error closing Group c99Gid" - << "\n"; - return; - } - - // qDebug() << logTime() << "----------- Testing Writing/Reading of Datasets using Raw Pointers -----------" << "\n"; - DREAM3D_REQUIRE(testWritePointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWritePointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWritePointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWritePointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWritePointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWritePointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWritePointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWritePointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWritePointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWritePointer2DArrayDataset(file_id) >= 0); - - DREAM3D_REQUIRE(testWriteVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteVectorDataset(file_id) >= 0); - - DREAM3D_REQUIRE(testWriteScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testWriteScalarDataset(file_id) >= 0); - - DREAM3D_REQUIRE(testWriteStringDatasetAndAttributes(file_id) >= 0); - - // DREAM3D_REQUIRE ( testWriteMXAArray(file_id) >= 0); - // DREAM3D_REQUIRE ( testWriteMXAArray(file_id) >= 0); - // DREAM3D_REQUIRE ( testWriteMXAArray(file_id) >= 0); - // DREAM3D_REQUIRE ( testWriteMXAArray(file_id) >= 0); - // DREAM3D_REQUIRE ( testWriteMXAArray(file_id) >= 0); - // DREAM3D_REQUIRE ( testWriteMXAArray(file_id) >= 0); - // DREAM3D_REQUIRE ( testWriteMXAArray(file_id) >= 0); - // DREAM3D_REQUIRE ( testWriteMXAArray(file_id) >= 0); - // DREAM3D_REQUIRE ( testWriteMXAArray(file_id) >= 0); - // DREAM3D_REQUIRE ( testWriteMXAArray(file_id) >= 0); - - // // ******************* Test Reading Data ************************************* - DREAM3D_REQUIRE(testReadPointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadPointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadPointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadPointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadPointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadPointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadPointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadPointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadPointer2DArrayDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadPointer2DArrayDataset(file_id) >= 0); - - DREAM3D_REQUIRE(testReadVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadVectorDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadVectorDataset(file_id) >= 0); - // - DREAM3D_REQUIRE(testReadScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadScalarDataset(file_id) >= 0); - DREAM3D_REQUIRE(testReadScalarDataset(file_id) >= 0); - - DREAM3D_REQUIRE(testReadStringDatasetAndAttributes(file_id) >= 0); - - /* Close the file. */ - H5Fclose(file_id); - // qDebug() << logTime() << "Testing Complete" << "\n"; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestLargeFileSupport() - { - // herr_t err = -1; - hid_t file_id; - /* Create a new file using default properties. */ - file_id = H5Fcreate(UnitTest::H5LiteTest::LargeFile.toLatin1().data(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - DREAM3D_REQUIRE(file_id > 0); - QVector buffer(1000000); // Create a 4 MegaByte Buffer - int32_t rank = 1; - QVector dims(1, 1000000); - QString dsetName; - for(int i = 0; i < 1000; ++i) - { - dsetName = "/" + QString::number(i); - QH5Lite::writePointerDataset(file_id, dsetName, rank, &(dims.front()), &(buffer.front())); - qDebug() << "Large File " << i << "/1000" - << "\n"; - } - - herr_t err = H5Fclose(file_id); - DREAM3D_REQUIRE(err >= 0); - } - -#define TYPE_DETECTION(m_msgType, check) \ - { \ - m_msgType v = 0x00; \ - hid_t t = QH5Lite::HDFTypeForPrimitive(v); \ - DREAM3D_REQUIRE_EQUAL(t, check); \ - } - - template hid_t _testTypeName() - { - T v = 0x00; - return QH5Lite::HDFTypeForPrimitive(v); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestTypeDetection() - { - - DREAM3D_REQUIRE_EQUAL(_testTypeName(), H5T_NATIVE_INT8) -#if CMP_TYPE_CHAR_IS_SIGNED - DREAM3D_REQUIRE_EQUAL(_testTypeName(), H5T_NATIVE_INT8) -#else - DREAM3D_REQUIRE_EQUAL(_testTypeName(), H5T_NATIVE_UINT8) -#endif - DREAM3D_REQUIRE_EQUAL(_testTypeName(), H5T_NATIVE_INT8) - DREAM3D_REQUIRE_EQUAL(_testTypeName(), H5T_NATIVE_UINT8) - DREAM3D_REQUIRE_EQUAL(_testTypeName(), H5T_NATIVE_UINT8) - - // TYPE_DETECTION(uint8_t, H5T_NATIVE_UINT8); - // - // TYPE_DETECTION(char, H5T_NATIVE_INT8); - // TYPE_DETECTION(signed char, H5T_NATIVE_INT8); - } - -#if 0 - class WriteString - { - public: - WriteString (hid_t dataset, hid_t datatype - , hid_t dataspace, hid_t memspace) - : m_dataset (dataset), m_datatype (datatype) - , m_dataspace (dataspace), m_memspace (memspace) - , m_pos () {} - - private: - hid_t m_dataset; - hid_t m_datatype; - hid_t m_dataspace; - hid_t m_memspace; - int m_pos; - //... - - public: - void operator ()(std::vector::value_type const& v) - { - // Select the file position, 1 record at position 'pos' - hsize_t count[] = { 1 } ; - hsize_t offset[] = { m_pos++ } ; - H5Sselect_hyperslab( m_dataspace - , H5S_SELECT_SET - , offset - , nullptr - , count - , nullptr ); - - const char* s = v.c_str (); - H5Dwrite (m_dataset - , m_datatype - , m_memspace - , m_dataspace - , H5P_DEFAULT - , &s ); - } - }; - - void writeVector (hid_t group, std::vector const& v) - { - hsize_t dims[] = { v.size () } ; - hid_t dataspace = H5Screate_simple(sizeof(dims) / sizeof(*dims), dims, nullptr); - - dims[0] = 1; - hid_t memspace = H5Screate_simple(sizeof(dims) / sizeof(*dims), dims, nullptr); - - hid_t datatype = H5Tcopy (H5T_C_S1); - H5Tset_size (datatype, H5T_VARIABLE); - - hid_t dataset = H5Dcreate(group, "files", datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - - // - // Select the "memory" to be written out - just 1 record. - hsize_t offset[] = { 0 } ; - hsize_t count[] = { 1 } ; - H5Sselect_hyperslab( memspace, H5S_SELECT_SET, offset, nullptr, count, nullptr ); - - std::for_each (v.begin (), v.end (), WriteString (dataset, datatype, dataspace, memspace)); - - H5Dclose (dataset); - H5Sclose (dataspace); - H5Sclose (memspace); - H5Tclose (datatype); - } - - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestVLength() - { - std::string data_set_name("Variable Length String Array"); - std::vector strings; - strings.push_back("A Test"); - strings.push_back("Another Test with \n a new line"); - strings.push_back("Some other string thing"); - - hid_t file_id = H5Utilities::createFile(UnitTest::H5LiteTest::VLengthFile.toStdString()); - - writeVector(file_id, strings); - - H5Utilities::closeFile(file_id); - - file_id = -1; - - } - -#else - - class WriteString - { - public: - WriteString(hid_t dataset, hid_t datatype, hid_t dataspace, hid_t memspace) - : m_dataset(dataset) - , m_datatype(datatype) - , m_dataspace(dataspace) - , m_memspace(memspace) - , m_pos() - { - } - - private: - hid_t m_dataset; - hid_t m_datatype; - hid_t m_dataspace; - hid_t m_memspace; - int m_pos; - //... - - public: - void operator()(std::vector::value_type const& v) - { - // Select the file position, 1 record at position 'pos' - hsize_t count[] = {1}; - hsize_t offset[] = {static_cast(m_pos++)}; - H5Sselect_hyperslab(m_dataspace, H5S_SELECT_SET, offset, nullptr, count, nullptr); - - const char* s = v.c_str(); - H5Dwrite(m_dataset, m_datatype, m_memspace, m_dataspace, H5P_DEFAULT, &s); - } - }; - - // ----------------------------------------------------------------------------- - // Use unit test framework - // ----------------------------------------------------------------------------- - void TestVLengStringReadWrite() - { - // Write a Single String as a VLength String and read back as a normal string. - { - hid_t file_id = H5Utilities::createFile(UnitTest::H5LiteTest::VLengthFile.toStdString()); - - std::vector strings; - strings.push_back("Testing 1 2 3"); - herr_t err = H5Lite::writeVectorOfStringsDataset(file_id, "VlenStrings", strings); - DREAM3D_REQUIRE(err >= 0) - H5Utilities::closeFile(file_id); - - file_id = QH5Utilities::openFile(UnitTest::H5LiteTest::VLengthFile, true); - - std::string data; - err = H5Lite::readStringDataset(file_id, "VlenStrings", data); - DREAM3D_REQUIRE(err > -1) - DREAM3D_REQUIRE(data.size() == 13) - - QH5Utilities::closeFile(file_id); - } - - { - hid_t file_id = H5Utilities::createFile(UnitTest::H5LiteTest::VLengthFile.toStdString()); - - std::vector strings; - strings.push_back("Testing 1 2 3"); - strings.push_back("String with a\n newline"); - strings.push_back("Some other String"); - strings.push_back("Titanium"); - strings.push_back("Nickel"); - - herr_t err = H5Lite::writeVectorOfStringsDataset(file_id, "VlenStrings", strings); - DREAM3D_REQUIRE(err >= 0) - - H5Utilities::closeFile(file_id); - } - - { - - hid_t file_id = H5Utilities::openFile(UnitTest::H5LiteTest::VLengthFile.toStdString(), true); - - std::vector data; - H5Lite::readVectorOfStringDataset(file_id, "VlenStrings", data); - DREAM3D_REQUIRE(data.size() == 5) - } - - { - hid_t file_id = QH5Utilities::createFile(UnitTest::H5LiteTest::VLengthFile); - - QVector strings; - strings.push_back("Testing 1 2 3"); - strings.push_back("String with a\n newline"); - strings.push_back("Some other String"); - strings.push_back("Titanium"); - strings.push_back("Nickel"); - - herr_t err = QH5Lite::writeVectorOfStringsDataset(file_id, "VlenStrings", strings); - DREAM3D_REQUIRE(err >= 0) - - QH5Utilities::closeFile(file_id); - } - - { - - hid_t file_id = QH5Utilities::openFile(UnitTest::H5LiteTest::VLengthFile, true); - - QVector data; - QH5Lite::readVectorOfStringDataset(file_id, "VlenStrings", data); - DREAM3D_REQUIRE(data.size() == 5) - - QH5Utilities::closeFile(file_id); - } - } - -#endif - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void operator()() - { - int err = EXIT_SUCCESS; - - DREAM3D_REGISTER_TEST(TestVLengStringReadWrite()) - - DREAM3D_REGISTER_TEST(TestTypeDetection()) - DREAM3D_REGISTER_TEST(QH5LiteTest()) - DREAM3D_REGISTER_TEST(RemoveTestFiles()) - } - -private: - H5LiteTest(const H5LiteTest&); // Copy Constructor Not Implemented - void operator=(const H5LiteTest&); // Move assignment Not Implemented -}; diff --git a/Source/H5Support/Test/H5SupportTestMain.cpp.in b/Source/H5Support/Test/H5SupportTestMain.cpp.in deleted file mode 100644 index ce151a5403..0000000000 --- a/Source/H5Support/Test/H5SupportTestMain.cpp.in +++ /dev/null @@ -1,53 +0,0 @@ - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Winconsistent-missing-override" -#endif - - -#include - -#if 0 -#include "SIMPLib/Filtering/FilterManager.h" -#include "SIMPLib/Plugin/ISIMPLibPlugin.h" -#include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/Utilities/UnitTestSupport.hpp" -#include "SIMPLib/Utilities/QMetaObjectUtilities.h" -#endif - -@FilterTestIncludes@ - - -// ----------------------------------------------------------------------------- -// Use test framework -// ----------------------------------------------------------------------------- -int main(int argc, char** argv) -{ - int err = EXIT_SUCCESS; - - // Instantiate the QCoreApplication that we need to get the current path and load plugins. - QCoreApplication app(argc, argv); - QCoreApplication::setOrganizationName("Your Company"); - QCoreApplication::setOrganizationDomain("Your Domain"); - QCoreApplication::setApplicationName("@PluginName@"); - - // Register all the filters including trying to load those from Plugins - // FilterManager* fm = FilterManager::Instance(); - // SIMPLibPluginLoader::LoadPluginFilters(fm); - - // Send progress messages from PipelineBuilder to this object for display - // QMetaObjectUtilities::RegisterMetaTypes(); - - - @TestMainFunctors@ - - - PRINT_TEST_SUMMARY(); - - return err; -} - - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif diff --git a/Source/H5Support/Test/H5UtilitiesTest.cpp b/Source/H5Support/Test/H5UtilitiesTest.cpp deleted file mode 100644 index e13162ddd4..0000000000 --- a/Source/H5Support/Test/H5UtilitiesTest.cpp +++ /dev/null @@ -1,538 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2007, 2010 Michael A. Jackson for BlueQuartz Software -// All rights reserved. -// BSD License: http://www.opensource.org/licenses/bsd-license.html -// -// This code was written under United States Air Force Contract number -// FA8650-04-C-5229 -// -/////////////////////////////////////////////////////////////////////////////// - -#include -#ifdef _MSC_VER -#include - -/* -"It's a known, long-standing bug in the compiler system's headers. For -some reason the manufacturer, in its infinite wisdom, chose to #define -macros min() and max() in violation of the upper-case convention and so -break any legitimate functions with those names, including those in the -standard C++ library." -*/ - -#ifndef NOMINMAX -#define NOMINMAX -#endif - -#define WINDOWS_LARGE_FILE_SUPPORT -#if _MSC_VER < 1400 -#define snprintf _snprintf -#else -#define snprintf sprintf_s -#endif - -#endif - -//-- C++ includes -#include -#include -#include - -#include -#include -#include - -#include "H5Support/QH5Lite.h" -#include "H5Support/QH5Utilities.h" -#include "H5SupportTestFileLocations.h" - -// THIS IS REALLY DANGEROUS AS IT COULD SETUP A CIRCULAR REFERENCE WITH LIBRARY DEPENDECIES. -#include "UnitTestSupport.hpp" - -#define DIM 6 -#define DIM0 4 -#define DIM1 3 -#define DIM2 2 - -#define RANK_1D 1 -#define RANK_2D 2 -#define RANK_3D 3 - -class H5UtilitiesTest -{ -public: - H5UtilitiesTest() = default; - virtual ~H5UtilitiesTest() = default; - - int32_t AttrSize = 0; - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void RemoveTestFiles() - { -#if REMOVE_TEST_FILES - QFile::remove(UnitTest::H5UtilTest::FileName); -#endif - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testWritePointer1DArrayAttribute(hid_t file_id, const QString& dsetName) - { - AttrSize++; - T value = 0x0; - herr_t err = -1; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - attributeKey = "1DArrayAttribute<" + attributeKey + ">"; - int32_t rank = 1; - T data[DIM0]; - for(int i = 0; i < DIM0; ++i) - { - data[i] = (T)(i); - } - hsize_t dims[1]; - dims[0] = DIM0; - - err = QH5Lite::writePointerAttribute(file_id, dsetName, attributeKey, rank, dims, (T*)data); - DREAM3D_REQUIRE(err >= 0); - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testWritePointer2DArrayAttribute(hid_t file_id, const QString& dsetName) - { - // std::cout << DEBUG_OUT(logTime) << "testWritePointer2DArrayAttribute"; - AttrSize++; - T value = 0x0; - herr_t err = -1; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - - attributeKey = "2DArrayAttribute<" + attributeKey + ">"; - int32_t rank = RANK_2D; - T data[DIM0][DIM1]; - for(int i = 0; i < DIM0; ++i) - { - for(int j = 0; j < DIM1; ++j) - { - data[i][j] = (T)(i * j); - } - } - hsize_t dims[RANK_2D]; - dims[0] = DIM0; - dims[1] = DIM1; - err = QH5Lite::writePointerAttribute(file_id, dsetName, attributeKey, rank, dims, (T*)data); - DREAM3D_REQUIRE(err >= 0); - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testWritePointer3DArrayAttribute(hid_t file_id, const QString& dsetName) - { - AttrSize++; - T value = 0x0; - herr_t err = -1; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - attributeKey = "3DArrayAttribute<" + attributeKey + ">"; - int32_t rank = RANK_3D; - T data[DIM0][DIM1][DIM2]; - for(int i = 0; i < DIM0; ++i) - { - for(int j = 0; j < DIM1; ++j) - { - for(int k = 0; k < DIM2; ++k) - { - data[i][j][k] = (T)(i * j * k); - } - } - } - hsize_t dims[RANK_3D]; - dims[0] = DIM0; - dims[1] = DIM1; - dims[2] = DIM2; - err = QH5Lite::writePointerAttribute(file_id, dsetName, attributeKey, rank, dims, (T*)data); - DREAM3D_REQUIRE(err >= 0); - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testWriteVectorAttribute(hid_t file_id, QString dsetName) - { - AttrSize++; - T value = 0x0; - herr_t err = -1; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - attributeKey = "VectorAttribute<" + attributeKey + ">"; - - int32_t numElements = DIM0; - QVector dims(1, DIM0); - - /* Make dataset */ - QVector data(DIM0, 0); - for(int i = 0; i < numElements; ++i) - { - data[i] = (T)(i); - } - // std::cout << "Attribute->Write: " << objName; - err = QH5Lite::writeVectorAttribute(file_id, dsetName, attributeKey, dims, data); - DREAM3D_REQUIRE(err >= 0); - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template herr_t testWriteScalarAttribute(hid_t file_id, const QString& dsetName) - { - AttrSize++; - T value = 0x0F; - herr_t err = -1; - QString attributeKey = QH5Lite::HDFTypeForPrimitiveAsStr(value); - DREAM3D_REQUIRE(attributeKey.isEmpty() == false); - attributeKey = "ScalarAttribute<" + attributeKey + ">"; - err = QH5Lite::writeScalarAttribute(file_id, dsetName, attributeKey, value); - DREAM3D_REQUIRE(err >= 0); - return err; - } - - // ----------------------------------------------------------------------------- - // Uses Raw Pointers to save data to the data file - // ----------------------------------------------------------------------------- - template herr_t testWritePointer2DArrayDataset(hid_t file_id) - { - - T value = 0x0; - herr_t err = 1; - int32_t rank = 2; - // Create the Dimensions - hsize_t dims[2]; - dims[0] = DIM0; - dims[1] = DIM1; - - /* Make dataset char */ - int32_t tSize = dims[0] * dims[1]; - // T data[dimx*dimy]; - std::vector data(tSize); - for(int32_t i = 0; i < tSize; ++i) - { - data[i] = static_cast(i * 5); - } - - QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(value); - dsetName = "Pointer2DArrayDataset<" + dsetName + ">"; - qDebug() << "Running " << dsetName << " ... "; - err = QH5Lite::writePointerDataset(file_id, dsetName, rank, dims, &(data.front())); - DREAM3D_REQUIRE(err >= 0); - - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - err = testWritePointer3DArrayAttribute(file_id, dsetName); - - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - err = testWritePointer1DArrayAttribute(file_id, dsetName); - - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - err = testWritePointer2DArrayAttribute(file_id, dsetName); - - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - err = testWriteVectorAttribute(file_id, dsetName); - - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - err = testWriteScalarAttribute(file_id, dsetName); - - std::cout << " Passed"; - return err; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void QH5UtilitiesTest() - { - // herr_t err = -1; - hid_t file_id; - /* Create a new file using default properties. */ - file_id = H5Fcreate(UnitTest::H5UtilTest::FileName.toStdString().c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - DREAM3D_REQUIRE(file_id > 0); - - // std::cout << logTime() << "----------- Testing Writing/Reading of Datasets using Raw Pointers -----------"; - DREAM3D_REQUIRE(testWritePointer2DArrayDataset(file_id) >= 0); - - hid_t dsetId = QH5Utilities::openHDF5Object(file_id, "Pointer2DArrayDataset"); - DREAM3D_REQUIRE(dsetId > 0); - - DREAM3D_REQUIRE(QH5Utilities::isGroup(file_id, "/") == true); - DREAM3D_REQUIRE(QH5Utilities::isGroup(file_id, "Pointer2DArrayDataset") == false); - - QString objName; - int32_t err = QH5Utilities::objectNameAtIndex(file_id, 0, objName); - DREAM3D_REQUIRE(objName.compare("Pointer2DArrayDataset") == 0); - - int32_t objType = -1; - err = QH5Utilities::getObjectType(file_id, "Pointer2DArrayDataset", &objType); - DREAM3D_REQUIRE(objType == H5O_TYPE_DATASET); - DREAM3D_REQUIRE(err >= 0); - - err = QH5Utilities::getObjectType(file_id, "/", &objType); - DREAM3D_REQUIRE(objType == H5O_TYPE_GROUP); - DREAM3D_REQUIRE(err >= 0); - - QString objPath = QH5Utilities::getObjectPath(dsetId, false); - DREAM3D_REQUIRE(objPath.compare("Pointer2DArrayDataset") == 0); - - err = QH5Utilities::closeHDF5Object(dsetId); - DREAM3D_REQUIRE(err >= 0); - - DREAM3D_REQUIRE(QH5Utilities::createGroupsFromPath("/Test Path 1", file_id) >= 0); - DREAM3D_REQUIRE(QH5Utilities::createGroupsFromPath("/Test Path 2/", file_id) >= 0); - DREAM3D_REQUIRE(QH5Utilities::createGroupsFromPath("Test Path 3/", file_id) >= 0); - DREAM3D_REQUIRE(QH5Utilities::createGroupsFromPath("/", file_id) < 0); - DREAM3D_REQUIRE(QH5Utilities::createGroupsFromPath("/Test Path 4/Test Path 7", file_id) >= 0); - DREAM3D_REQUIRE(QH5Utilities::createGroupsFromPath("/Test Path 5/Test Path 8/", file_id) >= 0); - DREAM3D_REQUIRE(QH5Utilities::createGroupsFromPath("Test Path 6/Test Path 9/", file_id) >= 0); - - hid_t grpId = QH5Utilities::openHDF5Object(file_id, "Test Path 1"); - DREAM3D_REQUIRE(grpId > 0); - DREAM3D_REQUIRE(QH5Utilities::createGroupsFromPath("/Test Path 1", grpId) >= 0); - DREAM3D_REQUIRE(QH5Utilities::createGroupsFromPath("/Test Path 2/", grpId) >= 0); - DREAM3D_REQUIRE(QH5Utilities::createGroupsFromPath("Test Path 3/", grpId) >= 0); - DREAM3D_REQUIRE(QH5Utilities::createGroupsFromPath("/", grpId) < 0); - DREAM3D_REQUIRE(QH5Utilities::createGroupsFromPath("/Test Path 4/Test Path 7", grpId) >= 0); - DREAM3D_REQUIRE(QH5Utilities::createGroupsFromPath("/Test Path 5/Test Path 8/", grpId) >= 0); - DREAM3D_REQUIRE(QH5Utilities::createGroupsFromPath("Test Path 6/Test Path 9/", grpId) >= 0); - err = H5Gclose(grpId); - DREAM3D_REQUIRE(err >= 0); - - hid_t gid = QH5Utilities::createGroup(file_id, "test group"); - DREAM3D_REQUIRE(gid >= 0); - err = QH5Utilities::closeHDF5Object(gid); - - QList groups; - err = QH5Utilities::getGroupObjects(file_id, H5Utilities::H5Support_ANY, groups); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(groups.size() == 8); - - err = QH5Utilities::createGroupsForDataset("/group1/group2/group3/data", file_id); - DREAM3D_REQUIRE(err >= 0); - gid = QH5Utilities::openHDF5Object(file_id, "/group1/group2"); - DREAM3D_REQUIRE(gid >= 0); - err = QH5Utilities::closeHDF5Object(gid); - -#if 0 - bool success = QH5Utilities::probeForAttribute(file_id, "Pointer2DArrayDataset", "ScalarAttribute" ); - DREAM3D_REQUIRE(success == true); - - success = QH5Utilities::probeForAttribute(file_id, "Pointer2DArrayDataset", "ScalarAttribute<>" ); - DREAM3D_REQUIRE(success == false); -#endif - - QList attributes; - err = QH5Utilities::getAllAttributeNames(file_id, "Pointer2DArrayDataset", attributes); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(attributes.size() == AttrSize); - - dsetId = QH5Utilities::openHDF5Object(file_id, "Pointer2DArrayDataset"); - DREAM3D_REQUIRE(dsetId > 0); - attributes.clear(); - err = QH5Utilities::getAllAttributeNames(dsetId, attributes); - DREAM3D_REQUIRE(err >= 0); - DREAM3D_REQUIRE(attributes.size() == AttrSize); - err = QH5Utilities::closeHDF5Object(dsetId); - DREAM3D_REQUIRE(err >= 0); - - err = QH5Utilities::closeFile(file_id); - DREAM3D_REQUIRE(err >= 0); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void StressTestCreateGroups() - { - qDebug() << QDateTime::currentDateTime() << " Starting StressTestCreateGroups()"; - char path[64]; - ::memset(path, 0, 64); - int err = 0; - hid_t file_id; - hid_t grpId; - - /* Create a new file using default properties. */ - file_id = H5Fcreate(UnitTest::H5UtilTest::GroupTest.toStdString().c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - DREAM3D_REQUIRE(file_id > 0); - - for(int i = 0; i < 100; ++i) - { - qDebug() << QDateTime::currentDateTime() << "Outer Loop: " << i; - // err = H5Fclose(file_id); - // DREAM3D_REQUIRE(err >= 0); - // file_id = H5Fopen(MXAUnitTest::H5UtilTest::GroupTest.toStdString().c_str(), H5F_ACC_RDWR, H5P_DEFAULT); - ::memset(path, 0, 64); - snprintf(path, 64, "/%03d", i); - grpId = QH5Utilities::createGroup(file_id, path); - DREAM3D_REQUIRE(grpId > 0); - err = H5Gclose(grpId); - DREAM3D_REQUIRE(err >= 0); - - for(int j = 0; j < 100; ++j) - { - - snprintf(path, 64, "/%03d/%03d", i, j); - grpId = QH5Utilities::createGroup(file_id, path); - DREAM3D_REQUIRE(grpId > 0); - DREAM3D_REQUIRE(grpId > 0); - err = H5Gclose(grpId); - DREAM3D_REQUIRE(err >= 0); - - for(int k = 0; k < 100; ++k) - { - - snprintf(path, 64, "/%03d/%03d/%03d", i, j, k); - grpId = QH5Utilities::createGroup(file_id, path); - DREAM3D_REQUIRE(grpId >= 0); - DREAM3D_REQUIRE(grpId > 0); - err = H5Gclose(grpId); - DREAM3D_REQUIRE(err >= 0); - } - } - } - err = H5Fclose(file_id); - DREAM3D_REQUIRE(err >= 0); - } - -// ----------------------------------------------------------------------------- -// This function tests if we can write a data set larger than 2GB on Darwin/Apple -// systems. There is a bug in HDF5 versions up to and including 1.8.9 where this -// type of write will fail. This was used to report the bug to HDFGroup and should -// NOT be used for any test. At least not yet. -// ----------------------------------------------------------------------------- -#if __APPLE__ - void HDF5Darwin2GBWriteTest() - { - std::cout << "sizeof(ssize_t): " << sizeof(ssize_t); - size_t dim1 = 3; - size_t dim0 = 178956971; - int* data = (int*)(malloc(sizeof(int) * dim0 * dim1)); - - hid_t file_id; - /* Create a new file using default properties. */ - file_id = H5Fcreate("/tmp/HDF5_LARGE_WRITE_BUG.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - DREAM3D_REQUIRE(file_id > 0); - int32_t rank = 2; - hsize_t dims[2] = {dim0, dim1}; - - herr_t err = QH5Lite::writePointerDataset(file_id, "data", rank, dims, data); - DREAM3D_REQUIRE(err > -1); - } -#endif - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestOpenSameFile2x() - { - - herr_t err = -1; - hid_t file_id; - /* Create a new file using default properties. */ - file_id = H5Fcreate(UnitTest::H5UtilTest::FileName.toStdString().c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - DREAM3D_REQUIRE(file_id > 0); - - hid_t gid = H5Utilities::createGroup(file_id, "TestGroup"); - hid_t gid2 = H5Utilities::createGroup(file_id, "TestGroup2"); - - // std::cout << logTime() << "----------- Testing Writing/Reading of Datasets using Raw Pointers -----------"; - DREAM3D_REQUIRE(testWritePointer2DArrayDataset(gid) >= 0); - err = H5Gclose(gid); - err = H5Gclose(gid2); - gid = 0; - - err = H5Fclose(file_id); - file_id = 0; - - hid_t fileId = QH5Utilities::openFile(UnitTest::H5UtilTest::FileName.toStdString().c_str(), true); // Open the file Read Only - hid_t dcaGid = H5Gopen(fileId, "TestGroup", 0); - - { - hid_t fileId2 = QH5Utilities::openFile(UnitTest::H5UtilTest::FileName.toStdString().c_str(), true); // Open the file Read Only - hid_t dcaGid2 = H5Gopen(fileId2, "TestGroup2", 0); - err = H5Gclose(dcaGid2); - dcaGid2 = 0; - err = H5Utilities::closeFile(fileId2); - DREAM3D_REQUIRE(err == 0); - } - - err = H5Gclose(dcaGid); - DREAM3D_REQUIRE(err == 0); - - err = H5Utilities::closeFile(fileId); - DREAM3D_REQUIRE(err == 0); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void operator()() - { - - int err = EXIT_SUCCESS; - - DREAM3D_REGISTER_TEST(QH5UtilitiesTest()) - DREAM3D_REGISTER_TEST(TestOpenSameFile2x()) - DREAM3D_REGISTER_TEST(RemoveTestFiles()) - } - -private: - H5UtilitiesTest(const H5UtilitiesTest&); // Copy Constructor Not Implemented - void operator=(const H5UtilitiesTest&); // Move assignment Not Implemented -}; diff --git a/Source/H5Support/Test/TestFileLocations.h.in b/Source/H5Support/Test/TestFileLocations.h.in deleted file mode 100755 index f4ef4aa24a..0000000000 --- a/Source/H5Support/Test/TestFileLocations.h.in +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef _TestFileLocation_h_ -#define _TestFileLocation_h_ - -#include - -#define REMOVE_TEST_FILES 1 - -/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - * - * THIS FILE IS AUTO GENERATED AT CMAKE TIME. DO NOT EDIT THIS FILE. EDIT THE ORIGINAL TEMPLATE FILE - * LOCATED AT @DREAM3DProj_SOURCE_DIR@/Test/TestFileLocations.h.in - * - * -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ - - -namespace UnitTest -{ - - const QString DataDir("@DREAM3D_DATA_DIR@"); - const QString TestTempDir("@TEST_TEMP_DIR@"); - const QString DREAM3DProjDir("@DREAM3DProj_SOURCE_DIR@"); - - // ----------------------------------------------------------------------------- - // Define where to put our temporary files for the H5Utilities Test - // ----------------------------------------------------------------------------- - namespace H5UtilTest - { - const QString TestDir("H5UtilTest"); - const QString FileName("@TEST_TEMP_DIR@/H5Utilities_Test.h5"); - const QString GroupTest("@TEST_TEMP_DIR@/H5Utilities_GroupTest.h5"); - } - - // ----------------------------------------------------------------------------- - // Define where to put our temporary files for the H5Lite Test - // ----------------------------------------------------------------------------- - namespace H5LiteTest - { - const QString TestDir("@TEST_TEMP_DIR@/H5LiteTest"); - const QString FileName("@TEST_TEMP_DIR@/H5Lite_Test.h5"); - const QString LargeFile("@TEST_TEMP_DIR@/H5Lite_LargeFile_Test.h5"); - const QString VLengthFile("@TEST_TEMP_DIR@/H5Lite_VLength.h5"); - } - -} - -#endif diff --git a/Source/H5Support/Test/TestMain.cpp.in b/Source/H5Support/Test/TestMain.cpp.in deleted file mode 100644 index 2faf05901e..0000000000 --- a/Source/H5Support/Test/TestMain.cpp.in +++ /dev/null @@ -1,54 +0,0 @@ - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Winconsistent-missing-override" -#endif - -#if 0 -#include - -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Filtering/FilterManager.h" -#include "SIMPLib/Plugin/ISIMPLibPlugin.h" -#include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/Utilities/UnitTestSupport.hpp" -#include "SIMPLib/Utilities/QMetaObjectUtilities.h" - -#endif - -@FilterTestIncludes@ - - -// ----------------------------------------------------------------------------- -// Use test framework -// ----------------------------------------------------------------------------- -int main(int argc, char** argv) -{ - int err = EXIT_SUCCESS; - -#if 0 - // Instantiate the QCoreApplication that we need to get the current path and load plugins. - QCoreApplication app(argc, argv); - QCoreApplication::setOrganizationName("Your Company"); - QCoreApplication::setOrganizationDomain("Your Domain"); - QCoreApplication::setApplicationName("@PluginName@"); - // Register all the filters including trying to load those from Plugins - FilterManager* fm = FilterManager::Instance(); - SIMPLibPluginLoader::LoadPluginFilters(fm); - - // Send progress messages from PipelineBuilder to this object for display - QMetaObjectUtilities::RegisterMetaTypes(); -#endif - - @TestMainFunctors@ - - - PRINT_TEST_SUMMARY(); - - return err; -} - - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif diff --git a/Source/MakeFilterUuid/MakeFilterUuid.cpp b/Source/MakeFilterUuid/MakeFilterUuid.cpp index 4043511e54..0709831b24 100644 --- a/Source/MakeFilterUuid/MakeFilterUuid.cpp +++ b/Source/MakeFilterUuid/MakeFilterUuid.cpp @@ -1,9 +1,9 @@ +#include - +#include #include -#include #include -#include +#include /** * @brief main @@ -11,9 +11,13 @@ * @param argv * @return */ -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - + if(argc != 3) + { + std::cout << "Please supply 2 arguments\n LibraryName\n ClassName\n"; + return 1; + } QString libName = QString::fromLatin1(argv[1]); QString className = QString::fromLatin1(argv[2]); diff --git a/Source/PipelineRunner/CMakeLists.txt b/Source/PipelineRunner/CMakeLists.txt index ada9817e71..b31a3c79c6 100644 --- a/Source/PipelineRunner/CMakeLists.txt +++ b/Source/PipelineRunner/CMakeLists.txt @@ -1,7 +1,7 @@ # set project's name PROJECT( SIMPLTools ) -cmake_minimum_required(VERSION 3.8.0) +cmake_minimum_required(VERSION 3.14.0) # -------------------------------------------------------------------- # Setup the install rules for the various platforms @@ -17,6 +17,10 @@ elseif(WIN32) set(lib_install_dir ".") endif() +if(DREAM3D_ANACONDA AND WIN32) + set(install_dir "bin") + set(lib_install_dir "bin") +endif() #------------------------------------------------------------------------------- # Function COMPILE_TOOL to help alleviate lots of extra code below for adding @@ -63,5 +67,8 @@ if(SIMPL_Group_PLUGIN AND SIMPL_Group_BASE AND SIMPL_Group_FILTERS) INSTALL_DEST "${install_dir}" LINK_LIBRARIES SIMPLib Qt5::Core ) -endif() + if(DREAM3D_ANACONDA) + target_compile_definitions(PipelineRunner PRIVATE DREAM3D_ANACONDA) + endif() +endif() diff --git a/Source/PipelineRunner/PipelineRunner.cpp b/Source/PipelineRunner/PipelineRunner.cpp index eb9f2a4ddb..40fc11590b 100644 --- a/Source/PipelineRunner/PipelineRunner.cpp +++ b/Source/PipelineRunner/PipelineRunner.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ // C Includes #include @@ -43,15 +43,17 @@ // Qt Includes #include #include - #include -#include +#include #include -#include +#include #include -#include // DREAM3DLib includes +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/FilterParameters/H5FilterParametersReader.h" #include "SIMPLib/FilterParameters/JsonFilterParametersReader.h" @@ -61,17 +63,44 @@ #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/SIMPLibVersion.h" + +#ifdef SIMPL_EMBED_PYTHON +#include "SIMPLib/Python/PythonLoader.h" +#endif // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int main(int argc, char* argv[]) { +#ifdef DREAM3D_ANACONDA + { + constexpr const char k_PYTHONHOME[] = "PYTHONHOME"; + QString condaPrefix = qgetenv("CONDA_PREFIX"); + + QString pythonHome = qgetenv(k_PYTHONHOME); + if(pythonHome.isEmpty() && !condaPrefix.isEmpty()) + { + qputenv(k_PYTHONHOME, condaPrefix.toLocal8Bit()); + } + + qputenv("DREAM3D_PLUGINS_LOADED", "1"); + } +#endif + +#ifdef SIMPL_EMBED_PYTHON + bool hasPythonHome = PythonLoader::checkPythonHome(); + + if(!hasPythonHome) + { + std::cout << "Warning: \"PYTHONHOME\" not set. This environment variable must be set for embedded Python to work.\n"; + } + + PythonLoader::ScopedInterpreter interpreter_guard{hasPythonHome}; +#endif // Instantiate the QCoreApplication that we need to get the current path and load plugins. - QCoreApplication* app = new QCoreApplication(argc, argv); + QCoreApplication app(argc, argv); QCoreApplication::setOrganizationName("BlueQuartz Software"); QCoreApplication::setOrganizationDomain("bluequartz.net"); QCoreApplication::setApplicationName("PipelineRunner"); @@ -93,17 +122,34 @@ int main(int argc, char* argv[]) parser.addOption(pipelineFileArg); // Process the actual command line arguments given by the user - parser.process(*app); + parser.process(app); QString pipelineFile = parser.value(pipelineFileArg); - std::cout << "PipelineRunner Starting. " << std::endl; - std::cout << " " << SIMPLib::Version::PackageComplete().toStdString() << std::endl; + std::cout << "PipelineRunner " << SIMPLib::Version::PackageComplete().toStdString() << std::endl; + std::cout << "Input File: " << pipelineFile.toStdString() << std::endl; // Register all the filters including trying to load those from Plugins FilterManager* fm = FilterManager::Instance(); SIMPLibPluginLoader::LoadPluginFilters(fm); +#ifdef SIMPL_EMBED_PYTHON + if(hasPythonHome) + { + PythonLoader::addToPythonPath(PythonLoader::defaultSIMPLPythonLibPath()); + std::cout << "Loading Python filters:\n"; + auto paths = PythonLoader::defaultPythonFilterPaths(); + for(const auto& path : paths) + { + std::cout << "Searching \"" << path << "\"\n"; + } + auto pythonErrorCallback = [](const std::string& message, const std::string& filePath) { std::cout << message << "\nSkipping file: \"" << filePath << "\"\n"; }; + auto pythonLoadedCallback = [](const std::string& className, const std::string& filePath) { std::cout << "Loaded \"" << className << "\" from \"" << filePath << "\"\n"; }; + size_t numLoaded = PythonLoader::loadPythonFilters(*fm, paths, pythonErrorCallback, pythonLoadedCallback); + std::cout << "Loaded " << numLoaded << " filters\n"; + } +#endif + QMetaObjectUtilities::RegisterMetaTypes(); int err = 0; @@ -154,7 +200,7 @@ int main(int argc, char* argv[]) } // Now actually execute the pipeline pipeline->execute(); - err = pipeline->getErrorCondition(); + err = pipeline->getErrorCode(); if(err < 0) { std::cout << "Error Condition of Pipeline: " << err << std::endl; diff --git a/Source/RESTClient/CMakeLists.txt b/Source/RESTClient/CMakeLists.txt index ba0cdd52c8..a96c7d59f9 100755 --- a/Source/RESTClient/CMakeLists.txt +++ b/Source/RESTClient/CMakeLists.txt @@ -52,7 +52,7 @@ set(RESTClient_HDRS ${RESTClient_SOURCE_DIR}/mrestrequestmanager.h ${RESTClient_SOURCE_DIR}/mrestrequestptr.h ${RESTClient_SOURCE_DIR}/mrestrequestqueue.h - ${RESTClient_SOURCE_DIR}/RESTClientDLLExport + ${RESTClient_SOURCE_DIR}/RESTClientDLLExport.h ${RESTClient_SOURCE_DIR}/SIMPLClientRequest.h ${RESTClient_SOURCE_DIR}/SIMPLRestClient.h ${RESTClient_SOURCE_DIR}/userptr.h diff --git a/Source/RESTClient/RESTClientDLLExport.h b/Source/RESTClient/RESTClientDLLExport.h old mode 100755 new mode 100644 index 0f4a7db06e..95a0a3221c --- a/Source/RESTClient/RESTClientDLLExport.h +++ b/Source/RESTClient/RESTClientDLLExport.h @@ -1,55 +1,50 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - - - - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once - -#if defined (_MSC_VER) -#pragma warning(disable: 4251) -#pragma warning(disable: 4710) -#pragma warning(disable: 4820) -#pragma warning(disable: 4668) -#pragma warning(disable: 4265) -#pragma warning(disable: 4189) -#pragma warning(disable: 4640) -#pragma warning(disable: 4996) -#pragma warning(disable: 4548) +#if defined(_MSC_VER) +#pragma warning(disable : 4251) +#pragma warning(disable : 4710) +#pragma warning(disable : 4820) +#pragma warning(disable : 4668) +#pragma warning(disable : 4265) +#pragma warning(disable : 4189) +#pragma warning(disable : 4640) +#pragma warning(disable : 4996) +#pragma warning(disable : 4548) #endif /* Cmake will define RESTClient_EXPORTS on Windows when it @@ -59,19 +54,19 @@ projects by hand you need to define RESTClient_EXPORTS when building the RESTClientDatModel DLL on windows. */ -#if defined (RESTClient_BUILT_AS_DYNAMIC_LIB) +#if defined(RESTClient_BUILT_AS_DYNAMIC_LIB) -#if defined (RESTClient_EXPORTS) /* Compiling the RESTClient DLL/Dylib */ -#if defined (_MSC_VER) /* MSVC Compiler Case */ -#define RESTClient_EXPORT __declspec(dllexport) -#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ -#define RESTClient_EXPORT __attribute__ ((visibility("default"))) +#if defined(RESTClient_EXPORTS) /* Compiling the RESTClient DLL/Dylib */ +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define RESTClient_EXPORT __declspec(dllexport) +#elif(__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define RESTClient_EXPORT __attribute__((visibility("default"))) #endif -#else /* Importing the DLL into another project */ -#if defined (_MSC_VER) /* MSVC Compiler Case */ -#define RESTClient_EXPORT __declspec(dllimport) -#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ -#define RESTClient_EXPORT __attribute__ ((visibility("default"))) +#else /* Importing the DLL into another project */ +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define RESTClient_EXPORT __declspec(dllimport) +#elif(__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define RESTClient_EXPORT __attribute__((visibility("default"))) #endif #endif #endif @@ -82,24 +77,22 @@ building the RESTClientDatModel DLL on windows. #endif #if 0 -#if defined (_WIN32) || defined __CYGWIN__ +#if defined(_WIN32) || defined __CYGWIN__ -#if defined (RESTClient_BUILT_AS_DYNAMIC_LIB) +#if defined(RESTClient_BUILT_AS_DYNAMIC_LIB) #if defined(RESTClient_EXPORTS) -#define RESTClient_EXPORT __declspec(dllexport) +#define RESTClient_EXPORT __declspec(dllexport) #else -#define RESTClient_EXPORT __declspec(dllimport) +#define RESTClient_EXPORT __declspec(dllimport) #endif /* RESTClient_EXPORTS */ #else #define RESTClient_EXPORT #endif #elif __GNUC__ >= 4 -#define FLOW_DLL __attribute__ ((visibility("default"))) +#define FLOW_DLL __attribute__((visibility("default"))) #define DLL_LOCAL __attribute__ ((visibility("hidden") #else /* defined (_WIN32) && defined (RESTClient_BUILD_SHARED_LIBS) */ #define RESTClient_EXPORT #endif #endif - - diff --git a/Source/RESTClient/SIMPLClientRequest.cpp b/Source/RESTClient/SIMPLClientRequest.cpp index b74d475899..050d83917a 100644 --- a/Source/RESTClient/SIMPLClientRequest.cpp +++ b/Source/RESTClient/SIMPLClientRequest.cpp @@ -68,9 +68,9 @@ void SIMPLClientRequest::parseReplyData() const QJsonObject object(mReplyDocument.object()); QByteArray out = mReplyDocument.toJson(QJsonDocument::Indented); - emit notifyStatusMessage(out.data()); + Q_EMIT notifyStatusMessage(out.data()); - emit finished(); + Q_EMIT finished(); - // emit replyInfo(cityName, humidity, pressure, temp); + // Q_EMIT replyInfo(cityName, humidity, pressure, temp); } diff --git a/Source/RESTClient/SIMPLClientRequest.h b/Source/RESTClient/SIMPLClientRequest.h index ea750d8d27..bde65c8a0e 100644 --- a/Source/RESTClient/SIMPLClientRequest.h +++ b/Source/RESTClient/SIMPLClientRequest.h @@ -37,7 +37,7 @@ class RESTClient_EXPORT SIMPLClientRequest : public MRestRequest public: SIMPLClientRequest(QUrl url, Command command, Type msgType, QJsonObject jsonMsg = QJsonObject()); -signals: +Q_SIGNALS: void replyInfo(const QString& cityName, int humidity, int pressure, float temp) const; protected: diff --git a/Source/RESTClient/SIMPLRestClient.cpp b/Source/RESTClient/SIMPLRestClient.cpp index 37e2583a40..d6595a05a3 100644 --- a/Source/RESTClient/SIMPLRestClient.cpp +++ b/Source/RESTClient/SIMPLRestClient.cpp @@ -141,7 +141,7 @@ QSharedPointer SIMPLRestClient::createRequest(SIMPLClientReq m_NumOfActiveRequests--; if(m_NumOfActiveRequests <= 0) { - emit finished(); + Q_EMIT finished(); } }); diff --git a/Source/RESTClient/SIMPLRestClient.h b/Source/RESTClient/SIMPLRestClient.h index 24b75fa653..55abd96604 100644 --- a/Source/RESTClient/SIMPLRestClient.h +++ b/Source/RESTClient/SIMPLRestClient.h @@ -61,7 +61,7 @@ class RESTClient_EXPORT SIMPLRestClient : public MRestRequestManager void setServerUrl(QUrl url); -signals: +Q_SIGNALS: void notifyErrorMessage(const QString& msg); void notifyWarningMessage(const QString& msg); void notifyStatusMessage(const QString& msg); diff --git a/Source/RESTClient/config.cpp b/Source/RESTClient/config.cpp index 5312f0ecf1..01a0dfd492 100644 --- a/Source/RESTClient/config.cpp +++ b/Source/RESTClient/config.cpp @@ -51,7 +51,7 @@ void Config::load() { QSettings settings; settings.beginGroup(mGroupName); - foreach(const QByteArray& key, mValues.keys()) + for(const QByteArray& key : mValues.keys()) { copyValue(mValues.value(key).ptr, mValues.value(key).type, settings.value(key)); } @@ -64,7 +64,7 @@ void Config::save() { QSettings settings; settings.beginGroup(mGroupName); - foreach(const QByteArray& key, mValues.keys()) + for(const QByteArray& key : mValues.keys()) { QVariant value(mValues.value(key).type, mValues.value(key).ptr); settings.setValue(key, value); diff --git a/Source/RESTClient/mrestrequest.cpp b/Source/RESTClient/mrestrequest.cpp index 2b2884ef10..b96c21cf9f 100644 --- a/Source/RESTClient/mrestrequest.cpp +++ b/Source/RESTClient/mrestrequest.cpp @@ -172,7 +172,7 @@ void MRestRequest::send() { Q_ASSERT(mNetworkManager); QString msg = tr("%1 - Try %2").arg(m_RequestUrl.toDisplayString()).arg(QString::number(mRequestRetryCounter)); - emit notifyStatusMessage(msg); + Q_EMIT notifyStatusMessage(msg); mReplyData.clear(); QNetworkRequest request(m_RequestUrl); request.setOriginatingObject(this); @@ -180,7 +180,7 @@ void MRestRequest::send() if(mType == Type::None) { QString errMsg = "Request type is set to None - can't send. Please set request type to Put, Post, Get or Delete"; - emit notifyErrorMessage(errMsg); + Q_EMIT notifyErrorMessage(errMsg); } else if(mType == Type::Put) { @@ -208,7 +208,12 @@ void MRestRequest::send() connect(mActiveReply, &QNetworkReply::finished, this, &MRestRequest::onReplyFinished); connect(mActiveReply, &QNetworkReply::readyRead, mRequestTimer, static_cast(&QTimer::start)); connect(mActiveReply, &QNetworkReply::readyRead, this, &MRestRequest::onReadyRead); +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) connect(mActiveReply, static_cast(&QNetworkReply::error), this, &MRestRequest::onReplyError); +#else + connect(mActiveReply, static_cast(&QNetworkReply::errorOccurred), this, &MRestRequest::onReplyError); +#endif + mRequestTimer->start(); } @@ -229,7 +234,7 @@ void MRestRequest::retry() if(mActiveReply->bytesAvailable()) { QString msg = QObject::tr("Retrying request, %1 bytes lost.").arg(mActiveReply->bytesAvailable()); - emit notifyStatusMessage(msg); + Q_EMIT notifyStatusMessage(msg); send(); } } @@ -247,7 +252,7 @@ void MRestRequest::onReplyError(QNetworkReply::NetworkError code) reply->deleteLater(); mRequestTimer->stop(); mLastError = reply->errorString(); - emit notifyErrorMessage(mLastError); + Q_EMIT notifyErrorMessage(mLastError); } } @@ -284,8 +289,8 @@ void MRestRequest::onReplyFinished() if(mReplyData.isEmpty()) { - emit notifyErrorMessage(tr("%1 - %2 - Request reply is empty").arg(requestName).arg(status)); - emit finished(); + Q_EMIT notifyErrorMessage(tr("%1 - %2 - Request reply is empty").arg(requestName).arg(status)); + Q_EMIT finished(); return; } @@ -293,24 +298,24 @@ void MRestRequest::onReplyFinished() mReplyDocument = QJsonDocument::fromJson(mReplyData, &parseError); if(parseError.error != QJsonParseError::NoError) { - emit notifyWarningMessage(tr("%1 - %2 - Error while parsing json document: %3").arg(requestName).arg(status).arg(parseError.errorString())); - emit finished(); + Q_EMIT notifyWarningMessage(tr("%1 - %2 - Error while parsing json document: %3").arg(requestName).arg(status).arg(parseError.errorString())); + Q_EMIT finished(); return; } - emit notifyStatusMessage(tr("%1 - request response received").arg(requestName)); + Q_EMIT notifyStatusMessage(tr("%1 - request response received").arg(requestName)); if(mReplyDocument.isNull()) { mLastError = "JSON document is invalid"; - emit notifyStatusMessage(tr("%1 - %2").arg(requestName).arg(mLastError)); - emit finished(); // rawData can still be parsed in another formats + Q_EMIT notifyStatusMessage(tr("%1 - %2").arg(requestName).arg(mLastError)); + Q_EMIT finished(); // rawData can still be parsed in another formats return; } // parse json document according to specific request reply format parseReplyData(); - emit finished(); + Q_EMIT finished(); } /*! diff --git a/Source/RESTClient/mrestrequest.h b/Source/RESTClient/mrestrequest.h index 7857403de6..89e2797b8c 100644 --- a/Source/RESTClient/mrestrequest.h +++ b/Source/RESTClient/mrestrequest.h @@ -73,7 +73,7 @@ class RESTClient_EXPORT MRestRequest : public QObject QJsonDocument document() const; QByteArray rawData() const; -signals: +Q_SIGNALS: void notifyStatusMessage(const QString& msg); void notifyErrorMessage(const QString& msg); void notifyWarningMessage(const QString& msg); @@ -81,7 +81,7 @@ class RESTClient_EXPORT MRestRequest : public QObject void finished() const; void replyError(const QString& msgs) const; -public slots: +public Q_SLOTS: protected: enum class Priority @@ -111,7 +111,7 @@ public slots: QJsonDocument mReplyDocument; QJsonDocument mRequestDocument; -private slots: +private Q_SLOTS: void onReplyError(QNetworkReply::NetworkError code); void onReadyRead(); void onReplyFinished(); diff --git a/Source/RESTClient/mrestrequestmanager.cpp b/Source/RESTClient/mrestrequestmanager.cpp index d6b02aa201..a24fcc85e4 100644 --- a/Source/RESTClient/mrestrequestmanager.cpp +++ b/Source/RESTClient/mrestrequestmanager.cpp @@ -106,7 +106,7 @@ void MRestRequestManager::removeActiveRequest(QObject* sender) return; } - foreach(const MRestRequestPtr& request, mActiveRequests) + for(const MRestRequestPtr& request : mActiveRequests) { if(request.data() == sender) { @@ -136,12 +136,12 @@ void MRestRequestManager::onSslErrors(QNetworkReply* reply, const QListdeleteLater(); mLastSslErrors.clear(); - foreach(QSslError error, errors) + for(QSslError error : errors) { mLastSslErrors << error.errorString(); } - emit sslErrorsChanged(mLastSslErrors); + Q_EMIT sslErrorsChanged(mLastSslErrors); } /*! @} */ diff --git a/Source/RESTClient/mrestrequestmanager.h b/Source/RESTClient/mrestrequestmanager.h index 1ce18948c4..e43523a0c7 100644 --- a/Source/RESTClient/mrestrequestmanager.h +++ b/Source/RESTClient/mrestrequestmanager.h @@ -42,7 +42,7 @@ class RESTClient_EXPORT MRestRequestManager : public QObject MRestRequestManager(QObject* parent = nullptr); void send(MRestRequestPtr request); void ignoreSslErrors(); -signals: +Q_SIGNALS: void sslErrorsChanged(const QStringList& errors); protected: @@ -54,6 +54,6 @@ class RESTClient_EXPORT MRestRequestManager : public QObject bool mIgnoreSslErrors; QNetworkAccessManager* networkManager = nullptr; int MaxActiveRequestsCount = 3; -private slots: +private Q_SLOTS: void onSslErrors(QNetworkReply* reply, const QList& errors); }; diff --git a/Source/RESTClient/mrestrequestqueue.h b/Source/RESTClient/mrestrequestqueue.h index f817b0b9ec..73b2273652 100644 --- a/Source/RESTClient/mrestrequestqueue.h +++ b/Source/RESTClient/mrestrequestqueue.h @@ -23,8 +23,8 @@ SOFTWARE. #pragma once -#include "mrestrequestptr.h" #include +#include "mrestrequestptr.h" #include "RESTClient/RESTClient.h" diff --git a/Source/RESTServer/main.cpp b/Source/RESTServer/main.cpp index 613538ac52..714016bc00 100644 --- a/Source/RESTServer/main.cpp +++ b/Source/RESTServer/main.cpp @@ -38,14 +38,12 @@ #include // Qt Includes -#include -#include #include +#include #include #include #include #include -#include #include "QtWebApp/httpserver/ServerSettings.h" #include "QtWebApp/httpserver/httplistener.h" @@ -53,6 +51,8 @@ #include "QtWebApp/logging/filelogger.h" // DREAM3DLib includes +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/FilterParameters/H5FilterParametersReader.h" #include "SIMPLib/FilterParameters/JsonFilterParametersReader.h" @@ -64,8 +64,6 @@ #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" #include "SIMPLib/REST/SIMPLRequestMapper.h" #include "SIMPLib/REST/V1Controllers/SIMPLStaticFileController.h" -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- // Search the configuration file @@ -79,7 +77,7 @@ QString searchConfigFile() QStringList searchList; searchList.append(binDir); - foreach(QString dir, searchList) + for(QString dir : searchList) { QFile file(dir + "/" + fileName); if(file.exists()) @@ -92,7 +90,7 @@ QString searchConfigFile() } // not found - foreach(QString dir, searchList) + for(QString dir : searchList) { qWarning("%s/%s not found", qPrintable(dir), qPrintable(fileName)); } @@ -142,7 +140,7 @@ int main(int argc, char* argv[]) ServerSettings serverSettings(config); HttpSessionStore* sessionStore = HttpSessionStore::CreateInstance(&serverSettings, &app); - + sessionStore = nullptr; // This is here to quiet the compiler about unused variable. // Configure static file controller SIMPLStaticFileController::CreateInstance(&serverSettings, &app); diff --git a/Source/SIMPLib/CMakeLists.txt b/Source/SIMPLib/CMakeLists.txt index 732a265420..7297684c9b 100755 --- a/Source/SIMPLib/CMakeLists.txt +++ b/Source/SIMPLib/CMakeLists.txt @@ -40,6 +40,10 @@ set(SIMPLib_FILTER_DOC_DIR ${SIMPLib_SOURCE_DIR}/Documentation/${PROJECT_NAME}Fi include(${CMP_SOURCE_DIR}/cmpProject.cmake) +if(BIGENDIAN) + message(FATAL_ERROR "Big endian architecture not supported") +endif() + #-- Configure Target Specific configuration file cmpConfigureFileWithMD5Check(CONFIGURED_TEMPLATE_PATH ${SIMPLib_SOURCE_DIR}/SIMPLibConfiguration.h.in GENERATED_FILE_PATH ${SIMPLib_BINARY_DIR}/${CMP_TOP_HEADER_FILE}) @@ -87,7 +91,11 @@ endMacro() #------------------------------------------------------------------------------ # Set up the directories that are used for each Group -set(SIMPL_Group_BASE_MODULES Common DataArrays DataContainers Geometry HDF5 Math StatsData Utilities ITK) +set(SIMPL_Group_BASE_MODULES Common DataArrays DataContainers Geometry HDF5 Math Messages Montages StatsData Utilities) +if (SIMPL_USE_ITK) + set(SIMPL_Group_BASE_MODULES ${SIMPL_Group_BASE_MODULES} ITK) +endif() + set(SIMPL_Group_FILTERS_MODULES Filtering FilterParameters VTKUtils) set(SIMPL_Group_PLUGIN_MODULES Plugin) set(SIMPL_Group_REST_MODULES REST) @@ -169,18 +177,66 @@ cmpReplaceFileIfDifferent(OLD_FILE_PATH ${SIMPLib_BINARY_DIR}/CoreFilters/Regis NEW_FILE_PATH ${RegisterKnownFiltersFile} ) -set(${PROJECT_NAME}_LINK_LIBS Qt5::Core Qt5::Network H5Support) +set(${PROJECT_NAME}_LINK_LIBS Qt5::Core Qt5::Network H5Support::H5Support) + if( "${SIMPL_USE_MULTITHREADED_ALGOS}" STREQUAL "ON") list(APPEND ${PROJECT_NAME}_LINK_LIBS TBB::tbb TBB::tbbmalloc) endif() -#-- Add a library for the SIMPLib Code +#----------------------------------------------------- +# --- ONLY Mac OS using ITK 5 needs SimpleITKExplicit +get_property(ITK_VERSION_MAJOR GLOBAL PROPERTY ITK_VERSION_MAJOR) +if(APPLE AND "${ITK_VERSION_MAJOR}" STREQUAL "5" AND SIMPL_USE_ITK) + message(STATUS "SimpleITKExplicit Enabled for APPLE build") + list(APPEND ${PROJECT_NAME}_LINK_LIBS SimpleITKExplicit) +endif() + +if(SIMPL_USE_GHC_FILESYSTEM) + list(APPEND ${PROJECT_NAME}_LINK_LIBS ghcFilesystem::ghc_filesystem) +endif() + +if(SIMPL_EMBED_PYTHON) + D3DCompileDir(Python) +endif() + +#------------------------------------------------------------------------------- +# Add the SIMPLib Library add_library(${PROJECT_NAME} ${LIB_TYPE} ${Project_SRCS} ) CMP_AddDefinitions(TARGET ${PROJECT_NAME}) +if(SIMPL_EMBED_PYTHON) + find_package(pybind11 2.6 REQUIRED) + target_link_libraries(${PROJECT_NAME} PRIVATE pybind11::embed) + + if(NOT DREAM3D_ANACONDA) + add_custom_command(TARGET ${PROJECT_NAME} + PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${SIMPLib_SOURCE_DIR}/Python/Filter.py $ + COMMAND ${CMAKE_COMMAND} -E make_directory $/Python + ) + endif() + + if(DREAM3D_ANACONDA) + configure_file(${SIMPLib_SOURCE_DIR}/Python/Filter.py.in ${DREAM3D_PYTHON_PACKAGE_DIR}/Filter.py COPYONLY) + file(APPEND ${DREAM3D_INIT_PY_FILE} "from . import Filter\n") + endif() + + if(NOT DREAM3D_ANACONDA) + install(DIRECTORY DESTINATION "Python") + install(FILES ${SIMPLib_SOURCE_DIR}/Python/Filter.py DESTINATION ".") + endif() +endif() + +if(DREAM3D_ANACONDA) + target_compile_definitions(${PROJECT_NAME} PRIVATE DREAM3D_ANACONDA) +endif() + +# Add H5Support +add_subdirectory(${H5Support_SOURCE_DIR} ${PROJECT_BINARY_DIR}/H5Support) + #-- Add Target specific definitions if(WIN32 AND BUILD_SHARED_LIBS) - target_compile_definitions(${PROJECT_NAME} PUBLIC "-DSIMPLib_BUILT_AS_DYNAMIC_LIB") + target_compile_definitions(${PROJECT_NAME} PUBLIC "-DSIMPLib_BUILT_AS_DYNAMIC_LIB") endif() #-- Configure Target Specific Include Directories @@ -192,8 +248,14 @@ target_include_directories(${PROJECT_NAME} $ $ $ +) + +if( "${SIMPL_USE_MULTITHREADED_ALGOS}" STREQUAL "ON") + target_include_directories(${PROJECT_NAME} + PUBLIC $ ) +endif() if(SIMPL_USE_EIGEN) target_include_directories(${PROJECT_NAME} @@ -246,13 +308,13 @@ endif() if(SIMPL_Group_REST) target_include_directories(${PROJECT_NAME} PUBLIC $) - target_link_libraries(${PROJECT_NAME} QtWebAppLib) + target_link_libraries(${PROJECT_NAME} PUBLIC QtWebAppLib) endif() #-- Configure Link Libraries for the Target LibraryProperties( ${PROJECT_NAME} ${EXE_DEBUG_EXTENSION} ) #-- Link the Target to its dependent libraries -target_link_libraries(${PROJECT_NAME} ${${PROJECT_NAME}_LINK_LIBS}) +target_link_libraries(${PROJECT_NAME} PUBLIC ${${PROJECT_NAME}_LINK_LIBS}) #-- Configure Target Installation Rules set(install_dir "tools") @@ -267,54 +329,60 @@ elseif(WIN32) set(lib_install_dir ".") endif() -INSTALL(TARGETS ${PROJECT_NAME} +if(DREAM3D_ANACONDA AND WIN32) + set(install_dir "bin") + set(lib_install_dir "bin") +endif() + +install(TARGETS ${PROJECT_NAME} + COMPONENT Applications + RUNTIME DESTINATION ${install_dir} + LIBRARY DESTINATION ${lib_install_dir} + BUNDLE DESTINATION "." +) + +if(NOT DREAM3D_ANACONDA) + install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets COMPONENT Applications + ARCHIVE DESTINATION lib RUNTIME DESTINATION ${install_dir} LIBRARY DESTINATION ${lib_install_dir} - ARCHIVE DESTINATION lib - BUNDLE DESTINATION "." -) - - -# -------------------------------------------------------------------- -# Allow the generation and installation of a CMake configuration file -# which makes using SIMPL from another project easier. -# -------------------------------------------------------------------- -export(EXPORT ${PROJECT_NAME}Targets - FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake" - NAMESPACE ${PROJECT_NAME}:: -) - -if(PROJECT_INSTALL_HEADERS) - install(EXPORT SIMPLibTargets - FILE - SIMPLibTargets.cmake - NAMESPACE - SIMPL:: - DESTINATION - ${ConfigPackageLocation} ) - install(FILES - ${CMP_HEADER_DIR}/${CMP_TOP_HEADER_FILE} - ${CMP_HEADER_DIR}/${CMP_TYPES_FILE_NAME} - ${CMP_HEADER_DIR}/${CMP_CONFIGURATION_FILE_NAME} - ${CMP_HEADER_DIR}/${CMP_VERSION_HEADER_FILE_NAME} - DESTINATION - include/${PROJECT_NAME} + # -------------------------------------------------------------------- + # Allow the generation and installation of a CMake configuration file + # which makes using SIMPL from another project easier. + # -------------------------------------------------------------------- + export(EXPORT ${PROJECT_NAME}Targets + FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake" + NAMESPACE ${PROJECT_NAME}:: ) + if(PROJECT_INSTALL_HEADERS) + install(EXPORT SIMPLibTargets + FILE + SIMPLibTargets.cmake + NAMESPACE + SIMPL:: + DESTINATION + ${ConfigPackageLocation} + ) + + install(FILES + ${CMP_HEADER_DIR}/${CMP_TOP_HEADER_FILE} + ${CMP_HEADER_DIR}/${CMP_TYPES_FILE_NAME} + ${CMP_HEADER_DIR}/${CMP_CONFIGURATION_FILE_NAME} + ${CMP_HEADER_DIR}/${CMP_VERSION_HEADER_FILE_NAME} + DESTINATION + include/${PROJECT_NAME} + ) + endif() endif() - # ------- Enable the CTest testing. --------------- # -------------------------------------------------------------------- # If Testing is enabled, turn on the Unit Tests if(SIMPL_BUILD_TESTING) include(${SIMPLib_SOURCE_DIR}/Testing/CMakeLists.txt) endif() - - - - diff --git a/Source/SIMPLib/Common/AppVersion.cpp b/Source/SIMPLib/Common/AppVersion.cpp index 5add61ae4d..c3c4c8e42b 100644 --- a/Source/SIMPLib/Common/AppVersion.cpp +++ b/Source/SIMPLib/Common/AppVersion.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "AppVersion.h" @@ -70,7 +70,6 @@ AppVersion::AppVersion(const AppVersion& rhs) // ----------------------------------------------------------------------------- AppVersion& AppVersion::operator=(const AppVersion& rhs) = default; - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -88,14 +87,14 @@ bool AppVersion::operator>(const AppVersion& rhs) { return true; } - + if(m_MajorNum == rhs.m_MajorNum) { if(m_MinorNum > rhs.m_MinorNum) { return true; } - + if(m_MinorNum == rhs.m_MinorNum) { return m_PatchNum > rhs.m_PatchNum; @@ -114,14 +113,14 @@ bool AppVersion::operator<(const AppVersion& rhs) { return true; } - + if(m_MajorNum == rhs.m_MajorNum) { if(m_MinorNum < rhs.m_MinorNum) { return true; } - + if(m_MinorNum == rhs.m_MinorNum) { return m_PatchNum < rhs.m_PatchNum; diff --git a/Source/SIMPLib/Common/AppVersion.h b/Source/SIMPLib/Common/AppVersion.h old mode 100755 new mode 100644 index e4459b638c..e4f26c0d0e --- a/Source/SIMPLib/Common/AppVersion.h +++ b/Source/SIMPLib/Common/AppVersion.h @@ -1,68 +1,68 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once #include "SIMPLib/SIMPLib.h" class SIMPLib_EXPORT AppVersion { - public: - AppVersion(); - AppVersion(int majorNum, int minorNum, int patchNum); +public: + AppVersion(); + AppVersion(int majorNum, int minorNum, int patchNum); - AppVersion(const AppVersion&); - AppVersion(const AppVersion&&) = delete; - AppVersion& operator=(const AppVersion&); - AppVersion& operator=(AppVersion&&) = delete; - - bool operator==(const AppVersion&); - bool operator>(const AppVersion&); - bool operator<(const AppVersion&); + AppVersion(const AppVersion&); + AppVersion(const AppVersion&&) = delete; + AppVersion& operator=(const AppVersion&); + AppVersion& operator=(AppVersion&&) = delete; - virtual ~AppVersion(); + bool operator==(const AppVersion&); + bool operator>(const AppVersion&); + bool operator<(const AppVersion&); - int getMajorNum(); - int getMinorNum(); - int getPatchNum(); + virtual ~AppVersion(); - void setMajorNum(int major); - void setMinorNum(int minor); - void setPatchNum(int patch); + int getMajorNum(); + int getMinorNum(); + int getPatchNum(); - private: - int m_MajorNum = -1; - int m_MinorNum = -1; - int m_PatchNum = -1; + void setMajorNum(int major); + void setMinorNum(int minor); + void setPatchNum(int patch); + +private: + int m_MajorNum = -1; + int m_MinorNum = -1; + int m_PatchNum = -1; }; diff --git a/Source/SIMPLib/Common/Constants.h b/Source/SIMPLib/Common/Constants.h index 6794f321a0..bfa0385586 100644 --- a/Source/SIMPLib/Common/Constants.h +++ b/Source/SIMPLib/Common/Constants.h @@ -1,966 +1,976 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once #if defined(_MSC_VER) #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +/* + "It's a known, long-standing bug in the compiler system's headers. For + some reason the manufacturer, in its infinite wisdom, chose to #define + macros min() and max() in violation of the upper-case convention and so + break any legitimate functions with those names, including those in the + standard C++ library." + */ +#ifndef NOMINMAX +#define NOMINMAX +#endif #endif +#include #include #include #include "SIMPLib/SIMPLib.h" -#define DEFAULT_BLOCKSIZE 1048576 - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- namespace SIMPL { +inline constexpr size_t DEFAULT_BLOCKSIZE = 1048576; + +using Rgb = uint32_t; +inline constexpr Rgb RGB_MASK = 0x00ffffff; // masks RGB values +inline const QString PathSep("|"); +inline constexpr uint8_t Unchecked = 0; +inline constexpr uint8_t PartiallyChecked = 1; +inline constexpr uint8_t Checked = 2; + +enum InfoStringFormat +{ + HtmlFormat = 0, + MarkDown = 1, + // JsonFormat, + // TextFormat, + // XmlFormat, + UnknownFormat +}; + +/** @brief Constants defined for the Stacking order of images into a 3D Volume */ +namespace RefFrameZDir +{ +inline constexpr uint32_t LowtoHigh = 0; +inline constexpr uint32_t HightoLow = 1; +inline constexpr uint32_t UnknownRefFrameZDirection = 2; +} // namespace RefFrameZDir + +namespace TypeNames +{ +inline const QString Bool("bool"); +inline const QString Float("float"); +inline const QString Double("double"); +inline const QString Int8("int8_t"); +inline const QString UInt8("uint8_t"); +inline const QString Int16("int16_t"); +inline const QString UInt16("uint16_t"); +inline const QString Int32("int32_t"); +inline const QString UInt32("uint32_t"); +inline const QString Int64("int64_t"); +inline const QString UInt64("uint64_t"); +inline const QString SizeT("size_t"); +inline const QString String("string"); +inline const QString StatsDataArray("StatsDataArray"); +inline const QString NeighborList("NeighborList"); +inline const QString StringArray("StringDataArray"); +inline const QString Unknown("Unknown"); +inline const QString SupportedTypeList(TypeNames::Bool + ", " + TypeNames::StringArray + ", " + TypeNames::Int8 + ", " + TypeNames::UInt8 + ", " + TypeNames::Int16 + ", " + TypeNames::UInt16 + ", " + + TypeNames::Int32 + ", " + TypeNames::UInt32 + ", " + TypeNames::Int64 + ", " + TypeNames::UInt64 + ", " + TypeNames::Float + ", " + TypeNames::Double + ", " + + TypeNames::SizeT); +} // namespace TypeNames + +namespace TypeEnums +{ +inline constexpr int32_t Int8 = 0; +inline constexpr int32_t UInt8 = 1; +inline constexpr int32_t Int16 = 2; +inline constexpr int32_t UInt16 = 3; +inline constexpr int32_t Int32 = 4; +inline constexpr int32_t UInt32 = 5; +inline constexpr int32_t Int64 = 6; +inline constexpr int32_t UInt64 = 7; +inline constexpr int32_t Float = 8; +inline constexpr int32_t Double = 9; +inline constexpr int32_t Bool = 10; +inline constexpr int32_t SizeT = 11; + +inline constexpr int32_t UnknownType = 12; +inline const QString SupportedTypeList(TypeNames::Bool + ", " + TypeNames::Int8 + ", " + TypeNames::UInt8 + ", " + TypeNames::Int16 + ", " + TypeNames::UInt16 + ", " + TypeNames::Int32 + ", " + + TypeNames::UInt32 + ", " + TypeNames::Int64 + ", " + TypeNames::UInt64 + ", " + TypeNames::Float + ", " + TypeNames::Double + ", " + TypeNames::SizeT); +} // namespace TypeEnums + +namespace NumericTypes +{ +namespace Names +{ +inline const QString Int8("signed int 8 bit"); +inline const QString UInt8("unsigned int 8 bit"); +inline const QString Int16("signed int 16 bit"); +inline const QString UInt16("unsigned int 16 bit"); +inline const QString Int32("signed int 32 bit"); +inline const QString UInt32("unsigned int 32 bit"); +inline const QString Int64("signed int 64 bit"); +inline const QString UInt64("unsigned int 64 bit"); +inline const QString Float("Float 32 bit"); +inline const QString Double("Double 64 bit"); +inline const QString Bool("Bool"); +inline const QString SizeT("size_t"); +} // namespace Names + +enum class Type : int32_t +{ + Int8 = 0, + UInt8, + Int16, + UInt16, + Int32, + UInt32, + Int64, + UInt64, + Float, + Double, + Bool, + SizeT, + UnknownNumType +}; + +inline const QString SupportedTypeList(NumericTypes::Names::Int8 + ", " + NumericTypes::Names::UInt8 + ", " + NumericTypes::Names::Int16 + ", " + NumericTypes::Names::UInt16 + ", " + + NumericTypes::Names::Int32 + ", " + NumericTypes::Names::UInt32 + ", " + NumericTypes::Names::Int64 + ", " + NumericTypes::Names::UInt64 + ", " + + NumericTypes::Names::Float + ", " + NumericTypes::Names::Double + ", " + NumericTypes::Names::Bool + ", " + NumericTypes::Names::SizeT); +} // namespace NumericTypes + +namespace DelimiterTypes +{ +enum class Type : int32_t +{ + Comma = 0, + Semicolon = 1, + Colon = 2, + Tab = 3, + Space = 4 +}; +} + +namespace ScalarTypes +{ +enum class Type : int32_t +{ + Int8 = 0, + UInt8, + Int16, + UInt16, + Int32, + UInt32, + Int64, + UInt64, + Float, + Double, + Bool, + SizeT +}; +} + +namespace IO +{ +inline const QString DAPSettingsHeader("Path"); +} + +namespace Defaults +{ +inline const QString None("None"); +inline const QString AnyPrimitive("Any"); +inline const size_t AnyComponentSize = std::numeric_limits::max(); +// inline constexpr uint32_t AnyAttributeMatrix = std::numeric_limits::max(); +// inline constexpr uint32_t AnyGeometry = std::numeric_limits::max(); + +inline const QString AttributeMatrixName("AttributeMatrix"); +inline const QString ElementAttributeMatrixName("ElementAttributeMatrix"); +inline const QString FeatureAttributeMatrixName("FeatureAttributeMatrix"); +inline const QString EnsembleAttributeMatrixName("EnsembleAttributeMatrix"); + +inline const QString ImageDataContainerName("ImageDataContainer"); +inline const QString NewImageDataContainerName("NewImageDataContainer"); +inline const QString TriangleDataContainerName("TriangleDataContainer"); +inline const QString QuadDataContainerName("QuadDataContainer"); +inline const QString TetrahedralDataContainerName("TetrahedralDataContainer"); +inline const QString HexahedralDataContainerName("HexahedralDataContainer"); + +inline const QString VertexDataContainerName("VertexDataContainer"); +inline const QString VertexAttributeMatrixName("VertexData"); +inline const QString VertexFeatureAttributeMatrixName("VertexFeatureData"); +inline const QString VertexEnsembleAttributeMatrixName("VertexEnsembleData"); + +inline const QString EdgeDataContainerName("EdgeDataContainer"); +inline const QString EdgeAttributeMatrixName("EdgeData"); +inline const QString EdgeFeatureAttributeMatrixName("EdgeFeatureData"); +inline const QString EdgeEnsembleAttributeMatrixName("EdgeEnsembleData"); + +inline const QString SurfaceDataContainerName("SurfaceDataContainer"); +inline const QString FaceAttributeMatrixName("FaceData"); +inline const QString FaceFeatureAttributeMatrixName("FaceFeatureData"); +inline const QString FaceEnsembleAttributeMatrixName("FaceEnsembleData"); + +inline const QString VolumeDataContainerName("VolumeDataContainer"); +inline const QString NewVolumeDataContainerName("NewVolumeDataContainer"); +inline const QString CellAttributeMatrixName("CellData"); +inline const QString NewCellAttributeMatrixName("NewCellData"); +inline const QString CellFeatureAttributeMatrixName("CellFeatureData"); +inline const QString NewCellFeatureAttributeMatrixName("NewCellFeatureData"); +inline const QString CellEnsembleAttributeMatrixName("CellEnsembleData"); + +inline const QString VoxelDataName("VoxelData"); + +inline const QString SyntheticVolumeDataContainerName("SyntheticVolumeDataContainer"); +inline const QString StatsGenerator("StatsGeneratorDataContainer"); + +inline const QString SomePath("SomeDataContainer|SomeAttributeMatrix|SomeDataArray"); + +inline const QString GenericBundleName("GenericBundle"); +inline const QString TimeSeriesBundleName("TimeSeriesBundle"); + +inline const QString GenericBundleAttributeMatrixName("GenericBundleAttributeMatrix"); +inline const QString TimeSeriesBundleAttributeMatrixName("TimeSeriesBundleAttributeMatrix"); + +inline const QString DataContainerName("DataContainer"); +inline const QString NewDataContainerName("NewDataContainer"); +inline const QString NewAttributeMatrixName("NewAttributeMatrixName"); +} // namespace Defaults + +namespace PipelineVersionNumbers +{ +inline constexpr int32_t CurrentVersion(6); +} + +namespace FilterGroups +{ +inline const QString CoreFilters("Core"); +inline const QString Generic("Generic"); +inline const QString IOFilters("IO"); +inline const QString ProcessingFilters("Processing"); +inline const QString ReconstructionFilters("Reconstruction"); +inline const QString SamplingFilters("Sampling"); +inline const QString StatisticsFilters("Statistics"); +inline const QString SyntheticBuildingFilters("Synthetic Building"); +inline const QString SurfaceMeshingFilters("Surface Meshing"); +inline const QString Utilities("Utilities"); +inline const QString CustomFilters("Custom"); +inline const QString Unsupported("Unsupported"); +} // namespace FilterGroups + +namespace FilterSubGroups +{ +inline const QString EnsembleStatsFilters("Ensemble"); +inline const QString MemoryManagementFilters("Memory/Management"); +inline const QString SpatialFilters("Spatial"); +inline const QString StatisticsFilters("Statistics"); +inline const QString FeatureIdentificationFilters("FeatureIdentification"); +inline const QString OutputFilters("Output"); +inline const QString InputFilters("Input"); +inline const QString ImageFilters("Image"); +inline const QString CleanupFilters("Cleanup"); +inline const QString ThresholdFilters("Threshold"); +inline const QString RegularizationFilters("Regularization"); +inline const QString ConversionFilters("Conversion"); +inline const QString FusionFilters("Fusion"); +inline const QString WarpingFilters("Warping"); +inline const QString AlignmentFilters("Alignment"); +inline const QString SegmentationFilters("Segmentation"); +inline const QString GroupingFilters("Grouping"); +inline const QString CropCutFilters("Croping/Cutting"); +inline const QString RotationTransformationFilters("Rotating/Transforming"); +inline const QString ResolutionFilters("Spacing"); +inline const QString MorphologicalFilters("Morphological"); +inline const QString PackingFilters("Packing"); +inline const QString CrystallographyFilters("Crystallography"); +inline const QString GenerationFilters("Generation"); +inline const QString SmoothingFilters("Smoothing"); +inline const QString CurvatureFilters("Curvature"); +inline const QString ConnectivityArrangementFilters("Connectivity/Arrangement"); +inline const QString MappingFilters("Mapping"); +inline const QString MiscFilters("Misc"); +inline const QString GeometryFilters("Geometry"); +inline const QString ImportFilters("Import"); +inline const QString ExportFilters("Export"); +} // namespace FilterSubGroups + +namespace GeneralData +{ +inline const QString CombinedData("CombinedData"); +inline const QString ThresholdArray("ThresholdArray"); +inline const QString Mask("Mask"); +} // namespace GeneralData + +namespace CellData +{ +inline const QString AxisAngles("AxisAngles"); +inline const QString BC("BandContrasts"); +inline const QString BandContrast("BandContrast"); +inline const QString CellPhases("Phases"); +inline const QString ConfidenceIndex("Confidence Index"); +inline const QString CAxisLocation("CAxisLocation"); +inline const QString ConfidenceIndexNoSpace("ConfidenceIndex"); +inline const QString Current("Current"); +inline const QString DislocationTensors("DislocationTensors"); +inline const QString EulerAngles("EulerAngles"); +inline const QString EulerColor("EulerColor"); +inline const QString FarFeatureQuats("FarFeatureQuats"); +inline const QString FarFeatureZoneIds("FarFeatureZoneIds"); +inline const QString FitQuality("FitQuality"); +inline const QString FlatImageData("FlatImageData"); +inline const QString GBEuclideanDistances("GBEuclideanDistances"); +inline const QString GBManhattanDistances("GBManhattanDistances"); +inline const QString GlobAlpha("GlobAlpha"); +inline const QString GoodVoxels("GoodVoxels"); +inline const QString FeatureIds("FeatureIds"); +inline const QString FeatureReferenceCAxisMisorientations("FeatureReferenceCAxisMisorientations"); +inline const QString FeatureReferenceMisorientations("FeatureReferenceMisorientations"); +inline const QString IPFColor("IPFColor"); +inline const QString ImageData("ImageData"); +inline const QString ImageQuality("Image Quality"); +inline const QString ImageQualityNoSpace("ImageQuality"); +inline const QString KernelAverageMisorientations("KernelAverageMisorientations"); +inline const QString Mask("Mask"); +inline const QString MotionDirection("MotionDirection"); +inline const QString MicroTexVolFrac("MicroTexVolFrac"); +inline const QString MisorientationColor("MisorientationColor"); +inline const QString ParentDensity("ParentDensity"); +inline const QString MTRgKAM("MTRgKAM"); +inline const QString NearestNeighbors("NearestNeighbors"); +inline const QString ParentIds("ParentIds"); +inline const QString Phases("Phases"); +inline const QString ProjectedImageMin("ProjectedImageMin"); +inline const QString ProjectedImageMax("ProjectedImageMax"); +inline const QString ProjectedImageAvg("ProjectedImageAvg"); +inline const QString ProjectedImageStd("ProjectedImageStd"); +inline const QString ProjectedImageVar("ProjectedImageVar"); +inline const QString QPEuclideanDistances("QPEuclideanDistances"); +inline const QString QPManhattanDistances("QPManhattanDistances"); +inline const QString Quats("Quats"); +inline const QString RodriguesColor("RodriguesColor"); +inline const QString RodriguesVectors("RodriguesVectors"); +inline const QString SolidMeshNodes("SolidMeshNodes"); +inline const QString SineParams("SineParams"); +inline const QString SolidMeshTetrahedrons("SolidMeshTetrahedrons"); +inline const QString Speed("Speed"); +inline const QString SurfaceMeshCells("SurfaceMeshCells"); +inline const QString BoundaryCells("BoundaryCells"); +inline const QString TJManhattanDistances("TJManhattanDistances"); +inline const QString TJEuclideanDistances("TJEuclideanDistances"); +inline const QString VectorColor("VectorColor"); +inline const QString VectorData("VectorData"); +inline const QString Histogram("Histogram"); +} // namespace CellData + +namespace FeatureData +{ +inline const QString FeatureID("Feature_ID"); +inline const QString Active("Active"); +inline const QString AspectRatios("AspectRatios"); +inline const QString AvgCAxes("AvgCAxes"); +inline const QString AvgCAxisMisalignments("AvgCAxisMisalignments"); +inline const QString LocalCAxisMisalignments("LocalCAxisMisalignments"); +inline const QString UnbiasedLocalCAxisMisalignments("UnbiasedLocalCAxisMisalignments"); +inline const QString AvgQuats("AvgQuats"); +inline const QString AxisEulerAngles("AxisEulerAngles"); +inline const QString AxisLengths("AxisLengths"); +inline const QString BasalLoadingFactor("BasalLoadingFactor"); +inline const QString BiasedFeatures("BiasedFeatures"); +inline const QString CAxisMisalignmentList("CAxisMisalignmentList"); +inline const QString Centroids("Centroids"); +inline const QString ClusteringList("ClusteringList"); +inline const QString ElasticStrains("ElasticStrains"); +inline const QString EquivalentDiameters("EquivalentDiameters"); +inline const QString SaltykovEquivalentDiameters("SaltykovEquivalentDiameters"); +inline const QString EulerAngles("EulerAngles"); +inline const QString AvgEulerAngles("AvgEulerAngles"); +inline const QString F1List("F1List"); +inline const QString F1sptList("F1sptList"); +inline const QString F7List("F7List"); +inline const QString FarFeatureOrientations("FarFeatureOrientations"); +inline const QString FeaturePhases("Phases"); +inline const QString GoodFeatures("GoodFeatures"); +inline const QString FeatureAvgCAxisMisorientations("FeatureAvgCAxisMisorientations"); +inline const QString FeatureAvgMisorientations("FeatureAvgMisorientations"); +inline const QString FeatureStdevCAxisMisorientations("FeatureStdevCAxisMisorientations"); +inline const QString KernelAvgMisorientations("KernelAvgMisorientations"); +inline const QString LMG("LMG"); +inline const QString LargestCrossSections("LargestCrossSections"); +inline const QString Mask("Mask"); +inline const QString MTRdensity("MTRdensity"); +inline const QString MTRgKAM("MTRgKAM"); + +inline const QString MisorientationList("MisorientationList"); +inline const QString NeighborList("NeighborList"); +inline const QString NeighborhoodList("NeighborhoodList"); +inline const QString Neighborhoods("Neighborhoods"); +inline const QString NumCells("NumCells"); +inline const QString NumElements("NumElements"); +inline const QString NumFeaturesPerParent("NumFeaturesPerParent"); +inline const QString NumNeighbors("NumNeighbors"); +inline const QString Omega3s("Omega3s"); +inline const QString ParentIds("ParentIds"); +inline const QString Phases("Phases"); +inline const QString Poles("Poles"); +inline const QString RGBs("RGBs"); +inline const QString Schmids("Schmids"); +inline const QString SharedSurfaceAreaList("SharedSurfaceAreaList"); +inline const QString SlipSystems("SlipSystems"); +inline const QString SurfaceAreaVol("SurfaceAreaVolumeRatio"); +inline const QString SurfaceFeatures("SurfaceFeatures"); +inline const QString SurfaceElementFractions("SurfaceElementFractions"); +inline const QString Volumes("Volumes"); +inline const QString AvgMisorientations("AvgMisorientations"); +inline const QString mPrimeList("mPrimeList"); +inline const QString NumBins("NumBins"); +inline const QString ScalarAverages("ScalarAverages"); + +} // namespace FeatureData + +namespace EnsembleData +{ +inline const QString NumFeatures("NumFeatures"); +inline const QString VolFractions("VolFractions"); +inline const QString TotalSurfaceAreas("TotalSurfaceAreas"); +inline const QString CrystalSymmetry("Crystal Symmetry"); +inline const QString CrystalStructures("CrystalStructures"); +inline const QString PhaseTypes("PhaseTypes"); +inline const QString BravaisLattice("BravaisLattice"); +inline const QString PrecipitateFractions("PrecipitateFractions"); +inline const QString ShapeTypes("ShapeTypes"); +inline const QString Statistics("Statistics"); +inline const QString PhaseName("PhaseName"); +inline const QString LatticeConstants("LatticeConstants"); +inline const QString GBCD("GBCD"); +inline const QString GBCDdimensions("GBCDdimensions"); +inline const QString FitParameters("FitParameters"); +inline const QString MaterialName("MaterialName"); +} // namespace EnsembleData + +namespace VertexData +{ +inline const QString AtomVelocities("AtomVelocities"); +inline const QString AtomTypes("AtomTypes"); +inline const QString AtomFeatureLabels("AtomFeatureLabels"); +inline const QString NumberOfArms("NumberOfArms"); +inline const QString NodeConstraints("NodeConstraints"); +inline const QString SurfaceMeshNodes("Nodes"); +inline const QString SurfaceMeshNodeType("NodeType"); +inline const QString SurfaceMeshNodeNormals("NodeNormals"); +inline const QString SurfaceMeshNodeFaces("NodeFaces"); +} // namespace VertexData + +namespace FaceData +{ +inline const QString SurfaceMeshFaces("Faces"); +inline const QString SurfaceMeshFaceIPFColors("IPFColors"); +inline const QString SurfaceMeshFaceMisorientationColors("MisorientationColors"); +inline const QString SurfaceMeshFaceSchuhMisorientationColors("SchuhMisorientationColors"); +inline const QString SurfaceMeshFaceLabels("FaceLabels"); +inline const QString SurfaceMeshFacePhases("Phases"); +inline const QString SurfaceMeshF1s("F1s"); +inline const QString SurfaceMeshF1spts("F1spts"); +inline const QString SurfaceMeshF7s("F7s"); +inline const QString SurfaceMeshmPrimes("mPrimes"); +inline const QString SurfaceMeshVoxels("SurfaceMeshVoxels"); +inline const QString SurfaceMeshFaceCentroids("FaceCentroids"); +inline const QString SurfaceMeshFaceAreas("FaceAreas"); +inline const QString SurfaceMeshTwinBoundary("TwinBoundary"); +inline const QString SurfaceMeshTwinBoundaryIncoherence("TwinBoundaryIncoherence"); +inline const QString SurfaceMeshTwinBoundarySchmidFactors("TwinBoundarySchmidFactors"); +inline const QString SurfaceMeshFaceDihedralAngles("FaceDihedralAngles"); +inline const QString SurfaceMeshFaceNormals("FaceNormals"); +inline const QString SurfaceMeshFeatureFaceId("FeatureFaceId"); +inline const QString SurfaceMeshGaussianCurvatures("GaussianCurvatures"); +inline const QString SurfaceMeshMeanCurvatures("MeanCurvatures"); +inline const QString SurfaceMeshPrincipalCurvature1("PrincipalCurvature1"); +inline const QString SurfaceMeshPrincipalCurvature2("PrincipalCurvature2"); +inline const QString SurfaceMeshPrincipalDirection1("PrincipalDirection1"); +inline const QString SurfaceMeshPrincipalDirection2("PrincipalDirection2"); +} // namespace FaceData + +namespace EdgeData +{ +inline const QString DislocationIds("DislocationIds"); +inline const QString BurgersVectors("BurgersVectors"); +inline const QString SlipPlaneNormals("SlipPlaneNormals"); +inline const QString SurfaceMeshEdges("SurfaceMeshEdges"); +inline const QString SurfaceMeshUniqueEdges("SurfaceMeshUniqueEdges"); +inline const QString SurfaceMeshInternalEdges("SurfaceMeshInternalEdges"); +inline const QString SurfaceMeshTriangleEdges("SurfaceMeshTriangleEdges"); +inline const QString SurfaceMeshEdgeFaces("SurfaceMeshEdgeFaces"); +} // namespace EdgeData + +namespace Settings +{ +inline const QString Library("Filter Library"); +inline const QString PrebuiltPipelines("Prebuilt Pipelines"); +inline const QString FavoritePipelines("Favorite Pipelines"); +inline const QString PipelineBuilderGroup("PipelineBuilder"); +inline const QString FavoriteConfig("favorite_config"); +inline const QString NumFilters("Number_Filters"); +inline const QString PipelineName("Name"); +inline const QString FilterName("Filter_Name"); +inline const QString FilterUuid("Filter_Uuid"); +inline const QString FilterVersion("FilterVersion"); +inline const QString HumanLabel("Filter_Human_Label"); +inline const QString FilterEnabled("Filter_Enabled"); +inline const QString GroupName("GroupName"); +inline const QString SubGroupName("SubGroupName"); +inline const QString BrandingString("BrandingString"); +inline const QString CompiledLibraryName("CompiledLibraryName"); +inline const QString Version("Version"); +inline const QString PipelineBuilderGeomertry("PipelineBuilderGeometry"); +} // namespace Settings + +namespace HDF5 +{ +inline const QString FileVersion("7.0"); +inline const QString FileVersionName("FileVersion"); +inline const QString DREAM3DVersion("DREAM3D Version"); +inline const QString ObjectType("ObjectType"); +inline const QString Rank("Rank"); +inline const QString TupleDimensions("TupleDimensions"); +inline const QString ComponentDimensions("ComponentDimensions"); +inline const QString AxisDimensions("Tuple Axis Dimensions"); +inline const QString DataArrayVersion("DataArrayVersion"); +} // namespace HDF5 + +namespace StringConstants +{ +inline const QString Alpha("Alpha"); +inline const QString Angle("Angle"); + +inline const QString Average("Average"); +inline const QString Axis("Axis"); +inline const QString AxisODFWeights("AxisODF-Weights"); +inline const QString AxisOrientation("AxisOrientation"); +inline const QString Beta("Beta"); +inline const QString BetaDistribution("Beta Distribution"); +inline const QString BinNumber("BinNumber"); +inline const QString BinCount("Bin Count"); +inline const QString BinStepSize("Bin Step Size"); +inline const QString BoundaryArea("BoundaryArea"); +inline const QString BoundaryStatsData("BoundaryStatsData"); +inline const QString CellNeighbors("CellNeighbors"); + +inline const QString CellsContainingVert("CellsContainingVert"); +inline const QString CellsName("Cells"); +inline const QString CrystalStructure("CrystalStructure"); +inline const QString DataContainerGroupName("DataContainers"); +inline const QString DataContainerBundleGroupName("DataContainerBundles"); +inline const QString DataContainerNames("DataContainerNames"); +inline const QString MetaDataArrays("MetaDataArrays"); +inline const QString MontageGroupName("Montages"); +inline const QString DataContainerType("DataContainerType"); +inline const QString AttributeMatrixType("AttributeMatrixType"); + +inline const QString Dims("Dims"); +inline const QString DistributionType("Distribution Type"); + +inline const QString EdgeNeighbors("EdgeNeighbors"); +inline const QString EdgesContainingVert("EdgesContainingVert"); +inline const QString EdgesName("Edges"); +inline const QString EdgeCentroids("EdgeCentroids"); +inline const QString EdgeLengths("EdgeLengths"); +inline const QString Euler1("Euler 1"); +inline const QString Euler2("Euler 2"); +inline const QString Euler3("Euler 3"); +inline const QString Exp_k("K"); + +inline const QString FaceNeighbors("FaceNeighbors"); +inline const QString FacesContainingVert("FacesContainingVert"); +inline const QString FacesName("Faces"); +inline const QString TrianglesName("Triangles"); +inline const QString TriangleNeighbors("TriangleNeighbors"); +inline const QString TrianglesContainingVert("TrianglesContainingVert"); +inline const QString TriangleCentroids("TriangleCentroids"); +inline const QString TriangleAreas("TriangleAreas"); +inline const QString Frequencies("Frequencies"); + +inline const QString QuadsName("Quadrilaterals"); +inline const QString QuadNeighbors("QuadrilateralNeighbors"); +inline const QString QuadsContainingVert("QuadrilateralsContainingVerts"); +inline const QString QuadCentroids("QuadrilateralCentroids"); +inline const QString QuadAreas("QuadrilateralAreas"); + +inline const QString TetsName("Tetrahedra"); +inline const QString TetNeighbors("TetrahedralNeighbors"); +inline const QString TetsContainingVert("TetrahedraContainingVerts"); +inline const QString TetCentroids("TetrahedralCentroids"); +inline const QString TetVolumes("TetrahedralVolumes"); + +inline const QString HexasName("Hexahedra"); +inline const QString HexNeighbors("HexahedralNeighbors"); +inline const QString HexasContainingVert("HexahedraContainingVerts"); +inline const QString HexCentroids("HexahedralCentroids"); +inline const QString HexVolumes("HexahedralVolumes"); + +inline const QString VoxelSizes("VoxelSizes"); +inline const QString VertexSizes("VertexSizes"); + +inline const QString GBCD("GBCD"); +inline const QString FeatureAvgDisorientation("FeatureAvgDisorientation"); +inline const QString Feature_Diameter_Info("Feature_Diameter_Info"); +inline const QString Feature_SizeVBoverA_Distributions("FeatureSize Vs B Over A Distributions"); +inline const QString Feature_SizeVCoverA_Distributions("FeatureSize Vs C Over A Distributions"); +inline const QString Feature_SizeVNeighbors_Distributions("FeatureSize Vs Neighbors Distributions"); +inline const QString Feature_SizeVOmega3_Distributions("FeatureSize Vs Omega3 Distributions"); +inline const QString Feature_SizeVClustering_Distributions("FeatureSize Vs Clustering Distributions"); +inline const QString Feature_Size_Distribution("FeatureSize Distribution"); +inline const QString KernelAvgDisorientation("KernelAvgDisorientation"); +inline const QString LogNormalDistribution("Log Normal Distribution"); +inline const QString MDFWeights("MDF-Weights"); +inline const QString MatrixStatsData("MatrixStatsData"); +inline const QString MeshFaceNeighborLists("MeshFaceNeighborLists"); +inline const QString MicroTextureBins("MicroTextureBins"); +inline const QString MinimumValue("Minimum Value"); +inline const QString MinMaxNoOfBins("MinMaxNoOfBins"); +inline const QString MisorientationBins("MisorientationBins"); +inline const QString Neighbor_Feature_ID_List("Neighbor_Feature_ID_List"); + +inline const QString ODF("ODF"); +inline const QString ODFWeights("ODF-Weights"); + +inline const QString ParentPhase("Parent Phase"); +inline const QString PhaseFraction("PhaseFraction"); +inline const QString PhaseType("PhaseType"); +inline const QString PipelineGroupName("Pipeline"); +inline const QString PipelineVersionName("Pipeline Version"); +inline const QString PipelineCurrentName("Current Pipeline"); +inline const QString PowerLawDistribution("Power Law Distribution"); +inline const QString PrecipitateBoundaryFraction("Precipitate Boundary Fraction"); +inline const QString PrecipitateStatsData("PrecipitateStatsData"); +inline const QString PrimaryStatsData("PrimaryStatsData"); +inline const QString PresetName("PresetName"); + +inline const QString RadialDistFunc("Radial Distribution Function"); +inline const QString RdfMinDistance("Min"); +inline const QString RdfMaxDistance("Max"); +inline const QString RdfBoxDims("BoxDims"); +inline const QString RdfBoxRes("BoxRes"); + +inline const QString Sigma("Sigma"); +inline const QString StandardDeviation("Standard Deviation"); +inline const QString Statistics("Statistics"); +inline const QString Stats("Stats"); +inline const QString StatsData("StatsData"); +inline const QString StatsType("StatsType"); + +inline const QString TransformationStatsData("TransformationStatsData"); +inline const QString UnknownDistribution("Unknown Distribution"); + +inline const QString VerticesName("Vertices"); +inline const QString VertsName("Verts"); +inline const QString ImageName("Image"); + +inline const QString Weight("Weight"); + +inline const QString MetaData("_META_DATA"); + +inline const QString Name("Name"); +inline const QString Index("Index"); +} // namespace StringConstants + +namespace CellType +{ +inline const QString Quadrilateral("Quadrilateral"); +inline const QString Tetrahedron("Tetrahedron"); +inline const QString Triangle("Triangle"); +inline const QString Face("Face"); +inline const QString Edge("Edge"); +inline const QString Vertex("Vertex"); +inline const QString Node("Node"); +} // namespace CellType + +// namespace PhaseType +//{ +// //inline constexpr uint32_t PrimaryPhase = 0; //!< +// //inline constexpr uint32_t PrecipitatePhase = 1; //!< +// //inline constexpr uint32_t TransformationPhase = 2; //!< +// //inline constexpr uint32_t MatrixPhase = 3; //!< +// //inline constexpr uint32_t BoundaryPhase = 4; //!< +// //inline constexpr uint32_t Unknown = 999; //!< + +// inline const QString Primary("Primary"); +// inline const QString Precipitate("Precipitate"); +// inline const QString Transformation("Transformation"); +// inline const QString Matrix("Matrix"); +// inline const QString Boundary("Boundary"); +// inline const QString UnknownPhase("Unknown"); +//} + +namespace AlignmentMethod +{ +inline constexpr uint32_t OuterBoundary = 0; //!< +inline constexpr uint32_t Misorientation = 1; //!< +inline constexpr uint32_t MutualInformation = 2; //!< +inline constexpr uint32_t Count = 3; //!< +inline constexpr uint32_t UnknownAlignmentMethod = 999; //!< +} // namespace AlignmentMethod + +namespace StatisticsType +{ +inline constexpr uint32_t Feature_SizeVBoverA = 0; //!< +inline constexpr uint32_t Feature_SizeVCoverA = 1; //!< +inline constexpr uint32_t Feature_SizeVNeighbors = 2; //!< +inline constexpr uint32_t Feature_SizeVOmega3 = 3; //!< +inline constexpr uint32_t Feature_SizeVClustering = 4; //!< +inline constexpr uint32_t UnknownStatisticsGroup = 999; //!< + +} // namespace StatisticsType + +namespace DistributionType +{ +inline constexpr uint32_t Beta = 0; //!< +inline constexpr uint32_t LogNormal = 1; //!< +inline constexpr uint32_t Power = 2; //!< +inline constexpr uint32_t RDFFrequency = 3; //!< +inline constexpr uint32_t RDFMaxMin = 4; //!< +inline constexpr uint32_t UnknownDistributionType = 5; //!< +inline constexpr uint32_t Count = 6; //!< + +enum ColumnCount +{ + BetaColumnCount = 2, //!< + LogNormalColumnCount = 2, //!< + PowerLawColumnCount = 2, //!< + RawDistDataColumnCount = 1, //!< + UnknownColumCount = 0 //!< +}; - typedef uint32_t Rgb; - const Rgb RGB_MASK = 0x00ffffff; // masks RGB values - const QString PathSep("|"); - static const uint8_t Unchecked = 0; - static const uint8_t PartiallyChecked = 1; - static const uint8_t Checked = 2; - - enum InfoStringFormat - { - HtmlFormat = 0, -// JsonFormat, -// TextFormat, -// XmlFormat, - UnknownFormat - }; - - - /** @brief Constants defined for the Stacking order of images into a 3D Volume */ - namespace RefFrameZDir - { - static const unsigned int LowtoHigh = 0; - static const unsigned int HightoLow = 1; - static const unsigned int UnknownRefFrameZDirection = 2; - } - - namespace TypeNames - { - const QString Bool("bool"); - const QString Float("float"); - const QString Double("double"); - const QString Int8("int8_t"); - const QString UInt8("uint8_t"); - const QString Int16("int16_t"); - const QString UInt16("uint16_t"); - const QString Int32("int32_t"); - const QString UInt32("uint32_t"); - const QString Int64("int64_t"); - const QString UInt64("uint64_t"); - const QString SizeT("size_t"); - const QString String("string"); - const QString StatsDataArray("StatsDataArray"); - const QString NeighborList("NeighborList"); - const QString StringArray("StringDataArray"); - const QString Unknown("Unknown"); - const QString SupportedTypeList(TypeNames::Bool + ", " + TypeNames::StringArray + ", " + TypeNames::Int8 + ", " + TypeNames::UInt8 + ", " + TypeNames::Int16 + ", " + TypeNames::UInt16 + ", " + - TypeNames::Int32 + ", " + TypeNames::UInt32 + ", " + TypeNames::Int64 + ", " + TypeNames::UInt64 + ", " + TypeNames::Float + ", " + TypeNames::Double + ", " + - TypeNames::SizeT); - } - - namespace TypeEnums - { - static const int Int8 = 0; - static const int UInt8 = 1; - static const int Int16 = 2; - static const int UInt16 = 3; - static const int Int32 = 4; - static const int UInt32 = 5; - static const int Int64 = 6; - static const int UInt64 = 7; - static const int Float = 8; - static const int Double = 9; - static const int Bool = 10; - static const int SizeT = 11; - - static const int UnknownType = 12; - const QString SupportedTypeList(TypeNames::Bool + ", " + TypeNames::Int8 + ", " + TypeNames::UInt8 + ", " + TypeNames::Int16 + ", " + TypeNames::UInt16 + ", " + TypeNames::Int32 + ", " + - TypeNames::UInt32 + ", " + TypeNames::Int64 + ", " + TypeNames::UInt64 + ", " + TypeNames::Float + ", " + TypeNames::Double + ", " + TypeNames::SizeT); - } - - namespace NumericTypes - { - namespace Names - { - const QString Int8("signed int 8 bit"); - const QString UInt8("unsigned int 8 bit"); - const QString Int16("signed int 16 bit"); - const QString UInt16("unsigned int 16 bit"); - const QString Int32("signed int 32 bit"); - const QString UInt32("unsigned int 32 bit"); - const QString Int64("signed int 64 bit"); - const QString UInt64("unsigned int 64 bit"); - const QString Float(" Float 32 bit"); - const QString Double(" Double 64 bit"); - const QString Bool("Bool"); - const QString SizeT("size_t"); - } - - enum class Type : int - { - Int8 = 0, - UInt8, - Int16, - UInt16, - Int32, - UInt32, - Int64, - UInt64, - Float, - Double, - Bool, - SizeT, - UnknownNumType - }; - - const QString SupportedTypeList(NumericTypes::Names::Int8 + ", " + NumericTypes::Names::UInt8 + ", " + NumericTypes::Names::Int16 + ", " + NumericTypes::Names::UInt16 + ", " + - NumericTypes::Names::Int32 + ", " + NumericTypes::Names::UInt32 + ", " + NumericTypes::Names::Int64 + ", " + NumericTypes::Names::UInt64 + ", " + - NumericTypes::Names::Float + ", " + NumericTypes::Names::Double + ", " + NumericTypes::Names::Bool + ", " + NumericTypes::Names::SizeT); - } - - namespace DelimiterTypes - { - enum class Type : int - { - Comma = 0, - Semicolon = 1, - Colon = 2, - Tab = 3, - Space = 4 - }; - } - - namespace ScalarTypes - { - enum class Type : int - { - Int8 = 0, - UInt8, - Int16, - UInt16, - Int32, - UInt32, - Int64, - UInt64, - Float, - Double, - Bool, - SizeT - }; - } - - namespace IO - { - const QString DAPSettingsHeader("Path"); - } - - - namespace Defaults - { - const QString None("None"); - const QString AnyPrimitive("Any"); - static const size_t AnyComponentSize = std::numeric_limits::max(); - //static const uint32_t AnyAttributeMatrix = std::numeric_limits::max(); - //static const uint32_t AnyGeometry = std::numeric_limits::max(); - - const QString AttributeMatrixName("AttributeMatrix"); - const QString ElementAttributeMatrixName("ElementAttributeMatrix"); - const QString FeatureAttributeMatrixName("FeatureAttributeMatrix"); - const QString EnsembleAttributeMatrixName("EnsembleAttributeMatrix"); - - const QString ImageDataContainerName("ImageDataContainer"); - const QString NewImageDataContainerName("NewImageDataContainer"); - const QString TriangleDataContainerName("TriangleDataContainer"); - const QString QuadDataContainerName("QuadDataContainer"); - const QString TetrahedralDataContainerName("TetrahedralDataContainer"); - const QString HexahedralDataContainerName("HexahedralDataContainer"); - - const QString VertexDataContainerName("VertexDataContainer"); - const QString VertexAttributeMatrixName("VertexData"); - const QString VertexFeatureAttributeMatrixName("VertexFeatureData"); - const QString VertexEnsembleAttributeMatrixName("VertexEnsembleData"); - - const QString EdgeDataContainerName("EdgeDataContainer"); - const QString EdgeAttributeMatrixName("EdgeData"); - const QString EdgeFeatureAttributeMatrixName("EdgeFeatureData"); - const QString EdgeEnsembleAttributeMatrixName("EdgeEnsembleData"); - - const QString SurfaceDataContainerName("SurfaceDataContainer"); - const QString FaceAttributeMatrixName("FaceData"); - const QString FaceFeatureAttributeMatrixName("FaceFeatureData"); - const QString FaceEnsembleAttributeMatrixName("FaceEnsembleData"); - - const QString VolumeDataContainerName("VolumeDataContainer"); - const QString NewVolumeDataContainerName("NewVolumeDataContainer"); - const QString CellAttributeMatrixName("CellData"); - const QString NewCellAttributeMatrixName("NewCellData"); - const QString CellFeatureAttributeMatrixName("CellFeatureData"); - const QString NewCellFeatureAttributeMatrixName("NewCellFeatureData"); - const QString CellEnsembleAttributeMatrixName("CellEnsembleData"); - - const QString VoxelDataName("VoxelData"); - - const QString SyntheticVolumeDataContainerName("SyntheticVolumeDataContainer"); - const QString StatsGenerator("StatsGeneratorDataContainer"); - - const QString SomePath("SomeDataContainer|SomeAttributeMatrix|SomeDataArray"); - - const QString GenericBundleName("GenericBundle"); - const QString TimeSeriesBundleName("TimeSeriesBundle"); - - const QString GenericBundleAttributeMatrixName("GenericBundleAttributeMatrix"); - const QString TimeSeriesBundleAttributeMatrixName("TimeSeriesBundleAttributeMatrix"); - - const QString DataContainerName("DataContainer"); - const QString NewDataContainerName("NewDataContainer"); - const QString NewAttributeMatrixName("NewAttributeMatrixName"); - } - - namespace PipelineVersionNumbers - { - const int CurrentVersion(6); - } - - namespace FilterGroups - { - const QString CoreFilters("Core"); - const QString Generic("Generic"); - const QString IOFilters("IO"); - const QString ProcessingFilters("Processing"); - const QString ReconstructionFilters("Reconstruction"); - const QString SamplingFilters("Sampling"); - const QString StatisticsFilters("Statistics"); - const QString SyntheticBuildingFilters("Synthetic Building"); - const QString SurfaceMeshingFilters("Surface Meshing"); - const QString Utilities("Utilities"); - const QString CustomFilters("Custom"); - const QString Unsupported("Unsupported"); - } - - namespace FilterSubGroups - { - const QString EnsembleStatsFilters("Ensemble"); - const QString MemoryManagementFilters("Memory/Management"); - const QString SpatialFilters("Spatial"); - const QString StatisticsFilters("Statistics"); - const QString FeatureIdentificationFilters("FeatureIdentification"); - const QString OutputFilters("Output"); - const QString InputFilters("Input"); - const QString ImageFilters("Image"); - const QString CleanupFilters("Cleanup"); - const QString ThresholdFilters("Threshold"); - const QString RegularizationFilters("Regularization"); - const QString ConversionFilters("Conversion"); - const QString FusionFilters("Fusion"); - const QString WarpingFilters("Warping"); - const QString AlignmentFilters("Alignment"); - const QString SegmentationFilters("Segmentation"); - const QString GroupingFilters("Grouping"); - const QString CropCutFilters("Croping/Cutting"); - const QString RotationTransformationFilters("Rotating/Transforming"); - const QString ResolutionFilters("Resolution"); - const QString MorphologicalFilters("Morphological"); - const QString PackingFilters("Packing"); - const QString CrystallographyFilters("Crystallography"); - const QString GenerationFilters("Generation"); - const QString SmoothingFilters("Smoothing"); - const QString CurvatureFilters("Curvature"); - const QString ConnectivityArrangementFilters("Connectivity/Arrangement"); - const QString MappingFilters("Mapping"); - const QString MiscFilters("Misc"); - const QString GeometryFilters("Geometry"); - } - - namespace GeneralData - { - const QString CombinedData("CombinedData"); - const QString ThresholdArray("ThresholdArray"); - const QString Mask("Mask"); - } - - namespace CellData - { - const QString AxisAngles("AxisAngles"); - const QString BC("BandContrasts"); - const QString BandContrast("BandContrast"); - const QString CellPhases("Phases"); - const QString ConfidenceIndex("Confidence Index"); - const QString CAxisLocation("CAxisLocation"); - const QString ConfidenceIndexNoSpace("ConfidenceIndex"); - const QString Current("Current"); - const QString DislocationTensors("DislocationTensors"); - const QString EulerAngles("EulerAngles"); - const QString EulerColor("EulerColor"); - const QString FarFeatureQuats("FarFeatureQuats"); - const QString FarFeatureZoneIds("FarFeatureZoneIds"); - const QString FitQuality("FitQuality"); - const QString FlatImageData("FlatImageData"); - const QString GBEuclideanDistances("GBEuclideanDistances"); - const QString GBManhattanDistances("GBManhattanDistances"); - const QString GlobAlpha("GlobAlpha"); - const QString GoodVoxels("GoodVoxels"); - const QString FeatureIds("FeatureIds"); - const QString FeatureReferenceCAxisMisorientations("FeatureReferenceCAxisMisorientations"); - const QString FeatureReferenceMisorientations("FeatureReferenceMisorientations"); - const QString IPFColor("IPFColor"); - const QString ImageData("ImageData"); - const QString ImageQuality("Image Quality"); - const QString ImageQualityNoSpace("ImageQuality"); - const QString KernelAverageMisorientations("KernelAverageMisorientations"); - const QString Mask("Mask"); - const QString MotionDirection("MotionDirection"); - const QString MicroTexVolFrac("MicroTexVolFrac"); - const QString MisorientationColor("MisorientationColor"); - const QString ParentDensity("ParentDensity"); - const QString MTRgKAM("MTRgKAM"); - const QString NearestNeighbors("NearestNeighbors"); - const QString ParentIds("ParentIds"); - const QString Phases("Phases"); - const QString ProjectedImageMin("ProjectedImageMin"); - const QString ProjectedImageMax("ProjectedImageMax"); - const QString ProjectedImageAvg("ProjectedImageAvg"); - const QString ProjectedImageStd("ProjectedImageStd"); - const QString ProjectedImageVar("ProjectedImageVar"); - const QString QPEuclideanDistances("QPEuclideanDistances"); - const QString QPManhattanDistances("QPManhattanDistances"); - const QString Quats("Quats"); - const QString RodriguesColor("RodriguesColor"); - const QString RodriguesVectors("RodriguesVectors"); - const QString SolidMeshNodes("SolidMeshNodes"); - const QString SineParams("SineParams"); - const QString SolidMeshTetrahedrons("SolidMeshTetrahedrons"); - const QString Speed("Speed"); - const QString SurfaceMeshCells("SurfaceMeshCells"); - const QString BoundaryCells("BoundaryCells"); - const QString TJManhattanDistances("TJManhattanDistances"); - const QString TJEuclideanDistances("TJEuclideanDistances"); - const QString VectorColor("VectorColor"); - const QString VectorData("VectorData"); - const QString Histogram("Histogram"); - } - - namespace FeatureData - { - const QString FeatureID("Feature_ID"); - const QString Active("Active"); - const QString AspectRatios("AspectRatios"); - const QString AvgCAxes("AvgCAxes"); - const QString AvgCAxisMisalignments("AvgCAxisMisalignments"); - const QString LocalCAxisMisalignments("LocalCAxisMisalignments"); - const QString UnbiasedLocalCAxisMisalignments("UnbiasedLocalCAxisMisalignments"); - const QString AvgQuats("AvgQuats"); - const QString AxisEulerAngles("AxisEulerAngles"); - const QString AxisLengths("AxisLengths"); - const QString BasalLoadingFactor("BasalLoadingFactor"); - const QString BiasedFeatures("BiasedFeatures"); - const QString CAxisMisalignmentList("CAxisMisalignmentList"); - const QString Centroids("Centroids"); - const QString ClusteringList("ClusteringList"); - const QString ElasticStrains("ElasticStrains"); - const QString EquivalentDiameters("EquivalentDiameters"); - const QString SaltykovEquivalentDiameters("SaltykovEquivalentDiameters"); - const QString EulerAngles("EulerAngles"); - const QString AvgEulerAngles("AvgEulerAngles"); - const QString F1List("F1List"); - const QString F1sptList("F1sptList"); - const QString F7List("F7List"); - const QString FarFeatureOrientations("FarFeatureOrientations"); - const QString FeaturePhases("Phases"); - const QString GoodFeatures("GoodFeatures"); - const QString FeatureAvgCAxisMisorientations("FeatureAvgCAxisMisorientations"); - const QString FeatureAvgMisorientations("FeatureAvgMisorientations"); - const QString FeatureStdevCAxisMisorientations("FeatureStdevCAxisMisorientations"); - const QString KernelAvgMisorientations("KernelAvgMisorientations"); - const QString LMG("LMG"); - const QString LargestCrossSections("LargestCrossSections"); - const QString Mask("Mask"); - const QString MTRdensity("MTRdensity"); - const QString MTRgKAM("MTRgKAM"); - - const QString MisorientationList("MisorientationList"); - const QString NeighborList("NeighborList"); - const QString NeighborhoodList("NeighborhoodList"); - const QString Neighborhoods("Neighborhoods"); - const QString NumCells("NumCells"); - const QString NumElements("NumElements"); - const QString NumFeaturesPerParent("NumFeaturesPerParent"); - const QString NumNeighbors("NumNeighbors"); - const QString Omega3s("Omega3s"); - const QString ParentIds("ParentIds"); - const QString Phases("Phases"); - const QString Poles("Poles"); - const QString RGBs("RGBs"); - const QString Schmids("Schmids"); - const QString SharedSurfaceAreaList("SharedSurfaceAreaList"); - const QString SlipSystems("SlipSystems"); - const QString SurfaceAreaVol("SurfaceAreaVolumeRatio"); - const QString SurfaceFeatures("SurfaceFeatures"); - const QString SurfaceElementFractions("SurfaceElementFractions"); - const QString Volumes("Volumes"); - const QString AvgMisorientations("AvgMisorientations"); - const QString mPrimeList("mPrimeList"); - const QString NumBins("NumBins"); - const QString ScalarAverages("ScalarAverages"); - - } - - namespace EnsembleData - { - const QString NumFeatures("NumFeatures"); - const QString VolFractions("VolFractions"); - const QString TotalSurfaceAreas("TotalSurfaceAreas"); - const QString CrystalSymmetry("Crystal Symmetry"); - const QString CrystalStructures("CrystalStructures"); - const QString PhaseTypes("PhaseTypes"); - const QString BravaisLattice("BravaisLattice"); - const QString PrecipitateFractions("PrecipitateFractions"); - const QString ShapeTypes("ShapeTypes"); - const QString Statistics("Statistics"); - const QString PhaseName("PhaseName"); - const QString LatticeConstants("LatticeConstants"); - const QString GBCD("GBCD"); - const QString GBCDdimensions("GBCDdimensions"); - const QString FitParameters("FitParameters"); - const QString MaterialName("MaterialName"); - } - - - namespace VertexData - { - const QString AtomVelocities("AtomVelocities"); - const QString AtomTypes("AtomTypes"); - const QString AtomFeatureLabels("AtomFeatureLabels"); - const QString NumberOfArms("NumberOfArms"); - const QString NodeConstraints("NodeConstraints"); - const QString SurfaceMeshNodes("Nodes"); - const QString SurfaceMeshNodeType("NodeType"); - const QString SurfaceMeshNodeNormals("NodeNormals"); - const QString SurfaceMeshNodeFaces("NodeFaces"); - } - - namespace FaceData - { - const QString SurfaceMeshFaces("Faces"); - const QString SurfaceMeshFaceIPFColors("IPFColors"); - const QString SurfaceMeshFaceMisorientationColors("MisorientationColors"); - const QString SurfaceMeshFaceSchuhMisorientationColors("SchuhMisorientationColors"); - const QString SurfaceMeshFaceLabels("FaceLabels"); - const QString SurfaceMeshFacePhases("Phases"); - const QString SurfaceMeshF1s("F1s"); - const QString SurfaceMeshF1spts("F1spts"); - const QString SurfaceMeshF7s("F7s"); - const QString SurfaceMeshmPrimes("mPrimes"); - const QString SurfaceMeshVoxels("SurfaceMeshVoxels"); - const QString SurfaceMeshFaceCentroids("FaceCentroids"); - const QString SurfaceMeshFaceAreas("FaceAreas"); - const QString SurfaceMeshTwinBoundary("TwinBoundary"); - const QString SurfaceMeshTwinBoundaryIncoherence("TwinBoundaryIncoherence"); - const QString SurfaceMeshTwinBoundarySchmidFactors("TwinBoundarySchmidFactors"); - const QString SurfaceMeshFaceDihedralAngles("FaceDihedralAngles"); - const QString SurfaceMeshFaceNormals("FaceNormals"); - const QString SurfaceMeshFeatureFaceId("FeatureFaceId"); - const QString SurfaceMeshGaussianCurvatures("GaussianCurvatures"); - const QString SurfaceMeshMeanCurvatures("MeanCurvatures"); - const QString SurfaceMeshPrincipalCurvature1("PrincipalCurvature1"); - const QString SurfaceMeshPrincipalCurvature2("PrincipalCurvature2"); - const QString SurfaceMeshPrincipalDirection1("PrincipalDirection1"); - const QString SurfaceMeshPrincipalDirection2("PrincipalDirection2"); - } - - namespace EdgeData - { - const QString DislocationIds("DislocationIds"); - const QString BurgersVectors("BurgersVectors"); - const QString SlipPlaneNormals("SlipPlaneNormals"); - const QString SurfaceMeshEdges("SurfaceMeshEdges"); - const QString SurfaceMeshUniqueEdges("SurfaceMeshUniqueEdges"); - const QString SurfaceMeshInternalEdges("SurfaceMeshInternalEdges"); - const QString SurfaceMeshTriangleEdges("SurfaceMeshTriangleEdges"); - const QString SurfaceMeshEdgeFaces("SurfaceMeshEdgeFaces"); - } - - namespace Settings - { - const QString Library("Filter Library"); - const QString PrebuiltPipelines("Prebuilt Pipelines"); - const QString FavoritePipelines("Favorite Pipelines"); - const QString PipelineBuilderGroup("PipelineBuilder"); - const QString FavoriteConfig("favorite_config"); - const QString NumFilters("Number_Filters"); - const QString PipelineName("Name"); - const QString FilterName("Filter_Name"); - const QString FilterUuid("Filter_Uuid"); - const QString FilterVersion("FilterVersion"); - const QString HumanLabel("Filter_Human_Label"); - const QString FilterEnabled("Filter_Enabled"); - const QString GroupName("GroupName"); - const QString SubGroupName("SubGroupName"); - const QString BrandingString("BrandingString"); - const QString CompiledLibraryName("CompiledLibraryName"); - const QString Version("Version"); - const QString PipelineBuilderGeomertry("PipelineBuilderGeometry"); - } - - - namespace HDF5 - { - const QString FileVersion("7.0"); - const QString FileVersionName("FileVersion"); - const QString DREAM3DVersion("DREAM3D Version"); - const QString ObjectType("ObjectType"); - const QString Rank("Rank"); - const QString TupleDimensions("TupleDimensions"); - const QString ComponentDimensions("ComponentDimensions"); - const QString AxisDimensions("Tuple Axis Dimensions"); - const QString DataArrayVersion("DataArrayVersion"); - } - - namespace StringConstants - { - const QString Alpha("Alpha"); - const QString Angle("Angle"); - - const QString Average("Average"); - const QString Axis("Axis"); - const QString AxisODFWeights("AxisODF-Weights"); - const QString AxisOrientation("AxisOrientation"); - const QString Beta("Beta"); - const QString BetaDistribution("Beta Distribution"); - const QString BinNumber("BinNumber"); - const QString BinCount("Bin Count"); - const QString BinStepSize("Bin Step Size"); - const QString BoundaryArea("BoundaryArea"); - const QString BoundaryStatsData("BoundaryStatsData"); - const QString CellNeighbors("CellNeighbors"); - - const QString CellsContainingVert("CellsContainingVert"); - const QString CellsName("Cells"); - const QString CrystalStructure("CrystalStructure"); - const QString DataContainerGroupName("DataContainers"); - const QString DataContainerBundleGroupName("DataContainerBundles"); - const QString DataContainerNames("DataContainerNames"); - const QString MetaDataArrays("MetaDataArrays"); - const QString DataContainerType("DataContainerType"); - const QString AttributeMatrixType("AttributeMatrixType"); - - const QString Dims("Dims"); - const QString DistributionType("Distribution Type"); - - const QString EdgeNeighbors("EdgeNeighbors"); - const QString EdgesContainingVert("EdgesContainingVert"); - const QString EdgesName("Edges"); - const QString EdgeCentroids("EdgeCentroids"); - const QString EdgeLengths("EdgeLengths"); - const QString Euler1("Euler 1"); - const QString Euler2("Euler 2"); - const QString Euler3("Euler 3"); - const QString Exp_k("K"); - - const QString FaceNeighbors("FaceNeighbors"); - const QString FacesContainingVert("FacesContainingVert"); - const QString FacesName("Faces"); - const QString TrianglesName("Triangles"); - const QString TriangleNeighbors("TriangleNeighbors"); - const QString TrianglesContainingVert("TrianglesContainingVert"); - const QString TriangleCentroids("TriangleCentroids"); - const QString TriangleAreas("TriangleAreas"); - const QString Frequencies("Frequencies"); - - const QString QuadsName("Quadrilaterals"); - const QString QuadNeighbors("QuadrilateralNeighbors"); - const QString QuadsContainingVert("QuadrilateralsContainingVerts"); - const QString QuadCentroids("QuadrilateralCentroids"); - const QString QuadAreas("QuadrilateralAreas"); - - const QString TetsName("Tetrahedra"); - const QString TetNeighbors("TetrahedralNeighbors"); - const QString TetsContainingVert("TetrahedraContainingVerts"); - const QString TetCentroids("TetrahedralCentroids"); - const QString TetVolumes("TetrahedralVolumes"); - - const QString HexasName("Hexahedra"); - const QString HexNeighbors("HexahedralNeighbors"); - const QString HexasContainingVert("HexahedraContainingVerts"); - const QString HexCentroids("HexahedralCentroids"); - const QString HexVolumes("HexahedralVolumes"); - - const QString VoxelSizes("VoxelSizes"); - const QString VertexSizes("VertexSizes"); - - const QString GBCD("GBCD"); - const QString FeatureAvgDisorientation ("FeatureAvgDisorientation"); - const QString Feature_Diameter_Info("Feature_Diameter_Info"); - const QString Feature_SizeVBoverA_Distributions("FeatureSize Vs B Over A Distributions"); - const QString Feature_SizeVCoverA_Distributions("FeatureSize Vs C Over A Distributions"); - const QString Feature_SizeVNeighbors_Distributions("FeatureSize Vs Neighbors Distributions"); - const QString Feature_SizeVOmega3_Distributions("FeatureSize Vs Omega3 Distributions"); - const QString Feature_SizeVClustering_Distributions("FeatureSize Vs Clustering Distributions"); - const QString Feature_Size_Distribution("FeatureSize Distribution"); - const QString KernelAvgDisorientation( "KernelAvgDisorientation"); - const QString LogNormalDistribution("Log Normal Distribution"); - const QString MDFWeights("MDF-Weights"); - const QString MatrixStatsData("MatrixStatsData"); - const QString MeshFaceNeighborLists("MeshFaceNeighborLists"); - const QString MicroTextureBins("MicroTextureBins"); - const QString MinimumValue("Minimum Value"); - const QString MinMaxNoOfBins("MinMaxNoOfBins"); - const QString MisorientationBins("MisorientationBins"); - const QString Neighbor_Feature_ID_List( "Neighbor_Feature_ID_List"); - - const QString ODF("ODF"); - const QString ODFWeights("ODF-Weights"); - - const QString ParentPhase("Parent Phase"); - const QString PhaseFraction("PhaseFraction"); - const QString PhaseType("PhaseType"); - const QString PipelineGroupName("Pipeline"); - const QString PipelineVersionName("Pipeline Version"); - const QString PipelineCurrentName("Current Pipeline"); - const QString PowerLawDistribution("Power Law Distribution"); - const QString PrecipitateBoundaryFraction("Precipitate Boundary Fraction"); - const QString PrecipitateStatsData("PrecipitateStatsData"); - const QString PrimaryStatsData("PrimaryStatsData"); - const QString PresetName("PresetName"); - - const QString RadialDistFunc("Radial Distribution Function"); - const QString RdfMinDistance("Min"); - const QString RdfMaxDistance("Max"); - const QString RdfBoxDims("BoxDims"); - const QString RdfBoxRes("BoxRes"); - - const QString Sigma("Sigma"); - const QString StandardDeviation("Standard Deviation"); - const QString Statistics("Statistics"); - const QString Stats("Stats"); - const QString StatsData("StatsData"); - const QString StatsType("StatsType"); - - const QString TransformationStatsData("TransformationStatsData"); - const QString UnknownDistribution("Unknown Distribution"); - - const QString VerticesName("Vertices"); - const QString VertsName("Verts"); - const QString ImageName("Image"); - - const QString Weight("Weight"); - - const QString MetaData("_META_DATA"); - - const QString Name("Name"); - const QString Index("Index"); - } - - namespace CellType - { - const QString Quadrilateral("Quadrilateral"); - const QString Tetrahedron("Tetrahedron"); - const QString Triangle("Triangle"); - const QString Face("Face"); - const QString Edge("Edge"); - const QString Vertex("Vertex"); - const QString Node("Node"); - } - - //namespace PhaseType - //{ - // //const unsigned int PrimaryPhase = 0; //!< - // //const unsigned int PrecipitatePhase = 1; //!< - // //const unsigned int TransformationPhase = 2; //!< - // //const unsigned int MatrixPhase = 3; //!< - // //const unsigned int BoundaryPhase = 4; //!< - // //const unsigned int Unknown = 999; //!< - - // const QString Primary("Primary"); - // const QString Precipitate("Precipitate"); - // const QString Transformation("Transformation"); - // const QString Matrix("Matrix"); - // const QString Boundary("Boundary"); - // const QString UnknownPhase("Unknown"); - //} - - namespace AlignmentMethod - { - const unsigned int OuterBoundary = 0; //!< - const unsigned int Misorientation = 1; //!< - const unsigned int MutualInformation = 2; //!< - const unsigned int Count = 3; //!< - const unsigned int UnknownAlignmentMethod = 999; //!< - } - - namespace StatisticsType - { - const unsigned int Feature_SizeVBoverA = 0; //!< - const unsigned int Feature_SizeVCoverA = 1; //!< - const unsigned int Feature_SizeVNeighbors = 2; //!< - const unsigned int Feature_SizeVOmega3 = 3; //!< - const unsigned int Feature_SizeVClustering = 4; //!< - const unsigned int UnknownStatisticsGroup = 999; //!< - - } - - namespace DistributionType - { - const unsigned int Beta = 0; //!< - const unsigned int LogNormal = 1; //!< - const unsigned int Power = 2; //!< - const unsigned int RDFFrequency = 3; //!< - const unsigned int RDFMaxMin = 4; //!< - const unsigned int UnknownDistributionType = 5; //!< - const unsigned int Count = 6; //!< - - enum ColumnCount - { - BetaColumnCount = 2, //!< - LogNormalColumnCount = 2, //!< - PowerLawColumnCount = 2, //!< - RawDistDataColumnCount = 1, //!< - UnknownColumCount = 0 //!< - }; - - - } - - namespace EulerAngleConversionType - { - const unsigned int DegreesToRadians = 0; //!< - const unsigned int RadiansToDegrees = 1; //!< - } - - namespace FlattenImageMethod - { - const unsigned int Lightness = 0; //!< - const unsigned int Average = 1; //!< - const unsigned int Luminosity = 2; //!< - } - - namespace EulerFrameRotationAxis - { - const unsigned int RD = 0; //!< - const unsigned int TD = 1; //!< - const unsigned int ND = 2; //!< - const unsigned int None = 3; //!< - } - - namespace SampleFrameRotationAxis - { - const unsigned int X = 0; //!< - const unsigned int Y = 1; //!< - const unsigned int Z = 2; //!< - const unsigned int None = 3; //!< - } - - namespace RefFrameRotationAngle - { - const unsigned int Ninety = 0; //!< - const unsigned int oneEighty = 1; //!< - const unsigned int twoSeventy = 2; //!< - const unsigned int Mirror = 3; //!< - const unsigned int Zero = 4; //!< - } - - namespace Overlap - { - const unsigned int Rigid = 0; //!< - const unsigned int Progressive = 1; //!< - const unsigned int UnknownOverlap = 999; //!< - } +} // namespace DistributionType + +namespace EulerAngleConversionType +{ +inline constexpr uint32_t DegreesToRadians = 0; //!< +inline constexpr uint32_t RadiansToDegrees = 1; //!< +} // namespace EulerAngleConversionType + +namespace FlattenImageMethod +{ +inline constexpr uint32_t Lightness = 0; //!< +inline constexpr uint32_t Average = 1; //!< +inline constexpr uint32_t Luminosity = 2; //!< +} // namespace FlattenImageMethod + +namespace EulerFrameRotationAxis +{ +inline constexpr uint32_t RD = 0; //!< +inline constexpr uint32_t TD = 1; //!< +inline constexpr uint32_t ND = 2; //!< +inline constexpr uint32_t None = 3; //!< +} // namespace EulerFrameRotationAxis + +namespace SampleFrameRotationAxis +{ +inline constexpr uint32_t X = 0; //!< +inline constexpr uint32_t Y = 1; //!< +inline constexpr uint32_t Z = 2; //!< +inline constexpr uint32_t None = 3; //!< +} // namespace SampleFrameRotationAxis + +namespace RefFrameRotationAngle +{ +inline constexpr uint32_t Ninety = 0; //!< +inline constexpr uint32_t oneEighty = 1; //!< +inline constexpr uint32_t twoSeventy = 2; //!< +inline constexpr uint32_t Mirror = 3; //!< +inline constexpr uint32_t Zero = 4; //!< +} // namespace RefFrameRotationAngle + +namespace Overlap +{ +inline constexpr uint32_t Rigid = 0; //!< +inline constexpr uint32_t Progressive = 1; //!< +inline constexpr uint32_t UnknownOverlap = 999; //!< +} // namespace Overlap // namespace DataContainerType // { -// const unsigned int VolumeDataContainer = 0; //!< -// const unsigned int SurfaceDataContainer = 1; //!< -// const unsigned int EdgeDataContainer = 2; //!< -// const unsigned int VertexDataContainer = 3; //!< -// const unsigned int UnknownDataContainer = 999; //!< +// inline constexpr uint32_t VolumeDataContainer = 0; //!< +// inline constexpr uint32_t SurfaceDataContainer = 1; //!< +// inline constexpr uint32_t EdgeDataContainer = 2; //!< +// inline constexpr uint32_t VertexDataContainer = 3; //!< +// inline constexpr uint32_t UnknownDataContainer = 999; //!< // } // namespace AttributeMatrixType // { -// const unsigned int Vertex = 0; //!< -// const unsigned int Edge = 1; //!< -// const unsigned int Face = 2; //!< -// const unsigned int Cell = 3; //!< -// const unsigned int VertexFeature = 4; //!< -// const unsigned int EdgeFeature = 5; //!< -// const unsigned int FaceFeature = 6; //!< -// const unsigned int CellFeature = 7; //!< -// const unsigned int VertexEnsemble = 8; //!< -// const unsigned int EdgeEnsemble = 9; //!< -// const unsigned int FaceEnsemble = 10; //!< -// const unsigned int CellEnsemble = 11; //!< -// const unsigned int MetaData = 12; //!< -// const unsigned int Generic = 13; //!< -// const unsigned int Unknown = 999; //!< +// inline constexpr uint32_t Vertex = 0; //!< +// inline constexpr uint32_t Edge = 1; //!< +// inline constexpr uint32_t Face = 2; //!< +// inline constexpr uint32_t Cell = 3; //!< +// inline constexpr uint32_t VertexFeature = 4; //!< +// inline constexpr uint32_t EdgeFeature = 5; //!< +// inline constexpr uint32_t FaceFeature = 6; //!< +// inline constexpr uint32_t CellFeature = 7; //!< +// inline constexpr uint32_t VertexEnsemble = 8; //!< +// inline constexpr uint32_t EdgeEnsemble = 9; //!< +// inline constexpr uint32_t FaceEnsemble = 10; //!< +// inline constexpr uint32_t CellEnsemble = 11; //!< +// inline constexpr uint32_t MetaData = 12; //!< +// inline constexpr uint32_t Generic = 13; //!< +// inline constexpr uint32_t Unknown = 999; //!< // } // namespace AttributeMatrixObjectType // { -// const unsigned int Element = 0; -// const unsigned int Feature = 1; -// const unsigned int Ensemble = 2; -// const unsigned int Any = 3; +// inline constexpr uint32_t Element = 0; +// inline constexpr uint32_t Feature = 1; +// inline constexpr uint32_t Ensemble = 2; +// inline constexpr uint32_t Any = 3; // } namespace Geometry { - const QString Geometry("_SIMPL_GEOMETRY"); - const QString GeometryName("GeometryName"); - const QString GeometryType("GeometryType"); - const QString GeometryTypeName("GeometryTypeName"); - const QString NumberOfTuples("NumberOfTuples"); - const QString UnitDimensionality("UnitDimensionality"); - const QString SpatialDimensionality("SpatialDimensionality"); - - const QString AnyGeometry("AnyGeometry"); - const QString UnknownGeometry("UnkownGeometry"); - const QString ImageGeometry("ImageGeometry"); - const QString RectGridGeometry("RectGridGeometry"); - const QString VertexGeometry("VertexGeometry"); - const QString EdgeGeometry("EdgeGeometry"); - const QString TriangleGeometry("TriangleGeometry"); - const QString QuadGeometry("QuadrilateralGeometry"); - const QString TetrahedralGeometry("TetrahedralGeometry"); - const QString HexahedralGeometry("HexahedralGeometry"); - - const QString xBoundsList("xBounds"); - const QString yBoundsList("yBounds"); - const QString zBoundsList("zBounds"); - const QString SharedVertexList("SharedVertexList"); - const QString SharedEdgeList("SharedEdgeList"); - const QString SharedTriList("SharedTriList"); - const QString SharedQuadList("SharedQuadList"); - const QString SharedTetList("SharedTetList"); - const QString SharedHexList("SharedHexList"); - const QString UnsharedEdgeList("UnsharedEdgeList"); - const QString UnsharedFaceList("UnsharedFaceList"); - - const QString TransformContainerGroup("TransformContainerGroup"); - const QString TransformContainer("TransformContainer"); - const QString CompositeTransformContainer("CompositeTransformContainer"); - const QString TransformContainerTypeName("TransformContainerTypeName"); - const QString UnknownTransformContainer("UnknownTransformContainer"); - const QString TransformContainerParameters("TransformParameters"); - const QString TransformContainerFixedParameters("TransformFixedParameters"); - const QString TransformContainerTypeAsString("TransformType"); - const QString TransformContainerMovingName("TransformMovingName"); - const QString TransformContainerReferenceName("TransformReferenceName"); - - const QString k_Yoctometer("Yoctometer"); - const QString k_Zeptometer("Zeptometer"); - const QString k_Attometer("Attometer"); - const QString k_Femtometer("Femtometer"); - const QString k_Picometer("Picometer"); - const QString k_Nanometer("Nanometer"); - const QString k_Micrometer("Micrometer"); - const QString k_Millimeter("Millimeter"); - const QString k_Centimeter("Centimeter"); - const QString k_Decimeter("Decimeter"); - const QString k_Meter("Meter"); - const QString k_Decameter("Decameter"); - const QString k_Hectometer("Hectometer"); - const QString k_Kilometer("Kilometer"); - const QString k_Megameter("Megameter"); - const QString k_Gigameter("Gigameter"); - const QString k_Terameter("Terameter"); - const QString k_Petameter("Petameter"); - const QString k_Exameter("Exameter"); - const QString k_Zettameter("Zettameter"); - const QString k_Yottameter("Yottameter"); - const QString k_Angstrom("Angstrom"); - const QString k_Mil("Mil"); - const QString k_Inch("Inch"); - const QString k_Foot("Foot"); - const QString k_Mile("Mile"); - const QString k_Fathom("Fathom"); - const QString k_Unspecified("Unspecified"); - const QString k_Unknown("Unknown"); -} +inline const QString Geometry("_SIMPL_GEOMETRY"); +inline const QString GeometryName("GeometryName"); +inline const QString GeometryType("GeometryType"); +inline const QString GeometryTypeName("GeometryTypeName"); +inline const QString NumberOfTuples("NumberOfTuples"); +inline const QString UnitDimensionality("UnitDimensionality"); +inline const QString SpatialDimensionality("SpatialDimensionality"); + +inline const QString AnyGeometry("AnyGeometry"); +inline const QString UnknownGeometry("UnkownGeometry"); +inline const QString ImageGeometry("ImageGeometry"); +inline const QString RectGridGeometry("RectGridGeometry"); +inline const QString VertexGeometry("VertexGeometry"); +inline const QString EdgeGeometry("EdgeGeometry"); +inline const QString TriangleGeometry("TriangleGeometry"); +inline const QString QuadGeometry("QuadrilateralGeometry"); +inline const QString TetrahedralGeometry("TetrahedralGeometry"); +inline const QString HexahedralGeometry("HexahedralGeometry"); + +inline const QString xBoundsList("xBounds"); +inline const QString yBoundsList("yBounds"); +inline const QString zBoundsList("zBounds"); +inline const QString SharedVertexList("SharedVertexList"); +inline const QString SharedEdgeList("SharedEdgeList"); +inline const QString SharedTriList("SharedTriList"); +inline const QString SharedQuadList("SharedQuadList"); +inline const QString SharedTetList("SharedTetList"); +inline const QString SharedHexList("SharedHexList"); +inline const QString UnsharedEdgeList("UnsharedEdgeList"); +inline const QString UnsharedFaceList("UnsharedFaceList"); + +inline const QString TransformContainerGroup("TransformContainerGroup"); +inline const QString TransformContainer("TransformContainer"); +inline const QString CompositeTransformContainer("CompositeTransformContainer"); +inline const QString TransformContainerTypeName("TransformContainerTypeName"); +inline const QString UnknownTransformContainer("UnknownTransformContainer"); +inline const QString TransformContainerParameters("TransformParameters"); +inline const QString TransformContainerFixedParameters("TransformFixedParameters"); +inline const QString TransformContainerTypeAsString("TransformType"); +inline const QString TransformContainerMovingName("TransformMovingName"); +inline const QString TransformContainerReferenceName("TransformReferenceName"); + +inline const QString k_Yoctometer("Yoctometer"); +inline const QString k_Zeptometer("Zeptometer"); +inline const QString k_Attometer("Attometer"); +inline const QString k_Femtometer("Femtometer"); +inline const QString k_Picometer("Picometer"); +inline const QString k_Nanometer("Nanometer"); +inline const QString k_Micrometer("Micrometer"); +inline const QString k_Millimeter("Millimeter"); +inline const QString k_Centimeter("Centimeter"); +inline const QString k_Decimeter("Decimeter"); +inline const QString k_Meter("Meter"); +inline const QString k_Decameter("Decameter"); +inline const QString k_Hectometer("Hectometer"); +inline const QString k_Kilometer("Kilometer"); +inline const QString k_Megameter("Megameter"); +inline const QString k_Gigameter("Gigameter"); +inline const QString k_Terameter("Terameter"); +inline const QString k_Petameter("Petameter"); +inline const QString k_Exameter("Exameter"); +inline const QString k_Zettameter("Zettameter"); +inline const QString k_Yottameter("Yottameter"); +inline const QString k_Angstrom("Angstrom"); +inline const QString k_Mil("Mil"); +inline const QString k_Inch("Inch"); +inline const QString k_Foot("Foot"); +inline const QString k_Mile("Mile"); +inline const QString k_Fathom("Fathom"); +inline const QString k_Unspecified("Unspecified"); +inline const QString k_Unknown("Unknown"); +} // namespace Geometry // namespace GeometryType // { -// const unsigned int ImageGeometry = 11; -// const unsigned int RectGridGeometry = 11; -// const unsigned int VertexGeometry = 1; -// const unsigned int EdgeGeometry = 3; -// const unsigned int TriangleGeometry = 5; -// const unsigned int QuadGeometry = 9; -// const unsigned int TetrahedralGeometry = 10; -// const unsigned int UnknownGeometry = 999; +// inline constexpr uint32_t ImageGeometry = 11; +// inline constexpr uint32_t RectGridGeometry = 11; +// inline constexpr uint32_t VertexGeometry = 1; +// inline constexpr uint32_t EdgeGeometry = 3; +// inline constexpr uint32_t TriangleGeometry = 5; +// inline constexpr uint32_t QuadGeometry = 9; +// inline constexpr uint32_t TetrahedralGeometry = 10; +// inline constexpr uint32_t UnknownGeometry = 999; // } namespace XdmfGridType { -const unsigned int PolyData = 0; -const unsigned int RectilinearGrid = 1; -const unsigned int UnknownGrid = 0xFFFFFFFF; -} +inline constexpr uint32_t PolyData = 0; +inline constexpr uint32_t RectilinearGrid = 1; +inline constexpr uint32_t UnknownGrid = 0xFFFFFFFF; +} // namespace XdmfGridType namespace XdmfCenterType { -const QString Node("Node"); -const QString Edge("Edge"); -const QString Face("Face"); -const QString Cell("Cell"); -const QString Grid("Grid"); -} +inline const QString Node("Node"); +inline const QString Edge("Edge"); +inline const QString Face("Face"); +inline const QString Cell("Cell"); +inline const QString Grid("Grid"); +} // namespace XdmfCenterType // namespace ShapeType //{ -// const unsigned int EllipsoidShape = 0; //!< -// const unsigned int SuperEllipsoidShape = 1; //!< -// const unsigned int CubeOctahedronShape = 2; //!< -// const unsigned int CylinderAShape = 3; //!< -// const unsigned int CylinderBShape = 4; //!< -// const unsigned int CylinderCShape = 5; //!< -// const unsigned int ShapeTypeEnd = 6; -// const unsigned int UnknownShapeType = 999; //!< +// inline constexpr uint32_t EllipsoidShape = 0; //!< +// inline constexpr uint32_t SuperEllipsoidShape = 1; //!< +// inline constexpr uint32_t CubeOctahedronShape = 2; //!< +// inline constexpr uint32_t CylinderAShape = 3; //!< +// inline constexpr uint32_t CylinderBShape = 4; //!< +// inline constexpr uint32_t CylinderCShape = 5; //!< +// inline constexpr uint32_t ShapeTypeEnd = 6; +// inline constexpr uint32_t UnknownShapeType = 999; //!< //} -enum class Precipitates : unsigned int +enum class Precipitates : uint32_t { NoPrecipitates = 0, //!< BoundaryPrecipitates = 1, //!< @@ -971,77 +981,77 @@ enum class Precipitates : unsigned int namespace Reconstruction { /* Reconstruction related */ -const QString H5VoxelFile("VoxelData.h5voxel"); +inline const QString H5VoxelFile("VoxelData.h5voxel"); -const QString VisualizationVizFile("Visualization.vtk"); // 11 -const QString DownSampledVizFile("DownSampled_Visualization.vtk"); // 11 -const QString HDF5FeatureFile("Features.h5feature"); -} +inline const QString VisualizationVizFile("Visualization.vtk"); // 11 +inline const QString DownSampledVizFile("DownSampled_Visualization.vtk"); // 11 +inline const QString HDF5FeatureFile("Features.h5feature"); +} // namespace Reconstruction namespace SyntheticBuilder { -const QString FeatureDataFile("FeatureData.csv"); -const QString H5VoxelFile("VoxelData.h5voxel"); +inline const QString FeatureDataFile("FeatureData.csv"); +inline const QString H5VoxelFile("VoxelData.h5voxel"); -const QString VisualizationVizFile("Visualization.vtk"); -const QString HDF5FeatureFile("Features.h5feature"); +inline const QString VisualizationVizFile("Visualization.vtk"); +inline const QString HDF5FeatureFile("Features.h5feature"); -const QString ErrorFile("Error.txt"); -const QString VtkFile("Test.vtk"); -} +inline const QString ErrorFile("Error.txt"); +inline const QString VtkFile("Test.vtk"); +} // namespace SyntheticBuilder /* Surface Meshing Related */ namespace SurfaceMesh { namespace NodeType { -const signed char Unused = 0; -const signed char Default = 2; -const signed char TriplePoint = 3; -const signed char QuadPoint = 4; -const signed char SurfaceDefault = 12; -const signed char SurfaceTriplePoint = 13; -const signed char SurfaceQuadPoint = 14; -} +inline constexpr int8_t Unused = 0; +inline constexpr int8_t Default = 2; +inline constexpr int8_t TriplePoint = 3; +inline constexpr int8_t QuadPoint = 4; +inline constexpr int8_t SurfaceDefault = 12; +inline constexpr int8_t SurfaceTriplePoint = 13; +inline constexpr int8_t SurfaceQuadPoint = 14; +} // namespace NodeType namespace NodeId { -const signed char Unused = -1; -} +inline constexpr int8_t Unused = -1; } +} // namespace SurfaceMesh namespace SolidMeshing { /* Solid Meshing Related */ -const QString MeshFile("solid_mesh_v5_1.vtk"); -const QString MeshFile2("solid_mesh_v5_2.vtk"); -const QString ElementQualityFile("element_quality_measures_v5.txt"); -const QString VoxelsFile("voxels_v5.txt"); -} +inline const QString MeshFile("solid_mesh_v5_1.vtk"); +inline const QString MeshFile2("solid_mesh_v5_2.vtk"); +inline const QString ElementQualityFile("element_quality_measures_v5.txt"); +inline const QString VoxelsFile("voxels_v5.txt"); +} // namespace SolidMeshing namespace Union { namespace Strings { -const QString And("And"); -const QString Or("Or"); -} +inline const QString And("And"); +inline const QString Or("Or"); +} // namespace Strings enum Enumeration { Operator_And = 0, Operator_Or, Operator_Unknown }; -} +} // namespace Union namespace Comparison { namespace Strings { -const QString LessThan("<"); -const QString GreaterThan(">"); -const QString Equal("="); -const QString NotEqual("!="); -} +inline const QString LessThan("<"); +inline const QString GreaterThan(">"); +inline const QString Equal("="); +inline const QString NotEqual("!="); +} // namespace Strings enum Enumeration { Operator_LessThan = 0, @@ -1050,27 +1060,27 @@ enum Enumeration Operator_NotEqual, Operator_Unknown }; -} +} // namespace Comparison namespace Layout { -const signed int Horizontal = 0; -const signed int Vertical = 1; -const signed int Square = 2; -}; -} +inline constexpr int32_t Horizontal = 0; +inline constexpr int32_t Vertical = 1; +inline constexpr int32_t Square = 2; +}; // namespace Layout +} // namespace SIMPL namespace Core { -const QString CoreBaseName("Core"); +inline const QString CoreBaseName("Core"); } namespace Test { -const QString TestPluginFile("TestPlugin"); -const QString TestPluginDisplayName("Test Plugin"); -const QString TestBaseName("Test"); -} +inline const QString TestPluginFile("TestPlugin"); +inline const QString TestPluginDisplayName("Test Plugin"); +inline const QString TestBaseName("Test"); +} // namespace Test Q_DECLARE_METATYPE(SIMPL::NumericTypes::Type) Q_DECLARE_METATYPE(SIMPL::ScalarTypes::Type) @@ -1079,15 +1089,15 @@ Q_DECLARE_METATYPE(SIMPL::DelimiterTypes::Type) #if 0 namespace Generic { - const QString GenericPluginFile("GenericPlugin"); - const QString GenericPluginDisplayName("Generic Plugin"); - const QString GenericBaseName("Generic"); + inline const QString GenericPluginFile("GenericPlugin"); + inline const QString GenericPluginDisplayName("Generic Plugin"); + inline const QString GenericBaseName("Generic"); } namespace IO { - const QString IOPluginFile("IOPlugin"); - const QString IOPluginDisplayName("IO Plugin"); - const QString IOBaseName("IO"); + inline const QString IOPluginFile("IOPlugin"); + inline const QString IOPluginDisplayName("IO Plugin"); + inline const QString IOBaseName("IO"); } #endif diff --git a/Source/SIMPLib/Common/CreatedArrayHelpIndexEntry.cpp b/Source/SIMPLib/Common/CreatedArrayHelpIndexEntry.cpp index e6becd2754..df0292e471 100644 --- a/Source/SIMPLib/Common/CreatedArrayHelpIndexEntry.cpp +++ b/Source/SIMPLib/Common/CreatedArrayHelpIndexEntry.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CreatedArrayHelpIndexEntry.h" @@ -47,3 +47,136 @@ CreatedArrayHelpIndexEntry::CreatedArrayHelpIndexEntry() // // ----------------------------------------------------------------------------- CreatedArrayHelpIndexEntry::~CreatedArrayHelpIndexEntry() = default; + +// ----------------------------------------------------------------------------- +CreatedArrayHelpIndexEntry::Pointer CreatedArrayHelpIndexEntry::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +CreatedArrayHelpIndexEntry::Pointer CreatedArrayHelpIndexEntry::New() +{ + Pointer sharedPtr(new(CreatedArrayHelpIndexEntry)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString CreatedArrayHelpIndexEntry::getNameOfClass() const +{ + return QString("CreatedArrayHelpIndexEntry"); +} + +// ----------------------------------------------------------------------------- +QString CreatedArrayHelpIndexEntry::ClassName() +{ + return QString("CreatedArrayHelpIndexEntry"); +} + +// ----------------------------------------------------------------------------- +void CreatedArrayHelpIndexEntry::setFilterName(const QString& value) +{ + m_FilterName = value; +} + +// ----------------------------------------------------------------------------- +QString CreatedArrayHelpIndexEntry::getFilterName() const +{ + return m_FilterName; +} + +// ----------------------------------------------------------------------------- +void CreatedArrayHelpIndexEntry::setFilterHumanLabel(const QString& value) +{ + m_FilterHumanLabel = value; +} + +// ----------------------------------------------------------------------------- +QString CreatedArrayHelpIndexEntry::getFilterHumanLabel() const +{ + return m_FilterHumanLabel; +} + +// ----------------------------------------------------------------------------- +void CreatedArrayHelpIndexEntry::setFilterGroup(const QString& value) +{ + m_FilterGroup = value; +} + +// ----------------------------------------------------------------------------- +QString CreatedArrayHelpIndexEntry::getFilterGroup() const +{ + return m_FilterGroup; +} + +// ----------------------------------------------------------------------------- +void CreatedArrayHelpIndexEntry::setFilterSubGroup(const QString& value) +{ + m_FilterSubGroup = value; +} + +// ----------------------------------------------------------------------------- +QString CreatedArrayHelpIndexEntry::getFilterSubGroup() const +{ + return m_FilterSubGroup; +} + +// ----------------------------------------------------------------------------- +void CreatedArrayHelpIndexEntry::setArrayDefaultName(const QString& value) +{ + m_ArrayDefaultName = value; +} + +// ----------------------------------------------------------------------------- +QString CreatedArrayHelpIndexEntry::getArrayDefaultName() const +{ + return m_ArrayDefaultName; +} + +// ----------------------------------------------------------------------------- +void CreatedArrayHelpIndexEntry::setArrayGroup(const QString& value) +{ + m_ArrayGroup = value; +} + +// ----------------------------------------------------------------------------- +QString CreatedArrayHelpIndexEntry::getArrayGroup() const +{ + return m_ArrayGroup; +} + +// ----------------------------------------------------------------------------- +void CreatedArrayHelpIndexEntry::setArrayType(const QString& value) +{ + m_ArrayType = value; +} + +// ----------------------------------------------------------------------------- +QString CreatedArrayHelpIndexEntry::getArrayType() const +{ + return m_ArrayType; +} + +// ----------------------------------------------------------------------------- +void CreatedArrayHelpIndexEntry::setArrayNumComponents(int value) +{ + m_ArrayNumComponents = value; +} + +// ----------------------------------------------------------------------------- +int CreatedArrayHelpIndexEntry::getArrayNumComponents() const +{ + return m_ArrayNumComponents; +} + +// ----------------------------------------------------------------------------- +void CreatedArrayHelpIndexEntry::setArrayDescription(const QString& value) +{ + m_ArrayDescription = value; +} + +// ----------------------------------------------------------------------------- +QString CreatedArrayHelpIndexEntry::getArrayDescription() const +{ + return m_ArrayDescription; +} diff --git a/Source/SIMPLib/Common/CreatedArrayHelpIndexEntry.h b/Source/SIMPLib/Common/CreatedArrayHelpIndexEntry.h old mode 100755 new mode 100644 index 7045004b2b..50634ab6fc --- a/Source/SIMPLib/Common/CreatedArrayHelpIndexEntry.h +++ b/Source/SIMPLib/Common/CreatedArrayHelpIndexEntry.h @@ -1,78 +1,179 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include #include +#include + #include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" class SIMPLib_EXPORT CreatedArrayHelpIndexEntry { - public: - SIMPL_SHARED_POINTERS(CreatedArrayHelpIndexEntry) - SIMPL_STATIC_NEW_MACRO(CreatedArrayHelpIndexEntry) - SIMPL_TYPE_MACRO(CreatedArrayHelpIndexEntry) +public: + using Self = CreatedArrayHelpIndexEntry; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - typedef QVector VectorType; + static Pointer New(); - virtual ~CreatedArrayHelpIndexEntry(); + /** + * @brief Returns the name of the class for CreatedArrayHelpIndexEntry + */ + QString getNameOfClass() const; + /** + * @brief Returns the name of the class for CreatedArrayHelpIndexEntry + */ + static QString ClassName(); - SIMPL_INSTANCE_STRING_PROPERTY(FilterName) - SIMPL_INSTANCE_STRING_PROPERTY(FilterHumanLabel) - SIMPL_INSTANCE_STRING_PROPERTY(FilterGroup) - SIMPL_INSTANCE_STRING_PROPERTY(FilterSubGroup) + typedef QVector VectorType; - SIMPL_INSTANCE_STRING_PROPERTY(ArrayDefaultName) - SIMPL_INSTANCE_STRING_PROPERTY(ArrayGroup) - SIMPL_INSTANCE_STRING_PROPERTY(ArrayType) - SIMPL_INSTANCE_PROPERTY(int, ArrayNumComponents) - SIMPL_INSTANCE_STRING_PROPERTY(ArrayDescription) + virtual ~CreatedArrayHelpIndexEntry(); + /** + * @brief Setter property for FilterName + */ + void setFilterName(const QString& value); + /** + * @brief Getter property for FilterName + * @return Value of FilterName + */ + QString getFilterName() const; - protected: - CreatedArrayHelpIndexEntry(); + /** + * @brief Setter property for FilterHumanLabel + */ + void setFilterHumanLabel(const QString& value); + /** + * @brief Getter property for FilterHumanLabel + * @return Value of FilterHumanLabel + */ + QString getFilterHumanLabel() const; - public: - CreatedArrayHelpIndexEntry(const CreatedArrayHelpIndexEntry&) = delete; // Copy Constructor Not Implemented - CreatedArrayHelpIndexEntry(CreatedArrayHelpIndexEntry&&) = delete; // Move Constructor Not Implemented - CreatedArrayHelpIndexEntry& operator=(const CreatedArrayHelpIndexEntry&) = delete; // Copy Assignment Not Implemented - CreatedArrayHelpIndexEntry& operator=(CreatedArrayHelpIndexEntry&&) = delete; // Move Assignment Not Implemented -}; + /** + * @brief Setter property for FilterGroup + */ + void setFilterGroup(const QString& value); + /** + * @brief Getter property for FilterGroup + * @return Value of FilterGroup + */ + QString getFilterGroup() const; + + /** + * @brief Setter property for FilterSubGroup + */ + void setFilterSubGroup(const QString& value); + /** + * @brief Getter property for FilterSubGroup + * @return Value of FilterSubGroup + */ + QString getFilterSubGroup() const; + + /** + * @brief Setter property for ArrayDefaultName + */ + void setArrayDefaultName(const QString& value); + /** + * @brief Getter property for ArrayDefaultName + * @return Value of ArrayDefaultName + */ + QString getArrayDefaultName() const; + /** + * @brief Setter property for ArrayGroup + */ + void setArrayGroup(const QString& value); + /** + * @brief Getter property for ArrayGroup + * @return Value of ArrayGroup + */ + QString getArrayGroup() const; + /** + * @brief Setter property for ArrayType + */ + void setArrayType(const QString& value); + /** + * @brief Getter property for ArrayType + * @return Value of ArrayType + */ + QString getArrayType() const; + /** + * @brief Setter property for ArrayNumComponents + */ + void setArrayNumComponents(int value); + /** + * @brief Getter property for ArrayNumComponents + * @return Value of ArrayNumComponents + */ + int getArrayNumComponents() const; + + /** + * @brief Setter property for ArrayDescription + */ + void setArrayDescription(const QString& value); + /** + * @brief Getter property for ArrayDescription + * @return Value of ArrayDescription + */ + QString getArrayDescription() const; + +protected: + CreatedArrayHelpIndexEntry(); + +public: + CreatedArrayHelpIndexEntry(const CreatedArrayHelpIndexEntry&) = delete; // Copy Constructor Not Implemented + CreatedArrayHelpIndexEntry(CreatedArrayHelpIndexEntry&&) = delete; // Move Constructor Not Implemented + CreatedArrayHelpIndexEntry& operator=(const CreatedArrayHelpIndexEntry&) = delete; // Copy Assignment Not Implemented + CreatedArrayHelpIndexEntry& operator=(CreatedArrayHelpIndexEntry&&) = delete; // Move Assignment Not Implemented + +private: + QString m_FilterName = {}; + QString m_FilterHumanLabel = {}; + QString m_FilterGroup = {}; + QString m_FilterSubGroup = {}; + QString m_ArrayDefaultName = {}; + QString m_ArrayGroup = {}; + QString m_ArrayType = {}; + int m_ArrayNumComponents = {}; + QString m_ArrayDescription = {}; +}; diff --git a/Source/SIMPLib/Common/DocRequestManager.cpp b/Source/SIMPLib/Common/DocRequestManager.cpp index 20324e0ee1..0097a22068 100644 --- a/Source/SIMPLib/Common/DocRequestManager.cpp +++ b/Source/SIMPLib/Common/DocRequestManager.cpp @@ -60,7 +60,7 @@ DocRequestManager* DocRequestManager::Instance() // ----------------------------------------------------------------------------- void DocRequestManager::requestFilterDocs(const QString& filter) { - emit showFilterDocs(filter); + Q_EMIT showFilterDocs(filter); } // ----------------------------------------------------------------------------- @@ -68,5 +68,5 @@ void DocRequestManager::requestFilterDocs(const QString& filter) // ----------------------------------------------------------------------------- void DocRequestManager::requestFilterDocUrl(const QUrl& url) { - emit showFilterDocUrl(url); + Q_EMIT showFilterDocUrl(url); } diff --git a/Source/SIMPLib/Common/DocRequestManager.h b/Source/SIMPLib/Common/DocRequestManager.h old mode 100755 new mode 100644 index de64169512..77b7d54d66 --- a/Source/SIMPLib/Common/DocRequestManager.h +++ b/Source/SIMPLib/Common/DocRequestManager.h @@ -37,7 +37,6 @@ #include "SIMPLib/SIMPLib.h" - /** * @brief The DocRequestManager class is the moderator between low level libraries * that request the documentation for a filter be shown to the user in some capacity. @@ -49,33 +48,31 @@ class SIMPLib_EXPORT DocRequestManager : public QObject { - Q_OBJECT - - public: - DocRequestManager(); - ~DocRequestManager() override; + Q_OBJECT - static DocRequestManager* Instance(); +public: + DocRequestManager(); + ~DocRequestManager() override; - public Q_SLOTS: - void requestFilterDocs(const QString &filter); + static DocRequestManager* Instance(); - void requestFilterDocUrl(const QUrl &filter); +public Q_SLOTS: + void requestFilterDocs(const QString& filter); - Q_SIGNALS: + void requestFilterDocUrl(const QUrl& filter); - void showFilterDocs(const QString &filter); +Q_SIGNALS: - void showFilterDocUrl(const QUrl &url); + void showFilterDocs(const QString& filter); - private: + void showFilterDocUrl(const QUrl& url); - static DocRequestManager *self; +private: + static DocRequestManager* self; - public: - DocRequestManager(const DocRequestManager&) = delete; // Copy Constructor Not Implemented - DocRequestManager(DocRequestManager&&) = delete; // Move Constructor Not Implemented - DocRequestManager& operator=(const DocRequestManager&) = delete; // Copy Assignment Not Implemented - DocRequestManager& operator=(DocRequestManager&&) = delete; // Move Assignment Not Implemented +public: + DocRequestManager(const DocRequestManager&) = delete; // Copy Constructor Not Implemented + DocRequestManager(DocRequestManager&&) = delete; // Move Constructor Not Implemented + DocRequestManager& operator=(const DocRequestManager&) = delete; // Copy Assignment Not Implemented + DocRequestManager& operator=(DocRequestManager&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/Common/EnsembleInfo.cpp b/Source/SIMPLib/Common/EnsembleInfo.cpp index 1e3a6741b0..e4b56235cb 100644 --- a/Source/SIMPLib/Common/EnsembleInfo.cpp +++ b/Source/SIMPLib/Common/EnsembleInfo.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "EnsembleInfo.h" @@ -200,7 +200,7 @@ void EnsembleInfo::setPhaseName(size_t index, QString phaseName) // ----------------------------------------------------------------------------- void EnsembleInfo::remove(size_t index) { - QVector indexVec; + std::vector indexVec; indexVec.push_back(index); m_CrystalStructures.erase(m_CrystalStructures.begin() + index); m_PhaseTypes.erase(m_PhaseTypes.begin() + index); diff --git a/Source/SIMPLib/Common/EnsembleInfo.h b/Source/SIMPLib/Common/EnsembleInfo.h index ba61112f89..7d2947f8b6 100644 --- a/Source/SIMPLib/Common/EnsembleInfo.h +++ b/Source/SIMPLib/Common/EnsembleInfo.h @@ -1,49 +1,43 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include -#include #include -#include - -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/PhaseType.h" - #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataArrays/StringDataArray.h" @@ -58,12 +52,15 @@ class SIMPLib_EXPORT EnsembleInfo : public QObject { Q_OBJECT // clang-format off - PYB11_CREATE_BINDINGS(EnsembleInfo) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(EnsembleInfo) PYB11_CREATION() - PYB11_METHOD(void addValues ARGS const,CrystalStructure const,PhaseType::Type const,QString) - PYB11_METHOD(void getValues ARGS size_t CrystalStructure& PhaseType::Type& QString&) - PYB11_METHOD(void remove ARGS size_t) + PYB11_METHOD(void addValues) + PYB11_METHOD(void getValues) + PYB11_METHOD(void remove) PYB11_METHOD(void clear) + PYB11_END_BINDINGS() + // End Python bindings declarations // clang-format on public: using EnumType = uint32_t; @@ -125,4 +122,3 @@ class SIMPLib_EXPORT EnsembleInfo : public QObject }; Q_DECLARE_METATYPE(EnsembleInfo) - diff --git a/Source/SIMPLib/Common/INamedCollection.cpp b/Source/SIMPLib/Common/INamedCollection.cpp new file mode 100644 index 0000000000..ece674c01a --- /dev/null +++ b/Source/SIMPLib/Common/INamedCollection.cpp @@ -0,0 +1,61 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "INamedCollection.h" + +#include "SIMPLib/Common/INamedObject.h" + +INamedCollection::INamedCollection() = default; + +INamedCollection::~INamedCollection() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void INamedCollection::handleAddingObject(INamedObject* obj) +{ + obj->addToCollection(this); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void INamedCollection::handleRemovingObject(INamedObject* obj) +{ + obj->removeFromCollection(this); +} + +// ----------------------------------------------------------------------------- +INamedCollection::Pointer INamedCollection::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} diff --git a/Source/SIMPLib/Common/INamedCollection.h b/Source/SIMPLib/Common/INamedCollection.h new file mode 100644 index 0000000000..2512f75314 --- /dev/null +++ b/Source/SIMPLib/Common/INamedCollection.h @@ -0,0 +1,119 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/SIMPLib.h" + +class INamedObject; + +/** + * @class INamedCollection INamedCollection.h SIMPLib/Common/INamedCollection.h + * @brief The INamedCollection class is used as an interface for INamedObject collections. + * Adding to or removing from the collection should alert the INamedObject to the action + * so that the INamedObject can check if it can be renamed. This also adds extended support + * for graph theory implementations as INamedObjects can have and keep track of multiple parents. + */ +class SIMPLib_EXPORT INamedCollection +{ +public: + using Self = INamedCollection; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + INamedCollection(); + virtual ~INamedCollection(); + + INamedCollection(const INamedCollection&) = default; // Copy Constructor Not Implemented + INamedCollection(INamedCollection&&) = default; // Move Constructor Not Implemented + INamedCollection& operator=(const INamedCollection&) = default; // Copy Assignment Not Implemented + INamedCollection& operator=(INamedCollection&&) = default; // Move Assignment Not Implemented + + using NameList = QStringList; + + /** + * @brief Returns the number of items in the collection. + * @return + */ + virtual size_t size() const = 0; + + /** + * @brief Returns true if the collection is empty. Returns false otherwise. + * @return + */ + virtual bool isEmpty() const = 0; + + /** + * @brief Clears the collection of all items. + */ + virtual void clear() = 0; + + /** + * @brief Erases any item with the given name. + * @param name + */ + virtual void erase(const QString& name) = 0; + + /** + * @brief Returns true if the collection contains an item with the given name. + * Returns false otherwise. + * @param name + * @return + */ + virtual bool contains(const QString& name) const = 0; + + /** + * @brief Returns a list of all names in the collection. + * @return + */ + virtual NameList getNameList() const = 0; + +protected: + /** + * @brief Alerts the INamedObject that it has been added to a collection. + * @param obj + */ + void handleAddingObject(INamedObject* obj); + + /** + * @brief Alerts the INamedObject that it has been removed from a collection. + * @param obj + */ + void handleRemovingObject(INamedObject* obj); + +private: +}; diff --git a/Source/SIMPLib/Common/INamedObject.cpp b/Source/SIMPLib/Common/INamedObject.cpp new file mode 100644 index 0000000000..f910671bb1 --- /dev/null +++ b/Source/SIMPLib/Common/INamedObject.cpp @@ -0,0 +1,140 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "INamedObject.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +INamedObject::HashType INamedObject::CreateHash(const QString& string) +{ + return std::hash()(string.toStdString()); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +INamedObject::INamedObject(const QString& name) +: m_Name(name) +, m_NameHash(CreateHash(name)) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +INamedObject::~INamedObject() +{ + ParentCollectionType collections = getParentCollections(); + for(const auto& collection : collections) + { + collection->erase(getName()); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString INamedObject::getName() const +{ + return m_Name; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool INamedObject::setName(const QString& name) +{ + for(const auto& collection : m_ParentCollctions) + { + // If collection does not exist, something has else gone wrong and requires attention. + if(collection->contains(name)) + { + return false; + } + } + + m_NameHash = CreateHash(name); + m_Name = name; + return true; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +INamedObject::HashType INamedObject::getNameHash() const +{ + return m_NameHash; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +INamedObject::ParentCollectionType INamedObject::getParentCollections() const +{ + return m_ParentCollctions; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void INamedObject::addToCollection(INamedCollection* collection) +{ + m_ParentCollctions.insert(collection); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void INamedObject::removeFromCollection(INamedCollection* collection) +{ + m_ParentCollctions.erase(collection); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool INamedObject::operator<(const INamedObject& other) const +{ + return getNameHash() < other.getNameHash(); +} + +bool INamedObject::operator==(const INamedObject& other) const +{ + return getNameHash() == other.getNameHash(); +} + +// ----------------------------------------------------------------------------- +INamedObject::Pointer INamedObject::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} diff --git a/Source/SIMPLib/Common/INamedObject.h b/Source/SIMPLib/Common/INamedObject.h new file mode 100644 index 0000000000..168ebcf7f6 --- /dev/null +++ b/Source/SIMPLib/Common/INamedObject.h @@ -0,0 +1,165 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include + +#include +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/INamedCollection.h" + +/** + * @class INamedObject INamedObject.h SIMPLib/Common/INamedObject.h + * @brief The INamedObject is a base class for named objects in SIMPL, allowing + * them to be placed in special containers that key off of the object's name + * instead of requiring the key and value to be updated separately. An added + * bonus is the ability to keep track of any naming conflicts that could occur + * when renaming an object when it is contained by multiple collections. This + * also offers the ability to track parent collections in a bi-directional graph. + */ +class SIMPLib_EXPORT INamedObject +{ + friend INamedCollection; + +public: + using Self = INamedObject; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + using HashType = size_t; + using ParentCollectionType = std::set; + + /** + * @brief Remove this object from its parent containers upon deletion. + */ + virtual ~INamedObject(); + + /** + * @brief Method for creating hashes from QString values. + * @param string + * @return + */ + static HashType CreateHash(const QString& string); + + /** + * @brief Returns the object's name value. + * @return + */ + QString getName() const; + + /** + * @brief Attempts to set the object's name value. + * Returns true if the operation succeded. Returns false otherwise. + * @param newName + * @return + */ + bool setName(const QString& newName); + + /** + * @brief Returns the hash value for the current name. + * This value should be set when the name is changed so that it does not + * have to be calculated every time this method is called. + * @return + */ + HashType getNameHash() const; + + /** + * @brief Returns a set with all parent collections. + * @return + */ + ParentCollectionType getParentCollections() const; + + /** + * @brief Compares the hash value between two INamedObjects and returns if this + * object's value is less than the other. + * @param other + * @return + */ + bool operator<(const INamedObject& other) const; + + /** + * @brief Compares the hash value of two INamedObjects for equality. + * Returns true if both are equal. Returns false otherwise. + * @param other + * @return + */ + bool operator==(const INamedObject& other) const; + +protected: + INamedObject(const QString& name); + +private: + /** + * @brief Adds the collection to the list of parents. + * @param collection + */ + void addToCollection(INamedCollection* collection); + + /** + * @brief Removed the collection from the list of parents. + * @param collection + */ + void removeFromCollection(INamedCollection* collection); + + ParentCollectionType m_ParentCollctions; + QString m_Name; + HashType m_NameHash; +}; + +/** + * @brief Compares two INamedObject shared pointers based on the less than operator of their base pointers. + * @param lhs + * @param rhs + * @return + */ +inline bool operator<(const INamedObject::Pointer& lhs, const INamedObject::Pointer& rhs) +{ + return (*lhs) < (*rhs); +} + +/** + * @brief Compares two INamedObject shared pointers based on the equality operator of their base pointers. + * @param lhs + * @param rhs + * @return + */ +inline bool operator==(const INamedObject::Pointer& lhs, const INamedObject::Pointer& rhs) +{ + return (*lhs) == (*rhs); +} diff --git a/Source/SIMPLib/Common/IObserver.cpp b/Source/SIMPLib/Common/IObserver.cpp index 994bfd205a..e26aead15c 100644 --- a/Source/SIMPLib/Common/IObserver.cpp +++ b/Source/SIMPLib/Common/IObserver.cpp @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "IObserver.h" +#include + #include // ----------------------------------------------------------------------------- @@ -50,34 +52,22 @@ IObserver::~IObserver() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void IObserver::processPipelineMessage(const PipelineMessage& pm) +void IObserver::processPipelineMessage(const AbstractMessage::Pointer& pm) { - PipelineMessage msg = pm; QString str; QTextStream ss(&str); - if(msg.getType() == PipelineMessage::MessageType::Error) - { - ss << msg.generateErrorString(); - } - else if(msg.getType() == PipelineMessage::MessageType::Warning) - { - ss << msg.generateWarningString(); - } - else if(msg.getType() == PipelineMessage::MessageType::StatusMessage) - { - ss << msg.generateStatusString(); - } - else if(msg.getType() == PipelineMessage::MessageType::StandardOutputMessage) - { - ss << msg.generateStandardOutputString(); - } - else if(msg.getType() == PipelineMessage::MessageType::ProgressValue) - { - ss << msg.getProgressValue() << "%"; - } - else if(msg.getType() == PipelineMessage::MessageType::StatusMessageAndProgressValue) - { - ss << msg.getProgressValue() << msg.generateStatusString(); - } - std::cout << msg.getFilterHumanLabel().toStdString() << ": " << str.toStdString() << std::endl; + ss << pm->generateMessageString(); + std::cout << str.toStdString() << std::endl; +} + +// ----------------------------------------------------------------------------- +QString IObserver::getNameOfClass() const +{ + return QString("IObserver"); +} + +// ----------------------------------------------------------------------------- +QString IObserver::ClassName() +{ + return QString("IObserver"); } diff --git a/Source/SIMPLib/Common/IObserver.h b/Source/SIMPLib/Common/IObserver.h old mode 100755 new mode 100644 index 7d9811cec2..51df7217be --- a/Source/SIMPLib/Common/IObserver.h +++ b/Source/SIMPLib/Common/IObserver.h @@ -1,58 +1,72 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once - #include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/PipelineMessage.h" +#include "SIMPLib/Messages/AbstractMessage.h" class SIMPLib_EXPORT IObserver { - public: - IObserver(); - virtual ~IObserver(); - SIMPL_TYPE_MACRO(IObserver) - - virtual void processPipelineMessage(const PipelineMessage& pm); - - public: - IObserver(const IObserver&) = delete; // Copy Constructor Not Implemented - IObserver(IObserver&&) = delete; // Move Constructor Not Implemented - IObserver& operator=(const IObserver&) = delete; // Copy Assignment Not Implemented - IObserver& operator=(IObserver&&) = delete; // Move Assignment Not Implemented -}; + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(IObserver) + PYB11_SHARED_POINTERS(IObserver) + PYB11_CREATION() + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + IObserver(); + virtual ~IObserver(); + /** + * @brief Returns the name of the class for IObserver + */ + virtual QString getNameOfClass() const; + /** + * @brief Returns the name of the class for IObserver + */ + static QString ClassName(); + + virtual void processPipelineMessage(const AbstractMessage::Pointer& pm); + +public: + IObserver(const IObserver&) = delete; // Copy Constructor Not Implemented + IObserver(IObserver&&) = delete; // Move Constructor Not Implemented + IObserver& operator=(const IObserver&) = delete; // Copy Assignment Not Implemented + IObserver& operator=(IObserver&&) = delete; // Move Assignment Not Implemented + +private: +}; diff --git a/Source/SIMPLib/Common/NamedCollection.hpp b/Source/SIMPLib/Common/NamedCollection.hpp new file mode 100644 index 0000000000..031bfc1ae4 --- /dev/null +++ b/Source/SIMPLib/Common/NamedCollection.hpp @@ -0,0 +1,269 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include +#include + +#include + +#include "SIMPLib/Common/INamedObject.h" + +//#include "SIMPLib/Montages/AbstractMontage.h" + +/** + * @class NamedCollection NamedCollection.hpp SIMPLib/Common/NamedCollection.hpp + * @brief NamedCollection is a templated set of named objects of a certain type. + * By deriving from INamedCollection, the items in the collection can keep track + * of what collections they are in. This, along with the custom hashing in + * INamedObject, allows the collection to be treated like a map without separating + * the key and value. + */ +template +class NamedCollection : public INamedCollection +{ + using Self = NamedCollection; + +public: + using ChildType = typename std::shared_ptr; + using Collection = typename std::set; + using Iterator = typename Collection::iterator; + // using ConstIterator = typename Collection::const_iterator; + +private: + Collection m_Items; + +public: + /* --------------- Begin STL iterator support ------------------ */ + /** + * @brief Returns an iterator to the first item in the collection. + * @return + */ + Iterator begin() + { + return m_Items.begin(); + } + + /** + * @brief Returns an iterator to the last item in the collection. + * @return + */ + Iterator end() + { + return m_Items.end(); + } + + /** + * @brief Returns a const iterator to the first item in the collection. + * @return + */ + Iterator begin() const + { + return m_Items.begin(); + } + + /** + * @brief Returns a const iterator to the last item in the collection. + * @return + */ + Iterator end() const + { + return m_Items.end(); + } + /* --------------- End STL iterator support ------------------ */ + + /** + * @brief Removes all items from the collection. + */ + void clear() override + { + for(const auto& item : m_Items) + { + handleRemovingObject(item.get()); + } + m_Items.clear(); + } + + /** + * @brief Default constructor + */ + NamedCollection() = default; + // NamedCollection(const NamedCollection& other) + //: m_Items(other.m_Items) + //{ + // for(const auto& item : *this) + // { + // handleAddingObject(item); + // } + //} + + /** + * @brief Remove all children from the collection before it is destroyed. + */ + ~NamedCollection() override + { + clear(); + } + + /** + * @brief Returns the size of the collection. + * @return + */ + size_t size() const override + { + return m_Items.size(); + } + + /** + * @brief Returns true if the collection is empty. + * @return + */ + bool isEmpty() const override + { + return m_Items.empty(); + } + + /** + * @brief Searches the collection for an object with the given name. + * @param name + * @return + */ + Iterator find(const QString& name) const + { + // Hash the target name to reduce the time required for each item + INamedObject::HashType targetHash = INamedObject::CreateHash(name); + auto unaryPredicate = [name, targetHash](const ChildType& obj) { + if(obj->getNameHash() == targetHash) + { + return true; + } + return false; + }; + + return std::find_if(begin(), end(), unaryPredicate); + } + + /** + * @brief Erases any item with the given name. + * @param name + */ + void erase(const QString& name) override + { + Iterator iter = find(name); + if(iter == end()) + { + return; + } + + handleRemovingObject((*iter).get()); + m_Items.erase(iter); + } + + /** + * @brief Attempts to insert the given item into the collection. + * This will fail if an item with the same name already exists in the collection. + * @return + */ + bool insert(const ChildType& newItem) + { + if(nullptr == newItem) + { + return false; + } + if(!m_Items.insert(newItem).second) + { + return false; + } + + handleAddingObject(newItem.get()); + return true; + } + + /** + * @brief Adds the given item to the collection. If an item with the same name already exists, it is removed. + * @param newItem + */ + void addOrReplace(const ChildType& newItem) + { + erase(newItem->getName()); + insert(newItem); + } + + /** + * @brief Returns true if the collection contains an object with the given name. Returns false otherwise. + * @param name + * @return + */ + bool contains(const QString& name) const override + { + return find(name) != end(); + } + + /** + * @brief Returns a list of all the names used in the collection. + * @return + */ + NameList getNameList() const override + { + NameList names; + for(const auto& obj : m_Items) + { + names.push_back(obj->getName()); + } + + return names; + } + + /** + * @brief Lexicographically compares collections. Returns true if the items in + * this collection are less than the other's. Returns false otherwise. + * @param other + * @return + */ + bool operator<(const Self& other) const + { + return m_Items < other.m_Items; + } + + /** + * @brief Lexicographically compares collections. Returns true if the items in + * this collection are equal to the other's. Returns false otherwise. + * @param other + * @return + */ + bool operator==(const Self& other) const + { + return m_Items == other.m_Items; + } +}; diff --git a/Source/SIMPLib/Common/Observable.cpp b/Source/SIMPLib/Common/Observable.cpp index d921d9090f..8e41bfa48b 100644 --- a/Source/SIMPLib/Common/Observable.cpp +++ b/Source/SIMPLib/Common/Observable.cpp @@ -1,40 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "Observable.h" +#include "SIMPLib/Messages/GenericErrorMessage.h" +#include "SIMPLib/Messages/GenericProgressMessage.h" +#include "SIMPLib/Messages/GenericStatusMessage.h" +#include "SIMPLib/Messages/GenericWarningMessage.h" + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -65,65 +70,91 @@ void Observable::operator=(const Observable&) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observable::broadcastPipelineMessage(const PipelineMessage& msg) +void Observable::setErrorCondition(int code, const QString& messageText) +{ + GenericErrorMessage::Pointer pm = GenericErrorMessage::New(messageText, code); + Q_EMIT messageGenerated(pm); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void Observable::setErrorConditionWithPrefix(int code, const QString& prefix, const QString& messageText) { - emit filterGeneratedMessage(msg); + QString msg = messageText; + msg.prepend(tr("%1 - ").arg(prefix)); + + setErrorCondition(code, msg); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observable::notifyErrorMessage(const QString& humanLabel, const QString& str, int code) +void Observable::setWarningCondition(int code, const QString& messageText) { - PipelineMessage pm = PipelineMessage::CreateErrorMessage(getNameOfClass(), humanLabel, str, code); - emit filterGeneratedMessage(pm); + GenericWarningMessage::Pointer pm = GenericWarningMessage::New(messageText, code); + Q_EMIT messageGenerated(pm); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observable::notifyStatusMessage(const QString& humanLabel, const QString& str) +void Observable::setWarningConditionWithPrefix(int code, const QString& prefix, const QString& messageText) { - PipelineMessage pm = PipelineMessage::CreateStatusMessage(getNameOfClass(), humanLabel, str); - emit filterGeneratedMessage(pm); + QString msg = messageText; + msg.prepend(tr("%1 - ").arg(prefix)); + + setWarningCondition(code, msg); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observable::notifyStatusMessage(const QString& prefix, const QString& humanLabel, const QString& str) +void Observable::notifyStatusMessage(const QString& messageText) const { - PipelineMessage pm = PipelineMessage::CreateStatusMessage(getNameOfClass(), humanLabel, str); - pm.setPrefix(prefix); - emit filterGeneratedMessage(pm); + GenericStatusMessage::Pointer pm = GenericStatusMessage::New(messageText); + Q_EMIT messageGenerated(pm); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observable::notifyStandardOutputMessage(const QString& humanLabel, int pipelineIndex, const QString& str) +void Observable::notifyStatusMessageWithPrefix(const QString& prefix, const QString& messageText) const { - PipelineMessage pm = PipelineMessage::CreateStandardOutputMessage(humanLabel, pipelineIndex, str); - emit filterGeneratedMessage(pm); + QString msg = messageText; + msg.prepend(tr("%1 - ").arg(prefix)); + + notifyStatusMessage(msg); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observable::notifyWarningMessage(const QString& humanLabel, const QString& str, int code) +void Observable::notifyProgressMessage(int progress, const QString& messageText) const { - PipelineMessage pm = PipelineMessage::CreateWarningMessage(getNameOfClass(), humanLabel, str, code); - emit filterGeneratedMessage(pm); + GenericProgressMessage::Pointer pm = GenericProgressMessage::New(messageText, progress); + Q_EMIT messageGenerated(pm); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observable::notifyProgressMessage(const QString& prefix, const QString& humanLabel, const QString& str, int progress) +void Observable::notifyProgressMessageWithPrefix(int progress, const QString& prefix, const QString& messageText) const +{ + QString msg = messageText; + msg.prepend(tr("%1: ").arg(prefix)); + + notifyProgressMessage(progress, msg); +} + +// ----------------------------------------------------------------------------- +QString Observable::getNameOfClass() const +{ + return QString("Observable"); +} + +// ----------------------------------------------------------------------------- +QString Observable::ClassName() { - PipelineMessage pm = PipelineMessage::CreateStatusMessage(getNameOfClass(), humanLabel, str); - pm.setPrefix(prefix); - pm.setProgressValue(progress); - pm.setType(PipelineMessage::MessageType::StatusMessageAndProgressValue); - emit filterGeneratedMessage(pm); + return QString("Observable"); } diff --git a/Source/SIMPLib/Common/Observable.h b/Source/SIMPLib/Common/Observable.h old mode 100755 new mode 100644 index 8480156c43..dfe82154c7 --- a/Source/SIMPLib/Common/Observable.h +++ b/Source/SIMPLib/Common/Observable.h @@ -1,47 +1,44 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include #include -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Common/PipelineMessage.h" - +#include "SIMPLib/Messages/AbstractMessage.h" /** * @class Observable Observable.h DREAM3D/Common/Observable.h @@ -53,54 +50,65 @@ */ class SIMPLib_EXPORT Observable : public QObject { - Q_OBJECT - PYB11_CREATE_BINDINGS(Observable) - PYB11_METHOD(void notifyErrorMessage ARGS humanLabel ss code) + Q_OBJECT - public: - SIMPL_TYPE_MACRO(Observable) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(Observable) + PYB11_METHOD(void setErrorCondition ARGS code messageText) + PYB11_METHOD(void setErrorConditionWithPrefix ARGS code prefix messageText) + PYB11_METHOD(void setWarningCondition ARGS code messageText) + PYB11_METHOD(void setWarningConditionWithPrefix ARGS code prefix messageText) + PYB11_METHOD(void notifyStatusMessage ARGS messageText) + PYB11_METHOD(void notifyStatusMessageWithPrefix ARGS prefix messageText) + PYB11_METHOD(void notifyProgressMessage ARGS progress messageText) + PYB11_METHOD(void notifyProgressMessageWithPrefix ARGS progress prefix messageText) + PYB11_END_BINDINGS() + // End Python bindings declarations - Observable(); +public: + /** + * @brief Returns the name of the class for Observable + */ + virtual QString getNameOfClass() const; + /** + * @brief Returns the name of the class for Observable + */ + static QString ClassName(); - Observable(const Observable& rhs); + Observable(); - ~Observable() override; + Observable(const Observable& rhs); - void operator=(const Observable&); + ~Observable() override; - // ------------------------------ - // These are convenience methods that construct a @see PipelineMessage object and then 'emit' that object - // ------------------------------ - virtual void notifyErrorMessage(const QString& humanLabel, const QString& ss, int code); + void operator=(const Observable&); - virtual void notifyWarningMessage(const QString& humanLabel, const QString& ss, int code); + // ------------------------------ + // These are convenience methods that construct a @see AbstractMessage object and then 'emit' that object + // ------------------------------ + virtual void setErrorCondition(int code, const QString& messageText); - virtual void notifyStatusMessage(const QString& humanLabel, const QString& ss); + void setErrorConditionWithPrefix(int code, const QString& prefix, const QString& messageText); - virtual void notifyStandardOutputMessage(const QString& humanLabel, int pipelineIndex, const QString& ss); + virtual void setWarningCondition(int code, const QString& messageText); - virtual void notifyStatusMessage(const QString& prefix, const QString& humanLabel, const QString& ss); + void setWarningConditionWithPrefix(int code, const QString& prefix, const QString& messageText); - virtual void notifyProgressMessage(const QString& prefix, const QString& humanLabel, const QString& str, int progress); + virtual void notifyStatusMessage(const QString& messageText) const; - public slots: + void notifyStatusMessageWithPrefix(const QString& prefix, const QString& messageText) const; - /** - * @brief This method will cause this object to 'emit' the filterGeneratedMessage() signal. This is useful if other - * classes need the filter to emit an error or warning messge from a class that is not able to emit the proper signals - * or the class is not connected to anything that would receive the signals - * @param msg - */ - void broadcastPipelineMessage(const PipelineMessage& msg); + virtual void notifyProgressMessage(int progress, const QString& messageText) const; + void notifyProgressMessageWithPrefix(int progress, const QString& prefix, const QString& messageText) const; - signals: - - /** - * @brief filterGeneratedMessage This is a Qt Signal that is used when the filter generates Errors, Warnings, Status and Progress Messages - * @param msg - */ - void filterGeneratedMessage(const PipelineMessage& msg); -}; +Q_SIGNALS: + /** + * @brief messageGenerated This is a Qt Signal that is used when the filter generates Errors, Warnings, Status and Progress Messages + * @param msg + */ + void messageGenerated(const AbstractMessage::Pointer& msg) const; +private: +}; diff --git a/Source/SIMPLib/Common/Observer.cpp b/Source/SIMPLib/Common/Observer.cpp index 05936774cb..63f97557d6 100644 --- a/Source/SIMPLib/Common/Observer.cpp +++ b/Source/SIMPLib/Common/Observer.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "Observer.h" @@ -50,8 +50,20 @@ Observer::~Observer() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void Observer::processPipelineMessage(const PipelineMessage& pm) +void Observer::processPipelineMessage(const AbstractMessage::Pointer& pm) { // Just call the superclass IObserver::processPipelineMessage(pm); } + +// ----------------------------------------------------------------------------- +QString Observer::getNameOfClass() const +{ + return QString("Observer"); +} + +// ----------------------------------------------------------------------------- +QString Observer::ClassName() +{ + return QString("Observer"); +} diff --git a/Source/SIMPLib/Common/Observer.h b/Source/SIMPLib/Common/Observer.h old mode 100755 new mode 100644 index db5aa2a174..bb76c0aae7 --- a/Source/SIMPLib/Common/Observer.h +++ b/Source/SIMPLib/Common/Observer.h @@ -1,49 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once - #include -#include #include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/Common/IObserver.h" -#include "SIMPLib/Common/PipelineMessage.h" +#include "SIMPLib/Messages/AbstractMessage.h" /** * @class Observer Observer.h DREAM3D/Common/Observer.h @@ -56,22 +52,37 @@ */ class SIMPLib_EXPORT Observer : public QObject, public IObserver { - Q_OBJECT + Q_OBJECT - public: - Observer(); - SIMPL_TYPE_MACRO_SUPER(Observer, IObserver) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(Observer SUPERCLASS IObserver) + PYB11_SHARED_POINTERS(Observer) + PYB11_CREATION() + PYB11_END_BINDINGS() + // End Python bindings declarations - ~Observer() override; +public: + Observer(); - public slots: - void processPipelineMessage(const PipelineMessage& pm) override; + /** + * @brief Returns the name of the class for Observer + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for Observer + */ + static QString ClassName(); - public: - Observer(const Observer&) = delete; // Copy Constructor Not Implemented - Observer(Observer&&) = delete; // Move Constructor Not Implemented - Observer& operator=(const Observer&) = delete; // Copy Assignment Not Implemented - Observer& operator=(Observer&&) = delete; // Move Assignment Not Implemented -}; + ~Observer() override; + +public Q_SLOTS: + void processPipelineMessage(const AbstractMessage::Pointer& pm) override; +public: + Observer(const Observer&) = delete; // Copy Constructor Not Implemented + Observer(Observer&&) = delete; // Move Constructor Not Implemented + Observer& operator=(const Observer&) = delete; // Copy Assignment Not Implemented + Observer& operator=(Observer&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/Common/PhaseType.cpp b/Source/SIMPLib/Common/PhaseType.cpp index c4c9ef7d56..750b608971 100644 --- a/Source/SIMPLib/Common/PhaseType.cpp +++ b/Source/SIMPLib/Common/PhaseType.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "PhaseType.h" @@ -50,7 +50,7 @@ PhaseType::~PhaseType() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector PhaseType::ToQVector(Types &types) +QVector PhaseType::ToQVector(Types& types) { QVector vec(types.size()); for(int i = 0; i < types.size(); i++) @@ -63,7 +63,7 @@ QVector PhaseType::ToQVector(Types &types) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PhaseType::Types PhaseType::FromQVector(QVector &vec) +PhaseType::Types PhaseType::FromQVector(QVector& vec) { PhaseType::Types types(vec.size()); for(int i = 0; i < vec.size(); i++) @@ -177,7 +177,7 @@ PhaseType::Type PhaseType::getPhaseType(const char* str) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void PhaseType::getPhaseTypeStrings(QStringList& strings) +void PhaseType::getPhaseTypeStrings(std::vector& strings) { strings.clear(); strings.push_back(PrimaryStr()); diff --git a/Source/SIMPLib/Common/PhaseType.h b/Source/SIMPLib/Common/PhaseType.h old mode 100755 new mode 100644 index eacf31cbcc..1a54b2b28a --- a/Source/SIMPLib/Common/PhaseType.h +++ b/Source/SIMPLib/Common/PhaseType.h @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once @@ -39,7 +39,6 @@ #include #include - #include "SIMPLib/SIMPLib.h" /** @@ -62,7 +61,7 @@ class SIMPLib_EXPORT PhaseType Transformation = 2, //!< Matrix = 3, //!< Boundary = 4, //!< - Unknown = 999, //!< + Unknown = 999, //!< Any = 4294967295U }; @@ -75,7 +74,7 @@ class SIMPLib_EXPORT PhaseType * @param types * @return */ - static QVector ToQVector(Types &types); + static QVector ToQVector(Types& types); /** * @brief Converts From a QVector to QVector. Useful for @@ -83,7 +82,7 @@ class SIMPLib_EXPORT PhaseType * @param types * @return */ - static Types FromQVector(QVector &types); + static Types FromQVector(QVector& types); /** * @brief PrimaryStr @@ -139,7 +138,7 @@ class SIMPLib_EXPORT PhaseType * @brief getPhaseTypeStrings * @param strings */ - static void getPhaseTypeStrings(QStringList& strings); + static void getPhaseTypeStrings(std::vector& strings); /** * @brief getPhaseTypeEnums @@ -165,4 +164,3 @@ class SIMPLib_EXPORT PhaseType Q_DECLARE_METATYPE(PhaseType::Type) Q_DECLARE_METATYPE(PhaseType::Types) - diff --git a/Source/SIMPLib/Common/PipelineMessage.cpp b/Source/SIMPLib/Common/PipelineMessage.cpp deleted file mode 100644 index 589326c086..0000000000 --- a/Source/SIMPLib/Common/PipelineMessage.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include "PipelineMessage.h" - -#include -#include - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -PipelineMessage::PipelineMessage() = default; - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -PipelineMessage::PipelineMessage(const PipelineMessage& rhs) -{ - m_FilterClassName = rhs.m_FilterClassName; - m_FilterHumanLabel = rhs.m_FilterHumanLabel; - m_Prefix = rhs.m_Prefix; - m_Text = rhs.m_Text; - m_Code = rhs.m_Code; - m_Type = rhs.m_Type; - m_ProgressValue = rhs.m_ProgressValue; - m_PipelineIndex = rhs.m_PipelineIndex; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -PipelineMessage::PipelineMessage(const QString& className, const char* msg, int code, MessageType msgType, int progress) -: m_FilterClassName(className) -, m_Text(msg) -, m_Code(code) -, m_Type(msgType) -, m_ProgressValue(progress) -{ -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -PipelineMessage::PipelineMessage(const QString& className, const QString& msg, int code, MessageType msgType, int progress) -: m_FilterClassName(className) -, m_FilterHumanLabel("") -, m_Text(msg) -, m_Code(code) -, m_Type(msgType) -, m_ProgressValue(progress) -{ -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -PipelineMessage::PipelineMessage(const QString& className, const QString& humanLabel, const QString& msg, int code, MessageType msgType, int progress) -: m_FilterClassName(className) -, m_FilterHumanLabel(humanLabel) -, m_Text(msg) -, m_Code(code) -, m_Type(msgType) -, m_ProgressValue(progress) -{ -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -PipelineMessage::PipelineMessage(const QString& humanLabel, int pipelineIndex, const QString& msg, MessageType msgType) -: m_FilterHumanLabel(humanLabel) -, m_Text(msg) -, m_PipelineIndex(pipelineIndex) -, m_Type(msgType) -{ -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -PipelineMessage PipelineMessage::CreateErrorMessage(const QString className, const QString humanLabel, const QString msg, int code) -{ - PipelineMessage em(className, humanLabel, msg, code, MessageType::Error, -1); - return em; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -PipelineMessage PipelineMessage::CreateStatusMessage(const QString className, const QString humanLabel, const QString msg) -{ - PipelineMessage em(className, humanLabel, msg, 0, MessageType::StatusMessage, -1); - return em; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -PipelineMessage PipelineMessage::CreateWarningMessage(const QString className, const QString humanLabel, const QString msg, int code) -{ - PipelineMessage em(className, humanLabel, msg, code, MessageType::Warning, -1); - return em; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -PipelineMessage PipelineMessage::CreateStandardOutputMessage(const QString humanLabel, int pipelineIndex, const QString msg) -{ - PipelineMessage em(humanLabel, pipelineIndex, msg, MessageType::StandardOutputMessage); - return em; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -PipelineMessage::~PipelineMessage() = default; - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -bool PipelineMessage::operator==(const PipelineMessage& rhs) -{ - return (m_FilterClassName == rhs.m_FilterClassName && m_Prefix == rhs.m_Prefix && m_FilterHumanLabel == rhs.m_FilterHumanLabel && m_Text == rhs.m_Text && m_Code == rhs.m_Code && - m_Type == rhs.m_Type && m_ProgressValue == rhs.m_ProgressValue && m_PipelineIndex == rhs.m_PipelineIndex); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void PipelineMessage::operator=(const PipelineMessage& rhs) -{ - m_FilterClassName = rhs.m_FilterClassName; - m_Prefix = rhs.m_Prefix; - m_FilterHumanLabel = rhs.m_FilterHumanLabel; - m_Text = rhs.m_Text; - m_Code = rhs.m_Code; - m_Type = rhs.m_Type; - m_ProgressValue = rhs.m_ProgressValue; - m_PipelineIndex = rhs.m_PipelineIndex; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString PipelineMessage::generateErrorString() const -{ - QString ss = QObject::tr("Error (%1): %2: %3").arg(m_Code).arg(m_Prefix).arg(m_Text); - return ss; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString PipelineMessage::generateWarningString() const -{ - QString ss = QObject::tr("Warning (%1): %2: %3").arg(m_Code).arg(m_Prefix).arg(m_Text); - return ss; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString PipelineMessage::generateStatusString() const -{ - if(m_Prefix.isEmpty()) - { - QString ss = QObject::tr("%2").arg(m_Text); - return ss; - } - - QString ss = QObject::tr("%1: %2").arg(m_Prefix).arg(m_Text); - return ss; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString PipelineMessage::generateProgressString() const -{ - if(m_Prefix.isEmpty()) - { - QString ss = QObject::tr("%1 %2%%").arg(m_Text).arg(m_ProgressValue); - return ss; - } - - QString ss = QObject::tr("%1: %2 %3%%").arg(m_Prefix).arg(m_Text).arg(m_ProgressValue); - return ss; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString PipelineMessage::generateStandardOutputString() const -{ - return m_Text; -} diff --git a/Source/SIMPLib/Common/PipelineMessage.h b/Source/SIMPLib/Common/PipelineMessage.h deleted file mode 100755 index 104190a972..0000000000 --- a/Source/SIMPLib/Common/PipelineMessage.h +++ /dev/null @@ -1,144 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#pragma once - -#include -#include - -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" - - -/** - * @class PipelineMessage PipelineMessage.h DREAM3DLib/Common/PipelineMessage.h - * @brief This class enables the creation of Error, Warning, and Status messages that - * can be sent up from filters to the DREAM3D GUI. - */ -class SIMPLib_EXPORT PipelineMessage -{ - public: - using EnumType = unsigned int; - - enum class MessageType : EnumType - { - Error = 0, - Warning = 1, - StatusMessage = 2, - StandardOutputMessage = 3, - ProgressValue = 4, - StatusMessageAndProgressValue = 5, - UnknownMessageType = 6 - }; - - PipelineMessage(); - - PipelineMessage(const PipelineMessage& rhs); - - PipelineMessage(const QString& className, const char* msg, int code, MessageType msgType = MessageType::UnknownMessageType, int progress = -1); - - PipelineMessage(const QString& className, const QString& msg, int code, MessageType msgType = MessageType::UnknownMessageType, int progress = -1); - PipelineMessage(const QString& className, const QString& humanLabel, const QString& msg, int code, MessageType msgType = MessageType::UnknownMessageType, int progress = -1); - - PipelineMessage(const QString& humanLabel, int pipelineIndex, const QString& msg, MessageType msgType = MessageType::UnknownMessageType); - - static PipelineMessage CreateErrorMessage(const QString className, const QString humanLabel, const QString msg, int code); - - static PipelineMessage CreateStatusMessage(const QString className, const QString humanLabel, const QString msg); - - static PipelineMessage CreateWarningMessage(const QString className, const QString humanLabel, const QString msg, int code); - - static PipelineMessage CreateStandardOutputMessage(const QString humanLabel, int pipelineIndex, const QString msg); - - - SIMPL_TYPE_MACRO(PipelineMessage) - - virtual ~PipelineMessage(); - - bool operator==(const PipelineMessage& rhs); - - void operator=(const PipelineMessage& rhs); - - SIMPL_INSTANCE_STRING_PROPERTY(FilterClassName) - - SIMPL_INSTANCE_STRING_PROPERTY(FilterHumanLabel) - - SIMPL_INSTANCE_STRING_PROPERTY(Prefix) - - SIMPL_INSTANCE_STRING_PROPERTY(Text) - - SIMPL_INSTANCE_PROPERTY(int, Code) - - SIMPL_INSTANCE_PROPERTY(int, PipelineIndex) - - SIMPL_INSTANCE_PROPERTY(MessageType, Type) - - SIMPL_INSTANCE_PROPERTY(int, ProgressValue) - - /** - * @brief This method creates and returns a string for error messages - */ - QString generateErrorString() const; - - /** - * @brief This method creates and returns a string for warning messages - */ - QString generateWarningString() const; - - /** - * @brief This method creates and returns a string for status messages - */ - QString generateStatusString() const; - - /** - * @brief This method creates and returns a string for standard output messages - */ - QString generateStandardOutputString() const; - - /** - * @brief This method generates a status message that includes a progress value. - * @return - */ - QString generateProgressString() const; - - - private: - -}; - - -Q_DECLARE_METATYPE(PipelineMessage) - - diff --git a/Source/SIMPLib/Common/QtBackwardCompatibilityMacro.h b/Source/SIMPLib/Common/QtBackwardCompatibilityMacro.h new file mode 100644 index 0000000000..0816ffb283 --- /dev/null +++ b/Source/SIMPLib/Common/QtBackwardCompatibilityMacro.h @@ -0,0 +1,57 @@ + + +#pragma once + +#include + +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) +#define QSTRING_KEEP_EMPTY_PARTS QString::KeepEmptyParts +#define QSTRING_SKIP_EMPTY_PARTS QString::SkipEmptyParts +#else +#define QSTRING_KEEP_EMPTY_PARTS Qt::KeepEmptyParts +#define QSTRING_SKIP_EMPTY_PARTS Qt::SkipEmptyParts +#endif + +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) +#define QFONTMETRICS_WIDTH width +#else +#define QFONTMETRICS_WIDTH horizontalAdvance +#endif + +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) +#define QFOREGROUND QPalette::Foreground +#define QBACKGROUND QPalette::Background +#else +#define QFOREGROUND QPalette::WindowText +#define QBACKGROUND QPalette::Window +#endif + +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) + +#ifndef QVECTOR_FROM_STD_VECTOR +#define QVECTOR_FROM_STD_VECTOR(def, qvector, other) def qvector = def::fromStdVector(other); +#endif + +#ifndef QVECTOR_TO_STD_VECTOR +#define QVECTOR_TO_STD_VECTOR(def, qvector, other) def other = qvector.toStdVector(); +#endif + +#ifndef QLIST_FROM_QSET +#define QLIST_FROM_QSET(def, qlist, other) def qlist = other.toList(); +#endif + +#else + +#ifndef QVECTOR_FROM_STD_VECTOR +#define QVECTOR_FROM_STD_VECTOR(def, qvecVarName, svector) def qvecVarName(svector.begin(), svector.end()); +#endif + +#ifndef QVECTOR_TO_STD_VECTOR +#define QVECTOR_TO_STD_VECTOR(def, qvecVarName, svector) def svector(qvecVarName.begin(), qvecVarName.end()); +#endif + +#ifndef QLIST_FROM_QSET +#define QLIST_FROM_QSET(def, qlist, other) def qlist = other.values(); +#endif + +#endif diff --git a/Source/SIMPLib/Common/SIMPLArray.hpp b/Source/SIMPLib/Common/SIMPLArray.hpp new file mode 100644 index 0000000000..e893e51aff --- /dev/null +++ b/Source/SIMPLib/Common/SIMPLArray.hpp @@ -0,0 +1,907 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#pragma once + +#include +#include +#include +#include + +/** + * @brief This class is a facade pattern around a std::array array to allow for some semantics + * for either a 2D or 3D point such as X,Y,Z. We Provide 3 concrete implementations that are for 2, 3 and 4 element + * arrays used in some of the filter parameters. The devloper can extend this quite easily to more + * elements should they need them + */ +template +class SIMPLArray +{ +public: + SIMPLArray() = default; + SIMPLArray(const SIMPLArray&) = default; + SIMPLArray(SIMPLArray&&) noexcept = default; + SIMPLArray& operator=(const SIMPLArray&) = default; + SIMPLArray& operator=(SIMPLArray&&) noexcept = default; + ~SIMPLArray() = default; + + /** + * @brief Constructor using a random access container type as the input. This will copy the data + */ + template + SIMPLArray(const InType& data) + { + for(size_t i = 0; i < Dimension; i++) + { + m_Array[i] = data[i]; + } + } + + //========================================= STL INTERFACE COMPATIBILITY ================================= + using size_type = size_t; + using value_type = T; + using reference = T&; + using const_reference = const T&; + using iterator_category = std::input_iterator_tag; + using pointer = T*; + using difference_type = value_type; + using iterator = typename std::array::iterator; + using const_iterator = typename std::array::const_iterator; + //========================================= END STL INTERFACE COMPATIBILITY ============================== + + /** + * @brief access specified element + * @param index + * @return + */ + inline reference operator[](size_type index) + { + return m_Array[index]; + } + + /** + * @brief access specified element + * @param index + * @return + */ + inline const_reference operator[](size_type index) const + { + return m_Array[index]; + } + + /** + * @brief access specified element with bounds checking + * @param index + * @return + */ + inline reference at(size_type index) + { + assert(index < Dimension); + return m_Array.at(index); + } + + /** + * @brief access specified element with bounds checking + * @param index + * @return + */ + inline const_reference at(size_type index) const + { + assert(index < Dimension); + return m_Array.at(index); + } + + /** + * @brief returns an iterator to the beginning + * @return + */ + iterator begin() + { + return m_Array.begin(); + } + + /** + * @brief returns an iterator to the end + * @return + */ + iterator end() + { + return m_Array.end(); + } + + /** + * @brief returns an iterator to the beginning + * @return + */ + const_iterator begin() const + { + return m_Array.cbegin(); + } + + /** + * @brief returns an iterator to the end + * @return + */ + const_iterator end() const + { + return m_Array.cend(); + } + + /** + * @brief returns an iterator to the beginning + * @return + */ + const_iterator cbegin() const + { + return m_Array.cbegin(); + } + + /** + * @brief returns an iterator to the end + * @return + */ + const_iterator cend() const + { + return m_Array.cend(); + } + + /** + * @brief direct access to the underlying array + * @return + */ + pointer data() + { + return m_Array.data(); + } + + /** + * @brief Returns the number of elements + * @return + */ + size_type size() const + { + return Dimension; + } + + /** + * @brief operator == Tests for an element by element equivelance of the underlying data + * @param rhs + * @return + */ + bool operator==(const SIMPLArray& rhs) const + { + return m_Array == rhs.m_Array; + } + + /** + * @brief Converts to another container type. The output type that is being used needs to have the "push_back()" method implemented. + * + * For STL containers this includes Vector, Deque. QVector will also work. + */ + template + OutContainerType toContainer() const + { + OutContainerType dest(Dimension); + for(typename OutContainerType::size_type i = 0; i < Dimension; i++) + { + dest[i] = m_Array[i]; + } + return dest; + } + + /** + * @brief Returns a copy of the data as a std::array + * @return + */ + std::array toArray() const + { + return m_Array; + } + +protected: + void setValue(size_t i, value_type value) + { + m_Array[i] = value; + } + +private: + std::array m_Array; +}; + +// ----------------------------------------------------------------------------- +template +class IVec2 : public SIMPLArray +{ + using ParentType = SIMPLArray; + +public: + IVec2(const IVec2&) = default; + IVec2(IVec2&&) noexcept = default; + IVec2& operator=(const IVec2&) = default; + IVec2& operator=(IVec2&&) noexcept = default; + ~IVec2() = default; + + /** + * @brief IVec2 Default constructor initializes all values to ZERO. + */ + IVec2() + { + (*this)[0] = static_cast(0); + (*this)[1] = static_cast(0); + } + /** + * @brief IVec2 + * @param x + * @param y + */ + IVec2(T x, T y) + { + (*this)[0] = x; + (*this)[1] = y; + } + /** + * @brief IVec2 + * @param data + */ + IVec2(const std::array& data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + } + /** + * @brief IVec2 + * @param data + */ + IVec2(const std::tuple& data) + { + (*this)[0] = std::get<0>(data); + (*this)[1] = std::get<1>(data); + } + /** + * @brief IVec2 + * @param data + */ + IVec2(const T* data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + } + + /** + * @brief IVec2 + * @param data + */ + IVec2(const std::vector& data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + } + + inline T getX() const + { + return ParentType::operator[](0); + } + inline T getY() const + { + return ParentType::operator[](1); + } + inline void setX(const T& x) + { + (*this)[0] = x; + } + inline void setY(const T& y) + { + (*this)[1] = y; + } + + /** + * @brief this is a convenience function that helps with the python bindings + */ + inline void setValues(const T& x, const T& y) + { + (*this)[0] = x; + (*this)[1] = y; + } + + /** + * @brief toTuple Converts the internal data structure to a std::tuple + * @return + */ + std::tuple toTuple() const + { + return std::make_tuple(getX(), getY()); + } + /** + * + */ + template + IVec2 convertType() + { + return IVec2(static_cast((*this)[0]), static_cast((*this)[1])); + } +}; + +using FloatVec2Type = IVec2; +using IntVec2Type = IVec2; +using SizeVec2Type = IVec2; + +// ----------------------------------------------------------------------------- +template +class IVec3 : public SIMPLArray +{ + using ParentType = SIMPLArray; + +public: + IVec3(const IVec3&) = default; + IVec3(IVec3&&) noexcept = default; + IVec3& operator=(const IVec3&) = default; + IVec3& operator=(IVec3&&) noexcept = default; + ~IVec3() = default; + + /** + * @brief IVec3 Default constructor initializes all values to ZERO. + */ + IVec3() + { + (*this)[0] = static_cast(0); + (*this)[1] = static_cast(0); + (*this)[2] = static_cast(0); + } + /** + * @brief IVec3 + * @param x + * @param y + * @param z + */ + IVec3(T x, T y, T z) + { + (*this)[0] = x; + (*this)[1] = y; + (*this)[2] = z; + } + /** + * @brief IVec3 + * @param data + */ + IVec3(const std::array& data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + } + /** + * @brief IVec3 + * @param data + */ + IVec3(const std::tuple& data) + { + (*this)[0] = std::get<0>(data); + (*this)[1] = std::get<1>(data); + (*this)[2] = std::get<2>(data); + } + /** + * @brief IVec3 + * @param data + */ + IVec3(const T* data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + } + /** + * @brief IVec3 + * @param data + */ + IVec3(const std::vector& data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + } + + inline T getX() const + { + return ParentType::operator[](0); + } + inline T getY() const + { + return ParentType::operator[](1); + } + inline T getZ() const + { + return ParentType::operator[](2); + } + inline void setX(const T& x) + { + (*this)[0] = x; + } + inline void setY(const T& y) + { + (*this)[1] = y; + } + inline void setZ(const T& z) + { + (*this)[2] = z; + } + + /** + * @brief this is a convenience function that helps with the python bindings + */ + inline void setValues(const T& x, const T& y, const T& z) + { + (*this)[0] = x; + (*this)[1] = y; + (*this)[2] = z; + } + + /** + * @brief toTuple Converts the internal data structure to a std::tuple + * @return + */ + std::tuple toTuple() const + { + return std::make_tuple(getX(), getY(), getZ()); + } + + /** + * @brief Converts to a new SIMPLArray with a different storage data type + */ + template + IVec3 convertType() + { + return IVec3(static_cast((*this)[0]), static_cast((*this)[1]), static_cast((*this)[2])); + } +}; + +// ----------------------------------------------------------------------------- +template +class IVec4 : public SIMPLArray +{ + using ParentType = SIMPLArray; + +public: + IVec4(const IVec4&) = default; + IVec4(IVec4&&) noexcept = default; + IVec4& operator=(const IVec4&) = default; + IVec4& operator=(IVec4&&) noexcept = default; + ~IVec4() = default; + + /** + * @brief IVec4 Default constructor initializes all values to ZERO. + */ + IVec4() + { + (*this)[0] = static_cast(0); + (*this)[1] = static_cast(0); + (*this)[2] = static_cast(0); + (*this)[3] = static_cast(0); + } + /** + * @brief IVec4 + * @param x + * @param y + * @param z + * @param w + */ + IVec4(T x, T y, T z, T w) + { + (*this)[0] = x; + (*this)[1] = y; + (*this)[2] = z; + (*this)[3] = w; + } + /** + * @brief IVec4 + * @param data + */ + IVec4(const std::array& data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + (*this)[3] = data[3]; + } + /** + * @brief IVec4 + * @param data + */ + IVec4(const std::tuple& data) + { + (*this)[0] = std::get<0>(data); + (*this)[1] = std::get<1>(data); + (*this)[2] = std::get<2>(data); + (*this)[3] = std::get<3>(data); + } + /** + * @brief IVec4 + * @param data + */ + IVec4(const T* data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + (*this)[3] = data[3]; + } + /** + * @brief IVec4 + * @param data + */ + IVec4(const std::vector& data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + (*this)[3] = data[3]; + } + + inline T getX() const + { + return ParentType::operator[](0); + } + inline T getY() const + { + return ParentType::operator[](1); + } + inline T getZ() const + { + return ParentType::operator[](2); + } + inline T getW() const + { + return ParentType::operator[](3); + } + inline void setX(const T& x) + { + (*this)[0] = x; + } + inline void setY(const T& y) + { + (*this)[1] = y; + } + inline void setZ(const T& z) + { + (*this)[2] = z; + } + inline void setW(const T& w) + { + (*this)[3] = w; + } + + /** + * @brief this is a convenience function that helps with the python bindings + */ + inline void setValues(const T& x, const T& y, const T& z, const T& w) + { + (*this)[0] = x; + (*this)[1] = y; + (*this)[2] = z; + (*this)[3] = w; + } + + /** + * @brief toTuple Converts the internal data structure to a std::tuple + * @return + */ + std::tuple toTuple() const + { + return std::make_tuple(getX(), getY(), getZ(), getW()); + } + + /** + * @brief Converts this array into another array using a static_cast mechanism + */ + template + IVec4 convertType() + { + return IVec4(static_cast((*this)[0]), static_cast((*this)[1]), static_cast((*this)[2]), static_cast((*this)[3])); + } +}; + +// ----------------------------------------------------------------------------- +template +class IVec6 : public SIMPLArray +{ + using ParentType = SIMPLArray; + +public: + IVec6(const IVec6&) = default; + IVec6(IVec6&&) noexcept = default; + IVec6& operator=(const IVec6&) = default; + IVec6& operator=(IVec6&&) noexcept = default; + ~IVec6() = default; + + /** + * @brief IVec6 Default constructor initializes all values to ZERO. + */ + IVec6() + { + (*this)[0] = static_cast(0); + (*this)[1] = static_cast(0); + (*this)[2] = static_cast(0); + (*this)[3] = static_cast(0); + (*this)[4] = static_cast(0); + (*this)[5] = static_cast(0); + } + /** + * @brief IVec6 + * @param x + * @param y + * @param z + * @param a + * @param b + * @param c + */ + IVec6(T x, T y, T z, T a, T b, T c) + { + (*this)[0] = x; + (*this)[1] = y; + (*this)[2] = z; + (*this)[3] = a; + (*this)[4] = b; + (*this)[5] = c; + } + /** + * @brief IVec6 + * @param data + */ + IVec6(const std::array& data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + (*this)[3] = data[3]; + (*this)[4] = data[4]; + (*this)[5] = data[5]; + } + /** + * @brief IVec6 + * @param data + */ + IVec6(const std::tuple& data) + { + (*this)[0] = std::get<0>(data); + (*this)[1] = std::get<1>(data); + (*this)[2] = std::get<2>(data); + (*this)[3] = std::get<3>(data); + (*this)[4] = std::get<4>(data); + (*this)[5] = std::get<5>(data); + } + /** + * @brief IVec6 + * @param data + */ + IVec6(const T* data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + (*this)[3] = data[3]; + (*this)[4] = data[4]; + (*this)[5] = data[5]; + } + /** + * @brief IVec6 + * @param data + */ + IVec6(const std::vector& data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + (*this)[3] = data[3]; + (*this)[4] = data[4]; + (*this)[5] = data[5]; + } + + /** + * @brief this is a convenience function that helps with the python bindings + */ + inline void setValues(const T& x, const T& y, const T& z, const T& i, const T& j, const T& k) + { + (*this)[0] = x; + (*this)[1] = y; + (*this)[2] = z; + (*this)[3] = i; + (*this)[4] = j; + (*this)[5] = k; + } + + /** + * @brief toTuple Converts the internal data structure to a std::tuple + * @return + */ + std::tuple toTuple() const + { + return std::make_tuple((*this)[0], (*this)[1], (*this)[2], (*this)[3], (*this)[4], (*this)[5]); + } + + /** + * @brief Converts this array into another array using a static_cast mechanism + */ + template + IVec6 convertType() + { + return IVec6(static_cast((*this)[0]), static_cast((*this)[1]), static_cast((*this)[2]), static_cast((*this)[3]), static_cast((*this)[4]), + static_cast((*this)[5])); + } +}; + +// ----------------------------------------------------------------------------- +template +class IVec7 : public SIMPLArray +{ + using ParentType = SIMPLArray; + +public: + IVec7(const IVec7&) = default; + IVec7(IVec7&&) noexcept = default; + IVec7& operator=(const IVec7&) = default; + IVec7& operator=(IVec7&&) noexcept = default; + ~IVec7() = default; + + /** + * @brief IVec6 Default constructor initializes all values to ZERO. + */ + IVec7() + { + (*this)[0] = static_cast(0); + (*this)[1] = static_cast(0); + (*this)[2] = static_cast(0); + (*this)[3] = static_cast(0); + (*this)[4] = static_cast(0); + (*this)[5] = static_cast(0); + (*this)[6] = static_cast(0); + } + /** + * @brief IVec6 + * @param x + * @param y + * @param z + * @param a + * @param b + * @param c + */ + IVec7(T x, T y, T z, T a, T b, T c, T d) + { + (*this)[0] = x; + (*this)[1] = y; + (*this)[2] = z; + (*this)[3] = a; + (*this)[4] = b; + (*this)[5] = c; + (*this)[6] = d; + } + /** + * @brief IVec6 + * @param data + */ + IVec7(const std::array& data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + (*this)[3] = data[3]; + (*this)[4] = data[4]; + (*this)[5] = data[5]; + (*this)[6] = data[6]; + } + /** + * @brief IVec6 + * @param data + */ + IVec7(const std::tuple& data) + { + (*this)[0] = std::get<0>(data); + (*this)[1] = std::get<1>(data); + (*this)[2] = std::get<2>(data); + (*this)[3] = std::get<3>(data); + (*this)[4] = std::get<4>(data); + (*this)[5] = std::get<5>(data); + (*this)[6] = std::get<6>(data); + } + /** + * @brief IVec6 + * @param data + */ + IVec7(const T* data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + (*this)[3] = data[3]; + (*this)[4] = data[4]; + (*this)[5] = data[5]; + (*this)[6] = data[6]; + } + /** + * @brief IVec6 + * @param data + */ + IVec7(const std::vector& data) + { + (*this)[0] = data[0]; + (*this)[1] = data[1]; + (*this)[2] = data[2]; + (*this)[3] = data[3]; + (*this)[4] = data[4]; + (*this)[5] = data[5]; + (*this)[6] = data[6]; + } + + /** + * @brief this is a convenience function that helps with the python bindings + */ + inline void setValues(const T& x, const T& y, const T& z, const T& i, const T& j, const T& k, const T& l) + { + (*this)[0] = x; + (*this)[1] = y; + (*this)[2] = z; + (*this)[3] = i; + (*this)[4] = j; + (*this)[5] = k; + (*this)[6] = l; + } + + /** + * @brief toTuple Converts the internal data structure to a std::tuple + * @return + */ + std::tuple toTuple() const + { + return std::make_tuple((*this)[0], (*this)[1], (*this)[2], (*this)[3], (*this)[4], (*this)[5], (*this)[6]); + } + + /** + * @brief Converts this array into another array using a static_cast mechanism + */ + template + IVec7 convertType() + { + return IVec6(static_cast((*this)[0]), static_cast((*this)[1]), static_cast((*this)[2]), static_cast((*this)[3]), static_cast((*this)[4]), + static_cast((*this)[5]), static_cast((*this)[6])); + } +}; + +using FloatVec3Type = IVec3; +using IntVec3Type = IVec3; +using SizeVec3Type = IVec3; + +using FloatVec4Type = IVec4; +using IntVec4Type = IVec4; +using SizeVec4Type = IVec4; + +using FloatVec6Type = IVec6; +using IntVec6Type = IVec6; + +using FloatVec7Type = IVec7; +using IntVec7Type = IVec7; diff --git a/Source/SIMPLib/Common/SIMPLPythonMacros.h b/Source/SIMPLib/Common/SIMPLPythonMacros.h new file mode 100644 index 0000000000..1f5435dfe6 --- /dev/null +++ b/Source/SIMPLib/Common/SIMPLPythonMacros.h @@ -0,0 +1,217 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#pragma once + +/* ***************************************************************************** + * ***************************************************************************** + * ***************************************************************************** + * + * PyBind11 Macros that we can use to explicitly define which setters & getters + * will be exposed to the Python library + */ + +/** + * @brief PYB11_BEGIN_BINDINGS This macro lets the wrapper know that we want to + * wrap this class with Python bindings. It should only take a single argument + * which is the name of the class. If this line is commented out using the standard + * C++ style of single line comment then NO WRAPPING will be performed + * on the class. + * @code + * PYB11_BEGIN_BINDINGS(AbstractFilter) + * @endcode + */ +#define PYB11_BEGIN_BINDINGS(...) + +/** + * @brief PYB11_END_BINDINGS This macro is used to define the end of the python bindings section + * @code + * PYB11_END_BINDINGS(AbstractFilter) + * @endcode + */ +#define PYB11_END_BINDINGS(...) + +/** + * @brief PYB11_STATIC_NEW_MACRO + * + */ +#define PYB11_STATIC_NEW_MACRO(...) + +/** + * @brief PYB11_FILTER_NEW_MACRO + * + */ +#define PYB11_FILTER_NEW_MACRO(...) + +/** + * @brief PYB11_SHARED_POINTERS + * + */ +#define PYB11_SHARED_POINTERS(...) + +/** + * @brief PYB11_NO_BINDINGS This macro will ensure that the class is NOT wrapped + * with python bindings. Only a single argument which is the name of the class + * should be used. + * @code + * PYB11_NO_BINDINGS(AbstractFilter) + * @endcode + */ +#define PYB11_NO_BINDINGS(...) + +/** + * @brief PYB11_STATIC_CREATION This macro will wrap the "static New()" function + * that most of the SIMPL classes implement as a way to instantiate the class in + * addition to other static methods that are used for a class. The argument types + * to the static method should be listed WITHOUT any spaces for each argument. + * + * @code + * PYB11_STATIC_CREATION(Create ARGS std::vector> std::list std::list) + * @endcode + * + * If there are several static creation methods that overload each other then the following form can be used: + * + * @code + * PYB11_STATIC_CREATION(New OVERLOAD QString) + * PYB11_STATIC_CREATION(New OVERLOAD DataArrayPath) + * @endcode + */ +#define PYB11_STATIC_CREATION(...) + +/** + * @brief PYB11_CREATION This macro is used for non-static constructors that need + * to be wrapped. The argument types need to be lists where each argument cannot + * containe spaces. Use a typedef if needed, but using a typedef also has its + * own issues. @see DataArrayPath for an example. + * + * @code + * PYB11_CREATION(ARGS QString QString QString) + * @endcode + */ +#define PYB11_CREATION(...) + +/** + * @brief PYB11_ENUMERATION This macro will allow a class enumeration to be wrapped + * in Python an available to the Python side. @see IGeoemtry for an example. The + * macro should only take a single argument. + * @code + * PYB11_ENUMERATION(Type) + * PYB11_ENUMERATION(VtkCellType) + * @endcode + */ +#define PYB11_ENUMERATION(...) + +/** +* @brief PYB11_PROPERTY This macro is used to wrap a single class instance property +* that is typically used as an input parameter for a filter. This macro should +* NOT be used for just wrapping instance methods. Use the PYB11_METHOD for +* that. @see AbstractFilter. There are number of arguments depending on if the +* property is a read-only or read-write variable. At least 4 arguments to the +* macro are required when the property is read only. +* @code + PYB11_PROPERTY(QString NameOfClass READ getNameOfClass) +* @endcode +* and 6 arguments when the property is read-write. +* @code +* PYB11_PROPERTY(bool Cancel READ getCancel WRITE setCancel) +* @endcode +* +* and if there are additional overloads of the Getter that returns a const reference such as +* @code +* const QString& getFoo() const; +* @endcode +* +* then you would add on the CONST_GET_OVERLOAD as the last argument to the macro. +*/ +#define PYB11_PROPERTY(...) + +/** + * @brief This macro is used to expose a method to the Python bindings. The signature + * of the macro should be the following: + * PYB11_METHOD( _return_type_ _name_of_method_ [ARGS|OVERLOAD] ....) + * If the ARGS command is used then simply list the variable names for each argument. + * For example if you have a method "void getFoo(const QString &foo)" that you want + * to expose: + * @code + * PYB11_METHOD(void getFoo ARGS Foo) + * @endcode + * + * If your method does not take any arguments then leave out the ARGS keyword. + * + * If you are have overloads of the method that you want to expose to Python then + * the "OVERLOAD" version of the method should be used. Again, say we have two + * methods that we want to expose. + * @code + * void setPath(const QString &name) + * void setPath(const DataArrayPath &path) + * @endcode + * + * then we would use the following set of invocations: + * @code + * PYB11_METHOD(void setPath OVERLOAD const.QString.&,Name) + * PYB11_METHOD(void setPath OVERLOAD const.DataArrayPath.&,Path) + * @endcode + * Note that in order to get the (const QString &) correct we used the '.' charater + * to declare the type. This is required as the macro is split using spaces. When + * then end code is generated the '.' characters will be replaced with spaces. + * + * If the method that is being wrapped in python is a 'const' method then the last argument should be CONST_METHOD. In + * the example below there is a pair of overloaded methods that are both 'const'. + * + * @code + * PYB11_METHOD(bool doesDataContainerExist OVERLOAD const.QString.&,Name CONST_METHOD) + * PYB11_METHOD(bool doesDataContainerExist OVERLOAD const.DataArrayPath.&,Path CONST_METHOD) + * @endcode + */ +#define PYB11_METHOD(...) + +/** + * @brief PYB11_FILTER This macro is used to flag the class as being a filter class. + * This will make the generator create a Pythonic interface for this filter. + */ +#define PYB11_FILTER(...) + +/** + * @brief PYB11_CUSTOM This macro is used to allow user created bindings on a per class basis. + */ +#define PYB11_CUSTOM(...) + +/** +* @brief PYB11_FIELD This macro is used to wrap instance variable of a class. +* It is similiar to PYB11_PROPERTY but without getters/setters. +*/ +#define PYB11_FIELD(...) + +// End of PYBIND11 Macro Definitions +/* ***************************************************************************** + * ***************************************************************************** + * ***************************************************************************** + */ diff --git a/Source/SIMPLib/Common/SIMPLRange.cpp b/Source/SIMPLib/Common/SIMPLRange.cpp new file mode 100644 index 0000000000..cafbbe457c --- /dev/null +++ b/Source/SIMPLib/Common/SIMPLRange.cpp @@ -0,0 +1,118 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "SIMPLib/Common/SIMPLRange.h" + +#include + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange::SIMPLRange() +: m_Range({{0, 0}}) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange::SIMPLRange(size_t begin, size_t end) +: m_Range({{begin, end}}) +{ +} + +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange::SIMPLRange(const tbb::blocked_range& r) +: m_Range({{r.begin(), r.end()}}) +{ +} +#endif + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange::RangeType SIMPLRange::getRange() const +{ + return m_Range; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +size_t SIMPLRange::min() const +{ + return m_Range[0]; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +size_t SIMPLRange::max() const +{ + return m_Range[1]; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +size_t SIMPLRange::size() const +{ + return m_Range[1] - m_Range[0]; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool SIMPLRange::empty() const +{ + return size() == 0; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +size_t SIMPLRange::operator[](size_t index) const +{ + switch(index) + { + case 0: + return min(); + case 1: + return max(); + default: + throw std::range_error("Range must be 0 or 1"); + } +} diff --git a/Source/SIMPLib/Common/SIMPLRange.h b/Source/SIMPLib/Common/SIMPLRange.h new file mode 100644 index 0000000000..a55e8115ad --- /dev/null +++ b/Source/SIMPLib/Common/SIMPLRange.h @@ -0,0 +1,108 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLArray.hpp" + +// SIMPLib.h MUST be included before this or the guard will block the include but not its uses below. +// This is consistent with previous behavior, only earlier parallelization split the includes between +// the corresponding .h and .cpp files. +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS +// clang-format off +#include +// clang-format on +#endif + +/** + * @class SIMPLRange SIMPLRange.h SIMPLib/Common/SIMPLRange.h + * @brief The SIMPLRange class defines a range between set of minimum and + * maximum values. The purpose of this class is mainly to allow a more unified + * control flow during parallelization between builds using TBB and those that + * do not. Because tbb::blocked_range is used in an implicit conversion constructor, + * a single operator accepting a SIMPLRange can be used TBB parallelized and + * non-paralleled versions without a branching code base. + */ +class SIMPLib_EXPORT SIMPLRange +{ +public: + using RangeType = std::array; + + SIMPLRange(); + SIMPLRange(size_t begin, size_t end); +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS + SIMPLRange(const tbb::blocked_range& r); +#endif + + /** + * @brief Returns an array representation of the range. + * @return + */ + RangeType getRange() const; + + /** + * @brief Returns the minimum index in the range. + * @return + */ + size_t min() const; + + /** + * @brief Returns the maximum index in the range. + * @return + */ + size_t max() const; + + /** + * @brief Returns the number of indices in the range. + * @return + */ + size_t size() const; + + /** + * @brief Returns true if the range is empty. Returns false otherwise. + * @return + */ + bool empty() const; + + /** + * @brief Returns the range based on the specified index. The range is + * organized as [min, max] + */ + size_t operator[](size_t index) const; + +private: + RangeType m_Range; +}; diff --git a/Source/SIMPLib/Common/SIMPLRange2D.cpp b/Source/SIMPLib/Common/SIMPLRange2D.cpp new file mode 100644 index 0000000000..3bc64a64c2 --- /dev/null +++ b/Source/SIMPLib/Common/SIMPLRange2D.cpp @@ -0,0 +1,148 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "SIMPLib/Common/SIMPLRange2D.h" + +#include + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange2D::SIMPLRange2D() +: m_Range({{0, 0, 0, 0}}) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange2D::SIMPLRange2D(size_t initRow, size_t initCol, size_t endRow, size_t endCol) +: m_Range({{initRow, initCol, endRow, endCol}}) +{ +} + +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange2D::SIMPLRange2D(const tbb::blocked_range2d& r) +: m_Range({{r.rows().begin(), r.cols().begin(), r.rows().end(), r.cols().end()}}) +{ +} +#endif + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange2D::RangeType SIMPLRange2D::getRange() const +{ + return m_Range; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +size_t SIMPLRange2D::minRow() const +{ + return m_Range[0]; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +size_t SIMPLRange2D::minCol() const +{ + return m_Range[1]; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +size_t SIMPLRange2D::maxRow() const +{ + return m_Range[2]; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +size_t SIMPLRange2D::maxCol() const +{ + return m_Range[3]; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +size_t SIMPLRange2D::numRows() const +{ + return maxRow() - minRow(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +size_t SIMPLRange2D::numCols() const +{ + return maxCol() - minCol(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +size_t SIMPLRange2D::size() const +{ + return numRows() * numCols(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool SIMPLRange2D::empty() const +{ + const bool emptyRows = (m_Range[0] == m_Range[2]) && (m_Range[0] == 0); + const bool emptyCols = (m_Range[1] == m_Range[3]) && (m_Range[1] == 0); + return emptyRows && emptyCols; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +size_t SIMPLRange2D::operator[](size_t index) const +{ + if(index < 4) + { + return m_Range[index]; + } + throw std::range_error("Range out of bounds"); +} diff --git a/Source/SIMPLib/Common/SIMPLRange2D.h b/Source/SIMPLib/Common/SIMPLRange2D.h new file mode 100644 index 0000000000..d1a31a7186 --- /dev/null +++ b/Source/SIMPLib/Common/SIMPLRange2D.h @@ -0,0 +1,132 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLArray.hpp" + +// SIMPLib.h MUST be included before this or the guard will block the include but not its uses below. +// This is consistent with previous behavior, only earlier parallelization split the includes between +// the corresponding .h and .cpp files. +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS +// clang-format off +#include +// clang-format on +#endif + +/** + * @class SIMPLRange2D SIMPLRange2D.h SIMPLib/Common/SIMPLRange2D.h + * @brief The SIMPLRange2D class defines a range between set of minimum and + * maximum values. The purpose of this class is mainly to allow a more unified + * control flow during parallelization between builds using TBB and those that + * do not. Because tbb::blocked_range is used in an implicit conversion constructor, + * a single operator accepting a SIMPLRange can be used TBB parallelized and + * non-paralleled versions without a branching code base. + */ +class SIMPLib_EXPORT SIMPLRange2D +{ +public: + using RangeType = std::array; // { init row, init col, final row, final col } + + SIMPLRange2D(); + SIMPLRange2D(size_t initRow, size_t initCol, size_t endRow, size_t endCol); +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS + SIMPLRange2D(const tbb::blocked_range2d& r); +#endif + + /** + * @brief Returns an array representation of the range. + * @return + */ + RangeType getRange() const; + + /** + * @brief Returns the minimum row index in the range. + * @return + */ + size_t minRow() const; + + /** + * @brief Returns the minimum column index in the range. + * @return + */ + size_t minCol() const; + + /** + * @brief Returns the maximum row index in the range. + * @return + */ + size_t maxRow() const; + + /** + * @brief Returns the maximum column index in the range. + * @return + */ + size_t maxCol() const; + + /** + * @brief Returns the number of rows in the range. + * @return + */ + size_t numRows() const; + + /** + * @brief Returns the number of columns in the range. + * @return + */ + size_t numCols() const; + + /** + * @brief Returns the number of indices in the range. + * @return + */ + size_t size() const; + + /** + * @brief Returns true if the range is empty. Returns false otherwise. + * @return + */ + bool empty() const; + + /** + * @brief Returns the range based on the specified index. The range is + * organized as [min, max] + */ + size_t operator[](size_t index) const; + +private: + RangeType m_Range; +}; diff --git a/Source/SIMPLib/Common/SIMPLRange3D.cpp b/Source/SIMPLib/Common/SIMPLRange3D.cpp new file mode 100644 index 0000000000..21778201c2 --- /dev/null +++ b/Source/SIMPLib/Common/SIMPLRange3D.cpp @@ -0,0 +1,123 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "SIMPLib/Common/SIMPLRange3D.h" + +#include + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange3D::SIMPLRange3D() +: m_Range({{0, 0, 0, 0, 0, 0}}) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange3D::SIMPLRange3D(size_t x, size_t y, size_t z) +: m_Range({{0, x, 0, y, 0, z}}) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange3D::SIMPLRange3D(size_t xMin, size_t xMax, size_t yMin, size_t yMax, size_t zMin, size_t zMax) +: m_Range({{xMin, xMax, yMin, yMax, zMin, zMax}}) +{ +} + +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange3D::SIMPLRange3D(const tbb::blocked_range3d& r) +: m_Range({{r.pages().begin(), r.pages().end(), r.rows().begin(), r.rows().end(), r.cols().begin(), r.cols().end()}}) +{ +} +#endif + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange3D::RangeType SIMPLRange3D::getRange() const +{ + return m_Range; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange3D::DimensionRange SIMPLRange3D::getXRange() const +{ + return {{m_Range[0], m_Range[1]}}; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange3D::DimensionRange SIMPLRange3D::getYRange() const +{ + return {{m_Range[2], m_Range[3]}}; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +SIMPLRange3D::DimensionRange SIMPLRange3D::getZRange() const +{ + return {{m_Range[4], m_Range[5]}}; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool SIMPLRange3D::empty() const +{ + return (m_Range[0] == m_Range[1]) && (m_Range[2] == m_Range[3]) && (m_Range[4] == m_Range[5]); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +size_t SIMPLRange3D::operator[](size_t index) const +{ + if(index < 6) + { + return m_Range[index]; + } + + throw std::range_error("Range must be 0 or 1"); +} diff --git a/Source/SIMPLib/Common/SIMPLRange3D.h b/Source/SIMPLib/Common/SIMPLRange3D.h new file mode 100644 index 0000000000..f504fd08fe --- /dev/null +++ b/Source/SIMPLib/Common/SIMPLRange3D.h @@ -0,0 +1,112 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLArray.hpp" + +// SIMPLib.h MUST be included before this or the guard will block the include but not its uses below. +// This is consistent with previous behavior, only earlier parallelization split the includes between +// the corresponding .h and .cpp files. +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS +// clang-format off +#include +// clang-format on +#endif + +/** + * @class SIMPLRange3D SIMPLRange3D.h SIMPLib/Common/SIMPLRange3D.h + * @brief The SIMPLRange3D class defines a range between set of minimum and + * maximum values. The purpose of this class is mainly to allow a more unified + * control flow during parallelization between builds using TBB and those that + * do not. Because tbb::blocked_range is used in an implicit conversion constructor, + * a single operator accepting a SIMPLRange can be used TBB parallelized and + * non-paralleled versions without a branching code base. + */ +class SIMPLib_EXPORT SIMPLRange3D +{ +public: + using RangeType = std::array; + using DimensionRange = std::array; + + SIMPLRange3D(); + SIMPLRange3D(size_t x, size_t y, size_t z); + SIMPLRange3D(size_t xMin, size_t xMax, size_t yMin, size_t yMax, size_t zMin, size_t zMax); +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS + SIMPLRange3D(const tbb::blocked_range3d& r); +#endif + + /** + * @brief Returns an array representation of the range. + * @return + */ + RangeType getRange() const; + + /** + * @brief Returns the range along the X dimension + * @return + */ + DimensionRange getXRange() const; + + /** + * @brief Returns the range along the Y dimension + * @return + */ + DimensionRange getYRange() const; + + /** + * @brief Returns the range along the Z dimension + * @return + */ + DimensionRange getZRange() const; + + /** + * @brief Returns true if the range is empty. Returns false otherwise. + * @return + */ + bool empty() const; + + /** + * @brief Returns the specified part of the range. The range is organized as + * [xMin, xMax, yMin, yMax, zMin, zMax]. + * @param index + * @return + */ + size_t operator[](size_t index) const; + +private: + RangeType m_Range; +}; diff --git a/Source/SIMPLib/Common/SIMPLibDLLExport.h b/Source/SIMPLib/Common/SIMPLibDLLExport.h old mode 100755 new mode 100644 index 2f6e83a7d4..ab5bf6700d --- a/Source/SIMPLib/Common/SIMPLibDLLExport.h +++ b/Source/SIMPLib/Common/SIMPLibDLLExport.h @@ -1,70 +1,62 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once - -#if defined (_MSC_VER) -#pragma warning(disable: 4267) -#pragma warning(disable: 4800) /* warning C4800: 'double' : forcing value to bool 'true' or 'false' */ -#endif - - /* Cmake will define SIMPLib_EXPORTS on Windows when it configures to build a shared library. If you are going to use another build system on windows or create the visual studio projects by hand you need to define SIMPLib_EXPORTS when -building the MXADatModel DLL on windows. +building on Windows with MSVC. */ -#if defined (SIMPLib_BUILT_AS_DYNAMIC_LIB) +#if defined(SIMPLib_BUILT_AS_DYNAMIC_LIB) -#if defined (SIMPLib_EXPORTS) /* Compiling the MXA DLL/Dylib */ -#if defined (_MSC_VER) /* MSVC Compiler Case */ -#define SIMPLib_EXPORT __declspec(dllexport) +#if defined(SIMPLib_EXPORTS) /* Compiling the SIMPLib DLL/Dylib */ +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define SIMPLib_EXPORT __declspec(dllexport) #define EXPIMP_TEMPLATE -#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ -#define SIMPLib_EXPORT __attribute__ ((visibility("default"))) +#elif(__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define SIMPLib_EXPORT __attribute__((visibility("default"))) #endif -#else /* Importing the DLL into another project */ -#if defined (_MSC_VER) /* MSVC Compiler Case */ -#define SIMPLib_EXPORT __declspec(dllimport) +#else /* Importing the DLL into another project */ +#if defined(_MSC_VER) /* MSVC Compiler Case */ +#define SIMPLib_EXPORT __declspec(dllimport) #define EXPIMP_TEMPLATE extern -#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ -#define SIMPLib_EXPORT __attribute__ ((visibility("default"))) +#elif(__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ +#define SIMPLib_EXPORT __attribute__((visibility("default"))) #endif #endif #endif @@ -79,24 +71,22 @@ building the MXADatModel DLL on windows. #endif #if 0 -#if defined (_WIN32) || defined __CYGWIN__ +#if defined(_WIN32) || defined __CYGWIN__ -#if defined (DREAM3D_BUILT_AS_DYNAMIC_LIB) +#if defined(DREAM3D_BUILT_AS_DYNAMIC_LIB) #if defined(SIMPLib_EXPORTS) -#define SIMPLib_EXPORT __declspec(dllexport) +#define SIMPLib_EXPORT __declspec(dllexport) #else -#define SIMPLib_EXPORT __declspec(dllimport) +#define SIMPLib_EXPORT __declspec(dllimport) #endif /* SIMPLib_EXPORTS */ #else #define SIMPLib_EXPORT #endif #elif __GNUC__ >= 4 -#define FLOW_DLL __attribute__ ((visibility("default"))) +#define FLOW_DLL __attribute__((visibility("default"))) #define DLL_LOCAL __attribute__ ((visibility("hidden") #else /* defined (_WIN32) && defined (DREAM3D_BUILD_SHARED_LIBS) */ #define SIMPLib_EXPORT #endif #endif - - diff --git a/Source/SIMPLib/Common/SIMPLibSetGetMacros.h b/Source/SIMPLib/Common/SIMPLibSetGetMacros.h old mode 100755 new mode 100644 index 1e94449b29..66a7e666be --- a/Source/SIMPLib/Common/SIMPLibSetGetMacros.h +++ b/Source/SIMPLib/Common/SIMPLibSetGetMacros.h @@ -1,40 +1,39 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once - #include #include #include @@ -54,57 +53,59 @@ //-- C++11 Includes #include - -#define COPY_ARRAY_3(var, obj)\ - (var)[0] = (obj)->(var)[0]; (var)[1] = (obj)->(var)[1]; (var)[2] = (obj)->(var)[2]; - -#define COPY_ARRAY_4(var, obj)\ - (var)[0] = (obj)->(var)[0]; (var)[1] = (obj)->(var)[1];\ - (var)[2] = (obj)->(var)[2]; (var)[3] = (obj)->(var)[3]; - -#define COPY_ARRAY_5(var, obj)\ - (var)[0] = (obj)->(var)[0]; (var)[1] = (obj)->(var)[1];\ - (var)[2] = (obj)->(var)[2]; (var)[3] = (obj)->(var)[3];\ +#define COPY_ARRAY_3(var, obj) \ + (var)[0] = (obj)->(var)[0]; \ + (var)[1] = (obj)->(var)[1]; \ + (var)[2] = (obj)->(var)[2]; + +#define COPY_ARRAY_4(var, obj) \ + (var)[0] = (obj)->(var)[0]; \ + (var)[1] = (obj)->(var)[1]; \ + (var)[2] = (obj)->(var)[2]; \ + (var)[3] = (obj)->(var)[3]; + +#define COPY_ARRAY_5(var, obj) \ + (var)[0] = (obj)->(var)[0]; \ + (var)[1] = (obj)->(var)[1]; \ + (var)[2] = (obj)->(var)[2]; \ + (var)[3] = (obj)->(var)[3]; \ (var)[4] = (obj)->(var)[4]; - /** * This will perform a deep copy of the content of the shared vector from * target to destination. This is NOT just a simple pointer copy. */ -#define DEEP_COPY_SHARED_VECTOR(sharedPtr, obj, VType, m_msgType)\ - if (nullptr != (sharedPtr))\ - {\ - (sharedPtr) = VType(static_cast*>(nullptr));\ - }\ - if (nullptr != (obj)->(sharedPtr).get())\ - {\ - (sharedPtr) = VType(new std::vector(*((obj)->(sharedPtr).get())));\ +#define DEEP_COPY_SHARED_VECTOR(sharedPtr, obj, VType, m_msgType) \ + if(nullptr != (sharedPtr)) \ + { \ + (sharedPtr) = VType(static_cast*>(nullptr)); \ + } \ + if(nullptr != (obj)->(sharedPtr).get()) \ + { \ + (sharedPtr) = VType(new std::vector(*((obj)->(sharedPtr).get()))); \ } - -#define SHARED_IS_NULL(ptr)\ - ( (ptr).get() == nullptr ) +#define SHARED_IS_NULL(ptr) ((ptr).get() == nullptr) /** * @brief Creates a static method that returns a nullptr pointer wrapped in a * std::shared_ptr<> * @param thisClass The name of the class. */ -#define SIMPL_NULL_SHARED_POINTER(thisClass)\ - static Pointer NullPointer(void)\ - { \ - return Pointer(static_cast(nullptr));\ +#define SIMPL_NULL_SHARED_POINTER(thisClass) \ + static Pointer NullPointer(void) \ + { \ + return Pointer(static_cast(nullptr)); \ } #ifndef QT_SHARED_POINTERS - /* @brief Creates some basic typedefs that can be used throughout the code to +/* @brief Creates some basic typedefs that can be used throughout the code to * reference the class. */ -#define QT_SHARED_POINTERS(thisClass)\ - typedef thisClass Self;\ - typedef QSharedPointer< Self > Pointer;\ - typedef QSharedPointer ConstPointer;\ +#define QT_SHARED_POINTERS(thisClass) \ + typedef thisClass Self; \ + typedef QSharedPointer Pointer; \ + typedef QSharedPointer ConstPointer; \ SIMPL_NULL_SHARED_POINTER(thisClass) #endif @@ -113,625 +114,411 @@ * @brief Creates some basic typedefs that can be used throughout the code to * reference the class. */ -#define SIMPL_SHARED_POINTERS(thisClass)\ - typedef thisClass Self;\ - typedef std::shared_ptr Pointer;\ - typedef std::shared_ptr ConstPointer;\ - typedef std::weak_ptr WeakPointer;\ - typedef std::weak_ptr ConstWeakPointer;\ +#define SIMPL_SHARED_POINTERS(thisClass) \ + typedef thisClass Self; \ + typedef std::shared_ptr Pointer; \ + typedef std::shared_ptr ConstPointer; \ + typedef std::weak_ptr WeakPointer; \ + typedef std::weak_ptr ConstWeakPointer; \ SIMPL_NULL_SHARED_POINTER(thisClass) - -#define SIMPL_STATIC_NEW_SUPERCLASS(superclass, theclass)\ - static superclass::Pointer New##superclass()\ - {\ - theclass* ptr = new theclass();\ - superclass::Pointer shared_ptr (dynamic_cast(ptr) );\ - return shared_ptr;\ +#define SIMPL_STATIC_NEW_SUPERCLASS(superclass, theclass) \ + static superclass::Pointer New##superclass() \ + { \ + theclass* ptr = new theclass(); \ + superclass::Pointer shared_ptr(dynamic_cast(ptr)); \ + return shared_ptr; \ } /** * @brief Creates a typedef that points to the superclass of this class */ -#define SIMPL_SUPERCLASS_POINTER(SuperClass)\ - typedef SuperClass::Pointer SuperClass; - +#define SIMPL_SUPERCLASS_POINTER(SuperClass) typedef SuperClass::Pointer SuperClass; /** * @brief Creates a static "New" method that creates an instance of thisClass */ -#define SIMPL_NEW_SUPERCLASS(thisClass, SuperClass)\ - typedef SuperClass::Pointer SuperClass##Type;\ - static SuperClass##Type New##SuperClass(void) \ - { \ - SuperClass##Type sharedPtr (new (thisClass)); \ - return sharedPtr; \ +#define SIMPL_NEW_SUPERCLASS(thisClass, SuperClass) \ + typedef SuperClass::Pointer SuperClass##Type; \ + static SuperClass##Type New##SuperClass(void) \ + { \ + SuperClass##Type sharedPtr(new(thisClass)); \ + return sharedPtr; \ } /** * @brief Implements a Static 'New' Method for a class */ -#define SIMPL_STATIC_NEW_MACRO(thisClass) \ - static Pointer New(void) \ - { \ - Pointer sharedPtr (new (thisClass)); \ - return sharedPtr; \ +#define SIMPL_STATIC_NEW_MACRO(thisClass) \ + static Pointer New(void) \ + { \ + Pointer sharedPtr(new(thisClass)); \ + return sharedPtr; \ } -#define SIMPL_STATIC_NEW_MACRO_WITH_ARGS(thisClass, args) \ - static Pointer New args \ - { \ - Pointer sharedPtr (new (thisClass)); \ - return sharedPtr; \ +#define SIMPL_STATIC_NEW_MACRO_WITH_ARGS(thisClass, args) \ + static Pointer New args \ + { \ + Pointer sharedPtr(new(thisClass)); \ + return sharedPtr; \ } /** Macro used to add standard methods to all classes, mainly type * information. */ -#define SIMPL_TYPE_MACRO(thisClass)\ -public: \ - virtual const QString getNameOfClass() const\ - { \ - return QString(#thisClass); \ - } \ - static int IsTypeOf(const char* type)\ - { \ - if(!strcmp(#thisClass, type)) \ - {\ - return 1; \ - }\ - return 0; \ +#define SIMPL_TYPE_MACRO(thisClass) \ +public: \ + virtual QString getNameOfClass() const \ + { \ + return QString(#thisClass); \ + } \ + static int IsTypeOf(const char* type) \ + { \ + if(!strcmp(#thisClass, type)) \ + { \ + return 1; \ + } \ + return 0; \ } -#define SIMPL_TYPE_MACRO_SUPER(thisClass, superclass) \ -public: \ - virtual const QString getNameOfClass() const\ - { \ - return QString(#thisClass); \ - } \ - static QString ClassName()\ - { \ - return QString(#thisClass); \ - } \ - static int IsTypeOf(const char* type)\ - { \ - if(!strcmp(#thisClass, type)) \ - {\ - return 1; \ - }\ - return superclass::IsTypeOf(type); \ +#define SIMPL_TYPE_MACRO_SUPER(thisClass, superclass) \ +public: \ + virtual QString getNameOfClass() const \ + { \ + return QString(#thisClass); \ + } \ + static QString ClassName() \ + { \ + return QString(#thisClass); \ + } \ + static int IsTypeOf(const char* type) \ + { \ + if(!strcmp(#thisClass, type)) \ + { \ + return 1; \ + } \ + return superclass::IsTypeOf(type); \ } -#define SIMPL_TYPE_MACRO_SUPER_OVERRIDE(thisClass, superclass) \ -public: \ - virtual const QString getNameOfClass() const override \ - { \ - return QString(#thisClass); \ - } \ - static QString ClassName()\ - { \ - return QString(#thisClass); \ - } \ - static int IsTypeOf(const char* type)\ - { \ - if(!strcmp(#thisClass, type)) \ - {\ - return 1; \ - }\ - return superclass::IsTypeOf(type); \ +#define SIMPL_TYPE_MACRO_SUPER_OVERRIDE(thisClass, superclass) \ +public: \ + QString getNameOfClass() const override \ + { \ + return QString(#thisClass); \ + } \ + static QString ClassName() \ + { \ + return QString(#thisClass); \ + } \ + static int IsTypeOf(const char* type) \ + { \ + if(!strcmp(#thisClass, type)) \ + { \ + return 1; \ + } \ + return superclass::IsTypeOf(type); \ } -#define SIMPL_CLASS_VERSION(vers)\ - virtual int getClassVersion() { return vers; } - +#define SIMPL_CLASS_VERSION(vers) \ + int getClassVersion() const override \ + { \ + return vers; \ + } //------------------------------------------------------------------------------ // Macros for Properties /** -* @brief Creates a QString constant for the Property so that the property -* can be retrieved by name. -*/ -#define SIMPL_PROPERTY_CONSTANT(prpty)\ - const QString prpty ( #prpty ); + * @brief Creates a QString constant for the Property so that the property + * can be retrieved by name. + */ +#define SIMPL_PROPERTY_CONSTANT(prpty) const QString prpty(#prpty); /** -* @brief Creates a "setter" method to set the property. -*/ -#define SIMPL_SET_PROPERTY(type, prpty)\ - void set##prpty(const type& value) { this->m_##prpty = value; } + * @brief Creates a "setter" method to set the property. + */ +#define SIMPL_SET_PROPERTY(type, prpty) \ + void set##prpty(const type& value) \ + { \ + this->m_##prpty = value; \ + } /** -* @brief Creates a "getter" method to retrieve the value of the property. -*/ -#define SIMPL_GET_PROPERTY(type, prpty)\ - type get##prpty() const { return m_##prpty; } + * @brief Creates a "getter" method to retrieve the value of the property. + */ +#define SIMPL_GET_PROPERTY(type, prpty) \ + type get##prpty() const \ + { \ + return m_##prpty; \ + } /** -* @brief -*/ -#define SIMPL_SET_FILTER_PARAMETER(type, prpty)\ - void set##prpty(const type& value) { this->m_##prpty = value; emit parametersChanged(); } - + * @brief + */ +#define SIMPL_SET_FILTER_PARAMETER(type, prpty) \ + void set##prpty(const type& value) \ + { \ + this->m_##prpty = value; \ + Q_EMIT parametersChanged(); \ + } -#define SIMPL_SET_PROPERTY_DECL(type, prpty)\ - void set##prpty(type value); +#define SIMPL_SET_PROPERTY_DECL(type, prpty) void set##prpty(type value); -#define SIMPL_GET_PROPERTY_DECL(type, prpty)\ - type get##prpty() const; +#define SIMPL_GET_PROPERTY_DECL(type, prpty) type get##prpty() const; -#define SIMPL_INSTANCE_PROPERTY_DECL(type, prpty)\ - private:\ - type m_##prpty;\ - public:\ - SIMPL_SET_PROPERTY_DECL(type, prpty)\ +#define SIMPL_INSTANCE_PROPERTY_DECL(type, prpty) \ +private: \ + type m_##prpty = {}; \ + \ +public: \ + SIMPL_SET_PROPERTY_DECL(type, prpty) \ SIMPL_GET_PROPERTY_DECL(type, prpty) -#define SIMPL_INSTANCE_PROPERTY_DECL(type, prpty)\ - private:\ - type m_##prpty;\ - public:\ - SIMPL_SET_PROPERTY_DECL(type, prpty)\ +#define SIMPL_INSTANCE_PROPERTY_DECL(type, prpty) \ +private: \ + type m_##prpty = {}; \ + \ +public: \ + SIMPL_SET_PROPERTY_DECL(type, prpty) \ SIMPL_GET_PROPERTY_DECL(type, prpty) -#define SIMPL_VIRTUAL_INSTANCE_PROPERTY_DECL(type, prpty)\ - private:\ - type m_##prpty;\ - public:\ - virtual SIMPL_SET_PROPERTY_DECL(type, prpty)\ - virtual SIMPL_GET_PROPERTY_DECL(type, prpty) - +#define SIMPL_VIRTUAL_INSTANCE_PROPERTY_DECL(type, prpty) \ +private: \ + type m_##prpty = {}; \ + \ +public: \ + virtual SIMPL_SET_PROPERTY_DECL(type, prpty) virtual SIMPL_GET_PROPERTY_DECL(type, prpty) -#define SIMPL_SET_PROPERTY_DEF(class, type, prpty)\ - void class::set##prpty(const type& value) { this->m_##prpty = value; } - -#define SIMPL_GET_PROPERTY_DEF(class, type, prpty)\ - type class::get##prpty() const { return m_##prpty; } - -#define SIMPL_INSTANCE_PROPERTY_DEF(class, type, prpty)\ - SIMPL_SET_PROPERTY_DEF(class, type, prpty)\ - SIMPL_GET_PROPERTY_DEF(class, type, prpty) - -#define SIMPL_INSTANCE_PROPERTY_DEF(class, type, prpty)\ - SIMPL_SET_PROPERTY_DEF(class, type, prpty)\ - SIMPL_GET_PROPERTY_DEF(class, type, prpty) - -/** -* @brief -*/ -#define SIMPL_VIRTUAL_INSTANCE_PROPERTY(type, prpty)\ - private:\ - type m_##prpty;\ - public:\ - virtual SIMPL_SET_PROPERTY(type, prpty)\ - virtual SIMPL_GET_PROPERTY(type, prpty) - - -#define SIMPL_INSTANCE_PROPERTY(type, prpty)\ - private:\ - type m_##prpty;\ - public:\ - SIMPL_SET_PROPERTY(type, prpty)\ - SIMPL_GET_PROPERTY(type, prpty) - - - -#define SIMPL_POINTER_PROPERTY(type, prpty)\ - private:\ - type* m_##prpty = nullptr;\ - public:\ - void set##prpty(type* f) { m_##prpty = f; }\ - SIMPL_GET_PROPERTY(type*, prpty) - - -#define SIMPL_PRIVATE_INSTANCE_PROPERTY(type, prpty)\ - private:\ - type m_##prpty;\ - SIMPL_SET_PROPERTY(type, prpty)\ - public:\ - SIMPL_GET_PROPERTY(type, prpty) - - -/* ***************************************************************************** - * ***************************************************************************** - * ***************************************************************************** - * - * PyBind11 Macros that we can use to explicitly define which setters & getters - * will be exposed to the Python library - */ - -/** -* @brief PYB11_CREATE_BINDINGS This macro lets the wrapper know that we want to -* wrap this class with Python bindings. It should only take a single argument -* which is the name of the class. If this line is commented out using the standard -* C++ style of single line comment then NO WRAPPING will be performed -* on the class. -* @code -* PYB11_CREATE_BINDINGS(AbstractFilter) -* @endcode -*/ -#define PYB11_CREATE_BINDINGS(...) - -/** -* @brief PYB11_NO_BINDINGS This macro will ensure that the class is NOT wrapped -* with python bindings. Only a single argument which is the name of the class -* should be used. -* @code -* PYB11_NO_BINDINGS(AbstractFilter) -* @endcode -*/ -#define PYB11_NO_BINDINGS(...) - -/** -* @brief PYB11_STATIC_CREATION This macro will wrap the "static New()" function -* that most of the SIMPL classes implement as a way to instantiate the class in -* addition to other static methods that are used for a class. The argument types -* to the static method should be listed WITHOUT any spaces for each argument. -* -* @code -* PYB11_STATIC_CREATION(Create ARGS std::vector> std::list std::list) -* @endcode -*/ -#define PYB11_STATIC_CREATION(...) +#define SIMPL_SET_PROPERTY_DEF(class, type, prpty) \ + void class ::set##prpty(const type& value) \ + { \ + this->m_##prpty = value; \ + } -/** -* @brief PYB11_CREATION This macro is used for non-static constructors that need -* to be wrapped. The argument types need to be lists where each argument cannot -* containe spaces. Use a typedef if needed, but using a typedef also has its -* own issues. @see DataArrayPath for an example. -* -* @code -* PYB11_CREATION(ARGS QString QString QString) -* @endcode -*/ -#define PYB11_CREATION(...) +#define SIMPL_GET_PROPERTY_DEF(class, type, prpty) \ + type class ::get##prpty() const \ + { \ + return m_##prpty; \ + } -/** -* @brief PYB11_ENUMERATION This macro will allow a class enumeration to be wrapped -* in Python an available to the Python side. @see IGeoemtry for an example. The -* macro should only take a single argument. -* @code -* PYB11_ENUMERATION(Type) -* PYB11_ENUMERATION(VtkCellType) -* @endcode -*/ -#define PYB11_ENUMERATION(...) +#define SIMPL_INSTANCE_PROPERTY_DEF(class, type, prpty) \ + SIMPL_SET_PROPERTY_DEF(class, type, prpty) \ + SIMPL_GET_PROPERTY_DEF(class, type, prpty) -/** -* @brief PYB11_PROPERTY This macro is used to wrap a single class instance property -* that is typically used as an input parameter for a filter. This macro should -* NOT be used for just wrapping instance methods. Use the PYB11_METHOD for -* that. @see AbstractFilter. There are number of arguments depending on if the -* property is a read-only or read-write variable. At least 4 arguments to the -* macro are required when the property is read only. -* @code - PYB11_PROPERTY(QString NameOfClass READ getNameOfClass) -* @endcode -* and 6 arguments when the property is read-write. -* @code -* PYB11_PROPERTY(bool Cancel READ getCancel WRITE setCancel) -* @endcode -* -* and if there are additional overloads of the Getter that returns a const reference such as -* @code -* const QString& getFoo() const; -* @endcode -* -* then you would add on the CONST_GET_OVERLOAD as the last argument to the macro. -*/ -#define PYB11_PROPERTY(...) +#define SIMPL_INSTANCE_PROPERTY_DEF(class, type, prpty) \ + SIMPL_SET_PROPERTY_DEF(class, type, prpty) \ + SIMPL_GET_PROPERTY_DEF(class, type, prpty) /** - * @brief This macro is used to expose a method to the Python bindings. The signature - * of the macro should be the following: - * PYB11_METHOD( _return_type_ _name_of_method_ [ARGS|OVERLOAD] ....) - * If the ARGS command is used then simply list the variable names for each argument. - * For example if you have a method "void getFoo(const QString &foo)" that you want - * to expose: - * @code - * PYB11_METHOD(void getFoo ARGS Foo) - * @endcode - * - * If your method does not take any arguments then leave out the ARGS keyword. - * - * If you are have overloads of the method that you want to expose to Python then - * the "OVERLOAD" version of the method should be used. Again, say we have two - * methods that we want to expose. - * @code - * void setPath(const QString &name) - * void setPath(const DataArrayPath &path) - * @endcode - * - * then we would use the following set of invocations: - * @code - * PYB11_METHOD(void setPath OVERLOAD const.QString.&,Name) - * PYB11_METHOD(void setPath OVERLOAD const.DataArrayPath.&,Path) - * @endcode - * Note that in order to get the (const QString &) correct we used the '.' charater - * to declare the type. This is required as the macro is split using spaces. When - * then end code is generated the '.' characters will be replaced with spaces. - */ -#define PYB11_METHOD(...) - -// End of PYBIND11 Macro Definitions -/* ***************************************************************************** - * ***************************************************************************** - * ***************************************************************************** + * @brief */ +#define SIMPL_VIRTUAL_INSTANCE_PROPERTY(type, prpty) \ +private: \ + type m_##prpty = {}; \ + \ +public: \ + virtual SIMPL_SET_PROPERTY(type, prpty) virtual SIMPL_GET_PROPERTY(type, prpty) + +#define SIMPL_INSTANCE_PROPERTY(type, prpty) \ +private: \ + type m_##prpty = {}; \ + \ +public: \ + SIMPL_SET_PROPERTY(type, prpty) \ + SIMPL_GET_PROPERTY(type, prpty) +#define SIMPL_POINTER_PROPERTY(type, prpty) \ +private: \ + type* m_##prpty = nullptr; \ + \ +public: \ + void set##prpty(type* f) \ + { \ + m_##prpty = f; \ + } \ + SIMPL_GET_PROPERTY(type*, prpty) + +#define SIMPL_PRIVATE_INSTANCE_PROPERTY(type, prpty) \ +private: \ + type m_##prpty = {}; \ + SIMPL_SET_PROPERTY(type, prpty) \ +public: \ + SIMPL_GET_PROPERTY(type, prpty) +#define SIMPL_SET_PROPERTY_DECL(type, prpty) void set##prpty(type value); -#define SIMPL_SET_PROPERTY_DECL(type, prpty)\ - void set##prpty(type value); +#define SIMPL_GET_PROPERTY_DECL(type, prpty) type get##prpty() const; -#define SIMPL_GET_PROPERTY_DECL(type, prpty)\ - type get##prpty() const; +#define SIMPL_PIMPL_PROPERTY_DECL(type, prpty) \ +public: \ + SIMPL_PIMPL_GET_PROPERTY_DECL(type, prpty) \ + SIMPL_PIMPL_SET_PROPERTY_DECL(type, prpty) +#define SIMPL_PIMPL_GET_PROPERTY_DECL(type, prpty) type get##prpty() const; -#define SIMPL_PIMPL_PROPERTY_DECL(type, prpty)\ - public:\ - void set##prpty(const type& value);\ - type get##prpty() const; +#define SIMPL_PIMPL_SET_PROPERTY_DECL(type, prpty) void set##prpty(const type& value); +#define SIMPL_PIMPL_PROPERTY_DEF(Class, type, prpty) \ + SIMPL_PIMPL_SET_PROPERTY_DEF(Class, type, prpty) \ + SIMPL_PIMPL_GET_PROPERTY_DEF(Class, type, prpty) -#define SIMPL_PIMPL_PROPERTY_DEF(Class, type, prpty)\ - void Class::set##prpty(const type& value) {\ - Q_D(Class);\ - d->m_##prpty = value;\ - }\ - type Class::get##prpty() const {\ - Q_D(const Class);\ - return d->m_##prpty;\ +#define SIMPL_PIMPL_GET_PROPERTY_DEF(Class, type, prpty) \ + type Class::get##prpty() const \ + { \ + Q_D(const Class); \ + return d->m_##prpty; \ } - -#define SIMPL_OVERLOAD_PROPERTY(type, prpty, overload)\ - private:\ - type m_##prpty;\ - public:\ - SIMPL_SET_PROPERTY(overload, prpty)\ - SIMPL_GET_PROPERTY(overload, prpty) - -#define SIMPL_BOOL_PROPERTY(prpty)\ - private:\ - bool m_##prpty;\ - public:\ - virtual SIMPL_SET_PROPERTY(bool, prpty)\ - SIMPL_GET_BOOL_PROPERTY(prpty)\ - -#define SIMPL_GET_BOOL_PROPERTY(prpty)\ - public:\ - virtual bool is##prpty() { return m_##prpty; } - -/** - * @brief - */ -#define SIMPL_FILTER_NEW_MACRO(Class) \ - static std::shared_ptr New() \ +#define SIMPL_PIMPL_SET_PROPERTY_DEF(Class, type, prpty) \ + void Class::set##prpty(const type& value) \ { \ - struct make_shared_enabler : public Class \ - { \ - }; \ - std::shared_ptr val = std::make_shared(); \ - val->setupFilterParameters(); \ - return val; \ + Q_D(Class); \ + d->m_##prpty = value; \ } -/** -* @brief -*/ -#define SIMPL_FILTER_PARAMETER(type, prpty)\ - private:\ - type m_##prpty;\ - public:\ - void set##prpty(const type& value) { this->m_##prpty = value; }\ - type get##prpty() const { return m_##prpty; } - - - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -#define SIMPL_SET_2DVECTOR_PROPERTY(type, prpty, varname)\ - void set##prpty(type value[2]) {\ - (varname)[0] = value[0]; (varname)[1] = value[1]; }\ - void set##prpty(const type& value_0, const type& value_1) {\ - (varname)[0] = value_0; (varname)[1] = value_1; }\ - void set##prpty(const std::tuple &var) {\ - (varname)[0] = std::get<0>(var); (varname)[1] = std::get<1>(var); } - -#define SIMPL_GET_2DVECTOR_PROPERTY(type, prpty, varname)\ - void get##prpty(type value[2]) {\ - value[0] = (varname)[0]; value[1] = (varname)[1]; }\ - void get##prpty((type) &value_0, (type) &value_1) {\ - value_0 = (varname)[0]; value_1 = (varname)[1]; }\ - std::tuple get##prpty() const {\ - return std::make_tuple((varname)[0], (varname)[1]); } - -#define SIMPL_INSTANCE_VEC2_PROPERTY(type, prpty)\ - private:\ - type m_##prpty[2];\ - public:\ - SIMPL_SET_2DVECTOR_PROPERTY(type, prpty, m_##prpty)\ - SIMPL_GET_2DVECTOR_PROPERTY(type, prpty, m_##prpty) - +#define SIMPL_OVERLOAD_PROPERTY(type, prpty, overload) \ +private: \ + type m_##prpty = {}; \ + \ +public: \ + SIMPL_SET_PROPERTY(overload, prpty) \ + SIMPL_GET_PROPERTY(overload, prpty) -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -#define SIMPL_SET_VEC3_PROPERTY(type, prpty, varname)\ - void set##prpty(type value[3]) {\ - (varname)[0] = value[0]; (varname)[1] = value[1]; (varname)[2] = value[2]; }\ - void set##prpty(type value_0, type value_1, type value_2) {\ - (varname)[0] = value_0; (varname)[1] = value_1; (varname)[2] = value_2; }\ - void set##prpty(const std::tuple &var) {\ - (varname)[0] = std::get<0>(var); (varname)[1] = std::get<1>(var); (varname)[2] = std::get<2>(var); } - -#define SIMPL_GET_VEC3_PROPERTY(type, prpty, varname)\ - void get##prpty(type value[3]) {\ - value[0] = (varname)[0]; value[1] = (varname)[1]; value[2] = (varname)[2]; }\ - void get##prpty(type &value_0, type &value_1, type &value_2) {\ - value_0 = (varname)[0]; value_1 = (varname)[1]; value_2 = (varname)[2]; }\ - std::tuple get##prpty() const {\ - return std::make_tuple((varname)[0], (varname)[1], (varname)[2]); } - -#define SIMPL_INSTANCE_VEC3_PROPERTY(type, prpty)\ - private:\ - type m_##prpty[3];\ - public:\ - SIMPL_SET_VEC3_PROPERTY(type, prpty, m_##prpty)\ - SIMPL_GET_VEC3_PROPERTY(type, prpty, m_##prpty) +#define SIMPL_BOOL_PROPERTY(prpty) \ +private: \ + bool m_##prpty = false; \ + \ +public: \ + virtual SIMPL_SET_PROPERTY(bool, prpty) SIMPL_GET_BOOL_PROPERTY(prpty) -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -#define SIMPL_SET_VEC3_PROPERTY_VO(type, prpty, varname)\ - void set##prpty(type value[3]) override {\ - (varname)[0] = value[0]; (varname)[1] = value[1]; (varname)[2] = value[2]; }\ - void set##prpty(type value_0, type value_1, type value_2) override {\ - (varname)[0] = value_0; (varname)[1] = value_1; (varname)[2] = value_2; }\ - void set##prpty(const std::tuple &var) override {\ - (varname)[0] = std::get<0>(var); (varname)[1] = std::get<1>(var); (varname)[2] = std::get<2>(var);} - -#define SIMPL_GET_VEC3_PROPERTY_VO(type, prpty, varname)\ - virtual std::tuple get##prpty() const override\ - {\ - return std::make_tuple((varname)[0], (varname)[1], (varname)[2]);\ +#define SIMPL_GET_BOOL_PROPERTY(prpty) \ +public: \ + virtual bool is##prpty() \ + { \ + return m_##prpty; \ } -#define SIMPL_INSTANCE_VEC3_PROPERTY_VO(type, prpty)\ - private:\ - type m_##prpty[3];\ - public:\ - SIMPL_SET_VEC3_PROPERTY_VO(type, prpty, m_##prpty)\ - SIMPL_GET_VEC3_PROPERTY_VO(type, prpty, m_##prpty) - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -#define SIMPL_CONTAINER_TYPE(thisClass, container) \ - typedef (container) ContainerT; \ - typedef std::shared_ptr<(container)<(thisClass)>> ContainerPType; - +#define SIMPL_CONTAINER_TYPE(thisClass, container) \ + typedef(container) ContainerT; \ + typedef std::shared_ptr<(container) < (thisClass)> > ContainerPType; /** -* @brief Creates a "setter" method to set the property. -*/ -#define SIMPL_SET_STRING_PROPERTY( prpty, varname) \ - void set##prpty(const QString& value) { this->varname = value; } + * @brief Creates a "setter" method to set the property. + */ +#define SIMPL_SET_STRING_PROPERTY(prpty, varname) \ + void set##prpty(const QString& value) \ + { \ + this->varname = value; \ + } /** -* @brief Creates a "getter" method to retrieve the value of the property. -*/ -#define SIMPL_GET_STRING_PROPERTY( prpty, varname) \ - QString get##prpty() const { return varname; } + * @brief Creates a "getter" method to retrieve the value of the property. + */ +#define SIMPL_GET_STRING_PROPERTY(prpty, varname) \ + QString get##prpty() const \ + { \ + return varname; \ + } /** -* @brief Creates a "setter" method to set the property. -*/ -#define SIMPL_SET_STRING_PROPERTY_OVERRIDE(prpty, varname) \ - void set##prpty(const QString& value) override \ - { \ - this->varname = value; \ + * @brief Creates a "setter" method to set the property. + */ +#define SIMPL_SET_STRING_PROPERTY_OVERRIDE(prpty, varname) \ + void set##prpty(const QString& value) override \ + { \ + this->varname = value; \ } /** -* @brief Creates a "getter" method to retrieve the value of the property. -*/ -#define SIMPL_GET_STRING_PROPERTY_OVERRIDE(prpty, varname) \ - QString get##prpty() const override \ - { \ - return varname;\ + * @brief Creates a "getter" method to retrieve the value of the property. + */ +#define SIMPL_GET_STRING_PROPERTY_OVERRIDE(prpty, varname) \ + QString get##prpty() const override \ + { \ + return varname; \ } /** * @brief Creates setters and getters in the form of 'setXXX()' and 'getXXX()' methods */ -#define SIMPL_INSTANCE_STRING_PROPERTY(prpty)\ - private:\ - QString m_##prpty;\ - public:\ - SIMPL_SET_STRING_PROPERTY(prpty, m_##prpty)\ - SIMPL_GET_STRING_PROPERTY(prpty, m_##prpty) +#define SIMPL_INSTANCE_STRING_PROPERTY(prpty) \ +private: \ + QString m_##prpty; \ + \ +public: \ + SIMPL_SET_STRING_PROPERTY(prpty, m_##prpty) \ + SIMPL_GET_STRING_PROPERTY(prpty, m_##prpty) /** -* @brief -*/ -#define SIMPL_INSTANCE_STRING_PROPERTY_OVERRIDE(prpty)\ -private:\ - QString m_##prpty;\ -public:\ - SIMPL_SET_STRING_PROPERTY_OVERRIDE(prpty, m_##prpty)\ + * @brief + */ +#define SIMPL_INSTANCE_STRING_PROPERTY_OVERRIDE(prpty) \ +private: \ + QString m_##prpty; \ + \ +public: \ + SIMPL_SET_STRING_PROPERTY_OVERRIDE(prpty, m_##prpty) \ SIMPL_GET_STRING_PROPERTY_OVERRIDE(prpty, m_##prpty) -#define SIMPL_VIRTUAL_INSTANCE_STRING_PROPERTY(prpty)\ - private:\ - QString m_##prpty;\ - public:\ - virtual SIMPL_SET_STRING_PROPERTY(prpty, m_##prpty)\ - virtual SIMPL_GET_STRING_PROPERTY(prpty, m_##prpty) - +#define SIMPL_VIRTUAL_INSTANCE_STRING_PROPERTY(prpty) \ +private: \ + QString m_##prpty; \ + \ +public: \ + virtual SIMPL_SET_STRING_PROPERTY(prpty, m_##prpty) virtual SIMPL_GET_STRING_PROPERTY(prpty, m_##prpty) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -#define SIMPL_DECLARE_ARRAY(Type, ptr, prpty )\ - private:\ - DataArray::Pointer m_##prpty;\ - Type* (ptr) = nullptr;\ - public:\ - SIMPL_SET_PROPERTY(DataArray::Pointer, prpty)\ +#define SIMPL_DECLARE_ARRAY(Type, ptr, prpty) \ +private: \ + DataArray::Pointer m_##prpty; \ + Type*(ptr) = nullptr; \ + \ +public: \ + SIMPL_SET_PROPERTY(DataArray::Pointer, prpty) \ SIMPL_GET_PROPERTY(DataArray::Pointer, prpty) - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -#define DEFINE_DATAARRAY_VARIABLE(type, name)\ - private:\ - DataArray::WeakPointer m_##name##Ptr;\ +#define DEFINE_DATAARRAY_VARIABLE(type, name) \ +private: \ + DataArray::WeakPointer m_##name##Ptr; \ type* m_##name = nullptr; -#define DEFINE_DATAARRAY_WEAKPTR(type, name) \ -private: \ +#define DEFINE_DATAARRAY_WEAKPTR(type, name) \ +private: \ DataArray::WeakPointer m_##name##Ptr; -#define DEFINE_STRINGARRAY_VARIABLE(name)\ - private:\ +#define DEFINE_STRINGARRAY_VARIABLE(name) \ +private: \ StringDataArray::WeakPointer m_##name##Ptr; -#define DEFINE_REQUIRED_VARIABLE(type, name)\ - SIMPL_INSTANCE_STRING_PROPERTY(name##ArrayName);\ - private:\ - type::WeakPointer m_##name##Ptr;\ +#define DEFINE_REQUIRED_VARIABLE(type, name) \ + SIMPL_INSTANCE_STRING_PROPERTY(name##ArrayName); \ + \ +private: \ + type::WeakPointer m_##name##Ptr; \ (type)* m_##name = nullptr; -//used in place of 'DEFINE_DATAARRAY_VARIABLE' in filter header -#define DEFINE_IDATAARRAY_VARIABLE(varName)\ - private:\ - IDataArray::WeakPointer m_##varName##Ptr;\ +// used in place of 'DEFINE_DATAARRAY_VARIABLE' in filter header +#define DEFINE_IDATAARRAY_VARIABLE(varName) \ +private: \ + IDataArray::WeakPointer m_##varName##Ptr; \ void* m_##varName = nullptr; -#define DEFINE_IDATAARRAY_WEAKPTR(varName) \ -private: \ +#define DEFINE_IDATAARRAY_WEAKPTR(varName) \ +private: \ IDataArray::WeakPointer m_##varName##Ptr; -#define SIMPL_COPY_INSTANCEVAR(name)\ - filter->set##name(get##name()); - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -/** -* @brief Macro to silence compiler warnings for unused parameters in methods. -*/ -#define SIMPL_NOT_USED(x) +#define SIMPL_COPY_INSTANCEVAR(name) filter->set##name(get##name()); // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - namespace SIMPLTesting { class bad_lexical_cast : public std::runtime_error @@ -752,7 +539,8 @@ class bad_any_cast : public std::runtime_error } }; -template T lexical_cast(const QString& s) +template +T lexical_cast(const QString& s) { std::istringstream i(s.toStdString()); T x; @@ -764,6 +552,3 @@ template T lexical_cast(const QString& s) return x; } } // namespace SIMPLTesting - - - diff --git a/Source/SIMPLib/Common/ScopedFileMonitor.hpp b/Source/SIMPLib/Common/ScopedFileMonitor.hpp old mode 100755 new mode 100644 index bf68196a5a..4e67aa209c --- a/Source/SIMPLib/Common/ScopedFileMonitor.hpp +++ b/Source/SIMPLib/Common/ScopedFileMonitor.hpp @@ -1,41 +1,41 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include /** * @brief The ScopedFileMonitor class will automatically close an open FILE pointer @@ -43,13 +43,28 @@ */ class ScopedFileMonitor { - public: - ScopedFileMonitor(FILE* f) : m_File(f) {} - virtual ~ScopedFileMonitor() { if (nullptr != m_File) fclose(m_File);} - private: - FILE* m_File; - ScopedFileMonitor(const ScopedFileMonitor&); // Copy Constructor Not Implemented - void operator=(const ScopedFileMonitor&); // Move assignment Not Implemented -}; +public: + ScopedFileMonitor(FILE* f) + : m_File(f) + { + } + + ~ScopedFileMonitor() noexcept + { + if(m_File != nullptr) + { + [[maybe_unused]] auto result = std::fclose(m_File); + } + } + + ScopedFileMonitor() = delete; + ScopedFileMonitor(const ScopedFileMonitor&) = delete; + ScopedFileMonitor& operator=(const ScopedFileMonitor&) = delete; + ScopedFileMonitor(ScopedFileMonitor&&) noexcept = delete; + ScopedFileMonitor& operator=(ScopedFileMonitor&&) noexcept = delete; + +private: + FILE* m_File; +}; diff --git a/Source/SIMPLib/Common/ShapeType.cpp b/Source/SIMPLib/Common/ShapeType.cpp index 271b4b30a2..82a8539501 100644 --- a/Source/SIMPLib/Common/ShapeType.cpp +++ b/Source/SIMPLib/Common/ShapeType.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ShapeType.h" @@ -48,7 +48,7 @@ ShapeType::~ShapeType() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector ShapeType::ToQVector(Types &types) +QVector ShapeType::ToQVector(Types& types) { QVector vec(types.size()); for(int i = 0; i < types.size(); i++) @@ -61,7 +61,7 @@ QVector ShapeType::ToQVector(Types &types) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ShapeType::Types ShapeType::FromQVector(QVector &vec) +ShapeType::Types ShapeType::FromQVector(QVector& vec) { ShapeType::Types types(vec.size()); for(int i = 0; i < vec.size(); i++) @@ -71,7 +71,6 @@ ShapeType::Types ShapeType::FromQVector(QVector &vec) return types; } - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -151,7 +150,7 @@ QString ShapeType::getShapeTypeString(Type ShapeType) case Type::CylinderC: return CylinderCStr(); case Type::ShapeTypeEnd: - return ShapeTypeEndStr(); + return ShapeTypeEndStr(); case Type::Unknown: return UnknownShapeTypeStr(); default: @@ -211,7 +210,6 @@ void ShapeType::getShapeTypeStrings(QVector& strings) strings.push_back(CylinderCStr()); strings.push_back(ShapeTypeEndStr()); strings.push_back(UnknownShapeTypeStr()); - } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/Common/ShapeType.h b/Source/SIMPLib/Common/ShapeType.h old mode 100755 new mode 100644 index eea8e06b5b..bba70d65d0 --- a/Source/SIMPLib/Common/ShapeType.h +++ b/Source/SIMPLib/Common/ShapeType.h @@ -1,47 +1,46 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once #include #include -#include #include -#include "SIMPLib/Common/Constants.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/Constants.h" /** * @class ShapeType ShapeType.h PathToHeader/ShapeType.h @@ -55,7 +54,7 @@ class SIMPLib_EXPORT ShapeType public: virtual ~ShapeType(); - using EnumType = unsigned int; + using EnumType = uint32_t; enum class Type : EnumType { @@ -65,8 +64,8 @@ class SIMPLib_EXPORT ShapeType CylinderA = 3, //!< CylinderB = 4, //!< CylinderC = 5, //!< - ShapeTypeEnd = 6, //! - Unknown = 999, //!< + ShapeTypeEnd = 6, //! + Unknown = 999, //!< Any = 4294967295U }; @@ -79,7 +78,7 @@ class SIMPLib_EXPORT ShapeType * @param types * @return */ - static QVector ToQVector(Types &types); + static QVector ToQVector(Types& types); /** * @brief Converts From a QVector to QVector. Useful for @@ -87,7 +86,7 @@ class SIMPLib_EXPORT ShapeType * @param types * @return */ - static Types FromQVector(QVector &types); + static Types FromQVector(QVector& types); static QString EllipsoidStr(); static QString SuperEllipsoid(); @@ -120,4 +119,3 @@ class SIMPLib_EXPORT ShapeType Q_DECLARE_METATYPE(ShapeType::Type) Q_DECLARE_METATYPE(ShapeType::Types) - diff --git a/Source/SIMPLib/Common/SourceList.cmake b/Source/SIMPLib/Common/SourceList.cmake index 2217d459b0..59e92de368 100755 --- a/Source/SIMPLib/Common/SourceList.cmake +++ b/Source/SIMPLib/Common/SourceList.cmake @@ -19,32 +19,41 @@ set_source_files_properties( ${SIMPLib_${SUBDIR_NAME}_Generated_MOC_SRCS} PROPER set(SIMPLib_${SUBDIR_NAME}_HDRS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AppVersion.h - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Constants.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/CreatedArrayHelpIndexEntry.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IObserver.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/INamedCollection.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/INamedObject.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/NamedCollection.hpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PhaseType.h - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineMessage.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/QtBackwardCompatibilityMacro.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SIMPLibDLLExport.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SIMPLibSetGetMacros.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ScopedFileMonitor.hpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ShapeType.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SIMPLArray.hpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SIMPLRange.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SIMPLRange2D.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SIMPLRange3D.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/TemplateHelpers.h ) set(SIMPLib_${SUBDIR_NAME}_SRCS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AppVersion.cpp - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/CreatedArrayHelpIndexEntry.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DocRequestManager.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/EnsembleInfo.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IObserver.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/INamedCollection.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/INamedObject.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Observable.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Observer.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PhaseType.cpp - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/PipelineMessage.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ShapeType.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SIMPLRange.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SIMPLRange2D.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SIMPLRange3D.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/TemplateHelpers.cpp ) @@ -62,4 +71,11 @@ set(SIMPLib_${SUBDIR_NAME}_SRCS ${SIMPLib_${SUBDIR_NAME}_Generated_MOC_SRCS} ) +#------------------------------------------------------------------------------- +# Add the unit testing sources +# -------------------------------------------------------------------- +# If Testing is enabled, turn on the Unit Tests +if(SIMPL_BUILD_TESTING) + include(${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Testing/Cxx/SourceList.cmake) +endif() diff --git a/Source/SIMPLib/Common/TemplateHelpers.cpp b/Source/SIMPLib/Common/TemplateHelpers.cpp index 691b501a3f..a7fcd0eaa9 100644 --- a/Source/SIMPLib/Common/TemplateHelpers.cpp +++ b/Source/SIMPLib/Common/TemplateHelpers.cpp @@ -31,137 +31,140 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "TemplateHelpers.h" +#include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataArrays/IDataArray.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/AbstractFilter.h" using namespace TemplateHelpers; // ----------------------------------------------------------------------------- -IDataArrayWkPtr CreateNonPrereqArrayFromArrayType::operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const QVector& compDims, const IDataArrayShPtr& sourceArrayType) +IDataArrayWkPtr CreateNonPrereqArrayFromArrayType::operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const std::vector& compDims, const IDataArrayShPtr& sourceArrayType, + RenameDataPath::DataID_t id) { IDataArrayShPtr ptr = IDataArray::NullPointer(); if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(f, arrayPath, 0.0f, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, 0.0f, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, double>(f, arrayPath, 0.0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, 0.0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int8_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint8_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int16_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint16_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int32_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint32_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint64_t>(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, 0, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath(f, arrayPath, false, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath(f, arrayPath, false, compDims, "", id); } else if(CanDynamicCast()(sourceArrayType)) { - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath(f, arrayPath, 0, compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath(f, arrayPath, 0, compDims, "", id); } else { QString msg = QObject::tr("The created array '%1' is of unsupported type. The following types are supported: %3").arg(arrayPath.getDataArrayName()).arg(SIMPL::TypeNames::SupportedTypeList); - f->setErrorCondition(Errors::UnsupportedType); - f->notifyErrorMessage(f->getHumanLabel(), msg, f->getErrorCondition()); + f->setErrorCondition(Errors::UnsupportedDataType, msg); } return ptr; } // ----------------------------------------------------------------------------- -IDataArrayWkPtr CreateNonPrereqArrayFromTypeEnum::operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const QVector& compDims, int arrayType, double initValue) +IDataArrayWkPtr CreateNonPrereqArrayFromTypeEnum::operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const std::vector& compDims, int arrayType, double initValue, + RenameDataPath::DataID_t id) { IDataArrayShPtr ptr = IDataArray::NullPointer(); switch(arrayType) { case SIMPL::TypeEnums::Int8: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int8_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::UInt8: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint8_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::Int16: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int16_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::UInt16: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint16_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::Int32: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int32_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::UInt32: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint32_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::Int64: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::UInt64: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint64_t>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::Float: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::Double: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, double>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::Bool: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, bool>(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath>(f, arrayPath, static_cast(initValue), compDims, "", id); break; case SIMPL::TypeEnums::SizeT: - ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath(f, arrayPath, static_cast(initValue), compDims); + ptr = f->getDataContainerArray()->createNonPrereqArrayFromPath(f, arrayPath, static_cast(initValue), compDims, "", id); break; default: QString msg = QObject::tr("The created array '%1' is of unsupported type. The following types are supported: %3").arg(arrayPath.getDataArrayName()).arg(SIMPL::TypeEnums::SupportedTypeList); - f->setErrorCondition(Errors::UnsupportedType); - f->notifyErrorMessage(f->getHumanLabel(), msg, f->getErrorCondition()); + f->setErrorCondition(Errors::UnsupportedDataType, msg); break; } return ptr; } // ----------------------------------------------------------------------------- -IDataArrayShPtr CreateArrayFromArrayType::operator()(AbstractFilter* f, const size_t& numTuples, const QVector& compDims, const QString& arrayName, bool allocate, +IDataArrayShPtr CreateArrayFromArrayType::operator()(AbstractFilter* f, const size_t& numTuples, const std::vector& compDims, const QString& arrayName, bool allocate, const IDataArrayShPtr& sourceArrayType) { CreateArrayFromArrayType classInstance; - QVector tupleDims(1, numTuples); + std::vector tupleDims = {numTuples}; return classInstance(f, tupleDims, compDims, arrayName, allocate, sourceArrayType); } // ----------------------------------------------------------------------------- -IDataArrayShPtr CreateArrayFromArrayType::operator()(AbstractFilter* f, const QVector& tupleDims, const QVector& compDims, const QString& arrayName, bool allocate, +IDataArrayShPtr CreateArrayFromArrayType::operator()(AbstractFilter* f, const std::vector& tupleDims, const std::vector& compDims, const QString& arrayName, bool allocate, const IDataArrayShPtr& sourceArrayType) { IDataArrayShPtr ptr = IDataArray::NullPointer(); @@ -217,22 +220,22 @@ IDataArrayShPtr CreateArrayFromArrayType::operator()(AbstractFilter* f, const QV else { QString msg = QObject::tr("The created array is of unsupported type."); - f->setErrorCondition(Errors::UnsupportedType); - f->notifyErrorMessage(f->getHumanLabel(), msg, f->getErrorCondition()); + f->setErrorCondition(Errors::UnsupportedDataType, msg); } return ptr; } // ----------------------------------------------------------------------------- -IDataArrayShPtr CreateArrayFromType::operator()(AbstractFilter* f, const size_t& numTuples, const QVector& compDims, const QString& arrayName, bool allocate, const QString& type) +IDataArrayShPtr CreateArrayFromType::operator()(AbstractFilter* f, const size_t& numTuples, const std::vector& compDims, const QString& arrayName, bool allocate, const QString& type) { CreateArrayFromType classInstance; - QVector tupleDims(1, numTuples); + std::vector tupleDims(1, numTuples); return classInstance(f, tupleDims, compDims, arrayName, allocate, type); } // ----------------------------------------------------------------------------- -IDataArrayShPtr CreateArrayFromType::operator()(AbstractFilter* f, const QVector& tupleDims, const QVector& compDims, const QString& arrayName, bool allocate, const QString& type) +IDataArrayShPtr CreateArrayFromType::operator()(AbstractFilter* f, const std::vector& tupleDims, const std::vector& compDims, const QString& arrayName, bool allocate, + const QString& type) { IDataArrayShPtr ptr = IDataArray::NullPointer(); @@ -284,41 +287,37 @@ IDataArrayShPtr CreateArrayFromType::operator()(AbstractFilter* f, const QVector else { QString msg = QObject::tr("The created array is of unsupported type."); - f->setErrorCondition(Errors::UnsupportedType); - f->notifyErrorMessage(f->getHumanLabel(), msg, f->getErrorCondition()); + f->setErrorCondition(Errors::UnsupportedDataType, msg); } return ptr; } // ----------------------------------------------------------------------------- -IDataArrayWkPtr GetPrereqArrayFromPath::operator()(AbstractFilter* f, const DataArrayPath& arrayPath, QVector& compDims) +IDataArrayWkPtr GetPrereqArrayFromPath::operator()(AbstractFilter* f, const DataArrayPath& arrayPath, std::vector& compDims) { IDataArrayShPtr retPtr = IDataArray::NullPointer(); - DataContainer::Pointer volDataCntr = f->getDataContainerArray()->template getPrereqDataContainer(f, arrayPath.getDataContainerName(), false); - if(f->getErrorCondition() < 0 || nullptr == volDataCntr) + DataContainer::Pointer volDataCntr = f->getDataContainerArray()->getPrereqDataContainer(f, arrayPath.getDataContainerName(), false); + if(f->getErrorCode() < 0 || nullptr == volDataCntr) { QString ss = QObject::tr("The Data Container '%1' does not exist").arg(arrayPath.getDataContainerName()); - f->setErrorCondition(Errors::MissingDataContainer); - f->notifyErrorMessage(f->getHumanLabel(), ss, f->getErrorCondition()); + f->setErrorCondition(Errors::MissingDataContainer, ss); return retPtr; } AttributeMatrix::Pointer cell_attr_matrix = volDataCntr->getPrereqAttributeMatrix(f, arrayPath.getAttributeMatrixName(), Errors::MissingAttributeMatrix); - if(f->getErrorCondition() < 0 || nullptr == cell_attr_matrix.get()) + if(f->getErrorCode() < 0 || nullptr == cell_attr_matrix.get()) { QString ss = QObject::tr("The Attribute Matrix '%1' does not exist").arg(arrayPath.getAttributeMatrixName()); - f->setErrorCondition(Errors::MissingAttributeMatrix); - f->notifyErrorMessage(f->getHumanLabel(), ss, f->getErrorCondition()); + f->setErrorCondition(Errors::MissingAttributeMatrix, ss); return retPtr; } IDataArrayShPtr templ_ptr = cell_attr_matrix->getAttributeArray(arrayPath.getDataArrayName()); if(nullptr == templ_ptr.get()) { QString ss = QObject::tr("The input array '%1' was not found in the AttributeMatrix '%2'.").arg(arrayPath.getDataArrayName()).arg(arrayPath.getAttributeMatrixName()); - f->setErrorCondition(Errors::MissingArray); - f->notifyErrorMessage(f->getHumanLabel(), ss, f->getErrorCondition()); + f->setErrorCondition(Errors::MissingArray, ss); return retPtr; } - if(compDims.isEmpty()) + if(compDims.empty()) { compDims = templ_ptr->getComponentDimensions(); } @@ -326,51 +325,51 @@ IDataArrayWkPtr GetPrereqArrayFromPath::operator()(AbstractFilter* f, const Data IDataArrayShPtr i_data_array = cell_attr_matrix->getAttributeArray(arrayPath.getDataArrayName()); if(CanDynamicCast()(i_data_array)) { - retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath, AbstractFilter>(f, arrayPath, compDims); + retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath>(f, arrayPath, compDims); } else if(CanDynamicCast()(i_data_array)) { - retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath, AbstractFilter>(f, arrayPath, compDims); + retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath>(f, arrayPath, compDims); } else if(CanDynamicCast()(i_data_array)) { - retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath, AbstractFilter>(f, arrayPath, compDims); + retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath>(f, arrayPath, compDims); } else if(CanDynamicCast()(i_data_array)) { - retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath, AbstractFilter>(f, arrayPath, compDims); + retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath>(f, arrayPath, compDims); } else if(CanDynamicCast()(i_data_array)) { - retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath, AbstractFilter>(f, arrayPath, compDims); + retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath>(f, arrayPath, compDims); } else if(CanDynamicCast()(i_data_array)) { - retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath, AbstractFilter>(f, arrayPath, compDims); + retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath>(f, arrayPath, compDims); } else if(CanDynamicCast()(i_data_array)) { - retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath, AbstractFilter>(f, arrayPath, compDims); + retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath>(f, arrayPath, compDims); } else if(CanDynamicCast()(i_data_array)) { - retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath, AbstractFilter>(f, arrayPath, compDims); + retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath>(f, arrayPath, compDims); } else if(CanDynamicCast()(i_data_array)) { - retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath, AbstractFilter>(f, arrayPath, compDims); + retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath>(f, arrayPath, compDims); } else if(CanDynamicCast()(i_data_array)) { - retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath, AbstractFilter>(f, arrayPath, compDims); + retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath>(f, arrayPath, compDims); } else if(CanDynamicCast()(i_data_array)) { - retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath, AbstractFilter>(f, arrayPath, compDims); + retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath>(f, arrayPath, compDims); } else if(CanDynamicCast()(i_data_array)) { - retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath(f, arrayPath, compDims); + retPtr = f->getDataContainerArray()->template getPrereqArrayFromPath(f, arrayPath, compDims); } else { @@ -378,8 +377,7 @@ IDataArrayWkPtr GetPrereqArrayFromPath::operator()(AbstractFilter* f, const Data .arg(arrayPath.getDataArrayName()) .arg(i_data_array->getTypeAsString()) .arg(SIMPL::TypeNames::SupportedTypeList); - f->setErrorCondition(Errors::UnsupportedType); - f->notifyErrorMessage(f->getHumanLabel(), ss, f->getErrorCondition()); + f->setErrorCondition(Errors::UnsupportedDataType, ss); } return retPtr; } diff --git a/Source/SIMPLib/Common/TemplateHelpers.h b/Source/SIMPLib/Common/TemplateHelpers.h old mode 100755 new mode 100644 index 4f30b5ab62..226ee90444 --- a/Source/SIMPLib/Common/TemplateHelpers.h +++ b/Source/SIMPLib/Common/TemplateHelpers.h @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -36,10 +36,13 @@ //-- C++11 Includes #include +#include #include +#include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/DataContainers/RenameDataPath.h" class AbstractFilter; @@ -55,6 +58,70 @@ using IDataArrayShPtr = std::shared_ptr; namespace TemplateHelpers { +/** + * @brief This macro does NOT include the 'bool' type due to some templated classes not being able + * to template over the 'bool' type. + */ +#define EXECUTE_FUNCTION_TEMPLATE_NO_BOOL(IDataArraySubClass, observableObj, templateName, inputData, ...) \ + if(TemplateHelpers::CanDynamicCast>()(inputData)) \ + { \ + templateName(__VA_ARGS__); \ + } \ + else if(TemplateHelpers::CanDynamicCast>()(inputData)) \ + { \ + templateName(__VA_ARGS__); \ + } \ + else if(TemplateHelpers::CanDynamicCast>()(inputData)) \ + { \ + templateName(__VA_ARGS__); \ + } \ + else if(TemplateHelpers::CanDynamicCast>()(inputData)) \ + { \ + templateName(__VA_ARGS__); \ + } \ + else if(TemplateHelpers::CanDynamicCast>()(inputData)) \ + { \ + templateName(__VA_ARGS__); \ + } \ + else if(TemplateHelpers::CanDynamicCast>()(inputData)) \ + { \ + templateName(__VA_ARGS__); \ + } \ + else if(TemplateHelpers::CanDynamicCast>()(inputData)) \ + { \ + templateName(__VA_ARGS__); \ + } \ + else if(TemplateHelpers::CanDynamicCast>()(inputData)) \ + { \ + templateName(__VA_ARGS__); \ + } \ + else if(TemplateHelpers::CanDynamicCast>()(inputData)) \ + { \ + templateName(__VA_ARGS__); \ + } \ + else if(TemplateHelpers::CanDynamicCast>()(inputData)) \ + { \ + templateName(__VA_ARGS__); \ + } \ + else if(TemplateHelpers::CanDynamicCast>()(inputData)) \ + { \ + templateName(__VA_ARGS__); \ + } \ + else if(TemplateHelpers::CanDynamicCast>()(inputData)) \ + { \ + observableObj->setErrorConditionWithPrefix(TemplateHelpers::Errors::UnsupportedDataType, #templateName, "Boolean input arrays are not supported"); \ + } \ + else \ + { \ + QString msg; \ + QTextStream out(&msg); \ + out << "The input array " << inputData->getDataArrayPath().serialize("/") << " is not a supported type. Type is: " << inputData->getTypeAsString(); \ + observableObj->setErrorConditionWithPrefix(TemplateHelpers::Errors::UnsupportedDataType, #templateName, msg); \ + } + +/** + * @brief This macro includes the 'bool' type. + */ #define EXECUTE_FUNCTION_TEMPLATE(observableObj, templateName, inputData, ...) \ if(TemplateHelpers::CanDynamicCast()(inputData)) \ { \ @@ -106,7 +173,7 @@ namespace TemplateHelpers } \ else \ { \ - observableObj->notifyErrorMessage(#templateName, "The input array was of unsupported type", TemplateHelpers::Errors::UnsupportedType); \ + observableObj->setErrorConditionWithPrefix(TemplateHelpers::Errors::UnsupportedDataType, #templateName, "The input array was of unsupported type"); \ } #define EXECUTE_TEMPLATE(observableObj, templateName, inputData, ...) \ @@ -172,7 +239,7 @@ namespace TemplateHelpers } \ else \ { \ - observableObj->notifyErrorMessage(#templateName, "The input array was of unsupported type", TemplateHelpers::Errors::UnsupportedType); \ + observableObj->setErrorConditionWithPrefix(TemplateHelpers::Errors::UnsupportedDataType, #templateName, "The input array was of unsupported type"); \ } /** @@ -180,17 +247,19 @@ namespace TemplateHelpers */ namespace Errors { -const int UnsupportedType(-401); -const int MissingDataContainer(-402); -const int MissingAttributeMatrix(-403); -const int MissingArray(-404); +const int UnsupportedDataType(-401); +const int UnsupportedImageType(-402); +const int MissingDataContainer(-403); +const int MissingAttributeMatrix(-404); +const int MissingArray(-405); } // namespace Errors /** * @brief This class (functor) simply returns true or false if the IDataArray can be downcast to a certain DataArray type * parameterized by the template parameter T. */ -template class CanDynamicCast +template +class CanDynamicCast { public: CanDynamicCast() = default; @@ -228,7 +297,8 @@ class SIMPLib_EXPORT CreateNonPrereqArrayFromArrayType * @param sourceArrayType * @return */ - IDataArrayWkPtr operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const QVector& compDims, const IDataArrayShPtr& sourceArrayType); + IDataArrayWkPtr operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const std::vector& compDims, const IDataArrayShPtr& sourceArrayType, + RenameDataPath::DataID_t = RenameDataPath::k_Invalid_ID); }; /** @@ -254,7 +324,8 @@ class SIMPLib_EXPORT CreateNonPrereqArrayFromTypeEnum * @param initValue * @return */ - IDataArrayWkPtr operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const QVector& compDims, int arrayType, double initValue); + IDataArrayWkPtr operator()(AbstractFilter* f, const DataArrayPath& arrayPath, const std::vector& compDims, int arrayType, double initValue, + RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID); }; /** @@ -271,7 +342,7 @@ class SIMPLib_EXPORT CreateArrayFromArrayType CreateArrayFromArrayType& operator=(const CreateArrayFromArrayType&) = delete; // Copy Assignment Not Implemented CreateArrayFromArrayType& operator=(CreateArrayFromArrayType&&) = delete; // Move Assignment Not Implemented - IDataArrayShPtr operator()(AbstractFilter* f, const size_t& numTuples, const QVector& compDims, const QString& arrayName, bool allocate, const IDataArrayShPtr& sourceArrayType); + IDataArrayShPtr operator()(AbstractFilter* f, const size_t& numTuples, const std::vector& compDims, const QString& arrayName, bool allocate, const IDataArrayShPtr& sourceArrayType); /** * @brief operator () @@ -283,7 +354,8 @@ class SIMPLib_EXPORT CreateArrayFromArrayType * @param sourceArrayType * @return */ - IDataArrayShPtr operator()(AbstractFilter* f, const QVector& tupleDims, const QVector& compDims, const QString& arrayName, bool allocate, const IDataArrayShPtr& sourceArrayType); + IDataArrayShPtr operator()(AbstractFilter* f, const std::vector& tupleDims, const std::vector& compDims, const QString& arrayName, bool allocate, + const IDataArrayShPtr& sourceArrayType); }; /** @@ -310,7 +382,7 @@ class SIMPLib_EXPORT CreateArrayFromType * @param type * @return */ - IDataArrayShPtr operator()(AbstractFilter* f, const size_t& numTuples, const QVector& compDims, const QString& arrayName, bool allocate, const QString& type); + IDataArrayShPtr operator()(AbstractFilter* f, const size_t& numTuples, const std::vector& compDims, const QString& arrayName, bool allocate, const QString& type); /** * @brief operator () @@ -322,7 +394,7 @@ class SIMPLib_EXPORT CreateArrayFromType * @param type * @return */ - IDataArrayShPtr operator()(AbstractFilter* f, const QVector& tupleDims, const QVector& compDims, const QString& arrayName, bool allocate, const QString& type); + IDataArrayShPtr operator()(AbstractFilter* f, const std::vector& tupleDims, const std::vector& compDims, const QString& arrayName, bool allocate, const QString& type); }; /** @@ -345,7 +417,7 @@ class SIMPLib_EXPORT GetPrereqArrayFromPath * @param compDims * @return */ - IDataArrayWkPtr operator()(AbstractFilter* f, const DataArrayPath& arrayPath, QVector& compDims); + IDataArrayWkPtr operator()(AbstractFilter* f, const DataArrayPath& arrayPath, std::vector& compDims); // Move assignment Not Implemented }; diff --git a/Source/SIMPLib/Common/Testing/Cxx/SIMPLArrayTest.cpp b/Source/SIMPLib/Common/Testing/Cxx/SIMPLArrayTest.cpp new file mode 100644 index 0000000000..31a6d7c2bb --- /dev/null +++ b/Source/SIMPLib/Common/Testing/Cxx/SIMPLArrayTest.cpp @@ -0,0 +1,242 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include +#include +#include +#include +#include + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLArray.hpp" +#include "SIMPLib/Testing/SIMPLTestFileLocations.h" +#include "SIMPLib/Testing/UnitTestSupport.hpp" + +class SIMPLArrayTest +{ +public: + SIMPLArrayTest() = default; + virtual ~SIMPLArrayTest() = default; + + SIMPLArrayTest(const SIMPLArrayTest&) = delete; // Copy Constructor Not Implemented + SIMPLArrayTest(SIMPLArrayTest&&) = delete; // Move Constructor Not Implemented + SIMPLArrayTest& operator=(const SIMPLArrayTest&) = delete; // Copy Assignment Not Implemented + SIMPLArrayTest& operator=(SIMPLArrayTest&&) = delete; // Move Assignment Not Implemented + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void RemoveTestFiles() + { +#if REMOVE_TEST_FILES + +#endif + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void TestVec2() + { + FloatVec2Type f3(1.0f, 2.0f); + + std::array i32Array = {1, 2}; + IntVec2Type i3(i32Array); + + std::tuple tpl = std::make_tuple(1, 2); + i3 = tpl; + + std::vector iv3 = {4, 5}; + i3 = iv3.data(); + + std::vector iv2 = {6, 5}; + i3 = IntVec2Type(iv2); + + int32_t x = i3.getX(); + DREAM3D_REQUIRED(x, ==, 6) + int32_t y = i3.getY(); + DREAM3D_REQUIRED(y, ==, 5) + + tpl = i3.toTuple(); + DREAM3D_REQUIRED(std::get<0>(tpl), ==, 6) + DREAM3D_REQUIRED(std::get<1>(tpl), ==, 5) + + DREAM3D_REQUIRED(i3.size(), ==, 2) + DREAM3D_REQUIRED(i3[0], ==, 6) + DREAM3D_REQUIRED(i3[1], ==, 5) + + std::vector oVec = i3.toContainer>(); + std::deque oDeque = i3.toContainer>(); + + QVector oQVec = i3.toContainer>(); + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void TestVec3() + { + FloatVec3Type f3(1.0f, 2.0f, 3.0f); + + std::array i32Array = {1, 2, 3}; + IntVec3Type i3(i32Array); + + std::tuple tpl = std::make_tuple(1, 2, 3); + i3 = tpl; + + std::vector iv3 = {4, 5, 6}; + i3 = iv3.data(); + + int32_t x = i3.getX(); + DREAM3D_REQUIRED(x, ==, 4) + int32_t y = i3.getY(); + DREAM3D_REQUIRED(y, ==, 5) + int32_t z = i3.getZ(); + DREAM3D_REQUIRED(z, ==, 6) + + tpl = i3.toTuple(); + DREAM3D_REQUIRED(std::get<0>(tpl), ==, 4) + DREAM3D_REQUIRED(std::get<1>(tpl), ==, 5) + DREAM3D_REQUIRED(std::get<2>(tpl), ==, 6) + + DREAM3D_REQUIRED(i3.size(), ==, 3) + DREAM3D_REQUIRED(i3[0], ==, 4) + DREAM3D_REQUIRED(i3[1], ==, 5) + DREAM3D_REQUIRED(i3[2], ==, 6) + + std::vector oVec = i3.toContainer>(); + std::deque oDeque = i3.toContainer>(); + + QVector oQVec = i3.toContainer>(); + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void TestVec4() + { + FloatVec4Type f3(1.0f, 2.0f, 3.0f, 4.0f); + + std::array i32Array = { + 1, + 2, + 3, + 4, + }; + IntVec4Type i3(i32Array); + + std::tuple tpl = std::make_tuple(1, 2, 3, 4); + i3 = tpl; + + std::vector iv3 = {4, 5, 6, 7}; + i3 = iv3.data(); + + int32_t x = i3.getX(); + DREAM3D_REQUIRED(x, ==, 4) + int32_t y = i3.getY(); + DREAM3D_REQUIRED(y, ==, 5) + int32_t z = i3.getZ(); + DREAM3D_REQUIRED(z, ==, 6) + + tpl = i3.toTuple(); + DREAM3D_REQUIRED(std::get<0>(tpl), ==, 4) + DREAM3D_REQUIRED(std::get<1>(tpl), ==, 5) + DREAM3D_REQUIRED(std::get<2>(tpl), ==, 6) + + DREAM3D_REQUIRED(i3.size(), ==, 4) + DREAM3D_REQUIRED(i3[0], ==, 4) + DREAM3D_REQUIRED(i3[1], ==, 5) + DREAM3D_REQUIRED(i3[2], ==, 6) + DREAM3D_REQUIRED(i3[3], ==, 7) + + std::vector oVec = i3.toContainer>(); + std::deque oDeque = i3.toContainer>(); + + QVector oQVec = i3.toContainer>(); + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void TestVec6() + { + FloatVec6Type f3(1.0f, 2.0f, 3.0f, 6.0f, 7.0f, 8.0f); + + std::array i32Array = {1, 2, 3, 4, 5, 6}; + IntVec6Type i3(i32Array); + + std::tuple tpl = std::make_tuple(1, 2, 3, 5, 6, 7); + i3 = tpl; + + std::vector iv3 = {4, 5, 6, 7, 8, 9}; + i3 = iv3.data(); + + tpl = i3.toTuple(); + DREAM3D_REQUIRED(std::get<0>(tpl), ==, 4) + DREAM3D_REQUIRED(std::get<1>(tpl), ==, 5) + DREAM3D_REQUIRED(std::get<2>(tpl), ==, 6) + + DREAM3D_REQUIRED(i3.size(), ==, 6) + DREAM3D_REQUIRED(i3[0], ==, 4) + DREAM3D_REQUIRED(i3[1], ==, 5) + DREAM3D_REQUIRED(i3[2], ==, 6) + DREAM3D_REQUIRED(i3[3], ==, 7) + DREAM3D_REQUIRED(i3[4], ==, 8) + DREAM3D_REQUIRED(i3[5], ==, 9) + + std::vector oVec = i3.toContainer>(); + std::deque oDeque = i3.toContainer>(); + + QVector oQVec = i3.toContainer>(); + } + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void operator()() + { + int err = EXIT_SUCCESS; + + std::cout << "#### SIMPLArrayTest Starting ####" << std::endl; +#if !REMOVE_TEST_FILES + DREAM3D_REGISTER_TEST(RemoveTestFiles()) +#endif + DREAM3D_REGISTER_TEST(TestVec2()) + DREAM3D_REGISTER_TEST(TestVec3()) + DREAM3D_REGISTER_TEST(TestVec4()) + DREAM3D_REGISTER_TEST(TestVec6()) + +#if REMOVE_TEST_FILES + DREAM3D_REGISTER_TEST(RemoveTestFiles()) +#endif + } +}; diff --git a/Source/SIMPLib/Common/Testing/Cxx/SourceList.cmake b/Source/SIMPLib/Common/Testing/Cxx/SourceList.cmake new file mode 100644 index 0000000000..8775c7812f --- /dev/null +++ b/Source/SIMPLib/Common/Testing/Cxx/SourceList.cmake @@ -0,0 +1,6 @@ + +set(TEST_${SUBDIR_NAME}_NAMES + SIMPLArrayTest +) + +SIMPL_ADD_UNIT_TEST("${TEST_${SUBDIR_NAME}_NAMES}" "${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Testing/Cxx") diff --git a/Source/SIMPLib/CoreFilters/ApplyImageTransforms.cpp b/Source/SIMPLib/CoreFilters/ApplyImageTransforms.cpp new file mode 100644 index 0000000000..23b21b8fae --- /dev/null +++ b/Source/SIMPLib/CoreFilters/ApplyImageTransforms.cpp @@ -0,0 +1,275 @@ +/* ============================================================================ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "ApplyImageTransforms.h" + +#include + +#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" +#include "SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.h" +#include "SIMPLib/FilterParameters/StringFilterParameter.h" +#include "SIMPLib/Geometry/ImageGeom.h" +#include "SIMPLib/Geometry/TransformContainer.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +ApplyImageTransforms::ApplyImageTransforms() +: AbstractFilter() +{ + initialize(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +ApplyImageTransforms::~ApplyImageTransforms() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ApplyImageTransforms::initialize() +{ + clearErrorCode(); + clearWarningCode(); + setCancel(false); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ApplyImageTransforms::setupFilterParameters() +{ + FilterParameterVectorType parameters; + + { + MultiDataContainerSelectionFilterParameter::RequirementType req = + MultiDataContainerSelectionFilterParameter::CreateRequirement(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, AttributeMatrix::Type::Cell, IGeometry::Type::Image); + parameters.push_back(SIMPL_NEW_MDC_SELECTION_FP("Image Data Containers", ImageDataContainers, FilterParameter::Category::RequiredArray, ApplyImageTransforms, req)); + } + + setFilterParameters(parameters); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ApplyImageTransforms::dataCheck() +{ + clearErrorCode(); + clearWarningCode(); + + int selectedDCCount = getImageDataContainers().size(); + if(selectedDCCount < 1) + { + QString ss = QObject::tr("At least one Data Container must be selected"); + setErrorCondition(-11001, ss); + return; + } + + for(int i = 0; i < selectedDCCount; i++) + { + QString dcName = m_ImageDataContainers[i]; + + ImageGeom::Pointer imageGeom = getDataContainerArray()->getPrereqGeometryFromDataContainer(this, dcName); + if(getErrorCode() < 0) + { + return; + } + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ApplyImageTransforms::execute() +{ + initialize(); + dataCheck(); + if(getErrorCode() < 0) + { + return; + } + + int selectedDCCount = getImageDataContainers().size(); + for(int i = 0; i < selectedDCCount; i++) + { + QString dcName = m_ImageDataContainers[i]; + + DataContainer::Pointer dc = getDataContainerArray()->getDataContainer(dcName); + ImageGeom::Pointer imageGeom = dc->getGeometryAs(); + + FloatVec3Type origin = imageGeom->getOrigin(); + + ::ITransformContainer::Pointer iTransformContainer = imageGeom->getTransformContainer(); + if(iTransformContainer) + { + TransformContainer::Pointer transformContainer = std::dynamic_pointer_cast(iTransformContainer); + if(transformContainer) + { + TransformContainer::TransformParametersType parameters = transformContainer->getParameters(); + + double xTranslation = parameters[9]; + double yTranslation = parameters[10]; + + origin[0] = origin[0] - xTranslation; + origin[1] = origin[1] - yTranslation; + + imageGeom->setOrigin(origin); + + parameters[9] = 0; + parameters[10] = 0; + transformContainer->setParameters(parameters); + } + } + } + + notifyStatusMessage("Complete"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AbstractFilter::Pointer ApplyImageTransforms::newFilterInstance(bool copyFilterParameters) const +{ + ApplyImageTransforms::Pointer filter = ApplyImageTransforms::New(); + if(copyFilterParameters) + { + copyFilterParameterInstanceVariables(filter.get()); + } + return filter; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString ApplyImageTransforms::getCompiledLibraryName() const +{ + return Core::CoreBaseName; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString ApplyImageTransforms::getBrandingString() const +{ + return "SIMPLib Core Filter"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString ApplyImageTransforms::getFilterVersion() const +{ + QString version; + QTextStream vStream(&version); + vStream << SIMPLib::Version::Major() << "." << SIMPLib::Version::Minor() << "." << SIMPLib::Version::Patch(); + return version; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString ApplyImageTransforms::getGroupName() const +{ + return SIMPL::FilterGroups::CoreFilters; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString ApplyImageTransforms::getSubGroupName() const +{ + return SIMPL::FilterSubGroups::ImageFilters; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString ApplyImageTransforms::getHumanLabel() const +{ + return "Apply Image Transforms"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QUuid ApplyImageTransforms::getUuid() const +{ + return QUuid("{a4bd18bc-3306-5e41-bc41-4cb4248226bd}"); +} + +// ----------------------------------------------------------------------------- +ApplyImageTransforms::Pointer ApplyImageTransforms::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr ApplyImageTransforms::New() +{ + struct make_shared_enabler : public ApplyImageTransforms + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString ApplyImageTransforms::getNameOfClass() const +{ + return QString("ApplyImageTransforms"); +} + +// ----------------------------------------------------------------------------- +QString ApplyImageTransforms::ClassName() +{ + return QString("ApplyImageTransforms"); +} + +// ----------------------------------------------------------------------------- +void ApplyImageTransforms::setImageDataContainers(const std::vector& value) +{ + m_ImageDataContainers = value; +} + +// ----------------------------------------------------------------------------- +std::vector ApplyImageTransforms::getImageDataContainers() const +{ + return m_ImageDataContainers; +} diff --git a/Source/SIMPLib/CoreFilters/ApplyImageTransforms.h b/Source/SIMPLib/CoreFilters/ApplyImageTransforms.h new file mode 100644 index 0000000000..3f5b5fa5f1 --- /dev/null +++ b/Source/SIMPLib/CoreFilters/ApplyImageTransforms.h @@ -0,0 +1,162 @@ +/* ============================================================================ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +/** + * @brief The ApplyImageTransforms class. See [Filter documentation](@ref applyimagetransforms) for details. + */ +class SIMPLib_EXPORT ApplyImageTransforms : public AbstractFilter +{ + Q_OBJECT + +public: + using Self = ApplyImageTransforms; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for ApplyImageTransforms + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ApplyImageTransforms + */ + static QString ClassName(); + + ~ApplyImageTransforms() override; + + /** + * @brief Setter property for ImageDataContainers + */ + void setImageDataContainers(const std::vector& value); + /** + * @brief Getter property for ImageDataContainers + * @return Value of ImageDataContainers + */ + std::vector getImageDataContainers() const; + + Q_PROPERTY(QStringVec ImageDataContainers READ getImageDataContainers WRITE setImageDataContainers) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + ApplyImageTransforms(); + + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + std::vector m_ImageDataContainers = {}; + +public: + /* Rule of 5: All special member functions should be defined if any are defined. + * CppCoreGuidelines #c21 if you define or delete any default operation define or delete them all + */ + ApplyImageTransforms(const ApplyImageTransforms&) = delete; // Copy Constructor Not Implemented + ApplyImageTransforms& operator=(const ApplyImageTransforms&) = delete; // Copy Assignment Not Implemented + ApplyImageTransforms(ApplyImageTransforms&&) = delete; // Move Constructor Not Implemented + ApplyImageTransforms& operator=(ApplyImageTransforms&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/CoreFilters/ArrayCalculator.cpp b/Source/SIMPLib/CoreFilters/ArrayCalculator.cpp index 911f47c4a7..a229db58cd 100644 --- a/Source/SIMPLib/CoreFilters/ArrayCalculator.cpp +++ b/Source/SIMPLib/CoreFilters/ArrayCalculator.cpp @@ -1,52 +1,51 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ArrayCalculator.h" -#include #include -#include +#include +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/CalculatorFilterParameter.h" #include "SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h" #include "SIMPLib/FilterParameters/ScalarTypeFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" #include "util/ABSOperator.h" #include "util/ACosOperator.h" @@ -131,15 +130,15 @@ itemPtr = CalculatorArray::New(arrayCast, ICalculatorArray::Array, !getInPreflight()); \ } +enum createdPathID : RenameDataPath::DataID_t +{ + DataArrayID = 1 +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- ArrayCalculator::ArrayCalculator() -: m_SelectedAttributeMatrix("", "", "") -, m_InfixEquation(QString()) -, m_CalculatedArray("", "", "Output") -, m_Units(Radians) -, m_ScalarType(SIMPL::ScalarTypes::Type::Double) { createSymbolMap(); @@ -155,19 +154,19 @@ ArrayCalculator::~ArrayCalculator() = default; // ----------------------------------------------------------------------------- void ArrayCalculator::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { AttributeMatrixSelectionFilterParameter::RequirementType req = AttributeMatrixSelectionFilterParameter::CreateRequirement(AttributeMatrix::Type::Any, IGeometry::Type::Any); - parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Cell Attribute Matrix", SelectedAttributeMatrix, FilterParameter::Parameter, ArrayCalculator, req)); + parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Cell Attribute Matrix", SelectedAttributeMatrix, FilterParameter::Category::Parameter, ArrayCalculator, req)); } - parameters.push_back(SIMPL_NEW_CALC_FP("Infix Expression", InfixEquation, FilterParameter::Parameter, ArrayCalculator)); + parameters.push_back(SIMPL_NEW_CALC_FP("Infix Expression", InfixEquation, FilterParameter::Category::Parameter, ArrayCalculator)); - parameters.push_back(SIMPL_NEW_SCALARTYPE_FP("Scalar Type", ScalarType, FilterParameter::CreatedArray, ArrayCalculator)); + parameters.push_back(SIMPL_NEW_SCALARTYPE_FP("Scalar Type", ScalarType, FilterParameter::Category::CreatedArray, ArrayCalculator)); { DataArrayCreationFilterParameter::RequirementType req = DataArrayCreationFilterParameter::CreateRequirement(AttributeMatrix::Type::Any, IGeometry::Type::Any); - parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Calculated Array", CalculatedArray, FilterParameter::CreatedArray, ArrayCalculator, req)); + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Calculated Array", CalculatedArray, FilterParameter::Category::CreatedArray, ArrayCalculator, req)); } setFilterParameters(parameters); @@ -219,20 +218,19 @@ void ArrayCalculator::initialize() // ----------------------------------------------------------------------------- void ArrayCalculator::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedAttributeMatrix, -301); - if(getErrorCondition() < 0) + getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedAttributeMatrix, -301); + if(getErrorCode() < 0) { return; } - if(m_InfixEquation.isEmpty() || m_InfixEquation.split(" ", QString::SkipEmptyParts).empty()) + if(m_InfixEquation.isEmpty() || m_InfixEquation.split(" ", QSTRING_SKIP_EMPTY_PARTS).empty()) { QString ss = QObject::tr("The infix expression is empty"); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::EMPTY_EQUATION)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::EMPTY_EQUATION), ss); return; } @@ -250,46 +248,43 @@ void ArrayCalculator::dataCheck() int errInt = static_cast(err); if(errInt < 0) { - setErrorCondition(errInt); - notifyErrorMessage(getHumanLabel(), errMsg, getErrorCondition()); + setErrorCondition(errInt, errMsg); return; } } if(!m_CalculatedArray.isValid()) { - setErrorCondition(-4675); QString ss = QObject::tr("The output path must be valid"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4675, ss); return; } AttributeMatrix::Pointer selectedAM = getDataContainerArray()->getAttributeMatrix(m_SelectedAttributeMatrix); - QVector cDims; + std::vector cDims; ICalculatorArray::ValueType resultType = ICalculatorArray::ValueType::Unknown; for(const auto& item1 : parsedInfix) - //for(int32_t i = 0; i < parsedInfix.size(); i++) + // for(int32_t i = 0; i < parsedInfix.size(); i++) { - //CalculatorItem::Pointer item1 = parsedInfix[i]; + // CalculatorItem::Pointer item1 = parsedInfix[i]; if(item1->isICalculatorArray()) { ICalculatorArray::Pointer array1 = std::dynamic_pointer_cast(item1); - if (item1->isArray()) + if(item1->isArray()) { - if(!cDims.isEmpty() && resultType == ICalculatorArray::ValueType::Array && cDims != array1->getArray()->getComponentDimensions()) + if(!cDims.empty() && resultType == ICalculatorArray::ValueType::Array && cDims != array1->getArray()->getComponentDimensions()) { QString ss = QObject::tr("Attribute Array symbols in the infix expression have mismatching component dimensions"); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCONSISTENT_COMP_DIMS)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCONSISTENT_COMP_DIMS), ss); return; } resultType = ICalculatorArray::ValueType::Array; cDims = array1->getArray()->getComponentDimensions(); } - else if (resultType == ICalculatorArray::ValueType::Unknown) + else if(resultType == ICalculatorArray::ValueType::Unknown) { resultType = ICalculatorArray::ValueType::Number; cDims = array1->getArray()->getComponentDimensions(); @@ -300,8 +295,7 @@ void ArrayCalculator::dataCheck() if(resultType == ICalculatorArray::ValueType::Unknown) { QString ss = QObject::tr("The expression does not have any arguments that simplify down to a number."); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::NO_NUMERIC_ARGUMENTS)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::NO_NUMERIC_ARGUMENTS), ss); return; } @@ -309,20 +303,16 @@ void ArrayCalculator::dataCheck() AttributeMatrix::Pointer calculatedAM = getDataContainerArray()->getAttributeMatrix(calculatedAMPath); if(nullptr == calculatedAM.get()) { - QString ss = QObject::tr("The AttributeMatrix at %1/%2 was not found") - .arg(calculatedAMPath.getDataContainerName(), calculatedAMPath.getAttributeMatrixName()); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::LOST_ATTR_MATRIX)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + QString ss = QObject::tr("The AttributeMatrix at %1/%2 was not found").arg(calculatedAMPath.getDataContainerName(), calculatedAMPath.getAttributeMatrixName()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::LOST_ATTR_MATRIX), ss); return; } - if(resultType == ICalculatorArray::ValueType::Number) { QString ss = QObject::tr("The result of the chosen expression will be a numeric value or contain one tuple." " This numeric value will be stored in an array with the number of tuples equal to 1"); - setWarningCondition(static_cast(CalculatorItem::WarningCode::NUMERIC_VALUE_WARNING)); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(static_cast(CalculatorItem::WarningCode::NUMERIC_VALUE_WARNING), ss); if(calculatedAM->getNumberOfTuples() > 1) { @@ -330,16 +320,14 @@ void ArrayCalculator::dataCheck() " expression evaluates to an array with a tuple count of 1, which does not match the output attribute matrix" " tuple count.") .arg(calculatedAMPath.getDataContainerName(), calculatedAMPath.getAttributeMatrixName()); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCORRECT_TUPLE_COUNT)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCORRECT_TUPLE_COUNT), ss); return; } } else if(calculatedAM->getNumberOfTuples() != selectedAM->getNumberOfTuples()) { QString ss = QObject::tr("The tuple count of the output Attribute Matrix is not equal to the tuple count of the selected Attribute Matrix"); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCORRECT_TUPLE_COUNT)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCORRECT_TUPLE_COUNT), ss); return; } @@ -352,68 +340,52 @@ void ArrayCalculator::dataCheck() switch(m_ScalarType) { case SIMPL::ScalarTypes::Type::Int8: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::UInt8: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::Int16: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::UInt16: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::Int32: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::UInt32: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::Int64: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::UInt64: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::Float: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::Double: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; case SIMPL::ScalarTypes::Type::Bool: - getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims); + getDataContainerArray()->createNonPrereqArrayFromPath(this, m_CalculatedArray, 0, cDims, "", DataArrayID); break; default: QString ss = QObject::tr("The output array type is not valid. No DataArray could be created."); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::InvalidOutputArrayType)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::InvalidOutputArrayType), ss); return; } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void ArrayCalculator::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ArrayCalculator::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -429,7 +401,7 @@ void ArrayCalculator::execute() int totalItems = rpn.size(); for(int rpnCount = 0; rpnCount < totalItems; rpnCount++) { - notifyStatusMessage(getMessagePrefix(), getHumanLabel(), "Computing Operator " + QString::number(rpnCount + 1) + "/" + QString::number(totalItems)); + notifyStatusMessage("Computing Operator " + QString::number(rpnCount + 1) + "/" + QString::number(totalItems)); CalculatorItem::Pointer rpnItem = rpn[rpnCount]; ICalculatorArray::Pointer calcArray = std::dynamic_pointer_cast(rpnItem); @@ -444,7 +416,7 @@ void ArrayCalculator::execute() CalculatorOperator::Pointer rpnOperator = std::dynamic_pointer_cast(rpnItem); rpnOperator->calculate(this, m_CalculatedArray, m_ExecutionStack); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -461,8 +433,7 @@ void ArrayCalculator::execute() if(m_ExecutionStack.size() != 1) { QString ss = QObject::tr("The chosen infix equation is not a valid equation."); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::INVALID_EQUATION)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::INVALID_EQUATION), ss); return; } if(!m_ExecutionStack.isEmpty()) @@ -472,35 +443,37 @@ void ArrayCalculator::execute() if(arrayItem != ICalculatorArray::NullPointer()) { - IDataArray::Pointer resultArray = IDataArray::NullPointer(); - resultArray = arrayItem->getArray(); + IDataArray::Pointer resultArray = arrayItem->getArray(); - IDataArray::Pointer resultTypeArray = IDataArray::NullPointer(); - resultTypeArray = convertArrayType(resultArray, m_ScalarType); + IDataArray::Pointer resultTypeArray = convertArrayType(resultArray, m_ScalarType); DataArrayPath createdAMPath(m_CalculatedArray.getDataContainerName(), m_CalculatedArray.getAttributeMatrixName(), ""); AttributeMatrix::Pointer createdAM = getDataContainerArray()->getAttributeMatrix(createdAMPath); if(nullptr != createdAM) { resultTypeArray->setName(m_CalculatedArray.getDataArrayName()); - createdAM->addAttributeArray(resultTypeArray->getName(), resultTypeArray); + if(!createdAM->insertOrAssign(resultTypeArray)) + { + QString ss = QObject::tr("Error inserting Output Array into Attribute Matrix"); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::AttributeMatrixInsertionError), ss); + return; + } } } else { QString ss = QObject::tr("Unexpected output item from chosen infix expression; the output item must be an array\n" "Please contact the DREAM.3D developers for more information"); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::UNEXPECTED_OUTPUT)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::UNEXPECTED_OUTPUT), ss); return; } - } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template IDataArray::Pointer convertArray(const DoubleArrayType::Pointer& inputArray) +template +IDataArray::Pointer convertArray(const DoubleArrayType::Pointer& inputArray) { if(nullptr == inputArray) { @@ -509,7 +482,7 @@ template IDataArray::Pointer convertArray(const DoubleArrayType::Poi double* rawInputarray = inputArray->getPointer(0); - typename DataArray::Pointer convertedArrayPtr = DataArray::CreateArray(inputArray->getNumberOfTuples(), inputArray->getComponentDimensions(), inputArray->getName()); + typename DataArray::Pointer convertedArrayPtr = DataArray::CreateArray(inputArray->getNumberOfTuples(), inputArray->getComponentDimensions(), inputArray->getName(), true); T* rawOutputArray = convertedArrayPtr->getPointer(0); int count = inputArray->getSize(); @@ -684,7 +657,7 @@ QVector ArrayCalculator::parseInfixEquation() { int err = 0; - AttributeMatrix::Pointer selectedAM = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedAttributeMatrix, err); + AttributeMatrix::Pointer selectedAM = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedAttributeMatrix, err); QVector itemList = getRegularExpressionMatches(); @@ -746,8 +719,7 @@ QVector ArrayCalculator::parseInfixEquation() else { QString ss = QObject::tr("An unrecognized item '%1' was found in the chosen infix expression").arg(strItem); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::UNRECOGNIZED_ITEM)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::UNRECOGNIZED_ITEM), ss); return QVector(); } } @@ -812,7 +784,7 @@ void ArrayCalculator::parseMinusSign(QString token, QVector& parsedInfix, double number) { // This is a number, so create an array with numOfTuples equal to 1 and set the value into it - DoubleArrayType::Pointer ptr = DoubleArrayType::CreateArray(1, QVector(1, 1), "INTERNAL_USE_ONLY_NumberArray"); + DoubleArrayType::Pointer ptr = DoubleArrayType::CreateArray(1, std::vector(1, 1), "INTERNAL_USE_ONLY_NumberArray", true); ptr->setValue(0, number); CalculatorItem::Pointer itemPtr = CalculatorArray::New(ptr, ICalculatorArray::Number, !getInPreflight()); parsedInfix.push_back(itemPtr); @@ -832,20 +804,17 @@ bool ArrayCalculator::parseIndexOperator(QString token, QVector(CalculatorItem::ErrorCode::ORPHANED_COMPONENT); if(idx < 0) { - setErrorCondition(errCode); - notifyErrorMessage(getHumanLabel(), errorMsg, getErrorCondition()); + setErrorCondition(errCode, errorMsg); return false; } if(!parsedInfix[idx]->isICalculatorArray()) { - setErrorCondition(errCode); - notifyErrorMessage(getHumanLabel(), errorMsg, getErrorCondition()); + setErrorCondition(errCode, errorMsg); return false; } if(parsedInfix[idx]->isNumber()) { - setErrorCondition(errCode); - notifyErrorMessage(getHumanLabel(), errorMsg, getErrorCondition()); + setErrorCondition(errCode, errorMsg); return false; } @@ -857,8 +826,7 @@ bool ArrayCalculator::parseIndexOperator(QString token, QVector(CalculatorItem::ErrorCode::INVALID_COMPONENT)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::INVALID_COMPONENT), ss); return false; } @@ -866,8 +834,7 @@ bool ArrayCalculator::parseIndexOperator(QString token, QVector= calcArray->getArray()->getNumberOfComponents()) { QString ss = QObject::tr("'%1' has an component index that is out of range").arg(calcArray->getArray()->getName()); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::COMPONENT_OUT_OF_RANGE)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::COMPONENT_OUT_OF_RANGE), ss); return false; } @@ -920,7 +887,7 @@ bool ArrayCalculator::parseCommaOperator(QString token, QVector& parsedInfix, AttributeMatrix::Pointer selectedAM) +bool ArrayCalculator::parseArray(QString token, QVector& parsedInfix, const AttributeMatrixShPtrType& selectedAM) { int firstArray_NumTuples = -1; QString firstArray_Name = ""; @@ -929,8 +896,7 @@ bool ArrayCalculator::parseArray(QString token, QVector if(!selectedAM->getAttributeArrayNames().contains(token)) { QString ss = QObject::tr("The item '%1' is not the name of any valid array in the selected Attribute Matrix").arg(token); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::INVALID_ARRAY_NAME)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::INVALID_ARRAY_NAME), ss); return false; } @@ -943,8 +909,7 @@ bool ArrayCalculator::parseArray(QString token, QVector else if(dataArray->getNumberOfTuples() != firstArray_NumTuples) { QString ss = QObject::tr("Arrays '%1' and '%2' in the infix expression have an inconsistent number of tuples").arg(firstArray_Name).arg(dataArray->getName()); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCONSISTENT_TUPLES)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::INCONSISTENT_TUPLES), ss); return false; } @@ -1035,15 +1000,14 @@ QVector ArrayCalculator::toRPN(QVector(item)) { QString ss = QObject::tr("One or more parentheses are mismatched in the chosen infix expression '%1'").arg(m_InfixEquation); - setErrorCondition(static_cast(CalculatorItem::ErrorCode::MISMATCHED_PARENTHESES)); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(static_cast(CalculatorItem::ErrorCode::MISMATCHED_PARENTHESES), ss); return QVector(); } rpnEquation.push_back(item); } - delete oneComponent; + delete oneComponent; return rpnEquation; } @@ -1056,8 +1020,8 @@ void ArrayCalculator::checkForAmbiguousArrayName(QString strItem, QString warnin if(getInPreflight()) { int err = 0; - AttributeMatrix::Pointer selectedAM = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedAttributeMatrix, err); - if(getErrorCondition() < 0) + AttributeMatrix::Pointer selectedAM = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedAttributeMatrix, err); + if(getErrorCode() < 0) { return; } @@ -1065,9 +1029,8 @@ void ArrayCalculator::checkForAmbiguousArrayName(QString strItem, QString warnin { IDataArray::Pointer dataArray = selectedAM->getAttributeArray(strItem); - setWarningCondition(static_cast(CalculatorItem::WarningCode::AMBIGUOUS_NAME_WARNING)); warningMsg.append("\nTo treat this item as an array name, please add double quotes around the item (i.e. \"" + strItem + "\")."); - notifyWarningMessage(getHumanLabel(), warningMsg, getWarningCondition()); + setWarningCondition(static_cast(CalculatorItem::WarningCode::AMBIGUOUS_NAME_WARNING), warningMsg); } } } @@ -1089,7 +1052,7 @@ AbstractFilter::Pointer ArrayCalculator::newFilterInstance(bool copyFilterParame // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ArrayCalculator::getCompiledLibraryName() const +QString ArrayCalculator::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -1097,7 +1060,7 @@ const QString ArrayCalculator::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ArrayCalculator::getBrandingString() const +QString ArrayCalculator::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -1105,7 +1068,7 @@ const QString ArrayCalculator::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ArrayCalculator::getFilterVersion() const +QString ArrayCalculator::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -1116,7 +1079,7 @@ const QString ArrayCalculator::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ArrayCalculator::getGroupName() const +QString ArrayCalculator::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -1124,7 +1087,7 @@ const QString ArrayCalculator::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid ArrayCalculator::getUuid() +QUuid ArrayCalculator::getUuid() const { return QUuid("{7ff0ebb3-7b0d-5ff7-b9d8-5147031aca10}"); } @@ -1132,7 +1095,7 @@ const QUuid ArrayCalculator::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ArrayCalculator::getSubGroupName() const +QString ArrayCalculator::getSubGroupName() const { return SIMPL::FilterSubGroups::GenerationFilters; } @@ -1140,7 +1103,96 @@ const QString ArrayCalculator::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ArrayCalculator::getHumanLabel() const +QString ArrayCalculator::getHumanLabel() const { return "Attribute Array Calculator"; } + +// ----------------------------------------------------------------------------- +ArrayCalculator::Pointer ArrayCalculator::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr ArrayCalculator::New() +{ + struct make_shared_enabler : public ArrayCalculator + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString ArrayCalculator::getNameOfClass() const +{ + return QString("ArrayCalculator"); +} + +// ----------------------------------------------------------------------------- +QString ArrayCalculator::ClassName() +{ + return QString("ArrayCalculator"); +} + +// ----------------------------------------------------------------------------- +void ArrayCalculator::setSelectedAttributeMatrix(const DataArrayPath& value) +{ + m_SelectedAttributeMatrix = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ArrayCalculator::getSelectedAttributeMatrix() const +{ + return m_SelectedAttributeMatrix; +} + +// ----------------------------------------------------------------------------- +void ArrayCalculator::setInfixEquation(const QString& value) +{ + m_InfixEquation = value; +} + +// ----------------------------------------------------------------------------- +QString ArrayCalculator::getInfixEquation() const +{ + return m_InfixEquation; +} + +// ----------------------------------------------------------------------------- +void ArrayCalculator::setCalculatedArray(const DataArrayPath& value) +{ + m_CalculatedArray = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ArrayCalculator::getCalculatedArray() const +{ + return m_CalculatedArray; +} + +// ----------------------------------------------------------------------------- +void ArrayCalculator::setUnits(const ArrayCalculator::AngleUnits& value) +{ + m_Units = value; +} + +// ----------------------------------------------------------------------------- +ArrayCalculator::AngleUnits ArrayCalculator::getUnits() const +{ + return m_Units; +} + +// ----------------------------------------------------------------------------- +void ArrayCalculator::setScalarType(SIMPL::ScalarTypes::Type value) +{ + m_ScalarType = value; +} + +// ----------------------------------------------------------------------------- +SIMPL::ScalarTypes::Type ArrayCalculator::getScalarType() const +{ + return m_ScalarType; +} diff --git a/Source/SIMPLib/CoreFilters/ArrayCalculator.h b/Source/SIMPLib/CoreFilters/ArrayCalculator.h index eb08a233a0..248dafae4c 100644 --- a/Source/SIMPLib/CoreFilters/ArrayCalculator.h +++ b/Source/SIMPLib/CoreFilters/ArrayCalculator.h @@ -1,275 +1,324 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +class IDataArray; +using IDataArrayShPtrType = std::shared_ptr; #include "util/ICalculatorArray.h" +class AttributeMatrix; +using AttributeMatrixShPtrType = std::shared_ptr; +class CalculatorItem; +using CalculatorItemShPtrType = std::shared_ptr; + /** * @brief The ArrayCalculator class. See [Filter documentation](@ref createdatacontainer) for details. */ class SIMPLib_EXPORT ArrayCalculator : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(ArrayCalculator SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath SelectedAttributeMatrix READ getSelectedAttributeMatrix WRITE setSelectedAttributeMatrix) - PYB11_PROPERTY(QString InfixEquation READ getInfixEquation WRITE setInfixEquation) - PYB11_PROPERTY(DataArrayPath CalculatedArray READ getCalculatedArray WRITE setCalculatedArray) - PYB11_PROPERTY(AngleUnits Units READ getUnits WRITE setUnits) - PYB11_PROPERTY(SIMPL::ScalarTypes::Type ScalarType READ getScalarType WRITE setScalarType) - - public: - enum AngleUnits - { - Degrees, - Radians - }; - - Q_ENUMS(AngleUnits) - - SIMPL_SHARED_POINTERS(ArrayCalculator) - SIMPL_FILTER_NEW_MACRO(ArrayCalculator) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ArrayCalculator, AbstractFilter) - - SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedAttributeMatrix) - Q_PROPERTY(DataArrayPath SelectedAttributeMatrix READ getSelectedAttributeMatrix WRITE setSelectedAttributeMatrix) - - SIMPL_FILTER_PARAMETER(QString, InfixEquation) - Q_PROPERTY(QString InfixEquation READ getInfixEquation WRITE setInfixEquation) - - SIMPL_FILTER_PARAMETER(DataArrayPath, CalculatedArray) - Q_PROPERTY(DataArrayPath CalculatedArray READ getCalculatedArray WRITE setCalculatedArray) - - SIMPL_FILTER_PARAMETER(AngleUnits, Units) - Q_PROPERTY(AngleUnits Units READ getUnits WRITE setUnits) - - SIMPL_FILTER_PARAMETER(SIMPL::ScalarTypes::Type, ScalarType) - Q_PROPERTY(SIMPL::ScalarTypes::Type ScalarType READ getScalarType WRITE setScalarType) - - ~ArrayCalculator() override; - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief readFilterParametersFromJson Reads the filter parameters from a file - * @param reader Reader that is used to read the parameters from a file - */ - void readFilterParameters(QJsonObject &obj) override; - - /** - * @brief writeFilterParametersToJson Writes the filter parameters to a file - * @param root The root json object - */ - void writeFilterParameters(QJsonObject &obj) const override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - ArrayCalculator(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - /** - * @brief Converts the given data array to one of the specified scalar type - * @param inputArray - * @param scalarType - * @return - */ - IDataArray::Pointer convertArrayType(const IDataArray::Pointer &inputArray, SIMPL::ScalarTypes::Type scalarType); - - - private: - QMap m_SymbolMap; - QStack m_ExecutionStack; - - void createSymbolMap(); - - QVector parseInfixEquation(); - QVector toRPN(QVector infixEquation); - - void checkForAmbiguousArrayName(QString itemStr, QString warningMsg); - - /** - * @brief getRegularExpressionMatches - * @return - */ - QVector getRegularExpressionMatches(); - - /** - * @brief parseNumberArray - * @param token - * @param parsedInfix - */ - void parseNumericValue(QString token, QVector& parsedInfix, double number); - - /** - * @brief parseMinusSign - * @param strItem - * @param parsedInfix - * @param loopIdx - */ - void parseMinusSign(QString strItem, QVector& parsedInfix, int loopIdx); - - /** - * @brief parseIndexOperator - * @param token - * @param parsedInfix - * @param number - */ - bool parseIndexOperator(QString token, QVector& parsedInfix); - - /** - * @brief parseCommaOperator - * @param token - * @param parsedInfix - * @return - */ - bool parseCommaOperator(QString token, QVector& parsedInfix); - - /** - * @brief parseArray - * @param token - * @param parsedInfix - * @param selectedAM - * @return - */ - bool parseArray(QString token, QVector& parsedInfix, AttributeMatrix::Pointer selectedAM); - - public: - ArrayCalculator(const ArrayCalculator&) = delete; // Copy Constructor Not Implemented - ArrayCalculator(ArrayCalculator&&) = delete; // Move Constructor Not Implemented - ArrayCalculator& operator=(const ArrayCalculator&) = delete; // Copy Assignment Not Implemented - ArrayCalculator& operator=(ArrayCalculator&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ArrayCalculator SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(ArrayCalculator) + PYB11_FILTER_NEW_MACRO(ArrayCalculator) + PYB11_PROPERTY(DataArrayPath SelectedAttributeMatrix READ getSelectedAttributeMatrix WRITE setSelectedAttributeMatrix) + PYB11_PROPERTY(QString InfixEquation READ getInfixEquation WRITE setInfixEquation) + PYB11_PROPERTY(DataArrayPath CalculatedArray READ getCalculatedArray WRITE setCalculatedArray) + PYB11_PROPERTY(ArrayCalculator::AngleUnits Units READ getUnits WRITE setUnits) + PYB11_PROPERTY(SIMPL::ScalarTypes::Type ScalarType READ getScalarType WRITE setScalarType) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + enum AngleUnits + { + Degrees, + Radians + }; + + Q_ENUMS(AngleUnits) + + using Self = ArrayCalculator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for ArrayCalculator + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ArrayCalculator + */ + static QString ClassName(); + + /** + * @brief Setter property for SelectedAttributeMatrix + */ + void setSelectedAttributeMatrix(const DataArrayPath& value); + /** + * @brief Getter property for SelectedAttributeMatrix + * @return Value of SelectedAttributeMatrix + */ + DataArrayPath getSelectedAttributeMatrix() const; + + Q_PROPERTY(DataArrayPath SelectedAttributeMatrix READ getSelectedAttributeMatrix WRITE setSelectedAttributeMatrix) + + /** + * @brief Setter property for InfixEquation + */ + void setInfixEquation(const QString& value); + /** + * @brief Getter property for InfixEquation + * @return Value of InfixEquation + */ + QString getInfixEquation() const; + + Q_PROPERTY(QString InfixEquation READ getInfixEquation WRITE setInfixEquation) + + /** + * @brief Setter property for CalculatedArray + */ + void setCalculatedArray(const DataArrayPath& value); + /** + * @brief Getter property for CalculatedArray + * @return Value of CalculatedArray + */ + DataArrayPath getCalculatedArray() const; + + Q_PROPERTY(DataArrayPath CalculatedArray READ getCalculatedArray WRITE setCalculatedArray) + + /** + * @brief Setter property for Units + */ + void setUnits(const ArrayCalculator::AngleUnits& value); + /** + * @brief Getter property for Units + * @return Value of Units + */ + ArrayCalculator::AngleUnits getUnits() const; + + Q_PROPERTY(AngleUnits Units READ getUnits WRITE setUnits) + + /** + * @brief Setter property for ScalarType + */ + void setScalarType(SIMPL::ScalarTypes::Type value); + /** + * @brief Getter property for ScalarType + * @return Value of ScalarType + */ + SIMPL::ScalarTypes::Type getScalarType() const; + + Q_PROPERTY(SIMPL::ScalarTypes::Type ScalarType READ getScalarType WRITE setScalarType) + + ~ArrayCalculator() override; + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief readFilterParametersFromJson Reads the filter parameters from a file + * @param reader Reader that is used to read the parameters from a file + */ + void readFilterParameters(QJsonObject& obj) override; + + /** + * @brief writeFilterParametersToJson Writes the filter parameters to a file + * @param root The root json object + */ + void writeFilterParameters(QJsonObject& obj) const override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + ArrayCalculator(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + + /** + * @brief Converts the given data array to one of the specified scalar type + * @param inputArray + * @param scalarType + * @return + */ + IDataArrayShPtrType convertArrayType(const IDataArrayShPtrType& inputArray, SIMPL::ScalarTypes::Type scalarType); + +private: + DataArrayPath m_SelectedAttributeMatrix = {"", "", ""}; + QString m_InfixEquation = {QString()}; + DataArrayPath m_CalculatedArray = {"", "", "Output"}; + ArrayCalculator::AngleUnits m_Units = {Radians}; + SIMPL::ScalarTypes::Type m_ScalarType = {SIMPL::ScalarTypes::Type::Double}; + + QMap m_SymbolMap; + QStack m_ExecutionStack; + + void createSymbolMap(); + + QVector parseInfixEquation(); + QVector toRPN(QVector infixEquation); + + void checkForAmbiguousArrayName(QString itemStr, QString warningMsg); + + /** + * @brief getRegularExpressionMatches + * @return + */ + QVector getRegularExpressionMatches(); + + /** + * @brief parseNumberArray + * @param token + * @param parsedInfix + */ + void parseNumericValue(QString token, QVector& parsedInfix, double number); + + /** + * @brief parseMinusSign + * @param strItem + * @param parsedInfix + * @param loopIdx + */ + void parseMinusSign(QString strItem, QVector& parsedInfix, int loopIdx); + + /** + * @brief parseIndexOperator + * @param token + * @param parsedInfix + * @param number + */ + bool parseIndexOperator(QString token, QVector& parsedInfix); + + /** + * @brief parseCommaOperator + * @param token + * @param parsedInfix + * @return + */ + bool parseCommaOperator(QString token, QVector& parsedInfix); + + /** + * @brief parseArray + * @param token + * @param parsedInfix + * @param selectedAM + * @return + */ + bool parseArray(QString token, QVector& parsedInfix, const AttributeMatrixShPtrType& selectedAM); + +public: + ArrayCalculator(const ArrayCalculator&) = delete; // Copy Constructor Not Implemented + ArrayCalculator(ArrayCalculator&&) = delete; // Move Constructor Not Implemented + ArrayCalculator& operator=(const ArrayCalculator&) = delete; // Copy Assignment Not Implemented + ArrayCalculator& operator=(ArrayCalculator&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/Breakpoint.cpp b/Source/SIMPLib/CoreFilters/Breakpoint.cpp index 0ae48bd92a..31577469f8 100644 --- a/Source/SIMPLib/CoreFilters/Breakpoint.cpp +++ b/Source/SIMPLib/CoreFilters/Breakpoint.cpp @@ -1,45 +1,44 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "Breakpoint.h" -#include +#include +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" -#include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- // @@ -56,7 +55,7 @@ Breakpoint::~Breakpoint() = default; // ----------------------------------------------------------------------------- void Breakpoint::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; setFilterParameters(parameters); } @@ -83,22 +82,8 @@ void Breakpoint::initialize() // ----------------------------------------------------------------------------- void Breakpoint::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void Breakpoint::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -115,11 +100,11 @@ void Breakpoint::execute() void Breakpoint::pause() { // Pause the pipeline at this point until someone chooses to resume - emit pipelineHasPaused(); + Q_EMIT pipelineHasPaused(); m_Mutex.lock(); QString ss = "The pipeline is paused - Press \"Resume\" to continue execution."; - notifyStatusMessage(getMessagePrefix(), getHumanLabel(), ss); + notifyStatusMessage(ss); m_WaitCondition.wait(&m_Mutex); m_Mutex.unlock(); } @@ -131,7 +116,7 @@ void Breakpoint::resumePipeline() { // Resume the pipeline m_WaitCondition.wakeAll(); - emit pipelineHasResumed(); + Q_EMIT pipelineHasResumed(); } // ----------------------------------------------------------------------------- @@ -150,7 +135,7 @@ AbstractFilter::Pointer Breakpoint::newFilterInstance(bool copyFilterParameters) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString Breakpoint::getCompiledLibraryName() const +QString Breakpoint::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -158,7 +143,7 @@ const QString Breakpoint::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString Breakpoint::getBrandingString() const +QString Breakpoint::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -166,7 +151,7 @@ const QString Breakpoint::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString Breakpoint::getFilterVersion() const +QString Breakpoint::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -177,7 +162,7 @@ const QString Breakpoint::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString Breakpoint::getGroupName() const +QString Breakpoint::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -185,7 +170,7 @@ const QString Breakpoint::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid Breakpoint::getUuid() +QUuid Breakpoint::getUuid() const { return QUuid("{a6d82abf-7043-51c0-88ed-b8d0153bf8ab}"); } @@ -193,7 +178,7 @@ const QUuid Breakpoint::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString Breakpoint::getSubGroupName() const +QString Breakpoint::getSubGroupName() const { return SIMPL::FilterSubGroups::MiscFilters; } @@ -201,7 +186,36 @@ const QString Breakpoint::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString Breakpoint::getHumanLabel() const +QString Breakpoint::getHumanLabel() const { return "Breakpoint"; } + +// ----------------------------------------------------------------------------- +Breakpoint::Pointer Breakpoint::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr Breakpoint::New() +{ + struct make_shared_enabler : public Breakpoint + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString Breakpoint::getNameOfClass() const +{ + return QString("Breakpoint"); +} + +// ----------------------------------------------------------------------------- +QString Breakpoint::ClassName() +{ + return QString("Breakpoint"); +} diff --git a/Source/SIMPLib/CoreFilters/Breakpoint.h b/Source/SIMPLib/CoreFilters/Breakpoint.h index 6be9c4091e..af7943246a 100644 --- a/Source/SIMPLib/CoreFilters/Breakpoint.h +++ b/Source/SIMPLib/CoreFilters/Breakpoint.h @@ -1,45 +1,47 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + +#include #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The Breakpoint class. See [Filter documentation](@ref breakpoint) for details. @@ -47,145 +49,146 @@ class SIMPLib_EXPORT Breakpoint : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(Breakpoint SUPERCLASS AbstractFilter) - - public: - SIMPL_SHARED_POINTERS(Breakpoint) - SIMPL_FILTER_NEW_MACRO(Breakpoint) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(Breakpoint, AbstractFilter) - - ~Breakpoint() override; - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - public slots: - /** - * @brief resumePipeline Resumes the pipeline - */ - void resumePipeline(); - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - /** - * @brief pipelineHasPaused Emitted when the pipeline needs to be paused - */ - void pipelineHasPaused(); - - /** - * @brief pipelineHasResumed Emitted when the pipeline needs to be resumed - */ - void pipelineHasResumed(); - - protected: - Breakpoint(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - /** - * @brief pause Pauses the pipeline - */ - void pause(); - - private: - QWaitCondition m_WaitCondition; - QMutex m_Mutex; - - public: - Breakpoint(const Breakpoint&) = delete; // Copy Constructor Not Implemented - Breakpoint(Breakpoint&&) = delete; // Move Constructor Not Implemented - Breakpoint& operator=(const Breakpoint&) = delete; // Copy Assignment Not Implemented - Breakpoint& operator=(Breakpoint&&) = delete; // Move Assignment Not Implemented -}; + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(Breakpoint SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(Breakpoint) + PYB11_FILTER_NEW_MACRO(Breakpoint) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = Breakpoint; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for Breakpoint + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for Breakpoint + */ + static QString ClassName(); + + ~Breakpoint() override; + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +public Q_SLOTS: + /** + * @brief resumePipeline Resumes the pipeline + */ + void resumePipeline(); + +Q_SIGNALS: + /** + * @brief pipelineHasPaused Emitted when the pipeline needs to be paused + */ + void pipelineHasPaused(); + + /** + * @brief pipelineHasResumed Emitted when the pipeline needs to be resumed + */ + void pipelineHasResumed(); + +protected: + Breakpoint(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + + /** + * @brief pause Pauses the pipeline + */ + void pause(); + +private: + QWaitCondition m_WaitCondition; + QMutex m_Mutex; + +public: + Breakpoint(const Breakpoint&) = delete; // Copy Constructor Not Implemented + Breakpoint(Breakpoint&&) = delete; // Move Constructor Not Implemented + Breakpoint& operator=(const Breakpoint&) = delete; // Copy Assignment Not Implemented + Breakpoint& operator=(Breakpoint&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/CoreFilters/CombineAttributeArrays.cpp b/Source/SIMPLib/CoreFilters/CombineAttributeArrays.cpp index de728baadf..d549df3163 100644 --- a/Source/SIMPLib/CoreFilters/CombineAttributeArrays.cpp +++ b/Source/SIMPLib/CoreFilters/CombineAttributeArrays.cpp @@ -1,53 +1,62 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CombineAttributeArrays.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" +#include "SIMPLib/DataArrays/IDataArray.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/BooleanFilterParameter.h" #include "SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + CombinedArrayID = 1 +}; /** * @brief The CombineAttributeArraysTemplatePrivate class is a templated private implementation that deals with * combining the various input arrays into one contiguous array */ -template class CombineAttributeArraysTemplatePrivate +template +class CombineAttributeArraysTemplatePrivate { public: typedef DataArray DataArrayType; @@ -161,21 +170,15 @@ template class CombineAttributeArraysTemplatePrivate } } -private: - CombineAttributeArraysTemplatePrivate(const CombineAttributeArraysTemplatePrivate&); // Copy Constructor Not Implemented - void operator=(const CombineAttributeArraysTemplatePrivate&); // Move assignment Not Implemented +public: + CombineAttributeArraysTemplatePrivate(const CombineAttributeArraysTemplatePrivate&) = delete; // Copy Constructor Not Implemented + void operator=(const CombineAttributeArraysTemplatePrivate&) = delete; // Move assignment Not Implemented }; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -CombineAttributeArrays::CombineAttributeArrays() -: m_SelectedDataArrayPaths(QVector()) -, m_StackedDataArrayName(SIMPL::GeneralData::CombinedData) -, m_NormalizeData(false) -, m_MoveValues(false) -{ -} +CombineAttributeArrays::CombineAttributeArrays() = default; // ----------------------------------------------------------------------------- // @@ -187,42 +190,29 @@ CombineAttributeArrays::~CombineAttributeArrays() = default; // ----------------------------------------------------------------------------- void CombineAttributeArrays::setupFilterParameters() { - FilterParameterVector parameters; - parameters.push_back(SIMPL_NEW_BOOL_FP("Normalize Data", NormalizeData, FilterParameter::Parameter, CombineAttributeArrays)); - parameters.push_back(SIMPL_NEW_BOOL_FP("Move Data", MoveValues, FilterParameter::Parameter, CombineAttributeArrays)); + FilterParameterVectorType parameters; + parameters.push_back(SIMPL_NEW_BOOL_FP("Normalize Data", NormalizeData, FilterParameter::Category::Parameter, CombineAttributeArrays)); + parameters.push_back(SIMPL_NEW_BOOL_FP("Move Data", MoveValues, FilterParameter::Category::Parameter, CombineAttributeArrays)); { MultiDataArraySelectionFilterParameter::RequirementType req = MultiDataArraySelectionFilterParameter::CreateRequirement(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, AttributeMatrix::Type::Any, IGeometry::Type::Any); - parameters.push_back(SIMPL_NEW_MDA_SELECTION_FP("Attribute Arrays to Combine", SelectedDataArrayPaths, FilterParameter::RequiredArray, CombineAttributeArrays, req)); + parameters.push_back(SIMPL_NEW_MDA_SELECTION_FP("Attribute Arrays to Combine", SelectedDataArrayPaths, FilterParameter::Category::RequiredArray, CombineAttributeArrays, req)); } - parameters.push_back(SIMPL_NEW_STRING_FP("Combined Data", StackedDataArrayName, FilterParameter::CreatedArray, CombineAttributeArrays)); + parameters.push_back(SIMPL_NEW_STRING_FP("Combined Data", StackedDataArrayName, FilterParameter::Category::CreatedArray, CombineAttributeArrays)); setFilterParameters(parameters); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void CombineAttributeArrays::readFilterParameters(AbstractFilterParametersReader* reader, int index) -{ - reader->openFilterGroup(this, index); - setSelectedDataArrayPaths(reader->readDataArrayPathVector("SelectedDataArrayPaths", getSelectedDataArrayPaths())); - setStackedDataArrayName(reader->readString("StackedDataArrayName", getStackedDataArrayName())); - setNormalizeData(reader->readValue("NormalizeData", getNormalizeData())); - setMoveValues(reader->readValue("MoveValues", getMoveValues())); - reader->closeFilterGroup(); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -template void verifyArrayList(AbstractFilter* filter, QVector ptrArray) +template +void verifyArrayList(AbstractFilter* filter, QVector ptrArray) { for(QVector::iterator it = ptrArray.begin(); it != ptrArray.end(); ++it) { if(!TemplateHelpers::CanDynamicCast>()((*it).lock())) { - filter->setErrorCondition(-90000); - filter->notifyErrorMessage(filter->getHumanLabel(), "Selected Attribute Arrays must all be of the same type", filter->getErrorCondition()); + filter->setErrorCondition(-90000, "Selected Attribute Arrays must all be of the same type"); return; } } @@ -242,32 +232,30 @@ void CombineAttributeArrays::dataCheck() { m_SelectedWeakPtrVector.clear(); - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(getSelectedDataArrayPaths().size() < 2) { - setErrorCondition(-11001); QString ss = QObject::tr("At least two Attribute Array must be selected"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11001, ss); return; } - QVector paths = getSelectedDataArrayPaths(); + std::vector paths = getSelectedDataArrayPaths(); if(!DataArrayPath::ValidateVector(paths)) { - setErrorCondition(-11002); QString ss = QObject::tr("There are Attribute Arrays selected that are not contained in the same Attribute Matrix. All selected Attribute Arrays must belong to the same Attribute Matrix"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } int32_t totalComps = 0; - for(int32_t i = 0; i < paths.count(); i++) + for(int32_t i = 0; i < paths.size(); i++) { DataArrayPath path = paths.at(i); - IDataArray::WeakPointer ptr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, path); + IDataArray::WeakPointer ptr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, path); if(nullptr != ptr.lock()) { m_SelectedWeakPtrVector.push_back(ptr); @@ -275,23 +263,23 @@ void CombineAttributeArrays::dataCheck() totalComps += numComps; } } - if(! m_SelectedWeakPtrVector.isEmpty() ) + if(!m_SelectedWeakPtrVector.isEmpty()) { EXECUTE_FUNCTION_TEMPLATE(this, verifyArrayList, m_SelectedWeakPtrVector[0].lock(), this, m_SelectedWeakPtrVector) } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - QVector cDims(1, totalComps); + std::vector cDims(1, totalComps); DataArrayPath tempPath(getSelectedDataArrayPaths()[0].getDataContainerName(), getSelectedDataArrayPaths()[0].getAttributeMatrixName(), getStackedDataArrayName()); - m_StackedDataPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, m_SelectedWeakPtrVector[0].lock()); + m_StackedDataPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, m_SelectedWeakPtrVector[0].lock(), CombinedArrayID); if(getMoveValues() && getInPreflight()) { - QVector paths = getSelectedDataArrayPaths(); + std::vector paths = getSelectedDataArrayPaths(); for(DataArrayPath path : paths) { AttributeMatrix::Pointer attrMat = getDataContainerArray()->getAttributeMatrix(path); @@ -300,28 +288,13 @@ void CombineAttributeArrays::dataCheck() } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void CombineAttributeArrays::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void CombineAttributeArrays::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -330,8 +303,8 @@ void CombineAttributeArrays::execute() if(getMoveValues()) { - QVector paths = getSelectedDataArrayPaths(); - for(DataArrayPath path : paths) + std::vector paths = getSelectedDataArrayPaths(); + for(const DataArrayPath& path : paths) { AttributeMatrix::Pointer attrMat = getDataContainerArray()->getAttributeMatrix(path); attrMat->removeAttributeArray(path.getDataArrayName()); @@ -339,6 +312,19 @@ void CombineAttributeArrays::execute() } } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::list CombineAttributeArrays::getDeletedPaths() +{ + if(getMoveValues()) + { + std::vector tList = getSelectedDataArrayPaths(); + return std::list(tList.cbegin(), tList.cend()); + } + return std::list(); +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -355,7 +341,7 @@ AbstractFilter::Pointer CombineAttributeArrays::newFilterInstance(bool copyFilte // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CombineAttributeArrays::getCompiledLibraryName() const +QString CombineAttributeArrays::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -363,7 +349,7 @@ const QString CombineAttributeArrays::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CombineAttributeArrays::getBrandingString() const +QString CombineAttributeArrays::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -371,7 +357,7 @@ const QString CombineAttributeArrays::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CombineAttributeArrays::getFilterVersion() const +QString CombineAttributeArrays::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -382,7 +368,7 @@ const QString CombineAttributeArrays::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CombineAttributeArrays::getGroupName() const +QString CombineAttributeArrays::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -390,7 +376,7 @@ const QString CombineAttributeArrays::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid CombineAttributeArrays::getUuid() +QUuid CombineAttributeArrays::getUuid() const { return QUuid("{a6b50fb0-eb7c-5d9b-9691-825d6a4fe772}"); } @@ -398,7 +384,7 @@ const QUuid CombineAttributeArrays::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CombineAttributeArrays::getSubGroupName() const +QString CombineAttributeArrays::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -406,7 +392,84 @@ const QString CombineAttributeArrays::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CombineAttributeArrays::getHumanLabel() const +QString CombineAttributeArrays::getHumanLabel() const { return "Combine Attribute Arrays"; } + +// ----------------------------------------------------------------------------- +CombineAttributeArrays::Pointer CombineAttributeArrays::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr CombineAttributeArrays::New() +{ + struct make_shared_enabler : public CombineAttributeArrays + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString CombineAttributeArrays::getNameOfClass() const +{ + return QString("CombineAttributeArrays"); +} + +// ----------------------------------------------------------------------------- +QString CombineAttributeArrays::ClassName() +{ + return QString("CombineAttributeArrays"); +} + +// ----------------------------------------------------------------------------- +void CombineAttributeArrays::setSelectedDataArrayPaths(const std::vector& value) +{ + m_SelectedDataArrayPaths = value; +} + +// ----------------------------------------------------------------------------- +std::vector CombineAttributeArrays::getSelectedDataArrayPaths() const +{ + return m_SelectedDataArrayPaths; +} + +// ----------------------------------------------------------------------------- +void CombineAttributeArrays::setStackedDataArrayName(const QString& value) +{ + m_StackedDataArrayName = value; +} + +// ----------------------------------------------------------------------------- +QString CombineAttributeArrays::getStackedDataArrayName() const +{ + return m_StackedDataArrayName; +} + +// ----------------------------------------------------------------------------- +void CombineAttributeArrays::setNormalizeData(bool value) +{ + m_NormalizeData = value; +} + +// ----------------------------------------------------------------------------- +bool CombineAttributeArrays::getNormalizeData() const +{ + return m_NormalizeData; +} + +// ----------------------------------------------------------------------------- +void CombineAttributeArrays::setMoveValues(bool value) +{ + m_MoveValues = value; +} + +// ----------------------------------------------------------------------------- +bool CombineAttributeArrays::getMoveValues() const +{ + return m_MoveValues; +} diff --git a/Source/SIMPLib/CoreFilters/CombineAttributeArrays.h b/Source/SIMPLib/CoreFilters/CombineAttributeArrays.h old mode 100755 new mode 100644 index 7f52bf7a36..2f7660fa18 --- a/Source/SIMPLib/CoreFilters/CombineAttributeArrays.h +++ b/Source/SIMPLib/CoreFilters/CombineAttributeArrays.h @@ -1,43 +1,48 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +class IDataArray; +using IDataArrayWkPtrType = std::weak_ptr; /** * @brief The CombineAttributeArrays class. See [Filter documentation](@ref combineattributearrays) for details. @@ -45,140 +50,182 @@ class SIMPLib_EXPORT CombineAttributeArrays : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(CombineAttributeArrays SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QVector SelectedDataArrayPaths READ getSelectedDataArrayPaths WRITE setSelectedDataArrayPaths) - PYB11_PROPERTY(QString StackedDataArrayName READ getStackedDataArrayName WRITE setStackedDataArrayName) - PYB11_PROPERTY(bool NormalizeData READ getNormalizeData WRITE setNormalizeData) - - public: - SIMPL_SHARED_POINTERS(CombineAttributeArrays) - SIMPL_FILTER_NEW_MACRO(CombineAttributeArrays) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(CombineAttributeArrays, AbstractFilter) - - ~CombineAttributeArrays() override; - - SIMPL_FILTER_PARAMETER(QVector, SelectedDataArrayPaths) - Q_PROPERTY(QVector SelectedDataArrayPaths READ getSelectedDataArrayPaths WRITE setSelectedDataArrayPaths) - - SIMPL_FILTER_PARAMETER(QString, StackedDataArrayName) - Q_PROPERTY(QString StackedDataArrayName READ getStackedDataArrayName WRITE setStackedDataArrayName) - - SIMPL_FILTER_PARAMETER(bool, NormalizeData) - Q_PROPERTY(bool NormalizeData READ getNormalizeData WRITE setNormalizeData) - - SIMPL_FILTER_PARAMETER(bool, MoveValues) - Q_PROPERTY(bool MoveValues READ getMoveValues WRITE setMoveValues) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - CombineAttributeArrays(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - DEFINE_IDATAARRAY_WEAKPTR(StackedData) - - QVector m_SelectedWeakPtrVector; - - public: - CombineAttributeArrays(const CombineAttributeArrays&) = delete; // Copy Constructor Not Implemented - CombineAttributeArrays(CombineAttributeArrays&&) = delete; // Move Constructor Not Implemented - CombineAttributeArrays& operator=(const CombineAttributeArrays&) = delete; // Copy Assignment Not Implemented - CombineAttributeArrays& operator=(CombineAttributeArrays&&) = delete; // Move Assignment Not Implemented -}; + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(CombineAttributeArrays SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(CombineAttributeArrays) + PYB11_FILTER_NEW_MACRO(CombineAttributeArrays) + PYB11_PROPERTY(std::vector SelectedDataArrayPaths READ getSelectedDataArrayPaths WRITE setSelectedDataArrayPaths) + PYB11_PROPERTY(QString StackedDataArrayName READ getStackedDataArrayName WRITE setStackedDataArrayName) + PYB11_PROPERTY(bool NormalizeData READ getNormalizeData WRITE setNormalizeData) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = CombineAttributeArrays; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for CombineAttributeArrays + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for CombineAttributeArrays + */ + static QString ClassName(); + + ~CombineAttributeArrays() override; + + /** + * @brief Setter property for SelectedDataArrayPaths + */ + void setSelectedDataArrayPaths(const std::vector& value); + /** + * @brief Getter property for SelectedDataArrayPaths + * @return Value of SelectedDataArrayPaths + */ + std::vector getSelectedDataArrayPaths() const; + + Q_PROPERTY(DataArrayPathVec SelectedDataArrayPaths READ getSelectedDataArrayPaths WRITE setSelectedDataArrayPaths) + + /** + * @brief Setter property for StackedDataArrayName + */ + void setStackedDataArrayName(const QString& value); + /** + * @brief Getter property for StackedDataArrayName + * @return Value of StackedDataArrayName + */ + QString getStackedDataArrayName() const; + + Q_PROPERTY(QString StackedDataArrayName READ getStackedDataArrayName WRITE setStackedDataArrayName) + + /** + * @brief Setter property for NormalizeData + */ + void setNormalizeData(bool value); + /** + * @brief Getter property for NormalizeData + * @return Value of NormalizeData + */ + bool getNormalizeData() const; + + Q_PROPERTY(bool NormalizeData READ getNormalizeData WRITE setNormalizeData) + + /** + * @brief Setter property for MoveValues + */ + void setMoveValues(bool value); + /** + * @brief Getter property for MoveValues + * @return Value of MoveValues + */ + bool getMoveValues() const; + + Q_PROPERTY(bool MoveValues READ getMoveValues WRITE setMoveValues) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + + /** + * @brief Returns the list of deleted data paths. + * @return + */ + std::list getDeletedPaths() override; + +protected: + CombineAttributeArrays(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + IDataArrayWkPtrType m_StackedDataPtr; + + std::vector m_SelectedDataArrayPaths = {}; + QString m_StackedDataArrayName = {SIMPL::GeneralData::CombinedData}; + bool m_NormalizeData = {false}; + bool m_MoveValues = {false}; + + QVector m_SelectedWeakPtrVector; + +public: + CombineAttributeArrays(const CombineAttributeArrays&) = delete; // Copy Constructor Not Implemented + CombineAttributeArrays(CombineAttributeArrays&&) = delete; // Move Constructor Not Implemented + CombineAttributeArrays& operator=(const CombineAttributeArrays&) = delete; // Copy Assignment Not Implemented + CombineAttributeArrays& operator=(CombineAttributeArrays&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.cpp b/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.cpp index 4e4d2f8fff..4478a81c66 100644 --- a/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.cpp +++ b/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.cpp @@ -1,61 +1,63 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + #include "CombineAttributeMatrices.h" -#include "SIMPLib/Common/Constants.h" +#include +#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" +#include "SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.h" #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + CombinedMatrixID = 1 +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -CombineAttributeMatrices::CombineAttributeMatrices() -: m_FirstAttributeMatrixPath("", "", "") -, m_SecondAttributeMatrixPath("", "", "") -, m_FirstIndexArrayPath("", "", "") -, m_SecondIndexArrayPath("", "", "") -, m_CombinedAttributeMatrixName("") -, m_NewIndexArrayName("") -{ -} +CombineAttributeMatrices::CombineAttributeMatrices() = default; // ----------------------------------------------------------------------------- // @@ -67,8 +69,8 @@ CombineAttributeMatrices::~CombineAttributeMatrices() = default; // ----------------------------------------------------------------------------- void CombineAttributeMatrices::setupFilterParameters() { - FilterParameterVector parameters; - parameters.push_back(SeparatorFilterParameter::New("Feature/Ensemble Data", FilterParameter::RequiredArray)); + FilterParameterVectorType parameters; + parameters.push_back(SeparatorFilterParameter::Create("Feature/Ensemble Data", FilterParameter::Category::RequiredArray)); { AttributeMatrixSelectionFilterParameter::RequirementType req; IGeometry::Types dcGeomTypes; @@ -84,8 +86,8 @@ void CombineAttributeMatrices::setupFilterParameters() dcGeomTypes.push_back(IGeometry::Type::Any); req.amTypes = amTypes; req.dcGeometryTypes = dcGeomTypes; - parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("First Feature/Ensemble Attribute Matrix", FirstAttributeMatrixPath, FilterParameter::RequiredArray, CombineAttributeMatrices, req)); - parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Second Feature/Ensemble Attribute Matrix", SecondAttributeMatrixPath, FilterParameter::RequiredArray, CombineAttributeMatrices, req)); + parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("First Feature/Ensemble Attribute Matrix", FirstAttributeMatrixPath, FilterParameter::Category::RequiredArray, CombineAttributeMatrices, req)); + parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Second Feature/Ensemble Attribute Matrix", SecondAttributeMatrixPath, FilterParameter::Category::RequiredArray, CombineAttributeMatrices, req)); } { DataArraySelectionFilterParameter::RequirementType req; @@ -100,9 +102,9 @@ void CombineAttributeMatrices::setupFilterParameters() amTypes.push_back(AttributeMatrix::Type::FaceFeature); amTypes.push_back(AttributeMatrix::Type::Vertex); amTypes.push_back(AttributeMatrix::Type::VertexFeature); - QVector daTypes; + std::vector daTypes; daTypes.push_back(SIMPL::TypeNames::Int32); - QVector> compDims; + std::vector> compDims; compDims.resize(1); compDims[0].resize(1); compDims[0][0] = 1; @@ -110,14 +112,16 @@ void CombineAttributeMatrices::setupFilterParameters() req.amTypes = amTypes; req.daTypes = daTypes; req.componentDimensions = compDims; - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("First Index Array", FirstIndexArrayPath, FilterParameter::RequiredArray, CombineAttributeMatrices, req)); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Second Index Array", SecondIndexArrayPath, FilterParameter::RequiredArray, CombineAttributeMatrices, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("First Index Array", FirstIndexArrayPath, FilterParameter::Category::RequiredArray, CombineAttributeMatrices, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Second Index Array", SecondIndexArrayPath, FilterParameter::Category::RequiredArray, CombineAttributeMatrices, req)); } - parameters.push_back(SeparatorFilterParameter::New("Cell/Feature Data", FilterParameter::CreatedArray)); - parameters.push_back(SIMPL_NEW_STRING_FP("New Index Array", NewIndexArrayName, FilterParameter::CreatedArray, CombineAttributeMatrices)); - parameters.push_back(SeparatorFilterParameter::New("Feature/Ensemble Data", FilterParameter::CreatedArray)); - parameters.push_back(SIMPL_NEW_STRING_FP("Combined Attribute Matrix", CombinedAttributeMatrixName, FilterParameter::CreatedArray, CombineAttributeMatrices)); + parameters.push_back(SeparatorFilterParameter::Create("Cell/Feature Data", FilterParameter::Category::CreatedArray)); + parameters.push_back( + SIMPL_NEW_DA_WITH_LINKED_AM_FP("New Index Array", NewIndexArrayName, FirstIndexArrayPath, FirstIndexArrayPath, FilterParameter::Category::CreatedArray, CombineAttributeMatrices)); + parameters.push_back(SeparatorFilterParameter::Create("Feature/Ensemble Data", FilterParameter::Category::CreatedArray)); + parameters.push_back( + SIMPL_NEW_AM_WITH_LINKED_DC_FP("Combined Attribute Matrix", CombinedAttributeMatrixName, FirstAttributeMatrixPath, FilterParameter::Category::CreatedArray, CombineAttributeMatrices)); setFilterParameters(parameters); } @@ -149,12 +153,12 @@ void CombineAttributeMatrices::initialize() // ----------------------------------------------------------------------------- void CombineAttributeMatrices::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); DataArrayPath tempPath; DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, getFirstAttributeMatrixPath().getDataContainerName(), false); - if(getErrorCondition() < 0 || nullptr == m.get()) + if(getErrorCode() < 0 || nullptr == m.get()) { return; } @@ -162,20 +166,18 @@ void CombineAttributeMatrices::dataCheck() if(getFirstAttributeMatrixPath().getDataContainerName().compare(getSecondAttributeMatrixPath().getDataContainerName()) != 0) { QString ss = QObject::tr("The selected attribute matrices must be in the same data container and currently are not"); - setErrorCondition(-5557); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5557, ss); } if(getFirstAttributeMatrixPath().getAttributeMatrixName().compare(getSecondAttributeMatrixPath().getAttributeMatrixName()) == 0) { QString ss = QObject::tr("The selected attribute matrices must be different and currently are the same"); - setErrorCondition(-5558); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5558, ss); } AttributeMatrix::Pointer firstAttrMat = m->getPrereqAttributeMatrix(this, getFirstAttributeMatrixPath().getAttributeMatrixName(), -301); AttributeMatrix::Pointer secondAttrMat = m->getPrereqAttributeMatrix(this, getSecondAttributeMatrixPath().getAttributeMatrixName(), -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -183,11 +185,10 @@ void CombineAttributeMatrices::dataCheck() if(firstAttrMat->getType() != secondAttrMat->getType()) { QString ss = QObject::tr("The selected attribute matrices must be of the same type (ie Feature) and currently are not"); - setErrorCondition(-5559); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5559, ss); } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -195,33 +196,31 @@ void CombineAttributeMatrices::dataCheck() // Note that the minus 1 in the totalTuples calculation is to account for the fact that the zeroth tuple in the two attribute matrices should only be counted once, not twice. // All Feature or Ensemble AMs should start from 1 and the zeroth tuple can be combined in the two AMs size_t totalTuples = firstAttrMat->getNumberOfTuples() + secondAttrMat->getNumberOfTuples() - 1; - QVector tDims(1, totalTuples); - m->createNonPrereqAttributeMatrix(this, getCombinedAttributeMatrixName(), tDims, firstAttrMat->getType()); - if(getErrorCondition() < 0) + std::vector tDims(1, totalTuples); + m->createNonPrereqAttributeMatrix(this, getCombinedAttributeMatrixName(), tDims, firstAttrMat->getType(), CombinedMatrixID); + if(getErrorCode() < 0) { return; } AttributeMatrix::Pointer combinedAttrMat = m->getAttributeMatrix(getCombinedAttributeMatrixName()); - QVector cDims(1, 1); - m_FirstIndexPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getFirstIndexArrayPath(), - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ - if(nullptr != m_FirstIndexPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ + std::vector cDims(1, 1); + m_FirstIndexPtr = getDataContainerArray()->getPrereqArrayFromPath>(this, getFirstIndexArrayPath(), cDims); + if(nullptr != m_FirstIndexPtr.lock()) { m_FirstIndex = m_FirstIndexPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - m_SecondIndexPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSecondIndexArrayPath(), - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ - if(nullptr != m_SecondIndexPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ + m_SecondIndexPtr = getDataContainerArray()->getPrereqArrayFromPath>(this, getSecondIndexArrayPath(), cDims); + if(nullptr != m_SecondIndexPtr.lock()) { m_SecondIndex = m_SecondIndexPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -231,10 +230,10 @@ void CombineAttributeMatrices::dataCheck() for(QList::iterator iter = fArrayNames.begin(); iter != fArrayNames.end(); ++iter) { tempPath.update(getFirstAttributeMatrixPath().getDataContainerName(), getCombinedAttributeMatrixName(), *iter); - IDataArray::Pointer tmpDataArray = firstAttrMat->getPrereqIDataArray(this, *iter, -90001); - if(getErrorCondition() >= 0) + IDataArray::Pointer tmpDataArray = firstAttrMat->getPrereqIDataArray(this, *iter, -90001); + if(getErrorCode() >= 0) { - QVector cDims = tmpDataArray->getComponentDimensions(); + std::vector cDims = tmpDataArray->getComponentDimensions(); TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, tmpDataArray); } } @@ -242,44 +241,31 @@ void CombineAttributeMatrices::dataCheck() for(QList::iterator iter = sArrayNames.begin(); iter != sArrayNames.end(); ++iter) { tempPath.update(getSecondAttributeMatrixPath().getDataContainerName(), getCombinedAttributeMatrixName(), *iter); - IDataArray::Pointer tmpDataArray = secondAttrMat->getPrereqIDataArray(this, *iter, -90001); - if(getErrorCondition() >= 0) + IDataArray::Pointer tmpDataArray = secondAttrMat->getPrereqIDataArray(this, *iter, -90001); + if(getErrorCode() >= 0) { if(!fArrayNames.contains(*iter)) { - QVector cDims = tmpDataArray->getComponentDimensions(); + std::vector cDims = tmpDataArray->getComponentDimensions(); TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, tmpDataArray); } } } tempPath.update(getFirstIndexArrayPath().getDataContainerName(), getFirstIndexArrayPath().getAttributeMatrixName(), getNewIndexArrayName()); - m_NewIndexPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int32_t>(this, tempPath, 0, - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ - if(nullptr != m_NewIndexPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ + m_NewIndexPtr = getDataContainerArray()->createNonPrereqArrayFromPath>(this, tempPath, 0, cDims); + if(nullptr != m_NewIndexPtr.lock()) { m_NewIndex = m_NewIndexPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void CombineAttributeMatrices::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - -template void copyData(IDataArray::Pointer fromData, IDataArray::Pointer toData, size_t location) +template +void copyData(IDataArray::Pointer fromData, IDataArray::Pointer toData, size_t location) { typename DataArray::Pointer fData = std::dynamic_pointer_cast>(fromData); typename DataArray::Pointer tData = std::dynamic_pointer_cast>(toData); @@ -296,10 +282,8 @@ template void copyData(IDataArray::Pointer fromData, IDataArray::Po // ----------------------------------------------------------------------------- void CombineAttributeMatrices::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -329,7 +313,7 @@ void CombineAttributeMatrices::execute() else if(m_SecondIndex[i] > 0 && m_NewIndex[i] != 0) { QString ss = QObject::tr("When copying the indices, the indices of the two attribute matrices overlapped. The index of the first attribute matrix was kept."); - notifyWarningMessage(getHumanLabel(), ss, -111); + setWarningCondition(-111, ss); } } @@ -351,7 +335,14 @@ void CombineAttributeMatrices::execute() IDataArray::Pointer toDataArray = combinedAttrMat->getAttributeArray(*iter); EXECUTE_FUNCTION_TEMPLATE(this, copyData, fromDataArray, fromDataArray, toDataArray, location); } +} +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::list CombineAttributeMatrices::getDeletedPaths() +{ + return {getFirstAttributeMatrixPath(), getSecondAttributeMatrixPath()}; } // ----------------------------------------------------------------------------- @@ -370,7 +361,7 @@ AbstractFilter::Pointer CombineAttributeMatrices::newFilterInstance(bool copyFil // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CombineAttributeMatrices::getCompiledLibraryName() const +QString CombineAttributeMatrices::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -378,7 +369,7 @@ const QString CombineAttributeMatrices::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CombineAttributeMatrices::getBrandingString() const +QString CombineAttributeMatrices::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -386,7 +377,7 @@ const QString CombineAttributeMatrices::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CombineAttributeMatrices::getFilterVersion() const +QString CombineAttributeMatrices::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -397,7 +388,7 @@ const QString CombineAttributeMatrices::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CombineAttributeMatrices::getGroupName() const +QString CombineAttributeMatrices::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -405,7 +396,7 @@ const QString CombineAttributeMatrices::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid CombineAttributeMatrices::getUuid() +QUuid CombineAttributeMatrices::getUuid() const { return QUuid("{334034e9-405f-51a3-9c3c-8d9c955835d9}"); } @@ -413,7 +404,7 @@ const QUuid CombineAttributeMatrices::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CombineAttributeMatrices::getSubGroupName() const +QString CombineAttributeMatrices::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -421,7 +412,108 @@ const QString CombineAttributeMatrices::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CombineAttributeMatrices::getHumanLabel() const +QString CombineAttributeMatrices::getHumanLabel() const { return "Combine Feature/Ensemble Attribute Matrices"; } + +// ----------------------------------------------------------------------------- +CombineAttributeMatrices::Pointer CombineAttributeMatrices::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr CombineAttributeMatrices::New() +{ + struct make_shared_enabler : public CombineAttributeMatrices + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString CombineAttributeMatrices::getNameOfClass() const +{ + return QString("CombineAttributeMatrices"); +} + +// ----------------------------------------------------------------------------- +QString CombineAttributeMatrices::ClassName() +{ + return QString("CombineAttributeMatrices"); +} + +// ----------------------------------------------------------------------------- +void CombineAttributeMatrices::setFirstAttributeMatrixPath(const DataArrayPath& value) +{ + m_FirstAttributeMatrixPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CombineAttributeMatrices::getFirstAttributeMatrixPath() const +{ + return m_FirstAttributeMatrixPath; +} + +// ----------------------------------------------------------------------------- +void CombineAttributeMatrices::setSecondAttributeMatrixPath(const DataArrayPath& value) +{ + m_SecondAttributeMatrixPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CombineAttributeMatrices::getSecondAttributeMatrixPath() const +{ + return m_SecondAttributeMatrixPath; +} + +// ----------------------------------------------------------------------------- +void CombineAttributeMatrices::setFirstIndexArrayPath(const DataArrayPath& value) +{ + m_FirstIndexArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CombineAttributeMatrices::getFirstIndexArrayPath() const +{ + return m_FirstIndexArrayPath; +} + +// ----------------------------------------------------------------------------- +void CombineAttributeMatrices::setSecondIndexArrayPath(const DataArrayPath& value) +{ + m_SecondIndexArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CombineAttributeMatrices::getSecondIndexArrayPath() const +{ + return m_SecondIndexArrayPath; +} + +// ----------------------------------------------------------------------------- +void CombineAttributeMatrices::setCombinedAttributeMatrixName(const QString& value) +{ + m_CombinedAttributeMatrixName = value; +} + +// ----------------------------------------------------------------------------- +QString CombineAttributeMatrices::getCombinedAttributeMatrixName() const +{ + return m_CombinedAttributeMatrixName; +} + +// ----------------------------------------------------------------------------- +void CombineAttributeMatrices::setNewIndexArrayName(const QString& value) +{ + m_NewIndexArrayName = value; +} + +// ----------------------------------------------------------------------------- +QString CombineAttributeMatrices::getNewIndexArrayName() const +{ + return m_NewIndexArrayName; +} diff --git a/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.h b/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.h old mode 100755 new mode 100644 index 5013be64b6..8535c622ab --- a/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.h +++ b/Source/SIMPLib/CoreFilters/CombineAttributeMatrices.h @@ -1,198 +1,261 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The CombineAttributeMatrices class. See [Filter documentation](@ref CombineAttributeMatrices) for details. */ class SIMPLib_EXPORT CombineAttributeMatrices : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(CombineAttributeMatrices SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath FirstAttributeMatrixPath READ getFirstAttributeMatrixPath WRITE setFirstAttributeMatrixPath) - PYB11_PROPERTY(DataArrayPath SecondAttributeMatrixPath READ getSecondAttributeMatrixPath WRITE setSecondAttributeMatrixPath) - PYB11_PROPERTY(DataArrayPath FirstIndexArrayPath READ getFirstIndexArrayPath WRITE setFirstIndexArrayPath) - PYB11_PROPERTY(DataArrayPath SecondIndexArrayPath READ getSecondIndexArrayPath WRITE setSecondIndexArrayPath) - PYB11_PROPERTY(QString CombinedAttributeMatrixName READ getCombinedAttributeMatrixName WRITE setCombinedAttributeMatrixName) - PYB11_PROPERTY(QString NewIndexArrayName READ getNewIndexArrayName WRITE setNewIndexArrayName) - - public: - SIMPL_SHARED_POINTERS(CombineAttributeMatrices) - SIMPL_FILTER_NEW_MACRO(CombineAttributeMatrices) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(CombineAttributeMatrices, AbstractFilter) - - ~CombineAttributeMatrices() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, FirstAttributeMatrixPath) - Q_PROPERTY(DataArrayPath FirstAttributeMatrixPath READ getFirstAttributeMatrixPath WRITE setFirstAttributeMatrixPath) - - SIMPL_FILTER_PARAMETER(DataArrayPath, SecondAttributeMatrixPath) - Q_PROPERTY(DataArrayPath SecondAttributeMatrixPath READ getSecondAttributeMatrixPath WRITE setSecondAttributeMatrixPath) - - SIMPL_FILTER_PARAMETER(DataArrayPath, FirstIndexArrayPath) - Q_PROPERTY(DataArrayPath FirstIndexArrayPath READ getFirstIndexArrayPath WRITE setFirstIndexArrayPath) - - SIMPL_FILTER_PARAMETER(DataArrayPath, SecondIndexArrayPath) - Q_PROPERTY(DataArrayPath SecondIndexArrayPath READ getSecondIndexArrayPath WRITE setSecondIndexArrayPath) - - SIMPL_FILTER_PARAMETER(QString, CombinedAttributeMatrixName) - Q_PROPERTY(QString CombinedAttributeMatrixName READ getCombinedAttributeMatrixName WRITE setCombinedAttributeMatrixName) - - SIMPL_FILTER_PARAMETER(QString, NewIndexArrayName) - Q_PROPERTY(QString NewIndexArrayName READ getNewIndexArrayName WRITE setNewIndexArrayName) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - CombineAttributeMatrices(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - /** - * @brief updateFeatureInstancePointers Updates raw feature pointers - */ - void updateFeatureInstancePointers(); - - private: - DEFINE_DATAARRAY_VARIABLE(int32_t, FirstIndex) - DEFINE_DATAARRAY_VARIABLE(int32_t, SecondIndex) - DEFINE_DATAARRAY_VARIABLE(int32_t, NewIndex) - - public: - CombineAttributeMatrices(const CombineAttributeMatrices&) = delete; // Copy Constructor Not Implemented - CombineAttributeMatrices(CombineAttributeMatrices&&) = delete; // Move Constructor Not Implemented - CombineAttributeMatrices& operator=(const CombineAttributeMatrices&) = delete; // Copy Assignment Not Implemented - CombineAttributeMatrices& operator=(CombineAttributeMatrices&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(CombineAttributeMatrices SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(CombineAttributeMatrices) + PYB11_FILTER_NEW_MACRO(CombineAttributeMatrices) + PYB11_PROPERTY(DataArrayPath FirstAttributeMatrixPath READ getFirstAttributeMatrixPath WRITE setFirstAttributeMatrixPath) + PYB11_PROPERTY(DataArrayPath SecondAttributeMatrixPath READ getSecondAttributeMatrixPath WRITE setSecondAttributeMatrixPath) + PYB11_PROPERTY(DataArrayPath FirstIndexArrayPath READ getFirstIndexArrayPath WRITE setFirstIndexArrayPath) + PYB11_PROPERTY(DataArrayPath SecondIndexArrayPath READ getSecondIndexArrayPath WRITE setSecondIndexArrayPath) + PYB11_PROPERTY(QString CombinedAttributeMatrixName READ getCombinedAttributeMatrixName WRITE setCombinedAttributeMatrixName) + PYB11_PROPERTY(QString NewIndexArrayName READ getNewIndexArrayName WRITE setNewIndexArrayName) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = CombineAttributeMatrices; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for CombineAttributeMatrices + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for CombineAttributeMatrices + */ + static QString ClassName(); + + ~CombineAttributeMatrices() override; + + /** + * @brief Setter property for FirstAttributeMatrixPath + */ + void setFirstAttributeMatrixPath(const DataArrayPath& value); + /** + * @brief Getter property for FirstAttributeMatrixPath + * @return Value of FirstAttributeMatrixPath + */ + DataArrayPath getFirstAttributeMatrixPath() const; + + Q_PROPERTY(DataArrayPath FirstAttributeMatrixPath READ getFirstAttributeMatrixPath WRITE setFirstAttributeMatrixPath) + + /** + * @brief Setter property for SecondAttributeMatrixPath + */ + void setSecondAttributeMatrixPath(const DataArrayPath& value); + /** + * @brief Getter property for SecondAttributeMatrixPath + * @return Value of SecondAttributeMatrixPath + */ + DataArrayPath getSecondAttributeMatrixPath() const; + + Q_PROPERTY(DataArrayPath SecondAttributeMatrixPath READ getSecondAttributeMatrixPath WRITE setSecondAttributeMatrixPath) + + /** + * @brief Setter property for FirstIndexArrayPath + */ + void setFirstIndexArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for FirstIndexArrayPath + * @return Value of FirstIndexArrayPath + */ + DataArrayPath getFirstIndexArrayPath() const; + + Q_PROPERTY(DataArrayPath FirstIndexArrayPath READ getFirstIndexArrayPath WRITE setFirstIndexArrayPath) + + /** + * @brief Setter property for SecondIndexArrayPath + */ + void setSecondIndexArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SecondIndexArrayPath + * @return Value of SecondIndexArrayPath + */ + DataArrayPath getSecondIndexArrayPath() const; + + Q_PROPERTY(DataArrayPath SecondIndexArrayPath READ getSecondIndexArrayPath WRITE setSecondIndexArrayPath) + + /** + * @brief Setter property for CombinedAttributeMatrixName + */ + void setCombinedAttributeMatrixName(const QString& value); + /** + * @brief Getter property for CombinedAttributeMatrixName + * @return Value of CombinedAttributeMatrixName + */ + QString getCombinedAttributeMatrixName() const; + + Q_PROPERTY(QString CombinedAttributeMatrixName READ getCombinedAttributeMatrixName WRITE setCombinedAttributeMatrixName) + + /** + * @brief Setter property for NewIndexArrayName + */ + void setNewIndexArrayName(const QString& value); + /** + * @brief Getter property for NewIndexArrayName + * @return Value of NewIndexArrayName + */ + QString getNewIndexArrayName() const; + + Q_PROPERTY(QString NewIndexArrayName READ getNewIndexArrayName WRITE setNewIndexArrayName) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + + /** + * @brief Returns the list of deleted data paths. + * @return + */ + std::list getDeletedPaths() override; + +protected: + CombineAttributeMatrices(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + + /** + * @brief updateFeatureInstancePointers Updates raw feature pointers + */ + void updateFeatureInstancePointers(); + +private: + std::weak_ptr> m_FirstIndexPtr; + int32_t* m_FirstIndex = nullptr; + std::weak_ptr> m_SecondIndexPtr; + int32_t* m_SecondIndex = nullptr; + std::weak_ptr> m_NewIndexPtr; + int32_t* m_NewIndex = nullptr; + + DataArrayPath m_FirstAttributeMatrixPath = {"", "", ""}; + DataArrayPath m_SecondAttributeMatrixPath = {"", "", ""}; + DataArrayPath m_FirstIndexArrayPath = {"", "", ""}; + DataArrayPath m_SecondIndexArrayPath = {"", "", ""}; + QString m_CombinedAttributeMatrixName = {""}; + QString m_NewIndexArrayName = {""}; + +public: + CombineAttributeMatrices(const CombineAttributeMatrices&) = delete; // Copy Constructor Not Implemented + CombineAttributeMatrices(CombineAttributeMatrices&&) = delete; // Move Constructor Not Implemented + CombineAttributeMatrices& operator=(const CombineAttributeMatrices&) = delete; // Copy Assignment Not Implemented + CombineAttributeMatrices& operator=(CombineAttributeMatrices&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/ConditionalSetValue.cpp b/Source/SIMPLib/CoreFilters/ConditionalSetValue.cpp index 67e915c41c..5ffe747d45 100644 --- a/Source/SIMPLib/CoreFilters/ConditionalSetValue.cpp +++ b/Source/SIMPLib/CoreFilters/ConditionalSetValue.cpp @@ -1,57 +1,57 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ConditionalSetValue.h" +#include + +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/DoubleFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- ConditionalSetValue::ConditionalSetValue() -: m_SelectedArrayPath("", "", "") -, m_ConditionalArrayPath("", "", "") -, m_ReplaceValue(0.0) -//, m_Array(nullptr) -{ -} + //, m_Array(nullptr) + = default; // ----------------------------------------------------------------------------- // @@ -63,15 +63,15 @@ ConditionalSetValue::~ConditionalSetValue() = default; // ----------------------------------------------------------------------------- void ConditionalSetValue::setupFilterParameters() { - FilterParameterVector parameters; - parameters.push_back(SIMPL_NEW_DOUBLE_FP("New Value", ReplaceValue, FilterParameter::Parameter, ConditionalSetValue)); + FilterParameterVectorType parameters; + parameters.push_back(SIMPL_NEW_DOUBLE_FP("New Value", ReplaceValue, FilterParameter::Category::Parameter, ConditionalSetValue)); { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Bool, 1, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Conditional Array", ConditionalArrayPath, FilterParameter::RequiredArray, ConditionalSetValue, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Conditional Array", ConditionalArrayPath, FilterParameter::Category::RequiredArray, ConditionalSetValue, req)); } { - DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::Defaults::AnyPrimitive, 1, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Attribute Array", SelectedArrayPath, FilterParameter::RequiredArray, ConditionalSetValue, req)); + DataArraySelectionFilterParameter::RequirementType req; + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Attribute Array", SelectedArrayPath, FilterParameter::Category::RequiredArray, ConditionalSetValue, req)); } setFilterParameters(parameters); } @@ -91,22 +91,23 @@ void ConditionalSetValue::readFilterParameters(AbstractFilterParametersReader* r // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void checkValuesInt(AbstractFilter* filter, double replaceValue, QString strType) +template +void checkValuesInt(AbstractFilter* filter, double replaceValue, QString strType) { QString ss; if(!((replaceValue >= std::numeric_limits::min()) && (replaceValue <= std::numeric_limits::max()))) { ss = QObject::tr("The %1 replace value was invalid. The valid range is %2 to %3").arg(strType).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - filter->setErrorCondition(-100); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-100, ss); } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void checkValuesFloatDouble(AbstractFilter* filter, double replaceValue, QString strType) +template +void checkValuesFloatDouble(AbstractFilter* filter, double replaceValue, QString strType) { QString ss; @@ -114,8 +115,7 @@ template void checkValuesFloatDouble(AbstractFilter* filter, double ((replaceValue >= std::numeric_limits::min()) && (replaceValue <= std::numeric_limits::max())))) { ss = QObject::tr("The %1 replace value was invalid. The valid ranges are -%3 to -%2, 0, %2 to %3").arg(strType).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - filter->setErrorCondition(-101); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-101, ss); } } @@ -123,13 +123,14 @@ template void checkValuesFloatDouble(AbstractFilter* filter, double // // ----------------------------------------------------------------------------- -template void replaceValue(AbstractFilter* filter, IDataArray::Pointer inDataPtr, BoolArrayType::Pointer condDataPtr, double replaceValue) +template +void replaceValue(AbstractFilter* filter, IDataArray::Pointer inDataPtr, BoolArrayType::Pointer condDataPtr, double replaceValue) { + std::ignore = filter; typename DataArray::Pointer inputArrayPtr = std::dynamic_pointer_cast>(inDataPtr); T replaceVal = static_cast(replaceValue); - T* inData = inputArrayPtr->getPointer(0); bool* condData = condDataPtr->getPointer(0); size_t numTuples = inputArrayPtr->getNumberOfTuples(); @@ -137,7 +138,7 @@ template void replaceValue(AbstractFilter* filter, IDataArray::Poin { if(condData[iter]) { - inData[iter] = replaceVal; + inputArrayPtr->initializeTuple(iter, &replaceVal); } } } @@ -154,44 +155,31 @@ void ConditionalSetValue::initialize() // ----------------------------------------------------------------------------- void ConditionalSetValue::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QVector dataArrayPaths; - m_ArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArrayPath()); - if(getErrorCondition() < 0) + m_ArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArrayPath()); + if(getErrorCode() < 0) { return; } - if(getErrorCondition() >= 0) - { - dataArrayPaths.push_back(getSelectedArrayPath()); - } + dataArrayPaths.push_back(getSelectedArrayPath()); - if(m_ArrayPtr.lock()->getNumberOfComponents() > 1) + std::vector cDims(1, 1); + m_ConditionalArrayPtr = getDataContainerArray()->getPrereqArrayFromPath>(this, getConditionalArrayPath(), cDims); + if(getErrorCode() < 0) { - QString ss = QObject::tr("Selected array '%1' must be a scalar array (1 component). The number of components is %2") - .arg(getSelectedArrayPath().getDataArrayName()) - .arg(m_ArrayPtr.lock()->getNumberOfComponents()); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } - - QVector cDims(1, 1); - m_ConditionalArrayPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getConditionalArrayPath(), - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ - if(nullptr != m_ConditionalArrayPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ + if(nullptr != m_ConditionalArrayPtr.lock()) { m_ConditionalArray = m_ConditionalArrayPtr.lock()->getPointer(0); - } /* Now assign the raw pointer to data from the DataArray object */ - if(getErrorCondition() >= 0) - { - dataArrayPaths.push_back(getConditionalArrayPath()); } + dataArrayPaths.push_back(getConditionalArrayPath()); - getDataContainerArray()->validateNumberOfTuples(this, dataArrayPaths); + getDataContainerArray()->validateNumberOfTuples(this, dataArrayPaths); QString dType = m_ArrayPtr.lock()->getTypeAsString(); if(dType.compare(SIMPL::TypeNames::Int8) == 0) @@ -243,34 +231,18 @@ void ConditionalSetValue::dataCheck() } else { - setErrorCondition(-4060); QString ss = QObject::tr("Incorrect data scalar type"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4060, ss); } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void ConditionalSetValue::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ConditionalSetValue::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -294,7 +266,7 @@ AbstractFilter::Pointer ConditionalSetValue::newFilterInstance(bool copyFilterPa // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConditionalSetValue::getCompiledLibraryName() const +QString ConditionalSetValue::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -302,7 +274,7 @@ const QString ConditionalSetValue::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConditionalSetValue::getBrandingString() const +QString ConditionalSetValue::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -310,7 +282,7 @@ const QString ConditionalSetValue::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConditionalSetValue::getFilterVersion() const +QString ConditionalSetValue::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -321,7 +293,7 @@ const QString ConditionalSetValue::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConditionalSetValue::getGroupName() const +QString ConditionalSetValue::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -329,7 +301,7 @@ const QString ConditionalSetValue::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid ConditionalSetValue::getUuid() +QUuid ConditionalSetValue::getUuid() const { return QUuid("{47cafe63-83cc-5826-9521-4fb5bea684ef}"); } @@ -337,7 +309,7 @@ const QUuid ConditionalSetValue::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConditionalSetValue::getSubGroupName() const +QString ConditionalSetValue::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -345,7 +317,72 @@ const QString ConditionalSetValue::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConditionalSetValue::getHumanLabel() const +QString ConditionalSetValue::getHumanLabel() const { return "Replace Value in Array (Conditional)"; } + +// ----------------------------------------------------------------------------- +ConditionalSetValue::Pointer ConditionalSetValue::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr ConditionalSetValue::New() +{ + struct make_shared_enabler : public ConditionalSetValue + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString ConditionalSetValue::getNameOfClass() const +{ + return QString("ConditionalSetValue"); +} + +// ----------------------------------------------------------------------------- +QString ConditionalSetValue::ClassName() +{ + return QString("ConditionalSetValue"); +} + +// ----------------------------------------------------------------------------- +void ConditionalSetValue::setSelectedArrayPath(const DataArrayPath& value) +{ + m_SelectedArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ConditionalSetValue::getSelectedArrayPath() const +{ + return m_SelectedArrayPath; +} + +// ----------------------------------------------------------------------------- +void ConditionalSetValue::setConditionalArrayPath(const DataArrayPath& value) +{ + m_ConditionalArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ConditionalSetValue::getConditionalArrayPath() const +{ + return m_ConditionalArrayPath; +} + +// ----------------------------------------------------------------------------- +void ConditionalSetValue::setReplaceValue(double value) +{ + m_ReplaceValue = value; +} + +// ----------------------------------------------------------------------------- +double ConditionalSetValue::getReplaceValue() const +{ + return m_ReplaceValue; +} diff --git a/Source/SIMPLib/CoreFilters/ConditionalSetValue.h b/Source/SIMPLib/CoreFilters/ConditionalSetValue.h old mode 100755 new mode 100644 index 00d70a149f..998cf52f02 --- a/Source/SIMPLib/CoreFilters/ConditionalSetValue.h +++ b/Source/SIMPLib/CoreFilters/ConditionalSetValue.h @@ -1,182 +1,207 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataArrays/IDataArray.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The ConditionalSetValue class. See [Filter documentation](@ref conditionalsetvalue) for details. */ class SIMPLib_EXPORT ConditionalSetValue : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(ConditionalSetValue SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) - PYB11_PROPERTY(DataArrayPath ConditionalArrayPath READ getConditionalArrayPath WRITE setConditionalArrayPath) - PYB11_PROPERTY(double ReplaceValue READ getReplaceValue WRITE setReplaceValue) - - public: - - SIMPL_SHARED_POINTERS(ConditionalSetValue) - SIMPL_FILTER_NEW_MACRO(ConditionalSetValue) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ConditionalSetValue, AbstractFilter) - - ~ConditionalSetValue() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedArrayPath) - Q_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) - - SIMPL_FILTER_PARAMETER(DataArrayPath, ConditionalArrayPath) - Q_PROPERTY(DataArrayPath ConditionalArrayPath READ getConditionalArrayPath WRITE setConditionalArrayPath) - - SIMPL_FILTER_PARAMETER(double, ReplaceValue) - Q_PROPERTY(double ReplaceValue READ getReplaceValue WRITE setReplaceValue) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - ConditionalSetValue(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - IDataArray::WeakPointer m_ArrayPtr; - DEFINE_DATAARRAY_VARIABLE(bool, ConditionalArray) - - public: - ConditionalSetValue(const ConditionalSetValue&) = delete; // Copy Constructor Not Implemented - ConditionalSetValue(ConditionalSetValue&&) = delete; // Move Constructor Not Implemented - ConditionalSetValue& operator=(const ConditionalSetValue&) = delete; // Copy Assignment Not Implemented - ConditionalSetValue& operator=(ConditionalSetValue&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ConditionalSetValue SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(ConditionalSetValue) + PYB11_FILTER_NEW_MACRO(ConditionalSetValue) + PYB11_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) + PYB11_PROPERTY(DataArrayPath ConditionalArrayPath READ getConditionalArrayPath WRITE setConditionalArrayPath) + PYB11_PROPERTY(double ReplaceValue READ getReplaceValue WRITE setReplaceValue) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = ConditionalSetValue; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for ConditionalSetValue + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ConditionalSetValue + */ + static QString ClassName(); + + ~ConditionalSetValue() override; + + /** + * @brief Setter property for SelectedArrayPath + */ + void setSelectedArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SelectedArrayPath + * @return Value of SelectedArrayPath + */ + DataArrayPath getSelectedArrayPath() const; + + Q_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) + + /** + * @brief Setter property for ConditionalArrayPath + */ + void setConditionalArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for ConditionalArrayPath + * @return Value of ConditionalArrayPath + */ + DataArrayPath getConditionalArrayPath() const; + + Q_PROPERTY(DataArrayPath ConditionalArrayPath READ getConditionalArrayPath WRITE setConditionalArrayPath) + + /** + * @brief Setter property for ReplaceValue + */ + void setReplaceValue(double value); + /** + * @brief Getter property for ReplaceValue + * @return Value of ReplaceValue + */ + double getReplaceValue() const; + + Q_PROPERTY(double ReplaceValue READ getReplaceValue WRITE setReplaceValue) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + ConditionalSetValue(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + std::weak_ptr> m_ConditionalArrayPtr; + bool* m_ConditionalArray = nullptr; + + DataArrayPath m_SelectedArrayPath = {"", "", ""}; + DataArrayPath m_ConditionalArrayPath = {"", "", ""}; + double m_ReplaceValue = {0.0}; + + IDataArray::WeakPointer m_ArrayPtr; + +public: + ConditionalSetValue(const ConditionalSetValue&) = delete; // Copy Constructor Not Implemented + ConditionalSetValue(ConditionalSetValue&&) = delete; // Move Constructor Not Implemented + ConditionalSetValue& operator=(const ConditionalSetValue&) = delete; // Copy Assignment Not Implemented + ConditionalSetValue& operator=(ConditionalSetValue&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.cpp b/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.cpp index 35f66a6ff3..627cc4dc5a 100644 --- a/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.cpp +++ b/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.cpp @@ -1,99 +1,96 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without -* modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of -* its -* contributors may be used to endorse or promote products derived from this -* software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without + * modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of + * its + * contributors may be used to endorse or promote products derived from this + * software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ConvertColorToGrayScale.h" -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS -#include -#include -#include -#include -#endif #include -#include "SIMPLib/Common/Constants.h" +#include + #include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" +#include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" #include "SIMPLib/FilterParameters/IntFilterParameter.h" #include "SIMPLib/FilterParameters/LinkedBooleanFilterParameter.h" #include "SIMPLib/FilterParameters/LinkedChoicesFilterParameter.h" #include "SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" +#include "SIMPLib/Utilities/ParallelDataAlgorithm.h" class LuminosityImpl { private: uint8_t* m_ImageData; uint8_t* m_FlatImageData; - FloatVec3_t m_ColorWeights; + FloatVec3Type m_ColorWeights; size_t m_NumComp; public: - LuminosityImpl(uint8_t* data, uint8_t* newdata, FloatVec3_t colorWeights, size_t comp) + LuminosityImpl(uint8_t* data, uint8_t* newdata, FloatVec3Type colorWeights, size_t comp) : m_ImageData(data) , m_FlatImageData(newdata) , m_ColorWeights(colorWeights) , m_NumComp(comp) { } - LuminosityImpl(const LuminosityImpl&) = default; // Copy Constructor Not Implemented - LuminosityImpl(LuminosityImpl&&) = default; // Move Constructor Not Implemented + LuminosityImpl(const LuminosityImpl&) = default; // Copy Constructor Not Implemented + LuminosityImpl(LuminosityImpl&&) = default; // Move Constructor Not Implemented LuminosityImpl& operator=(const LuminosityImpl&) = delete; // Copy Assignment Not Implemented LuminosityImpl& operator=(LuminosityImpl&&) = delete; // Move Assignment Not Implemented - ~LuminosityImpl() = default; + ~LuminosityImpl() = default; void convert(size_t start, size_t end) const { for(size_t i = start; i < end; i++) { - m_FlatImageData[i] = static_cast(roundf( - (m_ImageData[m_NumComp * i] * m_ColorWeights.x) - + (m_ImageData[m_NumComp * i + 1] * m_ColorWeights.y) - + (m_ImageData[m_NumComp * i + 2] * m_ColorWeights.z) - )); + m_FlatImageData[i] = static_cast( + roundf((m_ImageData[m_NumComp * i] * m_ColorWeights.getX()) + (m_ImageData[m_NumComp * i + 1] * m_ColorWeights.getY()) + (m_ImageData[m_NumComp * i + 2] * m_ColorWeights.getZ()))); } } -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - void operator()(const tbb::blocked_range& r) const { convert(r.begin(), r.end()); } -#endif + void operator()(const SIMPLRange& range) const + { + convert(range.min(), range.max()); + } }; class LightnessImpl @@ -110,26 +107,25 @@ class LightnessImpl , m_NumComp(comp) { } - LightnessImpl(const LightnessImpl&) = default; // Copy Constructor Not Implemented - LightnessImpl(LightnessImpl&&) = default; // Move Constructor Not Implemented + LightnessImpl(const LightnessImpl&) = default; // Copy Constructor Not Implemented + LightnessImpl(LightnessImpl&&) = default; // Move Constructor Not Implemented LightnessImpl& operator=(const LightnessImpl&) = delete; // Copy Assignment Not Implemented LightnessImpl& operator=(LightnessImpl&&) = delete; // Move Assignment Not Implemented - ~LightnessImpl() = default; + ~LightnessImpl() = default; void convert(size_t start, size_t end) const { for(size_t i = start; i < end; i++) { - std::pair minmax{ - std::minmax_element(m_ImageData + (start * m_NumComp), m_ImageData + (end * m_NumComp)) - }; + std::pair minmax{std::minmax_element(m_ImageData + (i * m_NumComp), m_ImageData + (i * m_NumComp + 3))}; m_FlatImageData[i] = static_cast(roundf((minmax.first[0] + minmax.second[0]) / 2.0f)); } } -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - void operator()(const tbb::blocked_range& r) const { convert(r.begin(), r.end()); } -#endif + void operator()(const SIMPLRange& range) const + { + convert(range.min(), range.max()); + } }; class SingleChannelImpl @@ -148,11 +144,11 @@ class SingleChannelImpl , m_Channel(channel) { } - SingleChannelImpl(const SingleChannelImpl&) = default; // Copy Constructor Not Implemented - SingleChannelImpl(SingleChannelImpl&&) = default; // Move Constructor Not Implemented + SingleChannelImpl(const SingleChannelImpl&) = default; // Copy Constructor Not Implemented + SingleChannelImpl(SingleChannelImpl&&) = default; // Move Constructor Not Implemented SingleChannelImpl& operator=(const SingleChannelImpl&) = delete; // Copy Assignment Not Implemented SingleChannelImpl& operator=(SingleChannelImpl&&) = delete; // Move Assignment Not Implemented - ~SingleChannelImpl() = default; + ~SingleChannelImpl() = default; void convert(size_t start, size_t end) const { @@ -162,47 +158,37 @@ class SingleChannelImpl } } -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - void operator()(const tbb::blocked_range& r) const { convert(r.begin(), r.end()); } -#endif - + void operator()(const SIMPLRange& range) const + { + convert(range.min(), range.max()); + } }; class ParallelWrapper { - public: - ~ParallelWrapper() = default; - ParallelWrapper(const ParallelWrapper&) = delete; // Copy Constructor Not Implemented - ParallelWrapper(ParallelWrapper&&) = delete; // Move Constructor Not Implemented - ParallelWrapper& operator=(const ParallelWrapper&) = delete; // Copy Assignment Not Implemented - ParallelWrapper& operator=(ParallelWrapper&&) = delete; // Move Assignment Not Implemented - - template - static void Run(T impl, size_t totalPoints) - { -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - tbb::parallel_for(tbb::blocked_range(0, totalPoints), impl, tbb::auto_partitioner()); -#else - impl.convert(0, totalPoints); -#endif - } +public: + ~ParallelWrapper() = default; + ParallelWrapper(const ParallelWrapper&) = delete; // Copy Constructor Not Implemented + ParallelWrapper(ParallelWrapper&&) = delete; // Move Constructor Not Implemented + ParallelWrapper& operator=(const ParallelWrapper&) = delete; // Copy Assignment Not Implemented + ParallelWrapper& operator=(ParallelWrapper&&) = delete; // Move Assignment Not Implemented + + template + static void Run(T impl, size_t totalPoints) + { + ParallelDataAlgorithm dataAlg; + dataAlg.setRange(0, totalPoints); + dataAlg.execute(impl); + } - protected: - ParallelWrapper() = default; +protected: + ParallelWrapper() = default; }; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ConvertColorToGrayScale::ConvertColorToGrayScale() -: m_ConversionAlgorithm(0) -, m_ColorWeights{0.2125f, 0.7154f, 0.0721f} -, m_ColorChannel(0) -, m_CreateNewAttributeMatrix(false) -, m_OutputAttributeMatrixName("GrayScaleData") -, m_OutputArrayPrefix("") -{ -} +ConvertColorToGrayScale::ConvertColorToGrayScale() = default; // ----------------------------------------------------------------------------- // @@ -215,17 +201,17 @@ ConvertColorToGrayScale::~ConvertColorToGrayScale() = default; void ConvertColorToGrayScale::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { - QVector choices; + std::vector choices; choices.push_back("Luminosity"); choices.push_back("Average"); choices.push_back("Lightness"); choices.push_back("SingleChannel"); - QStringList linkedProps; - linkedProps << "ColorWeights" - << "ColorChannel"; + std::vector linkedProps; + linkedProps.push_back("ColorWeights"); + linkedProps.push_back("ColorChannel"); LinkedChoicesFilterParameter::Pointer parameter = LinkedChoicesFilterParameter::New(); parameter->setHumanLabel("Conversion Algorithm"); @@ -234,65 +220,64 @@ void ConvertColorToGrayScale::setupFilterParameters() parameter->setGetterCallback(SIMPL_BIND_GETTER(ConvertColorToGrayScale, this, ConversionAlgorithm)); parameter->setChoices(choices); parameter->setLinkedProperties(linkedProps); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameters.push_back(parameter); } - parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Color Weighting", ColorWeights, FilterParameter::Parameter, ConvertColorToGrayScale, 0)); + parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Color Weighting", ColorWeights, FilterParameter::Category::Parameter, ConvertColorToGrayScale, 0)); - parameters.push_back(SIMPL_NEW_INTEGER_FP("Color Channel", ColorChannel, FilterParameter::Parameter, ConvertColorToGrayScale, 3)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Color Channel", ColorChannel, FilterParameter::Category::Parameter, ConvertColorToGrayScale, 3)); MultiDataArraySelectionFilterParameter::RequirementType req; req.dcGeometryTypes = IGeometry::Types(1, IGeometry::Type::Image); req.amTypes = AttributeMatrix::Types(1, AttributeMatrix::Type::Cell); - parameters.push_back(SIMPL_NEW_MDA_SELECTION_FP("Input Attribute Arrays", InputDataArrayVector, FilterParameter::RequiredArray, ConvertColorToGrayScale, req)); + parameters.push_back(SIMPL_NEW_MDA_SELECTION_FP("Input Attribute Arrays", InputDataArrayVector, FilterParameter::Category::RequiredArray, ConvertColorToGrayScale, req)); - QStringList linkedProps("OutputAttributeMatrixName"); - parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Create Attribute Matrix", CreateNewAttributeMatrix, FilterParameter::Parameter, ConvertColorToGrayScale, linkedProps)); - parameters.push_back(SIMPL_NEW_STRING_FP("Output Cell Attribute Matrix", OutputAttributeMatrixName, FilterParameter::CreatedArray, ConvertColorToGrayScale)); + std::vector linkedProps = {"OutputAttributeMatrixName"}; + parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Create Attribute Matrix", CreateNewAttributeMatrix, FilterParameter::Category::Parameter, ConvertColorToGrayScale, linkedProps)); + parameters.push_back(SIMPL_NEW_STRING_FP("Output Cell Attribute Matrix", OutputAttributeMatrixName, FilterParameter::Category::CreatedArray, ConvertColorToGrayScale)); - parameters.push_back(SIMPL_NEW_STRING_FP("Output Array Prefix", OutputArrayPrefix, FilterParameter::CreatedArray, ConvertColorToGrayScale)); + parameters.push_back(SIMPL_NEW_STRING_FP("Output Array Prefix", OutputArrayPrefix, FilterParameter::Category::CreatedArray, ConvertColorToGrayScale)); setFilterParameters(parameters); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ConvertColorToGrayScale::initialize() { } +void ConvertColorToGrayScale::initialize() +{ +} // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ConvertColorToGrayScale::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(!DataArrayPath::ValidateVector(getInputDataArrayVector())) { - setErrorCondition(-62100); QString ss = QObject::tr("All Attribute Arrays must belong to the same Data Container and Attribute Matrix"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-62100, ss); } if(getOutputArrayPrefix().isEmpty()) { - setErrorCondition(-62102); QString message = QObject::tr("Using a prefix (even a single alphanumeric value) is required so that the output Xdmf files can be written correctly"); - notifyErrorMessage(getHumanLabel(), message, getErrorCondition()); + setErrorCondition(-62102, message); } - if(getInputDataArrayVector().isEmpty()) + if(getInputDataArrayVector().empty()) { - setErrorCondition(-62103); QString message = QObject::tr("At least one Attribute Array must be selected"); - notifyErrorMessage(getHumanLabel(), message, getErrorCondition()); + setErrorCondition(-62103, message); return; } DataArrayPath inputAMPath = DataArrayPath::GetAttributeMatrixPath(getInputDataArrayVector()); - AttributeMatrix::Pointer inAM = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, inputAMPath, -301); - if(getErrorCondition() < 0 || nullptr == inAM.get()) + AttributeMatrix::Pointer inAM = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, inputAMPath, -301); + if(getErrorCode() < 0 || nullptr == inAM.get()) { return; } @@ -304,17 +289,17 @@ void ConvertColorToGrayScale::dataCheck() AttributeMatrix::Pointer outAM; if(m_CreateNewAttributeMatrix) { - QVector tDims = inAM->getTupleDimensions(); + std::vector tDims = inAM->getTupleDimensions(); outAM = dc->createNonPrereqAttributeMatrix(this, getOutputAttributeMatrixName(), tDims, AttributeMatrix::Type::Cell); - if(getErrorCondition() < 0 || nullptr == outAM.get()) + if(getErrorCode() < 0 || nullptr == outAM.get()) { return; } } // Get the list of checked array names from the input m_Data arrays list - QList arrayNames = DataArrayPath::GetDataArrayNames(getInputDataArrayVector()); + std::vector arrayNames = DataArrayPath::GetDataArrayNames(getInputDataArrayVector()); m_OutputArrayPaths.clear(); m_OutputArrayPaths.resize(arrayNames.size()); for(int32_t i = 0; i < arrayNames.size(); i++) @@ -323,11 +308,11 @@ void ConvertColorToGrayScale::dataCheck() QString newName = getOutputArrayPrefix() + arrayNames.at(i); inputAMPath.setDataArrayName(daName); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - QVector outCDims(1, 1); + std::vector outCDims(1, 1); if(outAM.get() == nullptr) { outAM = dc->getPrereqAttributeMatrix(this, inputAMPath.getAttributeMatrixName(), -62105); @@ -341,46 +326,31 @@ void ConvertColorToGrayScale::dataCheck() { if(m_ColorChannel < 0 || m_ColorChannel > 2) { - setErrorCondition(-62104); QString message = QObject::tr("The color channel should be 0, 1 or 2"); - notifyErrorMessage(getHumanLabel(), message, getErrorCondition()); + setErrorCondition(-62104, message); return; } } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void ConvertColorToGrayScale::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ConvertColorToGrayScale::execute() { initialize(); - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QString ss; dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { - setErrorCondition(-62106); ss = QObject::tr("DataCheck did not pass during execute"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-62106, ss); return; } - QVector inputArrayPaths = getInputDataArrayVector(); + std::vector inputArrayPaths = getInputDataArrayVector(); qint32 size = inputArrayPaths.size(); for(qint32 i = 0; i < size; i++) @@ -395,22 +365,18 @@ void ConvertColorToGrayScale::execute() if(nullptr == inputColorData.get()) { - setErrorCondition(-62107); ss = QObject::tr("Input Color Data at ArrayPath '%1' was not available. This array will be skipped.").arg(arrayPath.serialize("/")); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-62107, ss); continue; } DataArrayPath newPath = m_OutputArrayPaths[i]; - UInt8ArrayType::Pointer outputGrayData = getDataContainerArray()-> - getAttributeMatrix(newPath)-> - getAttributeArrayAs(newPath.getDataArrayName()); + UInt8ArrayType::Pointer outputGrayData = getDataContainerArray()->getAttributeMatrix(newPath)->getAttributeArrayAs(newPath.getDataArrayName()); if(nullptr == outputGrayData.get()) { - setErrorCondition(-62108); ss = QObject::tr("Output Data at ArrayPath '%1' was not available. This array will be skipped.").arg(newPath.serialize("/")); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-62108, ss); continue; } @@ -419,24 +385,20 @@ void ConvertColorToGrayScale::execute() size_t comp = inputColorData->getNumberOfComponents(); size_t totalPoints = inputColorData->getNumberOfTuples(); -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - tbb::task_scheduler_init init; -#endif - - switch (convType) + switch(convType) { - case ConversionType::Luminosity: - ParallelWrapper::Run(LuminosityImpl(inputColorData->getPointer(0), outputGrayData->getPointer(0), m_ColorWeights, comp), totalPoints ); - break; - case ConversionType::Average: - ParallelWrapper::Run(LuminosityImpl(inputColorData->getPointer(0), outputGrayData->getPointer(0), {0.3333f, 0.3333f, 0.3333f}, comp) , totalPoints); - break; - case ConversionType::Lightness: - ParallelWrapper::Run(LightnessImpl(inputColorData->getPointer(0), outputGrayData->getPointer(0), comp) , totalPoints); - break; - case ConversionType::SingleChannel: - ParallelWrapper::Run(SingleChannelImpl(inputColorData->getPointer(0), outputGrayData->getPointer(0), comp, getColorChannel()) , totalPoints); - break; + case ConversionType::Luminosity: + ParallelWrapper::Run(LuminosityImpl(inputColorData->getPointer(0), outputGrayData->getPointer(0), m_ColorWeights, comp), totalPoints); + break; + case ConversionType::Average: + ParallelWrapper::Run(LuminosityImpl(inputColorData->getPointer(0), outputGrayData->getPointer(0), {0.3333f, 0.3333f, 0.3333f}, comp), totalPoints); + break; + case ConversionType::Lightness: + ParallelWrapper::Run(LightnessImpl(inputColorData->getPointer(0), outputGrayData->getPointer(0), comp), totalPoints); + break; + case ConversionType::SingleChannel: + ParallelWrapper::Run(SingleChannelImpl(inputColorData->getPointer(0), outputGrayData->getPointer(0), comp, getColorChannel()), totalPoints); + break; } } } @@ -457,7 +419,7 @@ AbstractFilter::Pointer ConvertColorToGrayScale::newFilterInstance(bool copyFilt // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConvertColorToGrayScale::getCompiledLibraryName() const +QString ConvertColorToGrayScale::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -465,7 +427,7 @@ const QString ConvertColorToGrayScale::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConvertColorToGrayScale::getBrandingString() const +QString ConvertColorToGrayScale::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -473,7 +435,7 @@ const QString ConvertColorToGrayScale::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConvertColorToGrayScale::getFilterVersion() const +QString ConvertColorToGrayScale::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -484,7 +446,7 @@ const QString ConvertColorToGrayScale::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConvertColorToGrayScale::getGroupName() const +QString ConvertColorToGrayScale::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -492,7 +454,7 @@ const QString ConvertColorToGrayScale::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid ConvertColorToGrayScale::getUuid() +QUuid ConvertColorToGrayScale::getUuid() const { return QUuid("{eb5a89c4-4e71-59b1-9719-d10a652d961e}"); } @@ -500,7 +462,7 @@ const QUuid ConvertColorToGrayScale::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConvertColorToGrayScale::getSubGroupName() const +QString ConvertColorToGrayScale::getSubGroupName() const { return SIMPL::FilterSubGroups::ImageFilters; } @@ -508,7 +470,120 @@ const QString ConvertColorToGrayScale::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConvertColorToGrayScale::getHumanLabel() const +QString ConvertColorToGrayScale::getHumanLabel() const { return "Color to GrayScale"; } + +// ----------------------------------------------------------------------------- +ConvertColorToGrayScale::Pointer ConvertColorToGrayScale::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr ConvertColorToGrayScale::New() +{ + struct make_shared_enabler : public ConvertColorToGrayScale + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString ConvertColorToGrayScale::getNameOfClass() const +{ + return QString("ConvertColorToGrayScale"); +} + +// ----------------------------------------------------------------------------- +QString ConvertColorToGrayScale::ClassName() +{ + return QString("ConvertColorToGrayScale"); +} + +// ----------------------------------------------------------------------------- +void ConvertColorToGrayScale::setConversionAlgorithm(int value) +{ + m_ConversionAlgorithm = value; +} + +// ----------------------------------------------------------------------------- +int ConvertColorToGrayScale::getConversionAlgorithm() const +{ + return m_ConversionAlgorithm; +} + +// ----------------------------------------------------------------------------- +void ConvertColorToGrayScale::setColorWeights(const FloatVec3Type& value) +{ + m_ColorWeights = value; +} + +// ----------------------------------------------------------------------------- +FloatVec3Type ConvertColorToGrayScale::getColorWeights() const +{ + return m_ColorWeights; +} + +// ----------------------------------------------------------------------------- +void ConvertColorToGrayScale::setColorChannel(int value) +{ + m_ColorChannel = value; +} + +// ----------------------------------------------------------------------------- +int ConvertColorToGrayScale::getColorChannel() const +{ + return m_ColorChannel; +} + +// ----------------------------------------------------------------------------- +void ConvertColorToGrayScale::setInputDataArrayVector(const std::vector& value) +{ + m_InputDataArrayVector = value; +} + +// ----------------------------------------------------------------------------- +std::vector ConvertColorToGrayScale::getInputDataArrayVector() const +{ + return m_InputDataArrayVector; +} + +// ----------------------------------------------------------------------------- +void ConvertColorToGrayScale::setCreateNewAttributeMatrix(bool value) +{ + m_CreateNewAttributeMatrix = value; +} + +// ----------------------------------------------------------------------------- +bool ConvertColorToGrayScale::getCreateNewAttributeMatrix() const +{ + return m_CreateNewAttributeMatrix; +} + +// ----------------------------------------------------------------------------- +void ConvertColorToGrayScale::setOutputAttributeMatrixName(const QString& value) +{ + m_OutputAttributeMatrixName = value; +} + +// ----------------------------------------------------------------------------- +QString ConvertColorToGrayScale::getOutputAttributeMatrixName() const +{ + return m_OutputAttributeMatrixName; +} + +// ----------------------------------------------------------------------------- +void ConvertColorToGrayScale::setOutputArrayPrefix(const QString& value) +{ + m_OutputArrayPrefix = value; +} + +// ----------------------------------------------------------------------------- +QString ConvertColorToGrayScale::getOutputArrayPrefix() const +{ + return m_OutputArrayPrefix; +} diff --git a/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.h b/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.h index 3c3e4165da..4af764b45d 100644 --- a/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.h +++ b/Source/SIMPLib/CoreFilters/ConvertColorToGrayScale.h @@ -27,17 +27,18 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLArray.hpp" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The ConvertColorToGrayScale class. See [Filter documentation](@ref ConvertColorToGrayScale) for details. @@ -45,23 +46,53 @@ class SIMPLib_EXPORT ConvertColorToGrayScale : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(ConvertColorToGrayScale SUPERCLASS AbstractFilter) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ConvertColorToGrayScale SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(ConvertColorToGrayScale) + PYB11_FILTER_NEW_MACRO(ConvertColorToGrayScale) PYB11_PROPERTY(int ConversionAlgorithm READ getConversionAlgorithm WRITE setConversionAlgorithm) - PYB11_PROPERTY(FloatVec3_t ColorWeights READ getColorWeights WRITE setColorWeights) + PYB11_PROPERTY(FloatVec3Type ColorWeights READ getColorWeights WRITE setColorWeights) PYB11_PROPERTY(int ColorChannel READ getColorChannel WRITE setColorChannel) - PYB11_PROPERTY(QVector InputDataArrayVector READ getInputDataArrayVector WRITE setInputDataArrayVector) + PYB11_PROPERTY(std::vector InputDataArrayVector READ getInputDataArrayVector WRITE setInputDataArrayVector) PYB11_PROPERTY(bool CreateNewAttributeMatrix READ getCreateNewAttributeMatrix WRITE setCreateNewAttributeMatrix) PYB11_PROPERTY(QString OutputAttributeMatrixName READ getOutputAttributeMatrixName WRITE setOutputAttributeMatrixName) PYB11_PROPERTY(QString OutputArrayPrefix READ getOutputArrayPrefix WRITE setOutputArrayPrefix) + PYB11_END_BINDINGS() + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(ConvertColorToGrayScale) - SIMPL_FILTER_NEW_MACRO(ConvertColorToGrayScale) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ConvertColorToGrayScale, AbstractFilter) + using Self = ConvertColorToGrayScale; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for ConvertColorToGrayScale + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ConvertColorToGrayScale + */ + static QString ClassName(); ~ConvertColorToGrayScale() override; - using EnumType = unsigned int; + using EnumType = uint32_t; enum class ConversionType : EnumType { Luminosity = 0, @@ -70,45 +101,108 @@ class SIMPLib_EXPORT ConvertColorToGrayScale : public AbstractFilter SingleChannel = 3 }; - SIMPL_FILTER_PARAMETER(int, ConversionAlgorithm) + /** + * @brief Setter property for ConversionAlgorithm + */ + void setConversionAlgorithm(int value); + /** + * @brief Getter property for ConversionAlgorithm + * @return Value of ConversionAlgorithm + */ + int getConversionAlgorithm() const; + Q_PROPERTY(int ConversionAlgorithm READ getConversionAlgorithm WRITE setConversionAlgorithm) - SIMPL_FILTER_PARAMETER(FloatVec3_t, ColorWeights) - Q_PROPERTY(FloatVec3_t ColorWeights READ getColorWeights WRITE setColorWeights) + /** + * @brief Setter property for ColorWeights + */ + void setColorWeights(const FloatVec3Type& value); + /** + * @brief Getter property for ColorWeights + * @return Value of ColorWeights + */ + FloatVec3Type getColorWeights() const; + + Q_PROPERTY(FloatVec3Type ColorWeights READ getColorWeights WRITE setColorWeights) + + /** + * @brief Setter property for ColorChannel + */ + void setColorChannel(int value); + /** + * @brief Getter property for ColorChannel + * @return Value of ColorChannel + */ + int getColorChannel() const; - SIMPL_FILTER_PARAMETER(int, ColorChannel) Q_PROPERTY(int ColorChannel READ getColorChannel WRITE setColorChannel) - SIMPL_FILTER_PARAMETER(QVector, InputDataArrayVector) - Q_PROPERTY(QVector InputDataArrayVector READ getInputDataArrayVector WRITE setInputDataArrayVector) + /** + * @brief Setter property for InputDataArrayVector + */ + void setInputDataArrayVector(const std::vector& value); + /** + * @brief Getter property for InputDataArrayVector + * @return Value of InputDataArrayVector + */ + std::vector getInputDataArrayVector() const; + + Q_PROPERTY(DataArrayPathVec InputDataArrayVector READ getInputDataArrayVector WRITE setInputDataArrayVector) + + /** + * @brief Setter property for CreateNewAttributeMatrix + */ + void setCreateNewAttributeMatrix(bool value); + /** + * @brief Getter property for CreateNewAttributeMatrix + * @return Value of CreateNewAttributeMatrix + */ + bool getCreateNewAttributeMatrix() const; - SIMPL_FILTER_PARAMETER(bool, CreateNewAttributeMatrix) Q_PROPERTY(bool CreateNewAttributeMatrix READ getCreateNewAttributeMatrix WRITE setCreateNewAttributeMatrix) - SIMPL_FILTER_PARAMETER(QString, OutputAttributeMatrixName) + /** + * @brief Setter property for OutputAttributeMatrixName + */ + void setOutputAttributeMatrixName(const QString& value); + /** + * @brief Getter property for OutputAttributeMatrixName + * @return Value of OutputAttributeMatrixName + */ + QString getOutputAttributeMatrixName() const; + Q_PROPERTY(QString OutputAttributeMatrixName READ getOutputAttributeMatrixName WRITE setOutputAttributeMatrixName) - SIMPL_FILTER_PARAMETER(QString, OutputArrayPrefix) + /** + * @brief Setter property for OutputArrayPrefix + */ + void setOutputArrayPrefix(const QString& value); + /** + * @brief Getter property for OutputArrayPrefix + * @return Value of OutputArrayPrefix + */ + QString getOutputArrayPrefix() const; + Q_PROPERTY(QString OutputArrayPrefix READ getOutputArrayPrefix WRITE setOutputArrayPrefix) /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class */ - const QString getCompiledLibraryName() const override; + QString getCompiledLibraryName() const override; /** * @brief getBrandingString Returns the branding string for the filter, which is a tag * used to denote the filter's association with specific plugins * @return Branding string */ - const QString getBrandingString() const override; + QString getBrandingString() const override; /** * @brief getFilterVersion Returns a version string for this filter. Default * value is an empty string. * @return */ - const QString getFilterVersion() const override; + QString getFilterVersion() const override; /** * @brief newFilterInstance Reimplemented from @see AbstractFilter class @@ -118,23 +212,23 @@ class SIMPLib_EXPORT ConvertColorToGrayScale : public AbstractFilter /** * @brief getGroupName Reimplemented from @see AbstractFilter class */ - const QString getGroupName() const override; + QString getGroupName() const override; /** * @brief getSubGroupName Reimplemented from @see AbstractFilter class */ - const QString getSubGroupName() const override; + QString getSubGroupName() const override; /** * @brief getUuid Return the unique identifier for this filter. * @return A QUuid object. */ - const QUuid getUuid() override; + QUuid getUuid() const override; /** * @brief getHumanLabel Reimplemented from @see AbstractFilter class */ - const QString getHumanLabel() const override; + QString getHumanLabel() const override; /** * @brief setupFilterParameters Reimplemented from @see AbstractFilter class @@ -146,40 +240,12 @@ class SIMPLib_EXPORT ConvertColorToGrayScale : public AbstractFilter */ void execute() override; - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - -signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - protected: ConvertColorToGrayScale(); /** * @brief dataCheck Checks for the appropriate parameter values and availability of arrays */ - void dataCheck(); + void dataCheck() override; /** * @brief Initializes all the private instance variables. @@ -187,6 +253,14 @@ class SIMPLib_EXPORT ConvertColorToGrayScale : public AbstractFilter void initialize(); private: + int m_ConversionAlgorithm = {0}; + FloatVec3Type m_ColorWeights = {0.2125f, 0.7154f, 0.0721f}; + int m_ColorChannel = {0}; + std::vector m_InputDataArrayVector = {}; + bool m_CreateNewAttributeMatrix = {false}; + QString m_OutputAttributeMatrixName = {"GrayScaleData"}; + QString m_OutputArrayPrefix = {}; + QVector m_OutputArrayPaths; public: diff --git a/Source/SIMPLib/CoreFilters/ConvertData.cpp b/Source/SIMPLib/CoreFilters/ConvertData.cpp index 4756c492ac..eb6697a957 100644 --- a/Source/SIMPLib/CoreFilters/ConvertData.cpp +++ b/Source/SIMPLib/CoreFilters/ConvertData.cpp @@ -1,48 +1,52 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ConvertData.h" #include +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" -#include "SIMPLib/FilterParameters/NumericTypeFilterParameter.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" +#include "SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.h" +#include "SIMPLib/FilterParameters/NumericTypeFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" #define CHECK_AND_CONVERT(Type, DataContainer, ScalarType, Array, AttributeMatrixName, OutputName) \ if(false == completed) \ @@ -50,7 +54,7 @@ Type::Pointer Type##Ptr = std::dynamic_pointer_cast(Array); \ if(nullptr != Type##Ptr) \ { \ - QVector dims = Array->getComponentDimensions(); \ + std::vector dims = Array->getComponentDimensions(); \ Detail::ConvertData(this, Type##Ptr.get(), dims, DataContainer, ScalarType, AttributeMatrixName, OutputName); \ completed = true; \ } \ @@ -68,15 +72,16 @@ template * @param attributeMatrixName Name of target AttributeMatrix * @param name Name of converted array */ -void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataContainer::Pointer m, SIMPL::NumericTypes::Type scalarType, const QString attributeMatrixName, const QString& name) +void ConvertData(AbstractFilter* filter, T* ptr, const std::vector& dims, DataContainer::Pointer m, SIMPL::NumericTypes::Type scalarType, const QString attributeMatrixName, + const QString& name) { size_t voxels = ptr->getNumberOfTuples(); size_t size = ptr->getSize(); if(scalarType == SIMPL::NumericTypes::Type::Int8) { - Int8ArrayType::Pointer p = Int8ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + Int8ArrayType::Pointer p = Int8ArrayType::CreateArray(voxels, dims, name, true); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -84,8 +89,8 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta } else if(scalarType == SIMPL::NumericTypes::Type::UInt8) { - UInt8ArrayType::Pointer p = UInt8ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + UInt8ArrayType::Pointer p = UInt8ArrayType::CreateArray(voxels, dims, name, true); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -93,8 +98,8 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta } else if(scalarType == SIMPL::NumericTypes::Type::Int16) { - Int16ArrayType::Pointer p = Int16ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + Int16ArrayType::Pointer p = Int16ArrayType::CreateArray(voxels, dims, name, true); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -102,8 +107,8 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta } else if(scalarType == SIMPL::NumericTypes::Type::UInt16) { - UInt16ArrayType::Pointer p = UInt16ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + UInt16ArrayType::Pointer p = UInt16ArrayType::CreateArray(voxels, dims, name, true); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -111,8 +116,8 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta } else if(scalarType == SIMPL::NumericTypes::Type::Int32) { - Int32ArrayType::Pointer p = Int32ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + Int32ArrayType::Pointer p = Int32ArrayType::CreateArray(voxels, dims, name, true); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -120,8 +125,8 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta } else if(scalarType == SIMPL::NumericTypes::Type::UInt32) { - UInt32ArrayType::Pointer p = UInt32ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + UInt32ArrayType::Pointer p = UInt32ArrayType::CreateArray(voxels, dims, name, true); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -129,8 +134,8 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta } else if(scalarType == SIMPL::NumericTypes::Type::Int64) { - Int64ArrayType::Pointer p = Int64ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + Int64ArrayType::Pointer p = Int64ArrayType::CreateArray(voxels, dims, name, true); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -138,8 +143,8 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta } else if(scalarType == SIMPL::NumericTypes::Type::UInt64) { - UInt64ArrayType::Pointer p = UInt64ArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + UInt64ArrayType::Pointer p = UInt64ArrayType::CreateArray(voxels, dims, name, true); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -147,8 +152,8 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta } else if(scalarType == SIMPL::NumericTypes::Type::Float) { - FloatArrayType::Pointer p = FloatArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + FloatArrayType::Pointer p = FloatArrayType::CreateArray(voxels, dims, name, true); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -156,8 +161,8 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta } else if(scalarType == SIMPL::NumericTypes::Type::Double) { - DoubleArrayType::Pointer p = DoubleArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + DoubleArrayType::Pointer p = DoubleArrayType::CreateArray(voxels, dims, name, true); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -165,8 +170,8 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta } else if(scalarType == SIMPL::NumericTypes::Type::Bool) { - BoolArrayType::Pointer p = BoolArrayType::CreateArray(voxels, dims, name); - m->getAttributeMatrix(attributeMatrixName)->addAttributeArray(p->getName(), p); + BoolArrayType::Pointer p = BoolArrayType::CreateArray(voxels, dims, name, true); + m->getAttributeMatrix(attributeMatrixName)->insertOrAssign(p); for(size_t v = 0; v < size; ++v) { p->setValue(v, static_cast(ptr->getValue(v))); @@ -174,10 +179,9 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta } else { - filter->setErrorCondition(-399); QString ss = QString("Error Converting DataArray '%1/%2' from type %3 to type %4").arg(attributeMatrixName).arg(ptr->getName()).arg(static_cast(ptr->getType())).arg(static_cast(scalarType)); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-399, ss); } } } // End Namespace Detail @@ -185,12 +189,7 @@ void ConvertData(AbstractFilter* filter, T* ptr, QVector dims, DataConta // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ConvertData::ConvertData() -: m_ScalarType(SIMPL::NumericTypes::Type::Int8) -, m_OutputArrayName("") -, m_SelectedCellArrayPath("", "", "") -{ -} +ConvertData::ConvertData() = default; // ----------------------------------------------------------------------------- // @@ -202,16 +201,17 @@ ConvertData::~ConvertData() = default; // ----------------------------------------------------------------------------- void ConvertData::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(SIMPL_NEW_NUMERICTYPE_FP("Scalar Type", ScalarType, FilterParameter::Parameter, ConvertData)); + parameters.push_back(SIMPL_NEW_NUMERICTYPE_FP("Scalar Type", ScalarType, FilterParameter::Category::Parameter, ConvertData)); { DataArraySelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Attribute Array to Convert", SelectedCellArrayPath, FilterParameter::RequiredArray, ConvertData, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Attribute Array to Convert", SelectedCellArrayPath, FilterParameter::Category::RequiredArray, ConvertData, req)); } - parameters.push_back(SIMPL_NEW_STRING_FP("Converted Attribute Array", OutputArrayName, FilterParameter::CreatedArray, ConvertData)); + parameters.push_back( + SIMPL_NEW_DA_WITH_LINKED_AM_FP("Converted Attribute Array", OutputArrayName, SelectedCellArrayPath, SelectedCellArrayPath, FilterParameter::Category::CreatedArray, ConvertData)); setFilterParameters(parameters); } @@ -240,8 +240,8 @@ void ConvertData::initialize() // ----------------------------------------------------------------------------- void ConvertData::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, getSelectedCellArrayPath().getDataContainerName(), false); @@ -249,26 +249,25 @@ void ConvertData::dataCheck() if(m_OutputArrayName.isEmpty()) { ss = QObject::tr("The output array name must be set"); - setErrorCondition(-398); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-398, ss); return; } if(getInPreflight()) { - AttributeMatrix::Pointer cellAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedCellArrayPath, -301); - if(getErrorCondition() < 0) + AttributeMatrix::Pointer cellAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedCellArrayPath, -301); + if(getErrorCode() < 0) { return; } - IDataArray::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedCellArrayPath()); - if(getErrorCondition() < 0) + IDataArray::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedCellArrayPath()); + if(getErrorCode() < 0) { return; } - QVector dims = p->getComponentDimensions(); + std::vector dims = p->getComponentDimensions(); size_t voxels = cellAttrMat->getNumberOfTuples(); if(m_ScalarType == SIMPL::NumericTypes::Type::Int8) { @@ -314,32 +313,17 @@ void ConvertData::dataCheck() { p = BoolArrayType::CreateArray(voxels, dims, m_OutputArrayName, false); } - cellAttrMat->addAttributeArray(p->getName(), p); + cellAttrMat->insertOrAssign(p); } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void ConvertData::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ConvertData::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -349,9 +333,9 @@ void ConvertData::execute() IDataArray::Pointer iArray = am->getAttributeArray(m_SelectedCellArrayPath.getDataArrayName()); - if (nullptr == iArray.get()) + if(nullptr == iArray.get()) { - setErrorCondition(-90002); + setErrorCondition(-90002, tr("Data Array '%1' does not exist.").arg(m_SelectedCellArrayPath.getDataArrayName())); return; } @@ -385,7 +369,7 @@ AbstractFilter::Pointer ConvertData::newFilterInstance(bool copyFilterParameters // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConvertData::getCompiledLibraryName() const +QString ConvertData::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -393,7 +377,7 @@ const QString ConvertData::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConvertData::getBrandingString() const +QString ConvertData::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -401,7 +385,7 @@ const QString ConvertData::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConvertData::getFilterVersion() const +QString ConvertData::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -412,7 +396,7 @@ const QString ConvertData::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConvertData::getGroupName() const +QString ConvertData::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -420,7 +404,7 @@ const QString ConvertData::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid ConvertData::getUuid() +QUuid ConvertData::getUuid() const { return QUuid("{f4ba5fa4-bb5c-5dd1-9429-0dd86d0ecb37}"); } @@ -428,7 +412,7 @@ const QUuid ConvertData::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConvertData::getSubGroupName() const +QString ConvertData::getSubGroupName() const { return SIMPL::FilterSubGroups::ConversionFilters; } @@ -436,7 +420,72 @@ const QString ConvertData::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ConvertData::getHumanLabel() const +QString ConvertData::getHumanLabel() const { return "Convert AttributeArray Data Type"; } + +// ----------------------------------------------------------------------------- +ConvertData::Pointer ConvertData::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr ConvertData::New() +{ + struct make_shared_enabler : public ConvertData + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString ConvertData::getNameOfClass() const +{ + return QString("ConvertData"); +} + +// ----------------------------------------------------------------------------- +QString ConvertData::ClassName() +{ + return QString("ConvertData"); +} + +// ----------------------------------------------------------------------------- +void ConvertData::setScalarType(SIMPL::NumericTypes::Type value) +{ + m_ScalarType = value; +} + +// ----------------------------------------------------------------------------- +SIMPL::NumericTypes::Type ConvertData::getScalarType() const +{ + return m_ScalarType; +} + +// ----------------------------------------------------------------------------- +void ConvertData::setOutputArrayName(const QString& value) +{ + m_OutputArrayName = value; +} + +// ----------------------------------------------------------------------------- +QString ConvertData::getOutputArrayName() const +{ + return m_OutputArrayName; +} + +// ----------------------------------------------------------------------------- +void ConvertData::setSelectedCellArrayPath(const DataArrayPath& value) +{ + m_SelectedCellArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ConvertData::getSelectedCellArrayPath() const +{ + return m_SelectedCellArrayPath; +} diff --git a/Source/SIMPLib/CoreFilters/ConvertData.h b/Source/SIMPLib/CoreFilters/ConvertData.h old mode 100755 new mode 100644 index 7f92b02a8b..711445de79 --- a/Source/SIMPLib/CoreFilters/ConvertData.h +++ b/Source/SIMPLib/CoreFilters/ConvertData.h @@ -1,177 +1,201 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The ConvertData class. See [Filter documentation](@ref convertdata) for details. */ class SIMPLib_EXPORT ConvertData : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(ConvertData SUPERCLASS AbstractFilter) - PYB11_PROPERTY(SIMPL::NumericTypes::Type ScalarType READ getScalarType WRITE setScalarType) - PYB11_PROPERTY(QString OutputArrayName READ getOutputArrayName WRITE setOutputArrayName) - PYB11_PROPERTY(DataArrayPath SelectedCellArrayPath READ getSelectedCellArrayPath WRITE setSelectedCellArrayPath) - - public: - SIMPL_SHARED_POINTERS(ConvertData) - SIMPL_FILTER_NEW_MACRO(ConvertData) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ConvertData, AbstractFilter) - - ~ConvertData() override; - - SIMPL_FILTER_PARAMETER(SIMPL::NumericTypes::Type, ScalarType) - Q_PROPERTY(SIMPL::NumericTypes::Type ScalarType READ getScalarType WRITE setScalarType) - - SIMPL_FILTER_PARAMETER(QString, OutputArrayName) - Q_PROPERTY(QString OutputArrayName READ getOutputArrayName WRITE setOutputArrayName) - - SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedCellArrayPath) - Q_PROPERTY(DataArrayPath SelectedCellArrayPath READ getSelectedCellArrayPath WRITE setSelectedCellArrayPath) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - ConvertData(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - public: - ConvertData(const ConvertData&) = delete; // Copy Constructor Not Implemented - ConvertData(ConvertData&&) = delete; // Move Constructor Not Implemented - ConvertData& operator=(const ConvertData&) = delete; // Copy Assignment Not Implemented - ConvertData& operator=(ConvertData&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ConvertData SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(ConvertData) + PYB11_FILTER_NEW_MACRO(ConvertData) + PYB11_PROPERTY(SIMPL::NumericTypes::Type ScalarType READ getScalarType WRITE setScalarType) + PYB11_PROPERTY(QString OutputArrayName READ getOutputArrayName WRITE setOutputArrayName) + PYB11_PROPERTY(DataArrayPath SelectedCellArrayPath READ getSelectedCellArrayPath WRITE setSelectedCellArrayPath) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = ConvertData; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for ConvertData + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ConvertData + */ + static QString ClassName(); + + ~ConvertData() override; + + /** + * @brief Setter property for ScalarType + */ + void setScalarType(SIMPL::NumericTypes::Type value); + /** + * @brief Getter property for ScalarType + * @return Value of ScalarType + */ + SIMPL::NumericTypes::Type getScalarType() const; + + Q_PROPERTY(SIMPL::NumericTypes::Type ScalarType READ getScalarType WRITE setScalarType) + + /** + * @brief Setter property for OutputArrayName + */ + void setOutputArrayName(const QString& value); + /** + * @brief Getter property for OutputArrayName + * @return Value of OutputArrayName + */ + QString getOutputArrayName() const; + + Q_PROPERTY(QString OutputArrayName READ getOutputArrayName WRITE setOutputArrayName) + + /** + * @brief Setter property for SelectedCellArrayPath + */ + void setSelectedCellArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SelectedCellArrayPath + * @return Value of SelectedCellArrayPath + */ + DataArrayPath getSelectedCellArrayPath() const; + + Q_PROPERTY(DataArrayPath SelectedCellArrayPath READ getSelectedCellArrayPath WRITE setSelectedCellArrayPath) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + ConvertData(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +public: + ConvertData(const ConvertData&) = delete; // Copy Constructor Not Implemented + ConvertData(ConvertData&&) = delete; // Move Constructor Not Implemented + ConvertData& operator=(const ConvertData&) = delete; // Copy Assignment Not Implemented + ConvertData& operator=(ConvertData&&) = delete; // Move Assignment Not Implemented + +private: + SIMPL::NumericTypes::Type m_ScalarType = {SIMPL::NumericTypes::Type::Int8}; + QString m_OutputArrayName = {""}; + DataArrayPath m_SelectedCellArrayPath = {"", "", ""}; }; - diff --git a/Source/SIMPLib/CoreFilters/CopyFeatureArrayToElementArray.cpp b/Source/SIMPLib/CoreFilters/CopyFeatureArrayToElementArray.cpp index 4f667020f5..296907edb9 100644 --- a/Source/SIMPLib/CoreFilters/CopyFeatureArrayToElementArray.cpp +++ b/Source/SIMPLib/CoreFilters/CopyFeatureArrayToElementArray.cpp @@ -1,57 +1,60 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CopyFeatureArrayToElementArray.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" +#include "SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.h" #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + ElementArrayID = 1 +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -CopyFeatureArrayToElementArray::CopyFeatureArrayToElementArray() -: m_SelectedFeatureArrayPath("", "", "") -, m_FeatureIdsArrayPath("", "", "") -, m_CreatedArrayName("") -{ -} +CopyFeatureArrayToElementArray::CopyFeatureArrayToElementArray() = default; // ----------------------------------------------------------------------------- // @@ -63,22 +66,23 @@ CopyFeatureArrayToElementArray::~CopyFeatureArrayToElementArray() = default; // ----------------------------------------------------------------------------- void CopyFeatureArrayToElementArray::setupFilterParameters() { - FilterParameterVector parameters; - parameters.push_back(SeparatorFilterParameter::New("Feature Data", FilterParameter::RequiredArray)); + FilterParameterVectorType parameters; + parameters.push_back(SeparatorFilterParameter::Create("Feature Data", FilterParameter::Category::RequiredArray)); { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, AttributeMatrix::Category::Feature); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Feature Data to Copy to Element Data", SelectedFeatureArrayPath, FilterParameter::RequiredArray, CopyFeatureArrayToElementArray, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Feature Data to Copy to Element Data", SelectedFeatureArrayPath, FilterParameter::Category::RequiredArray, CopyFeatureArrayToElementArray, req)); } - parameters.push_back(SeparatorFilterParameter::New("Element Data", FilterParameter::RequiredArray)); + parameters.push_back(SeparatorFilterParameter::Create("Element Data", FilterParameter::Category::RequiredArray)); { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Int32, 1, AttributeMatrix::Category::Element); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Feature Ids", FeatureIdsArrayPath, FilterParameter::RequiredArray, CopyFeatureArrayToElementArray, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Feature Ids", FeatureIdsArrayPath, FilterParameter::Category::RequiredArray, CopyFeatureArrayToElementArray, req)); } - parameters.push_back(SeparatorFilterParameter::New("Element Data", FilterParameter::CreatedArray)); - parameters.push_back(SIMPL_NEW_STRING_FP("Copied Attribute Array", CreatedArrayName, FilterParameter::CreatedArray, CopyFeatureArrayToElementArray)); + parameters.push_back(SeparatorFilterParameter::Create("Element Data", FilterParameter::Category::CreatedArray)); + parameters.push_back( + SIMPL_NEW_DA_WITH_LINKED_AM_FP("Copied Attribute Array", CreatedArrayName, FeatureIdsArrayPath, FeatureIdsArrayPath, FilterParameter::Category::CreatedArray, CopyFeatureArrayToElementArray)); setFilterParameters(parameters); } @@ -107,56 +111,41 @@ void CopyFeatureArrayToElementArray::initialize() // ----------------------------------------------------------------------------- void CopyFeatureArrayToElementArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(getCreatedArrayName().isEmpty()) { - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), "The new Element array name must be set", getErrorCondition()); + setErrorCondition(-11002, "The new Element array name must be set"); return; } - QVector cDims(1, 1); - m_FeatureIdsPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getFeatureIdsArrayPath(), - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ - if(nullptr != m_FeatureIdsPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ + std::vector cDims(1, 1); + m_FeatureIdsPtr = getDataContainerArray()->getPrereqArrayFromPath>(this, getFeatureIdsArrayPath(), cDims); + if(nullptr != m_FeatureIdsPtr.lock()) { m_FeatureIds = m_FeatureIdsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ - m_InArrayPtr = - getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedFeatureArrayPath()); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ + m_InArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedFeatureArrayPath()); DataArrayPath tempPath(getFeatureIdsArrayPath().getDataContainerName(), getFeatureIdsArrayPath().getAttributeMatrixName(), ""); - getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, tempPath, -301); + getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, tempPath, -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } tempPath.update(getFeatureIdsArrayPath().getDataContainerName(), getFeatureIdsArrayPath().getAttributeMatrixName(), getCreatedArrayName()); - TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, m_InArrayPtr.lock()->getComponentDimensions(), m_InArrayPtr.lock()); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void CopyFeatureArrayToElementArray::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); + TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, m_InArrayPtr.lock()->getComponentDimensions(), m_InArrayPtr.lock(), ElementArrayID); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template IDataArray::Pointer copyData(IDataArray::Pointer inputData, size_t totalPoints, int32_t* featureIds) +template +IDataArray::Pointer copyData(IDataArray::Pointer inputData, size_t totalPoints, int32_t* featureIds) { QString cellArrayName = inputData->getName(); @@ -166,13 +155,13 @@ template IDataArray::Pointer copyData(IDataArray::Pointer inputData return IDataArray::NullPointer(); } - QVector cDims = inputData->getComponentDimensions(); - typename DataArray::Pointer cell = DataArray::CreateArray(totalPoints, cDims, cellArrayName); + std::vector cDims = inputData->getComponentDimensions(); + typename DataArray::Pointer cell = DataArray::CreateArray(totalPoints, cDims, cellArrayName, true); T* fPtr = feature->getPointer(0); T* cPtr = cell->getPointer(0); - int32_t numComp = feature->getNumberOfComponents(); + size_t numComp = static_cast(feature->getNumberOfComponents()); int32_t featureIdx = 0; for(size_t i = 0; i < totalPoints; ++i) @@ -195,10 +184,8 @@ template IDataArray::Pointer copyData(IDataArray::Pointer inputData // ----------------------------------------------------------------------------- void CopyFeatureArrayToElementArray::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -227,16 +214,14 @@ void CopyFeatureArrayToElementArray::execute() if(mismatchedFeatures) { QString ss = QObject::tr("The largest Feature Id (%1) in the FeatureIds array is larger than the number of Features in the InArray array (%2)").arg(largestFeature).arg(numFeatures); - setErrorCondition(-5555); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5555, ss); return; } if(largestFeature != (numFeatures - 1)) { QString ss = QObject::tr("The number of Features in the InArray array (%1) does not match the largest Feature Id in the FeatureIds array").arg(numFeatures); - setErrorCondition(-5555); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5555, ss); return; } @@ -289,17 +274,15 @@ void CopyFeatureArrayToElementArray::execute() else { QString ss = QObject::tr("The selected array was of unsupported type. The path is %1").arg(m_SelectedFeatureArrayPath.serialize()); - setErrorCondition(-14000); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-14000, ss); } if(p.get() != nullptr) { p->setName(getCreatedArrayName()); AttributeMatrix::Pointer am = getDataContainerArray()->getAttributeMatrix(getFeatureIdsArrayPath()); - am->addAttributeArray(p->getName(), p); + am->insertOrAssign(p); } - } // ----------------------------------------------------------------------------- @@ -318,7 +301,7 @@ AbstractFilter::Pointer CopyFeatureArrayToElementArray::newFilterInstance(bool c // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CopyFeatureArrayToElementArray::getCompiledLibraryName() const +QString CopyFeatureArrayToElementArray::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -326,7 +309,7 @@ const QString CopyFeatureArrayToElementArray::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CopyFeatureArrayToElementArray::getBrandingString() const +QString CopyFeatureArrayToElementArray::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -334,7 +317,7 @@ const QString CopyFeatureArrayToElementArray::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CopyFeatureArrayToElementArray::getFilterVersion() const +QString CopyFeatureArrayToElementArray::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -345,7 +328,7 @@ const QString CopyFeatureArrayToElementArray::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CopyFeatureArrayToElementArray::getGroupName() const +QString CopyFeatureArrayToElementArray::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -353,7 +336,7 @@ const QString CopyFeatureArrayToElementArray::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid CopyFeatureArrayToElementArray::getUuid() +QUuid CopyFeatureArrayToElementArray::getUuid() const { return QUuid("{99836b75-144b-5126-b261-b411133b5e8a}"); } @@ -361,7 +344,7 @@ const QUuid CopyFeatureArrayToElementArray::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CopyFeatureArrayToElementArray::getSubGroupName() const +QString CopyFeatureArrayToElementArray::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -369,7 +352,72 @@ const QString CopyFeatureArrayToElementArray::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CopyFeatureArrayToElementArray::getHumanLabel() const +QString CopyFeatureArrayToElementArray::getHumanLabel() const { return "Create Element Array from Feature Array"; } + +// ----------------------------------------------------------------------------- +CopyFeatureArrayToElementArray::Pointer CopyFeatureArrayToElementArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr CopyFeatureArrayToElementArray::New() +{ + struct make_shared_enabler : public CopyFeatureArrayToElementArray + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString CopyFeatureArrayToElementArray::getNameOfClass() const +{ + return QString("CopyFeatureArrayToElementArray"); +} + +// ----------------------------------------------------------------------------- +QString CopyFeatureArrayToElementArray::ClassName() +{ + return QString("CopyFeatureArrayToElementArray"); +} + +// ----------------------------------------------------------------------------- +void CopyFeatureArrayToElementArray::setSelectedFeatureArrayPath(const DataArrayPath& value) +{ + m_SelectedFeatureArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CopyFeatureArrayToElementArray::getSelectedFeatureArrayPath() const +{ + return m_SelectedFeatureArrayPath; +} + +// ----------------------------------------------------------------------------- +void CopyFeatureArrayToElementArray::setFeatureIdsArrayPath(const DataArrayPath& value) +{ + m_FeatureIdsArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CopyFeatureArrayToElementArray::getFeatureIdsArrayPath() const +{ + return m_FeatureIdsArrayPath; +} + +// ----------------------------------------------------------------------------- +void CopyFeatureArrayToElementArray::setCreatedArrayName(const QString& value) +{ + m_CreatedArrayName = value; +} + +// ----------------------------------------------------------------------------- +QString CopyFeatureArrayToElementArray::getCreatedArrayName() const +{ + return m_CreatedArrayName; +} diff --git a/Source/SIMPLib/CoreFilters/CopyFeatureArrayToElementArray.h b/Source/SIMPLib/CoreFilters/CopyFeatureArrayToElementArray.h old mode 100755 new mode 100644 index a2c1c7882c..75979c8e6b --- a/Source/SIMPLib/CoreFilters/CopyFeatureArrayToElementArray.h +++ b/Source/SIMPLib/CoreFilters/CopyFeatureArrayToElementArray.h @@ -1,181 +1,209 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/Filtering/AbstractFilter.h" + +class IDataArray; +using IDataArrayWkPtrType = std::weak_ptr; /** * @brief The CopyFeatureArrayToElementArray class. See [Filter documentation](@ref copyfeaturearraytoelementArray) for details. */ class SIMPLib_EXPORT CopyFeatureArrayToElementArray : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(CopyFeatureArrayToElementArray SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath SelectedFeatureArrayPath READ getSelectedFeatureArrayPath WRITE setSelectedFeatureArrayPath) - PYB11_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath) - PYB11_PROPERTY(QString CreatedArrayName READ getCreatedArrayName WRITE setCreatedArrayName) - - public: - SIMPL_SHARED_POINTERS(CopyFeatureArrayToElementArray) - SIMPL_FILTER_NEW_MACRO(CopyFeatureArrayToElementArray) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(CopyFeatureArrayToElementArray, AbstractFilter) - - ~CopyFeatureArrayToElementArray() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedFeatureArrayPath) - Q_PROPERTY(DataArrayPath SelectedFeatureArrayPath READ getSelectedFeatureArrayPath WRITE setSelectedFeatureArrayPath) - - SIMPL_FILTER_PARAMETER(DataArrayPath, FeatureIdsArrayPath) - Q_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath) - - SIMPL_FILTER_PARAMETER(QString, CreatedArrayName) - Q_PROPERTY(QString CreatedArrayName READ getCreatedArrayName WRITE setCreatedArrayName) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - CopyFeatureArrayToElementArray(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - DEFINE_DATAARRAY_VARIABLE(int32_t, FeatureIds) - DEFINE_IDATAARRAY_WEAKPTR(InArray) - - public: - CopyFeatureArrayToElementArray(const CopyFeatureArrayToElementArray&) = delete; // Copy Constructor Not Implemented - CopyFeatureArrayToElementArray(CopyFeatureArrayToElementArray&&) = delete; // Move Constructor Not Implemented - CopyFeatureArrayToElementArray& operator=(const CopyFeatureArrayToElementArray&) = delete; // Copy Assignment Not Implemented - CopyFeatureArrayToElementArray& operator=(CopyFeatureArrayToElementArray&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(CopyFeatureArrayToElementArray SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(CopyFeatureArrayToElementArray) + PYB11_FILTER_NEW_MACRO(CopyFeatureArrayToElementArray) + PYB11_PROPERTY(DataArrayPath SelectedFeatureArrayPath READ getSelectedFeatureArrayPath WRITE setSelectedFeatureArrayPath) + PYB11_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath) + PYB11_PROPERTY(QString CreatedArrayName READ getCreatedArrayName WRITE setCreatedArrayName) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = CopyFeatureArrayToElementArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for CopyFeatureArrayToElementArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for CopyFeatureArrayToElementArray + */ + static QString ClassName(); + + ~CopyFeatureArrayToElementArray() override; + + /** + * @brief Setter property for SelectedFeatureArrayPath + */ + void setSelectedFeatureArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SelectedFeatureArrayPath + * @return Value of SelectedFeatureArrayPath + */ + DataArrayPath getSelectedFeatureArrayPath() const; + + Q_PROPERTY(DataArrayPath SelectedFeatureArrayPath READ getSelectedFeatureArrayPath WRITE setSelectedFeatureArrayPath) + + /** + * @brief Setter property for FeatureIdsArrayPath + */ + void setFeatureIdsArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for FeatureIdsArrayPath + * @return Value of FeatureIdsArrayPath + */ + DataArrayPath getFeatureIdsArrayPath() const; + + Q_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath) + + /** + * @brief Setter property for CreatedArrayName + */ + void setCreatedArrayName(const QString& value); + /** + * @brief Getter property for CreatedArrayName + * @return Value of CreatedArrayName + */ + QString getCreatedArrayName() const; + + Q_PROPERTY(QString CreatedArrayName READ getCreatedArrayName WRITE setCreatedArrayName) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + CopyFeatureArrayToElementArray(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + std::weak_ptr> m_FeatureIdsPtr; + int32_t* m_FeatureIds = nullptr; + + IDataArrayWkPtrType m_InArrayPtr; + + DataArrayPath m_SelectedFeatureArrayPath = {"", "", ""}; + DataArrayPath m_FeatureIdsArrayPath = {"", "", ""}; + QString m_CreatedArrayName = {""}; + +public: + CopyFeatureArrayToElementArray(const CopyFeatureArrayToElementArray&) = delete; // Copy Constructor Not Implemented + CopyFeatureArrayToElementArray(CopyFeatureArrayToElementArray&&) = delete; // Move Constructor Not Implemented + CopyFeatureArrayToElementArray& operator=(const CopyFeatureArrayToElementArray&) = delete; // Copy Assignment Not Implemented + CopyFeatureArrayToElementArray& operator=(CopyFeatureArrayToElementArray&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/CopyObject.cpp b/Source/SIMPLib/CoreFilters/CopyObject.cpp index a6fff681aa..c5142f2eb6 100644 --- a/Source/SIMPLib/CoreFilters/CopyObject.cpp +++ b/Source/SIMPLib/CoreFilters/CopyObject.cpp @@ -26,35 +26,39 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - #include "CopyObject.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/LinkedChoicesFilterParameter.h" +#include "SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + DataContainerID = 1, + AttributeMatrixID, + DataArrayID +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -CopyObject::CopyObject() -: m_ObjectToCopy(0) -, m_DataContainerToCopy("") -, m_AttributeMatrixToCopy("", "", "") -, m_AttributeArrayToCopy("", "", "") -, m_CopiedObjectName("") -{ -} +CopyObject::CopyObject() = default; // ----------------------------------------------------------------------------- // @@ -66,40 +70,40 @@ CopyObject::~CopyObject() = default; // ----------------------------------------------------------------------------- void CopyObject::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { LinkedChoicesFilterParameter::Pointer parameter = LinkedChoicesFilterParameter::New(); parameter->setHumanLabel("Object Type to Copy"); parameter->setPropertyName("ObjectToCopy"); parameter->setSetterCallback(SIMPL_BIND_SETTER(CopyObject, this, ObjectToCopy)); parameter->setGetterCallback(SIMPL_BIND_GETTER(CopyObject, this, ObjectToCopy)); - QVector choices; + std::vector choices; choices.push_back("Data Container"); choices.push_back("Attribute Matrix"); choices.push_back("Attribute Array"); parameter->setChoices(choices); - QStringList linkedProps; - linkedProps << "DataContainerToCopy" - << "AttributeMatrixToCopy" - << "AttributeArrayToCopy"; + std::vector linkedProps; + linkedProps.push_back("DataContainerToCopy"); + linkedProps.push_back("AttributeMatrixToCopy"); + linkedProps.push_back("AttributeArrayToCopy"); parameter->setLinkedProperties(linkedProps); parameter->setEditable(false); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameters.push_back(parameter); } { DataContainerSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container to Copy", DataContainerToCopy, FilterParameter::RequiredArray, CopyObject, req, 0)); + parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container to Copy", DataContainerToCopy, FilterParameter::Category::RequiredArray, CopyObject, req, 0)); } { AttributeMatrixSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Attribute Matrix to Copy", AttributeMatrixToCopy, FilterParameter::RequiredArray, CopyObject, req, 1)); + parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Attribute Matrix to Copy", AttributeMatrixToCopy, FilterParameter::Category::RequiredArray, CopyObject, req, 1)); } { DataArraySelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Attribute Array to Copy", AttributeArrayToCopy, FilterParameter::RequiredArray, CopyObject, req, 2)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Attribute Array to Copy", AttributeArrayToCopy, FilterParameter::Category::RequiredArray, CopyObject, req, 2)); } - parameters.push_back(SIMPL_NEW_STRING_FP("Copied Object Name", CopiedObjectName, FilterParameter::CreatedArray, CopyObject)); + parameters.push_back(SIMPL_NEW_STRING_FP("Copied Object Name", CopiedObjectName, FilterParameter::Category::CreatedArray, CopyObject)); setFilterParameters(parameters); } @@ -110,7 +114,7 @@ void CopyObject::readFilterParameters(AbstractFilterParametersReader* reader, in { reader->openFilterGroup(this, index); setObjectToCopy(reader->readValue("ObjectToCopy", getObjectToCopy())); - setDataContainerToCopy(reader->readString("DataContainerToCopy", getDataContainerToCopy())); + setDataContainerToCopy(reader->readDataArrayPath("DataContainerToCopy", getDataContainerToCopy())); setAttributeMatrixToCopy(reader->readDataArrayPath("AttributeMatrixToCopy", getAttributeMatrixToCopy())); setAttributeArrayToCopy(reader->readDataArrayPath("AttributeArrayToCopy", getAttributeArrayToCopy())); setCopiedObjectName(reader->readString("CopiedObjectName", getCopiedObjectName())); @@ -129,126 +133,101 @@ void CopyObject::initialize() // ----------------------------------------------------------------------------- void CopyObject::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(getCopiedObjectName().isEmpty()) { - setErrorCondition(-11001); QString ss = QObject::tr("The copied object name must be set"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11001, ss); } switch(getObjectToCopy()) { // Copy Data Container - case 0: - { + case 0: { if(getDataContainerArray()->doesDataContainerExist(getCopiedObjectName())) { - setErrorCondition(-11001); QString ss = QObject::tr("A Data Container already exists with the name %1").arg(getCopiedObjectName()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11001, ss); } DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, getDataContainerToCopy()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } DataContainer::Pointer dcCopy = m->deepCopy(getInPreflight()); dcCopy->setName(getCopiedObjectName()); - getDataContainerArray()->addDataContainer(dcCopy); + getDataContainerArray()->addOrReplaceDataContainer(dcCopy); + RenameDataPath::AlertFilterCreatedPath(this, DataContainerID, dcCopy->getDataArrayPath()); break; } // Copy Attribute Matrix - case 1: - { + case 1: { DataArrayPath path(getAttributeMatrixToCopy().getDataContainerName(), getCopiedObjectName(), ""); if(getDataContainerArray()->doesAttributeMatrixExist(path)) { - setErrorCondition(-11001); QString ss = QObject::tr("An Attribute Matrix already exists with the name %1").arg(getCopiedObjectName()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11001, ss); } - AttributeMatrix::Pointer attrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getAttributeMatrixToCopy(), -301); + AttributeMatrix::Pointer attrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getAttributeMatrixToCopy(), -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } AttributeMatrix::Pointer attrMatCopy = attrMat->deepCopy(getInPreflight()); attrMatCopy->setName(getCopiedObjectName()); - getDataContainerArray()->getDataContainer(getAttributeMatrixToCopy().getDataContainerName())->addAttributeMatrix(getCopiedObjectName(), attrMatCopy); + getDataContainerArray()->getDataContainer(getAttributeMatrixToCopy().getDataContainerName())->addOrReplaceAttributeMatrix(attrMatCopy); + RenameDataPath::AlertFilterCreatedPath(this, AttributeMatrixID, attrMatCopy->getDataArrayPath()); break; } // Copy Attribute Array - case 2: - { + case 2: { DataArrayPath path(getAttributeArrayToCopy().getDataContainerName(), getAttributeArrayToCopy().getAttributeMatrixName(), getCopiedObjectName()); if(getDataContainerArray()->doesAttributeArrayExist(path)) { - setErrorCondition(-11001); QString ss = QObject::tr("An Attribute Array already exists with the name %1").arg(getCopiedObjectName()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11001, ss); } - IDataArray::Pointer array = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getAttributeArrayToCopy()); + IDataArray::Pointer array = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getAttributeArrayToCopy()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } IDataArray::Pointer arrayCopy = array->deepCopy(getInPreflight()); arrayCopy->setName(getCopiedObjectName()); - getDataContainerArray() - ->getDataContainer(getAttributeArrayToCopy().getDataContainerName()) - ->getAttributeMatrix(getAttributeArrayToCopy().getAttributeMatrixName()) - ->addAttributeArray(getCopiedObjectName(), arrayCopy); + getDataContainerArray()->getDataContainer(getAttributeArrayToCopy().getDataContainerName())->getAttributeMatrix(getAttributeArrayToCopy().getAttributeMatrixName())->insertOrAssign(arrayCopy); + RenameDataPath::AlertFilterCreatedPath(this, DataArrayID, arrayCopy->getDataArrayPath()); break; } - default: - { + default: { break; } } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void CopyObject::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void CopyObject::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - } // ----------------------------------------------------------------------------- @@ -267,7 +246,7 @@ AbstractFilter::Pointer CopyObject::newFilterInstance(bool copyFilterParameters) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CopyObject::getCompiledLibraryName() const +QString CopyObject::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -275,7 +254,7 @@ const QString CopyObject::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CopyObject::getBrandingString() const +QString CopyObject::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -283,7 +262,7 @@ const QString CopyObject::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CopyObject::getFilterVersion() const +QString CopyObject::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -293,7 +272,7 @@ const QString CopyObject::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CopyObject::getGroupName() const +QString CopyObject::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -301,7 +280,7 @@ const QString CopyObject::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid CopyObject::getUuid() +QUuid CopyObject::getUuid() const { return QUuid("{088ef69b-ca98-51a9-97ac-369862015d71}"); } @@ -309,7 +288,7 @@ const QUuid CopyObject::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CopyObject::getSubGroupName() const +QString CopyObject::getSubGroupName() const { return SIMPL::FilterSubGroups::ConversionFilters; } @@ -317,7 +296,96 @@ const QString CopyObject::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CopyObject::getHumanLabel() const +QString CopyObject::getHumanLabel() const { return "Copy Object"; } + +// ----------------------------------------------------------------------------- +CopyObject::Pointer CopyObject::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr CopyObject::New() +{ + struct make_shared_enabler : public CopyObject + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString CopyObject::getNameOfClass() const +{ + return QString("CopyObject"); +} + +// ----------------------------------------------------------------------------- +QString CopyObject::ClassName() +{ + return QString("CopyObject"); +} + +// ----------------------------------------------------------------------------- +void CopyObject::setObjectToCopy(int value) +{ + m_ObjectToCopy = value; +} + +// ----------------------------------------------------------------------------- +int CopyObject::getObjectToCopy() const +{ + return m_ObjectToCopy; +} + +// ----------------------------------------------------------------------------- +void CopyObject::setDataContainerToCopy(const DataArrayPath& value) +{ + m_DataContainerToCopy = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CopyObject::getDataContainerToCopy() const +{ + return m_DataContainerToCopy; +} + +// ----------------------------------------------------------------------------- +void CopyObject::setAttributeMatrixToCopy(const DataArrayPath& value) +{ + m_AttributeMatrixToCopy = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CopyObject::getAttributeMatrixToCopy() const +{ + return m_AttributeMatrixToCopy; +} + +// ----------------------------------------------------------------------------- +void CopyObject::setAttributeArrayToCopy(const DataArrayPath& value) +{ + m_AttributeArrayToCopy = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CopyObject::getAttributeArrayToCopy() const +{ + return m_AttributeArrayToCopy; +} + +// ----------------------------------------------------------------------------- +void CopyObject::setCopiedObjectName(const QString& value) +{ + m_CopiedObjectName = value; +} + +// ----------------------------------------------------------------------------- +QString CopyObject::getCopiedObjectName() const +{ + return m_CopiedObjectName; +} diff --git a/Source/SIMPLib/CoreFilters/CopyObject.h b/Source/SIMPLib/CoreFilters/CopyObject.h index 5e2323d3c6..df83ecd637 100644 --- a/Source/SIMPLib/CoreFilters/CopyObject.h +++ b/Source/SIMPLib/CoreFilters/CopyObject.h @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,9 +35,10 @@ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The CopyObject class. See [Filter documentation](@ref copyobject) for details. @@ -45,53 +46,128 @@ class SIMPLib_EXPORT CopyObject : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(CopyObject SUPERCLASS AbstractFilter) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(CopyObject SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(CopyObject) + PYB11_FILTER_NEW_MACRO(CopyObject) PYB11_PROPERTY(int ObjectToCopy READ getObjectToCopy WRITE setObjectToCopy) - PYB11_PROPERTY(QString DataContainerToCopy READ getDataContainerToCopy WRITE setDataContainerToCopy) + PYB11_PROPERTY(DataArrayPath DataContainerToCopy READ getDataContainerToCopy WRITE setDataContainerToCopy) PYB11_PROPERTY(DataArrayPath AttributeMatrixToCopy READ getAttributeMatrixToCopy WRITE setAttributeMatrixToCopy) PYB11_PROPERTY(DataArrayPath AttributeArrayToCopy READ getAttributeArrayToCopy WRITE setAttributeArrayToCopy) PYB11_PROPERTY(QString CopiedObjectName READ getCopiedObjectName WRITE setCopiedObjectName) + PYB11_END_BINDINGS() + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(CopyObject) - SIMPL_FILTER_NEW_MACRO(CopyObject) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(CopyObject, AbstractFilter) + using Self = CopyObject; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for CopyObject + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for CopyObject + */ + static QString ClassName(); ~CopyObject() override; - SIMPL_FILTER_PARAMETER(int, ObjectToCopy) + /** + * @brief Setter property for ObjectToCopy + */ + void setObjectToCopy(int value); + /** + * @brief Getter property for ObjectToCopy + * @return Value of ObjectToCopy + */ + int getObjectToCopy() const; + Q_PROPERTY(int ObjectToCopy READ getObjectToCopy WRITE setObjectToCopy) - SIMPL_FILTER_PARAMETER(QString, DataContainerToCopy) - Q_PROPERTY(QString DataContainerToCopy READ getDataContainerToCopy WRITE setDataContainerToCopy) + /** + * @brief Setter property for DataContainerToCopy + */ + void setDataContainerToCopy(const DataArrayPath& value); + /** + * @brief Getter property for DataContainerToCopy + * @return Value of DataContainerToCopy + */ + DataArrayPath getDataContainerToCopy() const; + + Q_PROPERTY(DataArrayPath DataContainerToCopy READ getDataContainerToCopy WRITE setDataContainerToCopy) + + /** + * @brief Setter property for AttributeMatrixToCopy + */ + void setAttributeMatrixToCopy(const DataArrayPath& value); + /** + * @brief Getter property for AttributeMatrixToCopy + * @return Value of AttributeMatrixToCopy + */ + DataArrayPath getAttributeMatrixToCopy() const; - SIMPL_FILTER_PARAMETER(DataArrayPath, AttributeMatrixToCopy) Q_PROPERTY(DataArrayPath AttributeMatrixToCopy READ getAttributeMatrixToCopy WRITE setAttributeMatrixToCopy) - SIMPL_FILTER_PARAMETER(DataArrayPath, AttributeArrayToCopy) + /** + * @brief Setter property for AttributeArrayToCopy + */ + void setAttributeArrayToCopy(const DataArrayPath& value); + /** + * @brief Getter property for AttributeArrayToCopy + * @return Value of AttributeArrayToCopy + */ + DataArrayPath getAttributeArrayToCopy() const; + Q_PROPERTY(DataArrayPath AttributeArrayToCopy READ getAttributeArrayToCopy WRITE setAttributeArrayToCopy) - SIMPL_FILTER_PARAMETER(QString, CopiedObjectName) + /** + * @brief Setter property for CopiedObjectName + */ + void setCopiedObjectName(const QString& value); + /** + * @brief Getter property for CopiedObjectName + * @return Value of CopiedObjectName + */ + QString getCopiedObjectName() const; + Q_PROPERTY(QString CopiedObjectName READ getCopiedObjectName WRITE setCopiedObjectName) /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class */ - const QString getCompiledLibraryName() const override; + QString getCompiledLibraryName() const override; /** * @brief getBrandingString Returns the branding string for the filter, which is a tag * used to denote the filter's association with specific plugins * @return Branding string */ - const QString getBrandingString() const override; + QString getBrandingString() const override; /** * @brief getFilterVersion Returns a version string for this filter. Default * value is an empty string. * @return */ - const QString getFilterVersion() const override; + QString getFilterVersion() const override; /** * @brief newFilterInstance Reimplemented from @see AbstractFilter class @@ -101,23 +177,23 @@ class SIMPLib_EXPORT CopyObject : public AbstractFilter /** * @brief getGroupName Reimplemented from @see AbstractFilter class */ - const QString getGroupName() const override; + QString getGroupName() const override; /** * @brief getSubGroupName Reimplemented from @see AbstractFilter class */ - const QString getSubGroupName() const override; + QString getSubGroupName() const override; /** * @brief getUuid Return the unique identifier for this filter. * @return A QUuid object. */ - const QUuid getUuid() override; + QUuid getUuid() const override; /** * @brief getHumanLabel Reimplemented from @see AbstractFilter class */ - const QString getHumanLabel() const override; + QString getHumanLabel() const override; /** * @brief setupFilterParameters Reimplemented from @see AbstractFilter class @@ -134,40 +210,12 @@ class SIMPLib_EXPORT CopyObject : public AbstractFilter */ void execute() override; - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - -signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - protected: CopyObject(); /** * @brief dataCheck Checks for the appropriate parameter values and availability of arrays */ - void dataCheck(); + void dataCheck() override; /** * @brief Initializes all the private instance variables. @@ -179,5 +227,11 @@ class SIMPLib_EXPORT CopyObject : public AbstractFilter CopyObject(CopyObject&&) = delete; // Move Constructor Not Implemented CopyObject& operator=(const CopyObject&) = delete; // Copy Assignment Not Implemented CopyObject& operator=(CopyObject&&) = delete; // Move Assignment Not Implemented -}; +private: + int m_ObjectToCopy = {0}; + DataArrayPath m_DataContainerToCopy = {"", "", ""}; + DataArrayPath m_AttributeMatrixToCopy = {"", "", ""}; + DataArrayPath m_AttributeArrayToCopy = {"", "", ""}; + QString m_CopiedObjectName = {""}; +}; diff --git a/Source/SIMPLib/CoreFilters/CoreResources/ColorTablePresets/ColorTablePresets.json b/Source/SIMPLib/CoreFilters/CoreResources/ColorTablePresets/ColorTablePresets.json index b2b8fdc6ed..334dbfb59b 100644 --- a/Source/SIMPLib/CoreFilters/CoreResources/ColorTablePresets/ColorTablePresets.json +++ b/Source/SIMPLib/CoreFilters/CoreResources/ColorTablePresets/ColorTablePresets.json @@ -412,6 +412,133 @@ 0.301960784314 ] }, + { + "ColorSpace": "RGB", + "Name": "Hot Iron", + "NanColor": [1,1,1], + "RGBPoints": [ + 0,0,0,0, + 0.0083999997,0,0,0.14117648, + 0.016799999,0,0,0.2, + 0.0252,0,0,0.25882354, + 0.033599999,0,0,0.31764707, + 0.041999999,0.0078431377,0,0.35294119, + 0.0504,0.015686275,0,0.3882353, + 0.058800001,0.027450981,0,0.41568628, + 0.067199998,0.043137256,0,0.4509804, + 0.075599998,0.054901961,0,0.46666667, + 0.083999999,0.078431375,0,0.48235294, + 0.092399999,0.10588235,0,0.50196081, + 0.1008,0.12941177,0,0.52156866, + 0.1092,0.16078432,0,0.53725493, + 0.1176,0.1882353,0,0.54901963, + 0.126,0.21568628,0,0.56078434, + 0.1344,0.23921569,0,0.57254905, + 0.1428,0.25882354,0,0.58431375, + 0.1512,0.28235295,0,0.58823532, + 0.1596,0.30588236,0,0.59215689, + 0.168,0.32941177,0,0.59607846, + 0.17640001,0.35686275,0,0.60000002, + 0.1848,0.38039216,0,0.60784316, + 0.19320001,0.40784314,0,0.60784316, + 0.2016,0.43137255,0,0.61176473, + 0.20999999,0.4509804,0,0.6156863, + 0.2184,0.47843137,0,0.6156863, + 0.22679999,0.50196081,0,0.6156863, + 0.2352,0.52549022,0,0.6156863, + 0.2436,0.54509807,0,0.6156863, + 0.252,0.57254905,0,0.61176473, + 0.2604,0.59607846,0,0.60784316, + 0.26879999,0.6156863,0,0.60784316, + 0.27720001,0.63529414,0,0.60784316, + 0.28560001,0.65490198,0,0.60392159, + 0.294,0.67058825,0,0.60000002, + 0.30239999,0.68627453,0.0039215689,0.59607846, + 0.31079999,0.69803923,0.0039215689,0.59215689, + 0.31920001,0.71372551,0.0078431377,0.58431375, + 0.3276,0.72549021,0.015686275,0.58431375, + 0.336,0.73725492,0.019607844,0.57647061, + 0.34439999,0.74901962,0.023529412,0.57254905, + 0.35280001,0.75686276,0.031372551,0.56470591, + 0.3612,0.7647059,0.043137256,0.55686277, + 0.3696,0.7764706,0.050980393,0.54509807, + 0.37799999,0.78823531,0.06666667,0.52941179, + 0.38640001,0.79607844,0.078431375,0.51764709, + 0.39480001,0.80784315,0.090196081,0.49803922, + 0.4032,0.81568629,0.10196079,0.47450981, + 0.41159999,0.82352942,0.11372549,0.45490196, + 0.41999999,0.83137256,0.12941177,0.43529412, + 0.42840001,0.8392157,0.14509805,0.40392157, + 0.4368,0.8509804,0.16078432,0.38039216, + 0.4452,0.85882354,0.18039216,0.34901962, + 0.45359999,0.86666667,0.19215687,0.30588236, + 0.46200001,0.87450981,0.20784314,0.25882354, + 0.47040001,0.87843138,0.21960784,0.21176471, + 0.4788,0.88627452,0.23529412,0.16470589, + 0.48719999,0.89411765,0.25098041,0.11764706, + 0.49559999,0.89803922,0.26666668,0.098039217, + 0.50400001,0.90588236,0.28235295,0.078431375, + 0.51239997,0.90980393,0.29803923,0.062745102, + 0.52079999,0.91764706,0.30588236,0.047058824, + 0.52920002,0.92156863,0.32156864,0.039215688, + 0.53759998,0.9254902,0.33725491,0.031372551, + 0.546,0.92941177,0.35294119,0.027450981, + 0.55440003,0.93333334,0.36470589,0.019607844, + 0.56279999,0.93725491,0.3764706,0.015686275, + 0.57120001,0.94117647,0.39215687,0.011764706, + 0.57959998,0.94509804,0.40392157,0.011764706, + 0.588,0.94509804,0.41568628,0.0078431377, + 0.59640002,0.94901961,0.42745098,0.0039215689, + 0.60479999,0.95294118,0.44313726,0.0039215689, + 0.61320001,0.95686275,0.45490196,0, + 0.62159997,0.95686275,0.47058824,0, + 0.63,0.96078432,0.49019608,0, + 0.63840002,0.96470588,0.50588238,0, + 0.64679998,0.96862745,0.52156866,0, + 0.6552,0.97254902,0.53333336,0, + 0.66360003,0.97254902,0.54509807,0, + 0.67199999,0.97647059,0.55686277,0, + 0.68040001,0.97647059,0.56862748,0, + 0.68879998,0.98039216,0.58431375,0, + 0.6972,0.98431373,0.60392159,0, + 0.70560002,0.98823529,0.62352943,0, + 0.71399999,0.99215686,0.63921571,0, + 0.72240001,0.99215686,0.65882355,0, + 0.73079997,0.99215686,0.67450982,0, + 0.7392,0.99607843,0.6901961,0, + 0.74760002,0.99607843,0.7019608,0, + 0.75599998,0.99607843,0.72156864,0, + 0.76440001,0.99607843,0.73333335,0, + 0.77280003,0.99607843,0.74901962,0, + 0.78119999,0.99607843,0.7647059,0, + 0.78960001,0.99607843,0.78039217,0, + 0.79799998,0.99607843,0.79215688,0.0039215689, + 0.8064,0.99607843,0.80392158,0.0078431377, + 0.81480002,0.99607843,0.81568629,0.019607844, + 0.82319999,0.99607843,0.83137256,0.035294119, + 0.83160001,0.99607843,0.84705883,0.047058824, + 0.83999997,1,0.85882354,0.05882353, + 0.8484,1,0.86666667,0.090196081, + 0.85680002,1,0.87843138,0.1254902, + 0.86519998,1,0.89019608,0.15294118, + 0.87360001,1,0.89803922,0.19607843, + 0.88200003,1,0.90980393,0.24705882, + 0.89039999,1,0.92156863,0.29411766, + 0.89880002,1,0.93333334,0.34509805, + 0.90719998,1,0.93725491,0.40000001, + 0.9156,1,0.94509804,0.45490196, + 0.92400002,1,0.94901961,0.52549022, + 0.93239999,1,0.95686275,0.58431375, + 0.94080001,1,0.96078432,0.64313728, + 0.94919997,1,0.96862745,0.7019608, + 0.9576,1,0.97254902,0.75294119, + 0.96600002,1,0.97647059,0.79607844, + 0.97439998,1,0.98431373,0.84705883, + 0.98280001,1,0.99215686,0.89411765, + 0.99119997,1,0.99607843,0.93725491, + 0.99959999,1,1,0.97647059 + ] + }, { "ColorSpace" : "RGB", "Name" : "Cold and Hot", diff --git a/Source/SIMPLib/CoreFilters/CreateAttributeMatrix.cpp b/Source/SIMPLib/CoreFilters/CreateAttributeMatrix.cpp index 52607b37b8..e58b11fa14 100644 --- a/Source/SIMPLib/CoreFilters/CreateAttributeMatrix.cpp +++ b/Source/SIMPLib/CoreFilters/CreateAttributeMatrix.cpp @@ -1,55 +1,59 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CreateAttributeMatrix.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.h" #include "SIMPLib/FilterParameters/ChoiceFilterParameter.h" #include "SIMPLib/FilterParameters/DynamicTableFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + AttributeMatrixID = 1 +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -CreateAttributeMatrix::CreateAttributeMatrix() -: m_CreatedAttributeMatrix("", "AttributeMatrix", "") -, m_AttributeMatrixType(static_cast(AttributeMatrix::Type::Generic)) -{ -} +CreateAttributeMatrix::CreateAttributeMatrix() = default; // ----------------------------------------------------------------------------- // @@ -61,10 +65,10 @@ CreateAttributeMatrix::~CreateAttributeMatrix() = default; // ----------------------------------------------------------------------------- void CreateAttributeMatrix::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { - QVector choices; + std::vector choices; choices.push_back("Vertex"); choices.push_back("Edge"); choices.push_back("Face"); @@ -79,14 +83,14 @@ void CreateAttributeMatrix::setupFilterParameters() choices.push_back("CellEnsemble"); choices.push_back("MetaData"); choices.push_back("Generic"); - parameters.push_back(SIMPL_NEW_CHOICE_FP("Attribute Matrix Type", AttributeMatrixType, FilterParameter::Parameter, CreateAttributeMatrix, choices, false)); + parameters.push_back(SIMPL_NEW_CHOICE_FP("Attribute Matrix Type", AttributeMatrixType, FilterParameter::Category::Parameter, CreateAttributeMatrix, choices, false)); } m_TupleDimensions.setDynamicCols(true); - parameters.push_back(SIMPL_NEW_DYN_TABLE_FP("Tuple Dimensions", TupleDimensions, FilterParameter::Parameter, CreateAttributeMatrix)); + parameters.push_back(SIMPL_NEW_DYN_TABLE_FP("Tuple Dimensions", TupleDimensions, FilterParameter::Category::Parameter, CreateAttributeMatrix)); { AttributeMatrixCreationFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_AM_CREATION_FP("Created Attribute Matrix", CreatedAttributeMatrix, FilterParameter::CreatedArray, CreateAttributeMatrix, req)); + parameters.push_back(SIMPL_NEW_AM_CREATION_FP("Created Attribute Matrix", CreatedAttributeMatrix, FilterParameter::Category::CreatedArray, CreateAttributeMatrix, req)); } setFilterParameters(parameters); @@ -116,11 +120,11 @@ void CreateAttributeMatrix::initialize() // ----------------------------------------------------------------------------- void CreateAttributeMatrix::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, getCreatedAttributeMatrix().getDataContainerName()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -131,48 +135,31 @@ void CreateAttributeMatrix::dataCheck() if(rows.size() != 1) { QString ss = QObject::tr("The number of rows of data must be 1. The data currently has %1").arg(rows.size()); - setErrorCondition(-11000); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11000, ss); return; } std::vector cols = rows[0]; // Get the first (and only) row of data - QVector tDims(cols.size(), 0); + std::vector tDims(cols.size(), 0); for(int i = 0; i < cols.size(); i++) { tDims[i] = static_cast(cols[i]); } - m->createNonPrereqAttributeMatrix(this, getCreatedAttributeMatrix().getAttributeMatrixName(), tDims, static_cast(getAttributeMatrixType())); - if(getErrorCondition() < 0) + m->createNonPrereqAttributeMatrix(this, getCreatedAttributeMatrix().getAttributeMatrixName(), tDims, static_cast(getAttributeMatrixType()), AttributeMatrixID); + if(getErrorCode() < 0) { return; } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void CreateAttributeMatrix::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void CreateAttributeMatrix::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -181,7 +168,6 @@ void CreateAttributeMatrix::execute() { return; } - } // ----------------------------------------------------------------------------- @@ -200,7 +186,7 @@ AbstractFilter::Pointer CreateAttributeMatrix::newFilterInstance(bool copyFilter // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateAttributeMatrix::getCompiledLibraryName() const +QString CreateAttributeMatrix::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -208,7 +194,7 @@ const QString CreateAttributeMatrix::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateAttributeMatrix::getBrandingString() const +QString CreateAttributeMatrix::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -216,7 +202,7 @@ const QString CreateAttributeMatrix::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateAttributeMatrix::getFilterVersion() const +QString CreateAttributeMatrix::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -227,7 +213,7 @@ const QString CreateAttributeMatrix::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateAttributeMatrix::getGroupName() const +QString CreateAttributeMatrix::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -235,7 +221,7 @@ const QString CreateAttributeMatrix::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateAttributeMatrix::getHumanLabel() const +QString CreateAttributeMatrix::getHumanLabel() const { return "Create Attribute Matrix"; } @@ -243,7 +229,7 @@ const QString CreateAttributeMatrix::getHumanLabel() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid CreateAttributeMatrix::getUuid() +QUuid CreateAttributeMatrix::getUuid() const { return QUuid("{93375ef0-7367-5372-addc-baa019b1b341}"); } @@ -251,7 +237,72 @@ const QUuid CreateAttributeMatrix::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateAttributeMatrix::getSubGroupName() const +QString CreateAttributeMatrix::getSubGroupName() const { return SIMPL::FilterSubGroups::GenerationFilters; } + +// ----------------------------------------------------------------------------- +CreateAttributeMatrix::Pointer CreateAttributeMatrix::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr CreateAttributeMatrix::New() +{ + struct make_shared_enabler : public CreateAttributeMatrix + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString CreateAttributeMatrix::getNameOfClass() const +{ + return QString("CreateAttributeMatrix"); +} + +// ----------------------------------------------------------------------------- +QString CreateAttributeMatrix::ClassName() +{ + return QString("CreateAttributeMatrix"); +} + +// ----------------------------------------------------------------------------- +void CreateAttributeMatrix::setCreatedAttributeMatrix(const DataArrayPath& value) +{ + m_CreatedAttributeMatrix = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateAttributeMatrix::getCreatedAttributeMatrix() const +{ + return m_CreatedAttributeMatrix; +} + +// ----------------------------------------------------------------------------- +void CreateAttributeMatrix::setAttributeMatrixType(int value) +{ + m_AttributeMatrixType = value; +} + +// ----------------------------------------------------------------------------- +int CreateAttributeMatrix::getAttributeMatrixType() const +{ + return m_AttributeMatrixType; +} + +// ----------------------------------------------------------------------------- +void CreateAttributeMatrix::setTupleDimensions(const DynamicTableData& value) +{ + m_TupleDimensions = value; +} + +// ----------------------------------------------------------------------------- +DynamicTableData CreateAttributeMatrix::getTupleDimensions() const +{ + return m_TupleDimensions; +} diff --git a/Source/SIMPLib/CoreFilters/CreateAttributeMatrix.h b/Source/SIMPLib/CoreFilters/CreateAttributeMatrix.h old mode 100755 new mode 100644 index 39481da307..13f5f283e2 --- a/Source/SIMPLib/CoreFilters/CreateAttributeMatrix.h +++ b/Source/SIMPLib/CoreFilters/CreateAttributeMatrix.h @@ -1,178 +1,202 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/FilterParameters/DynamicTableData.h" #include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/SIMPLib.h" /** * @brief The CreateAttributeMatrix class. See [Filter documentation](@ref createattributematrix) for details. */ class SIMPLib_EXPORT CreateAttributeMatrix : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(CreateAttributeMatrix SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath CreatedAttributeMatrix READ getCreatedAttributeMatrix WRITE setCreatedAttributeMatrix) - PYB11_PROPERTY(int AttributeMatrixType READ getAttributeMatrixType WRITE setAttributeMatrixType) - PYB11_PROPERTY(DynamicTableData TupleDimensions READ getTupleDimensions WRITE setTupleDimensions) - - public: - SIMPL_SHARED_POINTERS(CreateAttributeMatrix) - SIMPL_FILTER_NEW_MACRO(CreateAttributeMatrix) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(CreateAttributeMatrix, AbstractFilter) - - ~CreateAttributeMatrix() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, CreatedAttributeMatrix) - Q_PROPERTY(DataArrayPath CreatedAttributeMatrix READ getCreatedAttributeMatrix WRITE setCreatedAttributeMatrix) - - SIMPL_FILTER_PARAMETER(int, AttributeMatrixType) - Q_PROPERTY(int AttributeMatrixType READ getAttributeMatrixType WRITE setAttributeMatrixType) - - SIMPL_FILTER_PARAMETER(DynamicTableData, TupleDimensions) - Q_PROPERTY(DynamicTableData TupleDimensions READ getTupleDimensions WRITE setTupleDimensions) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - CreateAttributeMatrix(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - public: - CreateAttributeMatrix(const CreateAttributeMatrix&) = delete; // Copy Constructor Not Implemented - CreateAttributeMatrix(CreateAttributeMatrix&&) = delete; // Move Constructor Not Implemented - CreateAttributeMatrix& operator=(const CreateAttributeMatrix&) = delete; // Copy Assignment Not Implemented - CreateAttributeMatrix& operator=(CreateAttributeMatrix&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(CreateAttributeMatrix SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(CreateAttributeMatrix) + PYB11_FILTER_NEW_MACRO(CreateAttributeMatrix) + PYB11_PROPERTY(DataArrayPath CreatedAttributeMatrix READ getCreatedAttributeMatrix WRITE setCreatedAttributeMatrix) + PYB11_PROPERTY(int AttributeMatrixType READ getAttributeMatrixType WRITE setAttributeMatrixType) + PYB11_PROPERTY(DynamicTableData TupleDimensions READ getTupleDimensions WRITE setTupleDimensions) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = CreateAttributeMatrix; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for CreateAttributeMatrix + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for CreateAttributeMatrix + */ + static QString ClassName(); + + ~CreateAttributeMatrix() override; + + /** + * @brief Setter property for CreatedAttributeMatrix + */ + void setCreatedAttributeMatrix(const DataArrayPath& value); + /** + * @brief Getter property for CreatedAttributeMatrix + * @return Value of CreatedAttributeMatrix + */ + DataArrayPath getCreatedAttributeMatrix() const; + + Q_PROPERTY(DataArrayPath CreatedAttributeMatrix READ getCreatedAttributeMatrix WRITE setCreatedAttributeMatrix) + + /** + * @brief Setter property for AttributeMatrixType + */ + void setAttributeMatrixType(int value); + /** + * @brief Getter property for AttributeMatrixType + * @return Value of AttributeMatrixType + */ + int getAttributeMatrixType() const; + + Q_PROPERTY(int AttributeMatrixType READ getAttributeMatrixType WRITE setAttributeMatrixType) + + /** + * @brief Setter property for TupleDimensions + */ + void setTupleDimensions(const DynamicTableData& value); + /** + * @brief Getter property for TupleDimensions + * @return Value of TupleDimensions + */ + DynamicTableData getTupleDimensions() const; + + Q_PROPERTY(DynamicTableData TupleDimensions READ getTupleDimensions WRITE setTupleDimensions) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + CreateAttributeMatrix(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +public: + CreateAttributeMatrix(const CreateAttributeMatrix&) = delete; // Copy Constructor Not Implemented + CreateAttributeMatrix(CreateAttributeMatrix&&) = delete; // Move Constructor Not Implemented + CreateAttributeMatrix& operator=(const CreateAttributeMatrix&) = delete; // Copy Assignment Not Implemented + CreateAttributeMatrix& operator=(CreateAttributeMatrix&&) = delete; // Move Assignment Not Implemented + +private: + DataArrayPath m_CreatedAttributeMatrix = {"", "AttributeMatrix", ""}; + int m_AttributeMatrixType = {static_cast(AttributeMatrix::Type::Generic)}; + DynamicTableData m_TupleDimensions = {}; }; - diff --git a/Source/SIMPLib/CoreFilters/CreateDataArray.cpp b/Source/SIMPLib/CoreFilters/CreateDataArray.cpp index 807e568e5e..7f782daf86 100644 --- a/Source/SIMPLib/CoreFilters/CreateDataArray.cpp +++ b/Source/SIMPLib/CoreFilters/CreateDataArray.cpp @@ -1,46 +1,48 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CreateDataArray.h" -#include - +#include #include #include -#include +#include +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" @@ -50,87 +52,105 @@ #include "SIMPLib/FilterParameters/LinkedChoicesFilterParameter.h" #include "SIMPLib/FilterParameters/ScalarTypeFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" -/** -* @brief initializeArrayWithInts Initializes the array p with integers, either from the -* manual value entered in the filter, or with a random number. This function does not -* check that the template type actually is an integer, so it will most likely cause -* unexpected results when passing anything other than an integer as a template parameter. -* @param p The array that will be initialized -*/ -template void initializeArrayWithInts(IDataArray::Pointer outputArrayPtr, int initializationType, FPRangePair initializationRange, const QString& initializationValue, SIMPL::ScalarTypes::Type scalarType) +enum createdPathID : RenameDataPath::DataID_t { + DataArrayID = 1 +}; - typename DataArray::Pointer array = std::dynamic_pointer_cast>(outputArrayPtr); - size_t count = array->getSize(); - T* rawPointer = array->getPointer(0); +namespace CDA +{ - if(initializationType == CreateDataArray::Manual) - { +#define CDA_CREATE_CONVERTOR(type, func) \ + template <> \ + struct convert_from \ + { \ + static std::pair convert(const QString& input) \ + { \ + bool ok = false; \ + type value = static_cast(input.func(&ok)); \ + return {value, ok}; \ + } \ + }; + +template +struct convert_from +{ +}; + +CDA_CREATE_CONVERTOR(uint8_t, toUInt) +CDA_CREATE_CONVERTOR(int8_t, toInt) +CDA_CREATE_CONVERTOR(uint16_t, toUShort) +CDA_CREATE_CONVERTOR(int16_t, toShort) +CDA_CREATE_CONVERTOR(uint32_t, toUInt) +CDA_CREATE_CONVERTOR(int32_t, toInt) +CDA_CREATE_CONVERTOR(uint64_t, toULongLong) +CDA_CREATE_CONVERTOR(int64_t, toLongLong) +CDA_CREATE_CONVERTOR(bool, toInt) - qint8 i8 = static_cast(initializationValue.toInt()); - quint8 ui8 = static_cast(initializationValue.toUInt()); - qint16 i16 = static_cast(initializationValue.toShort()); - quint16 ui16 = static_cast(initializationValue.toUShort()); - qint32 i32 = static_cast(initializationValue.toInt()); - quint32 ui32 = static_cast(initializationValue.toUInt()); - qint64 i64 = static_cast(initializationValue.toLongLong()); - quint64 ui64 = static_cast(initializationValue.toULongLong()); +CDA_CREATE_CONVERTOR(float, toDouble) +CDA_CREATE_CONVERTOR(double, toDouble) - switch(scalarType) +constexpr char CDA_SEP = ';'; + +/** + * + */ +template +std::vector createInitVector(AbstractFilter* filter, const QString& initializationValue, int32_t numComponents) +{ + using ConvertOutputType = std::pair; + ConvertOutputType conversionResult; + std::vector values(numComponents); + + QStringList tokens = initializationValue.split(CDA_SEP, QSTRING_KEEP_EMPTY_PARTS); + + for(int32_t i = 0; i < numComponents; i++) + { + int32_t idx = (tokens.size() == 1 ? 0 : i); + if(idx >= tokens.size()) { - case SIMPL::ScalarTypes::Type::Int8: - for(size_t i = 0; i < count; i++) - { - rawPointer[i] = static_cast(i8); - } - break; - case SIMPL::ScalarTypes::Type::UInt8: - for(size_t i = 0; i < count; i++) - { - rawPointer[i] = static_cast(ui8); - } - break; - case SIMPL::ScalarTypes::Type::Int16: - for(size_t i = 0; i < count; i++) - { - rawPointer[i] = static_cast(i16); - } - break; - case SIMPL::ScalarTypes::Type::UInt16: - for(size_t i = 0; i < count; i++) - { - rawPointer[i] = static_cast(ui16); - } - break; - case SIMPL::ScalarTypes::Type::Int32: - for(size_t i = 0; i < count; i++) - { - rawPointer[i] = static_cast(i32); - } - break; - case SIMPL::ScalarTypes::Type::UInt32: - for(size_t i = 0; i < count; i++) - { - rawPointer[i] = static_cast(ui32); - } - break; - case SIMPL::ScalarTypes::Type::Int64: - for(size_t i = 0; i < count; i++) - { - rawPointer[i] = static_cast(i64); - } - break; - case SIMPL::ScalarTypes::Type::UInt64: - for(size_t i = 0; i < count; i++) + values.clear(); + return values; + } + conversionResult = convert_from::convert(tokens[idx]); + if(conversionResult.second) + { + values[i] = conversionResult.first; + } + else + { + if(filter) { - rawPointer[i] = static_cast(ui64); + QString msg = QString("Input String '%1' could not be converted to a numeric value(s). ").arg(tokens[0]); + filter->setErrorCondition(-5400, msg); + values.clear(); + return values; } - break; - default: - Q_ASSERT_X(false, __FILE__, "Incorrent use of CreateDataArray::initializeArrayWithInts when using a non-integer type"); - break; + } + } + return values; +} + +/** + * @brief CDA::initializeArrayWithInts Initializes the array p with integers, either from the + * manual value entered in the filter, or with a random number. This function does not + * check that the template type actually is an integer, so it will most likely cause + * unexpected results when passing anything other than an integer as a template parameter. + * @param p The array that will be initialized + */ +template +void initializeArrayWithInts(CreateDataArray* filter, IDataArray::Pointer outputArrayPtr, FPRangePair initializationRange) +{ + std::vector initValues = CDA::createInitVector(filter, filter->getInitializationValue(), filter->getNumberOfComponents()); + typename DataArray::Pointer array = std::dynamic_pointer_cast>(outputArrayPtr); + size_t numTuples = array->getNumberOfTuples(); + + if(filter->getInitializationType() == CreateDataArray::Manual) + { + for(size_t t = 0; t < numTuples; t++) + { + array->setTuple(t, initValues); } } else @@ -140,8 +160,10 @@ template void initializeArrayWithInts(IDataArray::Pointer outputArr std::mt19937_64::result_type seed = static_cast(std::chrono::steady_clock::now().time_since_epoch().count()); std::mt19937_64 generator(seed); // Standard mersenne_twister_engine seeded with milliseconds - std::uniform_int_distribution<> distribution(rangeMin , rangeMax); + std::uniform_int_distribution<> distribution(rangeMin, rangeMax); + size_t count = array->size(); + T* rawPointer = array->getPointer(0); for(size_t i = 0; i < count; i++) { T value = static_cast(distribution(generator)); @@ -151,26 +173,26 @@ template void initializeArrayWithInts(IDataArray::Pointer outputArr } /** -* @brief initializeArrayWithInts Initializes the array p with integers, either from the -* manual value entered in the filter, or with a random number. This function does not -* check that the template type actually is an integer, so it will most likely cause -* unexpected results when passing anything other than an integer as a template parameter. -* @param p The array that will be initialized -*/ -template <> void initializeArrayWithInts(IDataArray::Pointer outputArrayPtr, int initializationType, FPRangePair initializationRange, const QString& initializationValue, SIMPL::ScalarTypes::Type scalarType) + * @brief CDA::initializeArrayWithInts Initializes the array p with integers, either from the + * manual value entered in the filter, or with a random number. This function does not + * check that the template type actually is an integer, so it will most likely cause + * unexpected results when passing anything other than an integer as a template parameter. + * @param p The array that will be initialized + */ +void initializeArrayWithBool(CreateDataArray* filter, IDataArray::Pointer outputArrayPtr) { + std::vector initValues = CDA::createInitVector(filter, filter->getInitializationValue(), filter->getNumberOfComponents()); DataArray::Pointer array = std::dynamic_pointer_cast>(outputArrayPtr); - size_t count = array->getSize(); - bool* rawPointer = array->getPointer(0); - - if(initializationType == CreateDataArray::Manual) + size_t numTuples = array->getNumberOfTuples(); + int32_t numComp = array->getNumberOfComponents(); + if(filter->getInitializationType() == CreateDataArray::Manual) { - bool result; - result = initializationValue.toInt() != 0; - - for(size_t i = 0; i < count; i++) + for(size_t t = 0; t < numTuples; t++) { - rawPointer[i] = result; + for(int32_t c = 0; c < numComp; c++) + { + array->setComponent(t, c, initValues[c]); + } } } else @@ -178,6 +200,8 @@ template <> void initializeArrayWithInts(IDataArray::Pointer outputArrayPt std::mt19937_64::result_type seed = static_cast(std::chrono::steady_clock::now().time_since_epoch().count()); std::mt19937_64 generator(seed); // Standard mersenne_twister_engine seeded with milliseconds std::uniform_int_distribution distribution(0, 1); + size_t count = array->getSize(); + bool* rawPointer = array->getPointer(0); for(size_t i = 0; i < count; i++) { @@ -195,29 +219,32 @@ template <> void initializeArrayWithInts(IDataArray::Pointer outputArrayPt } /** -* @brief initializeArrayWithReals Initializes the array p with real numbers, either from the -* manual value entered in the filter, or with a random number. This function does not -* check that the template type actually is a non-integer, so it will most likely cause -* unexpected results when passing anything other than a float or double as a template -* parameter. -* @param p The array that will be initialized -*/ -template void initializeArrayWithReals(IDataArray::Pointer outputArrayPtr, int initializationType, FPRangePair initializationRange, const QString& initializationValue) + * @brief initializeArrayWithReals Initializes the array p with real numbers, either from the + * manual value entered in the filter, or with a random number. This function does not + * check that the template type actually is a non-integer, so it will most likely cause + * unexpected results when passing anything other than a float or double as a template + * parameter. + * @param p The array that will be initialized + */ +template +void initializeArrayWithReals(CreateDataArray* filter, IDataArray::Pointer outputArrayPtr, FPRangePair initializationRange) { + std::vector initValues = CDA::createInitVector(filter, filter->getInitializationValue(), filter->getNumberOfComponents()); + typename DataArray::Pointer array = std::dynamic_pointer_cast>(outputArrayPtr); - size_t count = array->getSize(); - T* rawPointer = array->getPointer(0); + size_t numTuples = array->getNumberOfTuples(); - if(initializationType == CreateDataArray::Manual) + if(filter->getInitializationType() == CreateDataArray::Manual) { - T value = static_cast(initializationValue.toDouble()); - for(size_t i = 0; i < count; i++) + for(size_t t = 0; t < numTuples; t++) { - rawPointer[i] = value; + array->setTuple(t, initValues); } } else { + size_t count = array->getSize(); + T* rawPointer = array->getPointer(0); T rangeMin = static_cast(initializationRange.first); T rangeMax = static_cast(initializationRange.second); @@ -225,7 +252,6 @@ template void initializeArrayWithReals(IDataArray::Pointer outputAr std::mt19937_64 generator(seed); // Standard mersenne_twister_engine seeded with milliseconds std::uniform_real_distribution<> distribution(rangeMin, rangeMax); - size_t count = array->getSize(); for(size_t i = 0; i < count; i++) { T value = distribution(generator); @@ -234,17 +260,12 @@ template void initializeArrayWithReals(IDataArray::Pointer outputAr } } +} // namespace CDA + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -CreateDataArray::CreateDataArray() -: m_ScalarType(SIMPL::ScalarTypes::Type::Int8) -, m_NumberOfComponents(0) -, m_NewArray("", "", "") -, m_InitializationType(Manual) -, m_InitializationValue("0") -{ -} +CreateDataArray::CreateDataArray() = default; // ----------------------------------------------------------------------------- // @@ -256,10 +277,10 @@ CreateDataArray::~CreateDataArray() = default; // ----------------------------------------------------------------------------- void CreateDataArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(SIMPL_NEW_SCALARTYPE_FP("Scalar Type", ScalarType, FilterParameter::Parameter, CreateDataArray)); - parameters.push_back(SIMPL_NEW_INTEGER_FP("Number of Components", NumberOfComponents, FilterParameter::Parameter, CreateDataArray)); + parameters.push_back(SIMPL_NEW_SCALARTYPE_FP("Scalar Type", ScalarType, FilterParameter::Category::Parameter, CreateDataArray)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Number of Components", NumberOfComponents, FilterParameter::Category::Parameter, CreateDataArray)); { LinkedChoicesFilterParameter::Pointer parameter = LinkedChoicesFilterParameter::New(); @@ -270,23 +291,23 @@ void CreateDataArray::setupFilterParameters() parameter->setDefaultValue(Manual); - QVector choices; + std::vector choices; choices.push_back("Manual"); choices.push_back("Random With Range"); parameter->setChoices(choices); - QStringList linkedProps; - linkedProps << "InitializationValue" - << "InitializationRange"; + std::vector linkedProps; + linkedProps.push_back("InitializationValue"); + linkedProps.push_back("InitializationRange"); parameter->setLinkedProperties(linkedProps); parameter->setEditable(false); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameters.push_back(parameter); } - parameters.push_back(SIMPL_NEW_STRING_FP("Initialization Value", InitializationValue, FilterParameter::Parameter, CreateDataArray, Manual)); - parameters.push_back(SIMPL_NEW_RANGE_FP("Initialization Range", InitializationRange, FilterParameter::Parameter, CreateDataArray, RandomWithRange)); + parameters.push_back(SIMPL_NEW_STRING_FP("Initialization Value", InitializationValue, FilterParameter::Category::Parameter, CreateDataArray, Manual)); + parameters.push_back(SIMPL_NEW_RANGE_FP("Initialization Range", InitializationRange, FilterParameter::Category::Parameter, CreateDataArray, RandomWithRange)); { DataArrayCreationFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Created Attribute Array", NewArray, FilterParameter::CreatedArray, CreateDataArray, req)); + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Created Attribute Array", NewArray, FilterParameter::Category::CreatedArray, CreateDataArray, req)); } setFilterParameters(parameters); @@ -319,10 +340,10 @@ void CreateDataArray::initialize() // ----------------------------------------------------------------------------- void CreateDataArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -330,36 +351,33 @@ void CreateDataArray::dataCheck() if(m_InitializationType == RandomWithRange && m_InitializationRange.first > m_InitializationRange.second) { QString ss = "Invalid initialization range. Minimum value is larger than maximum value."; - setErrorCondition(-5550); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5550, ss); return; } if(getNumberOfComponents() < 0) { - setErrorCondition(-8050); QString ss = QObject::tr("The number of components must non-negative"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-8050, ss); } if(getNumberOfComponents() == 0) { - setErrorCondition(-8051); QString ss = QObject::tr("The number of components is Zero. This will result in an array that has no memory allocated. Are you sure you wanted to do this?"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-8051, ss); } if(!getNewArray().isValid()) { - setErrorCondition(-8051); QString ss = QObject::tr("The Created DataArrayPath is invalid. Please select the Data Container, Attribute Matrix and set an output DataArray name."); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-8051, ss); } - QVector cDims(1, getNumberOfComponents()); - if(getErrorCondition() < 0) + std::vector cDims(1, getNumberOfComponents()); + if(getErrorCode() < 0) { return; } + // Create the data array and initialize it to a placeholder value - m_OutputArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromTypeEnum()(this, getNewArray(), cDims, static_cast(getScalarType()), 0); + m_OutputArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromTypeEnum()(this, getNewArray(), cDims, static_cast(getScalarType()), 0, DataArrayID); QString dataArrayName = getNewArray().getDataArrayName(); @@ -409,102 +427,91 @@ void CreateDataArray::dataCheck() } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void CreateDataArray::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void CreateDataArray::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } if(m_ScalarType == SIMPL::ScalarTypes::Type::Int8) { - initializeArrayWithInts(m_OutputArrayPtr.lock(), m_InitializationType, m_InitializationRange, m_InitializationValue, m_ScalarType); + CDA::initializeArrayWithInts(this, m_OutputArrayPtr.lock(), m_InitializationRange); } else if(m_ScalarType == SIMPL::ScalarTypes::Type::Int16) { - initializeArrayWithInts(m_OutputArrayPtr.lock(), m_InitializationType, m_InitializationRange, m_InitializationValue, m_ScalarType); + CDA::initializeArrayWithInts(this, m_OutputArrayPtr.lock(), m_InitializationRange); } else if(m_ScalarType == SIMPL::ScalarTypes::Type::Int32) { - initializeArrayWithInts(m_OutputArrayPtr.lock(), m_InitializationType, m_InitializationRange, m_InitializationValue, m_ScalarType); + CDA::initializeArrayWithInts(this, m_OutputArrayPtr.lock(), m_InitializationRange); } else if(m_ScalarType == SIMPL::ScalarTypes::Type::Int64) { - initializeArrayWithInts(m_OutputArrayPtr.lock(), m_InitializationType, m_InitializationRange, m_InitializationValue, m_ScalarType); + CDA::initializeArrayWithInts(this, m_OutputArrayPtr.lock(), m_InitializationRange); } else if(m_ScalarType == SIMPL::ScalarTypes::Type::UInt8) { - initializeArrayWithInts(m_OutputArrayPtr.lock(), m_InitializationType, m_InitializationRange, m_InitializationValue, m_ScalarType); + CDA::initializeArrayWithInts(this, m_OutputArrayPtr.lock(), m_InitializationRange); } else if(m_ScalarType == SIMPL::ScalarTypes::Type::UInt16) { - initializeArrayWithInts(m_OutputArrayPtr.lock(), m_InitializationType, m_InitializationRange, m_InitializationValue, m_ScalarType); + CDA::initializeArrayWithInts(this, m_OutputArrayPtr.lock(), m_InitializationRange); } else if(m_ScalarType == SIMPL::ScalarTypes::Type::UInt32) { - initializeArrayWithInts(m_OutputArrayPtr.lock(), m_InitializationType, m_InitializationRange, m_InitializationValue, m_ScalarType); + CDA::initializeArrayWithInts(this, m_OutputArrayPtr.lock(), m_InitializationRange); } else if(m_ScalarType == SIMPL::ScalarTypes::Type::UInt64) { - initializeArrayWithInts(m_OutputArrayPtr.lock(), m_InitializationType, m_InitializationRange, m_InitializationValue, m_ScalarType); + CDA::initializeArrayWithInts(this, m_OutputArrayPtr.lock(), m_InitializationRange); } else if(m_ScalarType == SIMPL::ScalarTypes::Type::Float) { - initializeArrayWithReals(m_OutputArrayPtr.lock(), m_InitializationType, m_InitializationRange, m_InitializationValue); + CDA::initializeArrayWithReals(this, m_OutputArrayPtr.lock(), m_InitializationRange); } else if(m_ScalarType == SIMPL::ScalarTypes::Type::Double) { - initializeArrayWithReals(m_OutputArrayPtr.lock(), m_InitializationType, m_InitializationRange, m_InitializationValue); + CDA::initializeArrayWithReals(this, m_OutputArrayPtr.lock(), m_InitializationRange); } else if(m_ScalarType == SIMPL::ScalarTypes::Type::Bool) { - initializeArrayWithInts(m_OutputArrayPtr.lock(), m_InitializationType, m_InitializationRange, m_InitializationValue, m_ScalarType); + CDA::initializeArrayWithBool(this, m_OutputArrayPtr.lock()); } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void CreateDataArray::checkInitialization(QString dataArrayName) +template +void CreateDataArray::checkInitialization(QString dataArrayName) { if(m_InitializationType == Manual) { - bool ok; - double input = m_InitializationValue.toDouble(&ok); - if(!ok) + // This next part will just ignore the return as we are looking for the ability to actually convert all the inputs + // into valid numbers. The method will report through the filter if there were errors attempting this conversion + std::vector initValues = CDA::createInitVector(this, m_InitializationValue, m_NumberOfComponents); + if(getErrorCode() < 0) { - QString ss = "Could not convert initialization value to a double."; - setErrorCondition(-5559); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } + bool ok = false; + if((initValues.size() == 1 && getNumberOfComponents() == 1) || (initValues.size() == 1 && getNumberOfComponents() > 1) || (initValues.size() == getNumberOfComponents())) + { + ok = true; + } - if(input < static_cast(std::numeric_limits().lowest()) || input > static_cast(std::numeric_limits().max())) + if(!ok) { - setErrorCondition(-4000); - QString ss = QObject::tr("%1: Invalid initialization value. The valid range is %2 to %3").arg(dataArrayName).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + QString ss("Number of init values does not match number of components or number of init values not equal to 1"); + setErrorCondition(-5548, ss); return; } + return; } else if(m_InitializationType == RandomWithRange) { @@ -513,22 +520,19 @@ template void CreateDataArray::checkInitialization(QString dataArra if(min > max) { QString ss = dataArrayName + ": Invalid initialization range. Minimum value is larger than maximum value."; - setErrorCondition(-5550); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5550, ss); return; } if(min < static_cast(std::numeric_limits().lowest()) || max > static_cast(std::numeric_limits().max())) { - setErrorCondition(-4001); QString ss = QObject::tr("%1: The initialization range can only be from %2 to %3").arg(dataArrayName).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4001, ss); return; } if(min == max) { - setErrorCondition(-4002); QString ss = dataArrayName + ": The initialization range must have differing values"; - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4002, ss); return; } } @@ -550,7 +554,7 @@ AbstractFilter::Pointer CreateDataArray::newFilterInstance(bool copyFilterParame // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateDataArray::getCompiledLibraryName() const +QString CreateDataArray::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -558,7 +562,7 @@ const QString CreateDataArray::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateDataArray::getBrandingString() const +QString CreateDataArray::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -566,7 +570,7 @@ const QString CreateDataArray::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateDataArray::getFilterVersion() const +QString CreateDataArray::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -577,7 +581,7 @@ const QString CreateDataArray::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateDataArray::getGroupName() const +QString CreateDataArray::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -585,7 +589,7 @@ const QString CreateDataArray::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid CreateDataArray::getUuid() +QUuid CreateDataArray::getUuid() const { return QUuid("{77f392fb-c1eb-57da-a1b1-e7acf9239fb8}"); } @@ -593,7 +597,7 @@ const QUuid CreateDataArray::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateDataArray::getSubGroupName() const +QString CreateDataArray::getSubGroupName() const { return SIMPL::FilterSubGroups::GenerationFilters; } @@ -601,7 +605,108 @@ const QString CreateDataArray::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateDataArray::getHumanLabel() const +QString CreateDataArray::getHumanLabel() const { return "Create Data Array"; } + +// ----------------------------------------------------------------------------- +CreateDataArray::Pointer CreateDataArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr CreateDataArray::New() +{ + struct make_shared_enabler : public CreateDataArray + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString CreateDataArray::getNameOfClass() const +{ + return QString("CreateDataArray"); +} + +// ----------------------------------------------------------------------------- +QString CreateDataArray::ClassName() +{ + return QString("CreateDataArray"); +} + +// ----------------------------------------------------------------------------- +void CreateDataArray::setScalarType(SIMPL::ScalarTypes::Type value) +{ + m_ScalarType = value; +} + +// ----------------------------------------------------------------------------- +SIMPL::ScalarTypes::Type CreateDataArray::getScalarType() const +{ + return m_ScalarType; +} + +// ----------------------------------------------------------------------------- +void CreateDataArray::setNumberOfComponents(int value) +{ + m_NumberOfComponents = value; +} + +// ----------------------------------------------------------------------------- +int CreateDataArray::getNumberOfComponents() const +{ + return m_NumberOfComponents; +} + +// ----------------------------------------------------------------------------- +void CreateDataArray::setNewArray(const DataArrayPath& value) +{ + m_NewArray = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateDataArray::getNewArray() const +{ + return m_NewArray; +} + +// ----------------------------------------------------------------------------- +void CreateDataArray::setInitializationType(int value) +{ + m_InitializationType = value; +} + +// ----------------------------------------------------------------------------- +int CreateDataArray::getInitializationType() const +{ + return m_InitializationType; +} + +// ----------------------------------------------------------------------------- +void CreateDataArray::setInitializationValue(const QString& value) +{ + m_InitializationValue = value; +} + +// ----------------------------------------------------------------------------- +QString CreateDataArray::getInitializationValue() const +{ + return m_InitializationValue; +} + +// ----------------------------------------------------------------------------- +void CreateDataArray::setInitializationRange(const FPRangePair& value) +{ + m_InitializationRange = value; +} + +// ----------------------------------------------------------------------------- +FPRangePair CreateDataArray::getInitializationRange() const +{ + return m_InitializationRange; +} diff --git a/Source/SIMPLib/CoreFilters/CreateDataArray.h b/Source/SIMPLib/CoreFilters/CreateDataArray.h index f34639a867..9f38fee12a 100644 --- a/Source/SIMPLib/CoreFilters/CreateDataArray.h +++ b/Source/SIMPLib/CoreFilters/CreateDataArray.h @@ -1,219 +1,274 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/Constants.h" #include "SIMPLib/FilterParameters/RangeFilterParameter.h" #include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/SIMPLib.h" + +class IDataArray; +using IDataArrayWkPtrType = std::weak_ptr; /** * @brief The CreateDataArray class. See [Filter documentation](@ref createdataarray) for details. */ class SIMPLib_EXPORT CreateDataArray : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(CreateDataArray SUPERCLASS AbstractFilter) - PYB11_PROPERTY(SIMPL::ScalarTypes::Type ScalarType READ getScalarType WRITE setScalarType) - PYB11_PROPERTY(int NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) - PYB11_PROPERTY(DataArrayPath NewArray READ getNewArray WRITE setNewArray) - PYB11_PROPERTY(int InitializationType READ getInitializationType WRITE setInitializationType) - PYB11_PROPERTY(QString InitializationValue READ getInitializationValue WRITE setInitializationValue) - PYB11_PROPERTY(FPRangePair InitializationRange READ getInitializationRange WRITE setInitializationRange) - - public: - SIMPL_SHARED_POINTERS(CreateDataArray) - SIMPL_FILTER_NEW_MACRO(CreateDataArray) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(CreateDataArray, AbstractFilter) - - ~CreateDataArray() override; - - enum InitializationChoices - { - Manual, - RandomWithRange - }; - - SIMPL_FILTER_PARAMETER(SIMPL::ScalarTypes::Type, ScalarType) - Q_PROPERTY(SIMPL::ScalarTypes::Type ScalarType READ getScalarType WRITE setScalarType) - - SIMPL_FILTER_PARAMETER(int, NumberOfComponents) - Q_PROPERTY(int NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) - - SIMPL_FILTER_PARAMETER(DataArrayPath, NewArray) - Q_PROPERTY(DataArrayPath NewArray READ getNewArray WRITE setNewArray) - - SIMPL_FILTER_PARAMETER(int, InitializationType) - Q_PROPERTY(int InitializationType READ getInitializationType WRITE setInitializationType) - - SIMPL_FILTER_PARAMETER(QString, InitializationValue) - Q_PROPERTY(QString InitializationValue READ getInitializationValue WRITE setInitializationValue) - - SIMPL_FILTER_PARAMETER(FPRangePair, InitializationRange) - Q_PROPERTY(FPRangePair InitializationRange READ getInitializationRange WRITE setInitializationRange) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - CreateDataArray(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - DEFINE_IDATAARRAY_WEAKPTR(OutputArray) - - /** - * @brief checkInitialization Checks that the chosen initialization value/range is inside - * the bounds of the array type - */ - template - void checkInitialization(QString dataArrayName); - - const QString Int8 = "signed int 8 bit"; - const QString UInt8 = "unsigned int 8 bit"; - const QString Int16 = "signed int 16 bit"; - const QString UInt16 = "unsigned int 16 bit"; - const QString Int32 = "signed int 32 bit"; - const QString UInt32 = "unsigned int 32 bit"; - const QString Int64 = "signed int 64 bit"; - const QString UInt64 = "unsigned int 64 bit"; - const QString Float = " Float 32 bit"; - const QString Double = " Double 64 bit"; - const QString Bool = "bool"; - - public: - CreateDataArray(const CreateDataArray&) = delete; // Copy Constructor Not Implemented - CreateDataArray(CreateDataArray&&) = delete; // Move Constructor Not Implemented - CreateDataArray& operator=(const CreateDataArray&) = delete; // Copy Assignment Not Implemented - CreateDataArray& operator=(CreateDataArray&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(CreateDataArray SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(CreateDataArray) + PYB11_FILTER_NEW_MACRO(CreateDataArray) + PYB11_PROPERTY(SIMPL::ScalarTypes::Type ScalarType READ getScalarType WRITE setScalarType) + PYB11_PROPERTY(int NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) + PYB11_PROPERTY(DataArrayPath NewArray READ getNewArray WRITE setNewArray) + PYB11_PROPERTY(int InitializationType READ getInitializationType WRITE setInitializationType) + PYB11_PROPERTY(QString InitializationValue READ getInitializationValue WRITE setInitializationValue) + PYB11_PROPERTY(FPRangePair InitializationRange READ getInitializationRange WRITE setInitializationRange) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = CreateDataArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for CreateDataArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for CreateDataArray + */ + static QString ClassName(); + + ~CreateDataArray() override; + + enum InitializationChoices + { + Manual, + RandomWithRange + }; + + /** + * @brief Setter property for ScalarType + */ + void setScalarType(SIMPL::ScalarTypes::Type value); + /** + * @brief Getter property for ScalarType + * @return Value of ScalarType + */ + SIMPL::ScalarTypes::Type getScalarType() const; + + Q_PROPERTY(SIMPL::ScalarTypes::Type ScalarType READ getScalarType WRITE setScalarType) + + /** + * @brief Setter property for NumberOfComponents + */ + void setNumberOfComponents(int value); + /** + * @brief Getter property for NumberOfComponents + * @return Value of NumberOfComponents + */ + int getNumberOfComponents() const; + + Q_PROPERTY(int NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) + + /** + * @brief Setter property for NewArray + */ + void setNewArray(const DataArrayPath& value); + /** + * @brief Getter property for NewArray + * @return Value of NewArray + */ + DataArrayPath getNewArray() const; + + Q_PROPERTY(DataArrayPath NewArray READ getNewArray WRITE setNewArray) + + /** + * @brief Setter property for InitializationType + */ + void setInitializationType(int value); + /** + * @brief Getter property for InitializationType + * @return Value of InitializationType + */ + int getInitializationType() const; + + Q_PROPERTY(int InitializationType READ getInitializationType WRITE setInitializationType) + + /** + * @brief Setter property for InitializationValue + */ + void setInitializationValue(const QString& value); + /** + * @brief Getter property for InitializationValue + * @return Value of InitializationValue + */ + QString getInitializationValue() const; + + Q_PROPERTY(QString InitializationValue READ getInitializationValue WRITE setInitializationValue) + + /** + * @brief Setter property for InitializationRange + */ + void setInitializationRange(const FPRangePair& value); + /** + * @brief Getter property for InitializationRange + * @return Value of InitializationRange + */ + FPRangePair getInitializationRange() const; + + Q_PROPERTY(FPRangePair InitializationRange READ getInitializationRange WRITE setInitializationRange) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + CreateDataArray(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + IDataArrayWkPtrType m_OutputArrayPtr; + + SIMPL::ScalarTypes::Type m_ScalarType = {SIMPL::ScalarTypes::Type::Int8}; + int m_NumberOfComponents = {0}; + DataArrayPath m_NewArray = {"", "", ""}; + int m_InitializationType = {Manual}; + QString m_InitializationValue = {"0"}; + FPRangePair m_InitializationRange = {}; + + /** + * @brief checkInitialization Checks that the chosen initialization value/range is inside + * the bounds of the array type + */ + template + void checkInitialization(QString dataArrayName); + + const QString Int8 = "signed int 8 bit"; + const QString UInt8 = "unsigned int 8 bit"; + const QString Int16 = "signed int 16 bit"; + const QString UInt16 = "unsigned int 16 bit"; + const QString Int32 = "signed int 32 bit"; + const QString UInt32 = "unsigned int 32 bit"; + const QString Int64 = "signed int 64 bit"; + const QString UInt64 = "unsigned int 64 bit"; + const QString Float = " Float 32 bit"; + const QString Double = " Double 64 bit"; + const QString Bool = "bool"; + +public: + CreateDataArray(const CreateDataArray&) = delete; // Copy Constructor Not Implemented + CreateDataArray(CreateDataArray&&) = delete; // Move Constructor Not Implemented + CreateDataArray& operator=(const CreateDataArray&) = delete; // Copy Assignment Not Implemented + CreateDataArray& operator=(CreateDataArray&&) = delete; // Move Assignment Not Implemented }; - - diff --git a/Source/SIMPLib/CoreFilters/CreateDataContainer.cpp b/Source/SIMPLib/CoreFilters/CreateDataContainer.cpp index 903d68a16e..a5b7d10cb1 100644 --- a/Source/SIMPLib/CoreFilters/CreateDataContainer.cpp +++ b/Source/SIMPLib/CoreFilters/CreateDataContainer.cpp @@ -1,52 +1,57 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CreateDataContainer.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + DataContainerID = 1 +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -CreateDataContainer::CreateDataContainer() -: m_DataContainerName("DataContainer") -{ -} +CreateDataContainer::CreateDataContainer() = default; // ----------------------------------------------------------------------------- // @@ -58,8 +63,8 @@ CreateDataContainer::~CreateDataContainer() = default; // ----------------------------------------------------------------------------- void CreateDataContainer::setupFilterParameters() { - FilterParameterVector parameters; - parameters.push_back(SIMPL_NEW_DC_CREATION_FP("Data Container Name", DataContainerName, FilterParameter::CreatedArray, CreateDataContainer)); + FilterParameterVectorType parameters; + parameters.push_back(SIMPL_NEW_DC_CREATION_FP("Data Container Name", DataContainerName, FilterParameter::Category::CreatedArray, CreateDataContainer)); setFilterParameters(parameters); } @@ -69,7 +74,6 @@ void CreateDataContainer::setupFilterParameters() void CreateDataContainer::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); - setDataContainerName(reader->readString("DataContainerName", getDataContainerName())); reader->closeFilterGroup(); } @@ -85,24 +89,10 @@ void CreateDataContainer::initialize() // ----------------------------------------------------------------------------- void CreateDataContainer::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); - - getDataContainerArray()->createNonPrereqDataContainer(this, getDataContainerName()); -} + clearErrorCode(); + clearWarningCode(); -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void CreateDataContainer::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. + getDataContainerArray()->createNonPrereqDataContainer(this, getDataContainerName(), DataContainerID); } // ----------------------------------------------------------------------------- @@ -110,10 +100,8 @@ void CreateDataContainer::preflight() // ----------------------------------------------------------------------------- void CreateDataContainer::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -122,7 +110,6 @@ void CreateDataContainer::execute() { return; } - } // ----------------------------------------------------------------------------- @@ -141,7 +128,7 @@ AbstractFilter::Pointer CreateDataContainer::newFilterInstance(bool copyFilterPa // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateDataContainer::getCompiledLibraryName() const +QString CreateDataContainer::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -149,7 +136,7 @@ const QString CreateDataContainer::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateDataContainer::getBrandingString() const +QString CreateDataContainer::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -157,7 +144,7 @@ const QString CreateDataContainer::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateDataContainer::getFilterVersion() const +QString CreateDataContainer::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -168,7 +155,7 @@ const QString CreateDataContainer::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateDataContainer::getGroupName() const +QString CreateDataContainer::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -176,7 +163,7 @@ const QString CreateDataContainer::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateDataContainer::getHumanLabel() const +QString CreateDataContainer::getHumanLabel() const { return "Create Data Container"; } @@ -184,7 +171,7 @@ const QString CreateDataContainer::getHumanLabel() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid CreateDataContainer::getUuid() +QUuid CreateDataContainer::getUuid() const { return QUuid("{816fbe6b-7c38-581b-b149-3f839fb65b93}"); } @@ -192,7 +179,48 @@ const QUuid CreateDataContainer::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateDataContainer::getSubGroupName() const +QString CreateDataContainer::getSubGroupName() const { return SIMPL::FilterSubGroups::GenerationFilters; } + +// ----------------------------------------------------------------------------- +CreateDataContainer::Pointer CreateDataContainer::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr CreateDataContainer::New() +{ + struct make_shared_enabler : public CreateDataContainer + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString CreateDataContainer::getNameOfClass() const +{ + return QString("CreateDataContainer"); +} + +// ----------------------------------------------------------------------------- +QString CreateDataContainer::ClassName() +{ + return QString("CreateDataContainer"); +} + +// ----------------------------------------------------------------------------- +void CreateDataContainer::setDataContainerName(const DataArrayPath& value) +{ + m_DataContainerName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateDataContainer::getDataContainerName() const +{ + return m_DataContainerName; +} diff --git a/Source/SIMPLib/CoreFilters/CreateDataContainer.h b/Source/SIMPLib/CoreFilters/CreateDataContainer.h old mode 100755 new mode 100644 index 5dc16a6cf2..7817e2ed3b --- a/Source/SIMPLib/CoreFilters/CreateDataContainer.h +++ b/Source/SIMPLib/CoreFilters/CreateDataContainer.h @@ -1,169 +1,172 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The CreateDataContainer class. See [Filter documentation](@ref createdatacontainer) for details. */ class SIMPLib_EXPORT CreateDataContainer : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(CreateDataContainer SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) - - public: - SIMPL_SHARED_POINTERS(CreateDataContainer) - SIMPL_FILTER_NEW_MACRO(CreateDataContainer) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(CreateDataContainer, AbstractFilter) - - ~CreateDataContainer() override; - - SIMPL_FILTER_PARAMETER(QString, DataContainerName) - Q_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - CreateDataContainer(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - public: - CreateDataContainer(const CreateDataContainer&) = delete; // Copy Constructor Not Implemented - CreateDataContainer(CreateDataContainer&&) = delete; // Move Constructor Not Implemented - CreateDataContainer& operator=(const CreateDataContainer&) = delete; // Copy Assignment Not Implemented - CreateDataContainer& operator=(CreateDataContainer&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(CreateDataContainer SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(CreateDataContainer) + PYB11_FILTER_NEW_MACRO(CreateDataContainer) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = CreateDataContainer; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for CreateDataContainer + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for CreateDataContainer + */ + static QString ClassName(); + + ~CreateDataContainer() override; + + /** + * @brief Setter property for DataContainerName + */ + void setDataContainerName(const DataArrayPath& value); + /** + * @brief Getter property for DataContainerName + * @return Value of DataContainerName + */ + DataArrayPath getDataContainerName() const; + + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + CreateDataContainer(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +public: + CreateDataContainer(const CreateDataContainer&) = delete; // Copy Constructor Not Implemented + CreateDataContainer(CreateDataContainer&&) = delete; // Move Constructor Not Implemented + CreateDataContainer& operator=(const CreateDataContainer&) = delete; // Copy Assignment Not Implemented + CreateDataContainer& operator=(CreateDataContainer&&) = delete; // Move Assignment Not Implemented + +private: + DataArrayPath m_DataContainerName = {"DataContainer", "", ""}; }; - diff --git a/Source/SIMPLib/CoreFilters/CreateFeatureArrayFromElementArray.cpp b/Source/SIMPLib/CoreFilters/CreateFeatureArrayFromElementArray.cpp index e4010e51cd..df83bd27e3 100644 --- a/Source/SIMPLib/CoreFilters/CreateFeatureArrayFromElementArray.cpp +++ b/Source/SIMPLib/CoreFilters/CreateFeatureArrayFromElementArray.cpp @@ -1,59 +1,61 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CreateFeatureArrayFromElementArray.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" +#include "SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.h" #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + FeatureArrayID = 1 +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -CreateFeatureArrayFromElementArray::CreateFeatureArrayFromElementArray() -: m_CellFeatureAttributeMatrixName("", "", "") -, m_SelectedCellArrayPath("", "", "") -, m_CreatedArrayName("") -, m_FeatureIdsArrayPath("", "", "") -{ -} +CreateFeatureArrayFromElementArray::CreateFeatureArrayFromElementArray() = default; // ----------------------------------------------------------------------------- // @@ -65,23 +67,24 @@ CreateFeatureArrayFromElementArray::~CreateFeatureArrayFromElementArray() = defa // ----------------------------------------------------------------------------- void CreateFeatureArrayFromElementArray::setupFilterParameters() { - FilterParameterVector parameters; - parameters.push_back(SeparatorFilterParameter::New("Element Data", FilterParameter::RequiredArray)); + FilterParameterVectorType parameters; + parameters.push_back(SeparatorFilterParameter::Create("Element Data", FilterParameter::Category::RequiredArray)); { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, AttributeMatrix::Category::Element); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Element Data to Copy to Feature Data", SelectedCellArrayPath, FilterParameter::RequiredArray, CreateFeatureArrayFromElementArray, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Element Data to Copy to Feature Data", SelectedCellArrayPath, FilterParameter::Category::RequiredArray, CreateFeatureArrayFromElementArray, req)); } { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Int32, 1, AttributeMatrix::Category::Element); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Feature Ids", FeatureIdsArrayPath, FilterParameter::RequiredArray, CreateFeatureArrayFromElementArray, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Feature Ids", FeatureIdsArrayPath, FilterParameter::Category::RequiredArray, CreateFeatureArrayFromElementArray, req)); } - parameters.push_back(SeparatorFilterParameter::New("Feature Data", FilterParameter::CreatedArray)); + parameters.push_back(SeparatorFilterParameter::Create("Feature Data", FilterParameter::Category::CreatedArray)); { AttributeMatrixSelectionFilterParameter::RequirementType req = AttributeMatrixSelectionFilterParameter::CreateRequirement(AttributeMatrix::Type::CellFeature, IGeometry::Type::Any); - parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Feature Attribute Matrix", CellFeatureAttributeMatrixName, FilterParameter::CreatedArray, CreateFeatureArrayFromElementArray, req)); + parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Feature Attribute Matrix", CellFeatureAttributeMatrixName, FilterParameter::Category::CreatedArray, CreateFeatureArrayFromElementArray, req)); } - parameters.push_back(SIMPL_NEW_STRING_FP("Copied Attribute Array", CreatedArrayName, FilterParameter::CreatedArray, CreateFeatureArrayFromElementArray)); + parameters.push_back(SIMPL_NEW_DA_WITH_LINKED_AM_FP("Copied Attribute Array", CreatedArrayName, CellFeatureAttributeMatrixName, CellFeatureAttributeMatrixName, + FilterParameter::Category::CreatedArray, CreateFeatureArrayFromElementArray)); setFilterParameters(parameters); } @@ -110,54 +113,40 @@ void CreateFeatureArrayFromElementArray::initialize() // ----------------------------------------------------------------------------- void CreateFeatureArrayFromElementArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(getCreatedArrayName().isEmpty()) { - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), "The new Feature Array name must be set", getErrorCondition()); + setErrorCondition(-11002, "The new Feature Array name must be set"); return; } - QVector cDims(1, 1); - m_FeatureIdsPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getFeatureIdsArrayPath(), - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ - if(nullptr != m_FeatureIdsPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ + std::vector cDims(1, 1); + m_FeatureIdsPtr = getDataContainerArray()->getPrereqArrayFromPath>(this, getFeatureIdsArrayPath(), cDims); + if(nullptr != m_FeatureIdsPtr.lock()) { m_FeatureIds = m_FeatureIdsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ - m_InArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedCellArrayPath()); + m_InArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedCellArrayPath()); - getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getCellFeatureAttributeMatrixName(), -301); + getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getCellFeatureAttributeMatrixName(), -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } DataArrayPath tempPath(getCellFeatureAttributeMatrixName().getDataContainerName(), getCellFeatureAttributeMatrixName().getAttributeMatrixName(), getCreatedArrayName()); - TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, m_InArrayPtr.lock()->getComponentDimensions(), m_InArrayPtr.lock()); + TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, m_InArrayPtr.lock()->getComponentDimensions(), m_InArrayPtr.lock(), FeatureArrayID); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void CreateFeatureArrayFromElementArray::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -template IDataArray::Pointer copyCellData(AbstractFilter* filter, IDataArray::Pointer inputData, int32_t features, int32_t* featureIds, const QString& createdArrayName) +template +IDataArray::Pointer copyCellData(AbstractFilter* filter, IDataArray::Pointer inputData, int32_t features, int32_t* featureIds, const QString& createdArrayName) { QString featureArrayName = inputData->getName(); @@ -167,13 +156,13 @@ template IDataArray::Pointer copyCellData(AbstractFilter* filter, I return IDataArray::NullPointer(); } - QVector dims = inputData->getComponentDimensions(); - typename DataArray::Pointer feature = DataArray::CreateArray(features, dims, createdArrayName); + std::vector dims = inputData->getComponentDimensions(); + typename DataArray::Pointer feature = DataArray::CreateArray(features, dims, createdArrayName, true); T* fPtr = feature->getPointer(0); T* cPtr = cell->getPointer(0); - int32_t numComp = cell->getNumberOfComponents(); + size_t numComp = static_cast(cell->getNumberOfComponents()); int32_t featureIdx = 0; size_t cells = inputData->getNumberOfTuples(); @@ -202,9 +191,8 @@ template IDataArray::Pointer copyCellData(AbstractFilter* filter, I if(currentDataPtr[j] != cSourcePtr[j] && !warningThrown) { // The values are inconsistent with the first values for this feature id, so throw a warning - filter->setWarningCondition(-1000); QString ss = QObject::tr("Elements from Feature %1 do not all have the same value. The last value copied into Feature %1 will be used").arg(featureIdx); - filter->notifyWarningMessage(filter->getHumanLabel(), ss, filter->getWarningCondition()); + filter->setWarningCondition(-1000, ss); warningThrown = true; } } @@ -223,10 +211,8 @@ template IDataArray::Pointer copyCellData(AbstractFilter* filter, I // ----------------------------------------------------------------------------- void CreateFeatureArrayFromElementArray::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -254,17 +240,19 @@ void CreateFeatureArrayFromElementArray::execute() if(mismatchedFeatures) { - QString ss = QObject::tr("Attribute Matrix %1 has %2 tuples but the input array %3 has a Feature ID value of at least %4").arg(m_CellFeatureAttributeMatrixName.serialize("/")).arg(totalFeatures).arg(getFeatureIdsArrayPath().serialize("/")).arg(largestFeature); - setErrorCondition(-5555); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + QString ss = QObject::tr("Attribute Matrix %1 has %2 tuples but the input array %3 has a Feature ID value of at least %4") + .arg(m_CellFeatureAttributeMatrixName.serialize("/")) + .arg(totalFeatures) + .arg(getFeatureIdsArrayPath().serialize("/")) + .arg(largestFeature); + setErrorCondition(-5555, ss); return; } if(largestFeature != (totalFeatures - 1)) { QString ss = QObject::tr("The number of Features in the InArray array (%1) does not match the largest Feature Id in the FeatureIds array").arg(totalFeatures); - setErrorCondition(-5556); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5556, ss); return; } @@ -317,15 +305,13 @@ void CreateFeatureArrayFromElementArray::execute() else { QString ss = QObject::tr("The selected array was of unsupported type. The path is %1").arg(m_SelectedCellArrayPath.serialize()); - setErrorCondition(-14000); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-14000, ss); } if(p.get() != nullptr) { - getDataContainerArray()->getAttributeMatrix(m_CellFeatureAttributeMatrixName)->addAttributeArray(p->getName(), p); + getDataContainerArray()->getAttributeMatrix(m_CellFeatureAttributeMatrixName)->insertOrAssign(p); } - } // ----------------------------------------------------------------------------- @@ -344,7 +330,7 @@ AbstractFilter::Pointer CreateFeatureArrayFromElementArray::newFilterInstance(bo // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateFeatureArrayFromElementArray::getCompiledLibraryName() const +QString CreateFeatureArrayFromElementArray::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -352,7 +338,7 @@ const QString CreateFeatureArrayFromElementArray::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateFeatureArrayFromElementArray::getBrandingString() const +QString CreateFeatureArrayFromElementArray::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -360,7 +346,7 @@ const QString CreateFeatureArrayFromElementArray::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateFeatureArrayFromElementArray::getFilterVersion() const +QString CreateFeatureArrayFromElementArray::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -371,7 +357,7 @@ const QString CreateFeatureArrayFromElementArray::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateFeatureArrayFromElementArray::getGroupName() const +QString CreateFeatureArrayFromElementArray::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -379,7 +365,7 @@ const QString CreateFeatureArrayFromElementArray::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid CreateFeatureArrayFromElementArray::getUuid() +QUuid CreateFeatureArrayFromElementArray::getUuid() const { return QUuid("{94438019-21bb-5b61-a7c3-66974b9a34dc}"); } @@ -387,7 +373,7 @@ const QUuid CreateFeatureArrayFromElementArray::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateFeatureArrayFromElementArray::getSubGroupName() const +QString CreateFeatureArrayFromElementArray::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -395,7 +381,84 @@ const QString CreateFeatureArrayFromElementArray::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateFeatureArrayFromElementArray::getHumanLabel() const +QString CreateFeatureArrayFromElementArray::getHumanLabel() const { return "Create Feature Array from Element Array"; } + +// ----------------------------------------------------------------------------- +CreateFeatureArrayFromElementArray::Pointer CreateFeatureArrayFromElementArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr CreateFeatureArrayFromElementArray::New() +{ + struct make_shared_enabler : public CreateFeatureArrayFromElementArray + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString CreateFeatureArrayFromElementArray::getNameOfClass() const +{ + return QString("CreateFeatureArrayFromElementArray"); +} + +// ----------------------------------------------------------------------------- +QString CreateFeatureArrayFromElementArray::ClassName() +{ + return QString("CreateFeatureArrayFromElementArray"); +} + +// ----------------------------------------------------------------------------- +void CreateFeatureArrayFromElementArray::setCellFeatureAttributeMatrixName(const DataArrayPath& value) +{ + m_CellFeatureAttributeMatrixName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateFeatureArrayFromElementArray::getCellFeatureAttributeMatrixName() const +{ + return m_CellFeatureAttributeMatrixName; +} + +// ----------------------------------------------------------------------------- +void CreateFeatureArrayFromElementArray::setSelectedCellArrayPath(const DataArrayPath& value) +{ + m_SelectedCellArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateFeatureArrayFromElementArray::getSelectedCellArrayPath() const +{ + return m_SelectedCellArrayPath; +} + +// ----------------------------------------------------------------------------- +void CreateFeatureArrayFromElementArray::setCreatedArrayName(const QString& value) +{ + m_CreatedArrayName = value; +} + +// ----------------------------------------------------------------------------- +QString CreateFeatureArrayFromElementArray::getCreatedArrayName() const +{ + return m_CreatedArrayName; +} + +// ----------------------------------------------------------------------------- +void CreateFeatureArrayFromElementArray::setFeatureIdsArrayPath(const DataArrayPath& value) +{ + m_FeatureIdsArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateFeatureArrayFromElementArray::getFeatureIdsArrayPath() const +{ + return m_FeatureIdsArrayPath; +} diff --git a/Source/SIMPLib/CoreFilters/CreateFeatureArrayFromElementArray.h b/Source/SIMPLib/CoreFilters/CreateFeatureArrayFromElementArray.h old mode 100755 new mode 100644 index 6c6022aa45..089b04acb3 --- a/Source/SIMPLib/CoreFilters/CreateFeatureArrayFromElementArray.h +++ b/Source/SIMPLib/CoreFilters/CreateFeatureArrayFromElementArray.h @@ -1,185 +1,223 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/Filtering/AbstractFilter.h" + +class IDataArray; +using IDataArrayWkPtrType = std::weak_ptr; /** * @brief The CreateFeatureArrayFromElementArray class. See [Filter documentation](@ref createfeaturearrayfromelementarray) for details. */ class SIMPLib_EXPORT CreateFeatureArrayFromElementArray : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(CreateFeatureArrayFromElementArray SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath CellFeatureAttributeMatrixName READ getCellFeatureAttributeMatrixName WRITE setCellFeatureAttributeMatrixName) - PYB11_PROPERTY(DataArrayPath SelectedCellArrayPath READ getSelectedCellArrayPath WRITE setSelectedCellArrayPath) - PYB11_PROPERTY(QString CreatedArrayName READ getCreatedArrayName WRITE setCreatedArrayName) - PYB11_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath) - - public: - SIMPL_SHARED_POINTERS(CreateFeatureArrayFromElementArray) - SIMPL_FILTER_NEW_MACRO(CreateFeatureArrayFromElementArray) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(CreateFeatureArrayFromElementArray, AbstractFilter) - - ~CreateFeatureArrayFromElementArray() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, CellFeatureAttributeMatrixName) - Q_PROPERTY(DataArrayPath CellFeatureAttributeMatrixName READ getCellFeatureAttributeMatrixName WRITE setCellFeatureAttributeMatrixName) - - SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedCellArrayPath) - Q_PROPERTY(DataArrayPath SelectedCellArrayPath READ getSelectedCellArrayPath WRITE setSelectedCellArrayPath) - - SIMPL_FILTER_PARAMETER(QString, CreatedArrayName) - Q_PROPERTY(QString CreatedArrayName READ getCreatedArrayName WRITE setCreatedArrayName) - - SIMPL_FILTER_PARAMETER(DataArrayPath, FeatureIdsArrayPath) - Q_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - CreateFeatureArrayFromElementArray(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - DEFINE_DATAARRAY_VARIABLE(int32_t, FeatureIds) - DEFINE_IDATAARRAY_WEAKPTR(InArray) - - public: - CreateFeatureArrayFromElementArray(const CreateFeatureArrayFromElementArray&) = delete; // Copy Constructor Not Implemented - CreateFeatureArrayFromElementArray(CreateFeatureArrayFromElementArray&&) = delete; // Move Constructor Not Implemented - CreateFeatureArrayFromElementArray& operator=(const CreateFeatureArrayFromElementArray&) = delete; // Copy Assignment Not Implemented - CreateFeatureArrayFromElementArray& operator=(CreateFeatureArrayFromElementArray&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(CreateFeatureArrayFromElementArray SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(CreateFeatureArrayFromElementArray) + PYB11_FILTER_NEW_MACRO(CreateFeatureArrayFromElementArray) + PYB11_PROPERTY(DataArrayPath CellFeatureAttributeMatrixName READ getCellFeatureAttributeMatrixName WRITE setCellFeatureAttributeMatrixName) + PYB11_PROPERTY(DataArrayPath SelectedCellArrayPath READ getSelectedCellArrayPath WRITE setSelectedCellArrayPath) + PYB11_PROPERTY(QString CreatedArrayName READ getCreatedArrayName WRITE setCreatedArrayName) + PYB11_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = CreateFeatureArrayFromElementArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for CreateFeatureArrayFromElementArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for CreateFeatureArrayFromElementArray + */ + static QString ClassName(); + + ~CreateFeatureArrayFromElementArray() override; + + /** + * @brief Setter property for CellFeatureAttributeMatrixName + */ + void setCellFeatureAttributeMatrixName(const DataArrayPath& value); + /** + * @brief Getter property for CellFeatureAttributeMatrixName + * @return Value of CellFeatureAttributeMatrixName + */ + DataArrayPath getCellFeatureAttributeMatrixName() const; + + Q_PROPERTY(DataArrayPath CellFeatureAttributeMatrixName READ getCellFeatureAttributeMatrixName WRITE setCellFeatureAttributeMatrixName) + + /** + * @brief Setter property for SelectedCellArrayPath + */ + void setSelectedCellArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SelectedCellArrayPath + * @return Value of SelectedCellArrayPath + */ + DataArrayPath getSelectedCellArrayPath() const; + + Q_PROPERTY(DataArrayPath SelectedCellArrayPath READ getSelectedCellArrayPath WRITE setSelectedCellArrayPath) + + /** + * @brief Setter property for CreatedArrayName + */ + void setCreatedArrayName(const QString& value); + /** + * @brief Getter property for CreatedArrayName + * @return Value of CreatedArrayName + */ + QString getCreatedArrayName() const; + + Q_PROPERTY(QString CreatedArrayName READ getCreatedArrayName WRITE setCreatedArrayName) + + /** + * @brief Setter property for FeatureIdsArrayPath + */ + void setFeatureIdsArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for FeatureIdsArrayPath + * @return Value of FeatureIdsArrayPath + */ + DataArrayPath getFeatureIdsArrayPath() const; + + Q_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + CreateFeatureArrayFromElementArray(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + std::weak_ptr> m_FeatureIdsPtr; + int32_t* m_FeatureIds = nullptr; + + IDataArrayWkPtrType m_InArrayPtr; + + DataArrayPath m_CellFeatureAttributeMatrixName = {"", "", ""}; + DataArrayPath m_SelectedCellArrayPath = {"", "", ""}; + QString m_CreatedArrayName = {""}; + DataArrayPath m_FeatureIdsArrayPath = {"", "", ""}; + +public: + CreateFeatureArrayFromElementArray(const CreateFeatureArrayFromElementArray&) = delete; // Copy Constructor Not Implemented + CreateFeatureArrayFromElementArray(CreateFeatureArrayFromElementArray&&) = delete; // Move Constructor Not Implemented + CreateFeatureArrayFromElementArray& operator=(const CreateFeatureArrayFromElementArray&) = delete; // Copy Assignment Not Implemented + CreateFeatureArrayFromElementArray& operator=(CreateFeatureArrayFromElementArray&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/CreateGeometry.cpp b/Source/SIMPLib/CoreFilters/CreateGeometry.cpp index 707885aa26..98518bc3fc 100644 --- a/Source/SIMPLib/CoreFilters/CreateGeometry.cpp +++ b/Source/SIMPLib/CoreFilters/CreateGeometry.cpp @@ -26,86 +26,41 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - #include "CreateGeometry.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/BooleanFilterParameter.h" #include "SIMPLib/FilterParameters/ChoiceFilterParameter.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/LinkedChoicesFilterParameter.h" +#include "SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.h" #include "SIMPLib/FilterParameters/PreflightUpdatedValueFilterParameter.h" -#include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/Geometry/EdgeGeom.h" +#include "SIMPLib/Geometry/HexahedralGeom.h" #include "SIMPLib/Geometry/ImageGeom.h" #include "SIMPLib/Geometry/QuadGeom.h" #include "SIMPLib/Geometry/RectGridGeom.h" #include "SIMPLib/Geometry/TetrahedralGeom.h" #include "SIMPLib/Geometry/TriangleGeom.h" #include "SIMPLib/Geometry/VertexGeom.h" -#include "SIMPLib/Geometry/HexahedralGeom.h" -#include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -CreateGeometry::CreateGeometry() -: m_GeometryType(0) -, m_DataContainerName("") -, m_SharedVertexListArrayPath0("", "", "") -, m_SharedVertexListArrayPath1("", "", "") -, m_SharedVertexListArrayPath2("", "", "") -, m_SharedVertexListArrayPath3("", "", "") -, m_SharedVertexListArrayPath4("", "", "") -, m_SharedVertexListArrayPath5("", "", "") -, m_SharedEdgeListArrayPath("", "", "") -, m_SharedTriListArrayPath("", "", "") -, m_SharedQuadListArrayPath("", "", "") -, m_SharedTetListArrayPath("", "", "") -, m_SharedHexListArrayPath("", "", "") -, m_XBoundsArrayPath("", "", "") -, m_YBoundsArrayPath("", "", "") -, m_ZBoundsArrayPath("", "", "") -, m_Dimensions({0, 0, 0}) -, m_Origin({0.0f, 0.0f, 0.0f}) -, m_Resolution({1.0f, 1.0f, 1.0f}) -, m_ImageCellAttributeMatrixName(SIMPL::Defaults::CellAttributeMatrixName) -, m_RectGridCellAttributeMatrixName(SIMPL::Defaults::CellAttributeMatrixName) -, m_VertexAttributeMatrixName0(SIMPL::Defaults::VertexAttributeMatrixName) -, m_VertexAttributeMatrixName1(SIMPL::Defaults::VertexAttributeMatrixName) -, m_VertexAttributeMatrixName2(SIMPL::Defaults::VertexAttributeMatrixName) -, m_VertexAttributeMatrixName3(SIMPL::Defaults::VertexAttributeMatrixName) -, m_VertexAttributeMatrixName4(SIMPL::Defaults::VertexAttributeMatrixName) -, m_VertexAttributeMatrixName5(SIMPL::Defaults::VertexAttributeMatrixName) -, m_EdgeAttributeMatrixName(SIMPL::Defaults::EdgeAttributeMatrixName) -, m_FaceAttributeMatrixName0(SIMPL::Defaults::FaceAttributeMatrixName) -, m_FaceAttributeMatrixName1(SIMPL::Defaults::FaceAttributeMatrixName) -, m_TetCellAttributeMatrixName(SIMPL::Defaults::CellAttributeMatrixName) -, m_HexCellAttributeMatrixName(SIMPL::Defaults::CellAttributeMatrixName) -, m_TreatWarningsAsErrors(false) -, m_ArrayHandling(false) -, m_NumVerts(0) -{ - m_Dimensions.x = 0; - m_Dimensions.y = 0; - m_Dimensions.z = 0; - - m_Origin.x = 0.0f; - m_Origin.y = 0.0f; - m_Origin.z = 0.0f; - - m_Resolution.x = 1.0f; - m_Resolution.y = 1.0f; - m_Resolution.z = 1.0f; -} +CreateGeometry::CreateGeometry() = default; // ----------------------------------------------------------------------------- // @@ -117,14 +72,14 @@ CreateGeometry::~CreateGeometry() = default; // ----------------------------------------------------------------------------- void CreateGeometry::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { LinkedChoicesFilterParameter::Pointer parameter = LinkedChoicesFilterParameter::New(); parameter->setHumanLabel("Geometry Type"); parameter->setPropertyName("GeometryType"); parameter->setSetterCallback(SIMPL_BIND_SETTER(CreateGeometry, this, GeometryType)); parameter->setGetterCallback(SIMPL_BIND_GETTER(CreateGeometry, this, GeometryType)); - QVector choices; + std::vector choices; choices.push_back("Image"); choices.push_back("Rectilinear Grid"); choices.push_back("Vertex"); @@ -134,113 +89,114 @@ void CreateGeometry::setupFilterParameters() choices.push_back("Tetrahedral"); choices.push_back("Hexahedral"); parameter->setChoices(choices); - QStringList linkedProps = {"Dimensions", - "Origin", - "Resolution", - "BoxDimensions", - "ImageCellAttributeMatrixName", // ImageGeom - "XBoundsArrayPath", - "YBoundsArrayPath", - "ZBoundsArrayPath", - "RectGridCellAttributeMatrixName", // RectGridGeom - "SharedVertexListArrayPath0", - "VertexAttributeMatrixName0", // VertexGeom - "SharedVertexListArrayPath1", - "SharedEdgeListArrayPath", - "VertexAttributeMatrixName1", - "EdgeAttributeMatrixName", // EdgeGeom - "SharedVertexListArrayPath2", - "SharedTriListArrayPath", - "VertexAttributeMatrixName2", - "FaceAttributeMatrixName0", // TriangleGeom - "SharedVertexListArrayPath3", - "SharedQuadListArrayPath", - "VertexAttributeMatrixName3", - "FaceAttributeMatrixName1", // QuadGeom - "SharedVertexListArrayPath4", - "SharedTetListArrayPath", - "VertexAttributeMatrixName4", - "TetCellAttributeMatrixName", // TetrahedralGeom - "SharedVertexListArrayPath5", - "SharedHexListArrayPath", - "VertexAttributeMatrixName5", - "HexCellAttributeMatrixName" }; // HexahedralGeom + std::vector linkedProps = {"Dimensions", + "Origin", + "Spacing", + "BoxDimensions", + "ImageCellAttributeMatrixName", // ImageGeom + "XBoundsArrayPath", + "YBoundsArrayPath", + "ZBoundsArrayPath", + "RectGridCellAttributeMatrixName", // RectGridGeom + "SharedVertexListArrayPath0", + "VertexAttributeMatrixName0", // VertexGeom + "SharedVertexListArrayPath1", + "SharedEdgeListArrayPath", + "VertexAttributeMatrixName1", + "EdgeAttributeMatrixName", // EdgeGeom + "SharedVertexListArrayPath2", + "SharedTriListArrayPath", + "VertexAttributeMatrixName2", + "FaceAttributeMatrixName0", // TriangleGeom + "SharedVertexListArrayPath3", + "SharedQuadListArrayPath", + "VertexAttributeMatrixName3", + "FaceAttributeMatrixName1", // QuadGeom + "SharedVertexListArrayPath4", + "SharedTetListArrayPath", + "VertexAttributeMatrixName4", + "TetCellAttributeMatrixName", // TetrahedralGeom + "SharedVertexListArrayPath5", + "SharedHexListArrayPath", + "VertexAttributeMatrixName5", + "HexCellAttributeMatrixName"}; // HexahedralGeom parameter->setLinkedProperties(linkedProps); parameter->setEditable(false); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameters.push_back(parameter); } - parameters.push_back(SIMPL_NEW_BOOL_FP("Treat Geometry Warnings as Errors", TreatWarningsAsErrors, FilterParameter::Parameter, CreateGeometry)); + parameters.push_back(SIMPL_NEW_BOOL_FP("Treat Geometry Warnings as Errors", TreatWarningsAsErrors, FilterParameter::Category::Parameter, CreateGeometry)); { - QVector choices = {"Copy Arrays", "Move Arrays"}; - parameters.push_back(SIMPL_NEW_CHOICE_FP("Array Handling", ArrayHandling, FilterParameter::Parameter, CreateGeometry, choices, false)); + std::vector choices = {"Copy Arrays", "Move Arrays"}; + parameters.push_back(SIMPL_NEW_CHOICE_FP("Array Handling", ArrayHandling, FilterParameter::Category::Parameter, CreateGeometry, choices, false)); } DataContainerSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container", DataContainerName, FilterParameter::RequiredArray, CreateGeometry, req)); + parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container", DataContainerName, FilterParameter::Category::RequiredArray, CreateGeometry, req)); { - parameters.push_back(SIMPL_NEW_INT_VEC3_FP("Dimensions", Dimensions, FilterParameter::Parameter, CreateGeometry, 0)); - parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Origin", Origin, FilterParameter::Parameter, CreateGeometry, 0)); - parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Resolution", Resolution, FilterParameter::Parameter, CreateGeometry, 0)); - parameters.push_back(SIMPL_NEW_STRING_FP("Cell Attribute Matrix", ImageCellAttributeMatrixName, FilterParameter::CreatedArray, CreateGeometry, 0)); + parameters.push_back(SIMPL_NEW_INT_VEC3_FP("Dimensions", Dimensions, FilterParameter::Category::Parameter, CreateGeometry, 0)); + parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Origin", Origin, FilterParameter::Category::Parameter, CreateGeometry, 0)); + parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Spacing", Spacing, FilterParameter::Category::Parameter, CreateGeometry, 0)); + parameters.back()->setLegacyPropertyName("Resolution"); + parameters.push_back(SIMPL_NEW_AM_WITH_LINKED_DC_FP("Cell Attribute Matrix", ImageCellAttributeMatrixName, DataContainerName, FilterParameter::Category::CreatedArray, CreateGeometry, 0)); } { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Float, 1, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("X Bounds", XBoundsArrayPath, FilterParameter::RequiredArray, CreateGeometry, req, 1)); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Y Bounds", YBoundsArrayPath, FilterParameter::RequiredArray, CreateGeometry, req, 1)); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Z Bounds", ZBoundsArrayPath, FilterParameter::RequiredArray, CreateGeometry, req, 1)); - parameters.push_back(SIMPL_NEW_STRING_FP("Cell Attribute Matrix", RectGridCellAttributeMatrixName, FilterParameter::CreatedArray, CreateGeometry, 1)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("X Bounds", XBoundsArrayPath, FilterParameter::Category::RequiredArray, CreateGeometry, req, 1)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Y Bounds", YBoundsArrayPath, FilterParameter::Category::RequiredArray, CreateGeometry, req, 1)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Z Bounds", ZBoundsArrayPath, FilterParameter::Category::RequiredArray, CreateGeometry, req, 1)); + parameters.push_back(SIMPL_NEW_AM_WITH_LINKED_DC_FP("Cell Attribute Matrix", RectGridCellAttributeMatrixName, DataContainerName, FilterParameter::Category::CreatedArray, CreateGeometry, 1)); - PreflightUpdatedValueFilterParameter::Pointer param = SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP("Box Size in Length Units", BoxDimensions, FilterParameter::Parameter, CreateGeometry); + PreflightUpdatedValueFilterParameter::Pointer param = SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP("Box Size in Length Units", BoxDimensions, FilterParameter::Category::Parameter, CreateGeometry); param->setReadOnly(true); param->setGroupIndex(0); parameters.push_back(param); } { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Float, 3, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Vertex List", SharedVertexListArrayPath0, FilterParameter::RequiredArray, CreateGeometry, req, 2)); - parameters.push_back(SIMPL_NEW_STRING_FP("Vertex Attribute Matrix", VertexAttributeMatrixName0, FilterParameter::CreatedArray, CreateGeometry, 2)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Vertex List", SharedVertexListArrayPath0, FilterParameter::Category::RequiredArray, CreateGeometry, req, 2)); + parameters.push_back(SIMPL_NEW_AM_WITH_LINKED_DC_FP("Vertex Attribute Matrix", VertexAttributeMatrixName0, DataContainerName, FilterParameter::Category::CreatedArray, CreateGeometry, 2)); } { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Float, 3, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Shared Vertex List", SharedVertexListArrayPath1, FilterParameter::RequiredArray, CreateGeometry, req, 3)); - req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Int64, 2, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Edge List", SharedEdgeListArrayPath, FilterParameter::RequiredArray, CreateGeometry, req, 3)); - parameters.push_back(SIMPL_NEW_STRING_FP("Vertex Attribute Matrix", VertexAttributeMatrixName1, FilterParameter::CreatedArray, CreateGeometry, 3)); - parameters.push_back(SIMPL_NEW_STRING_FP("Edge Attribute Matrix", EdgeAttributeMatrixName, FilterParameter::CreatedArray, CreateGeometry, 3)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Shared Vertex List", SharedVertexListArrayPath1, FilterParameter::Category::RequiredArray, CreateGeometry, req, 3)); + req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::UInt64, 2, AttributeMatrix::Category::Any); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Edge List", SharedEdgeListArrayPath, FilterParameter::Category::RequiredArray, CreateGeometry, req, 3)); + parameters.push_back(SIMPL_NEW_AM_WITH_LINKED_DC_FP("Vertex Attribute Matrix", VertexAttributeMatrixName1, DataContainerName, FilterParameter::Category::CreatedArray, CreateGeometry, 3)); + parameters.push_back(SIMPL_NEW_AM_WITH_LINKED_DC_FP("Edge Attribute Matrix", EdgeAttributeMatrixName, DataContainerName, FilterParameter::Category::CreatedArray, CreateGeometry, 3)); } { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Float, 3, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Shared Vertex List", SharedVertexListArrayPath2, FilterParameter::RequiredArray, CreateGeometry, req, 4)); - req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Int64, 3, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Triangle List", SharedTriListArrayPath, FilterParameter::RequiredArray, CreateGeometry, req, 4)); - parameters.push_back(SIMPL_NEW_STRING_FP("Vertex Attribute Matrix", VertexAttributeMatrixName2, FilterParameter::CreatedArray, CreateGeometry, 4)); - parameters.push_back(SIMPL_NEW_STRING_FP("Face Attribute Matrix", FaceAttributeMatrixName0, FilterParameter::CreatedArray, CreateGeometry, 4)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Shared Vertex List", SharedVertexListArrayPath2, FilterParameter::Category::RequiredArray, CreateGeometry, req, 4)); + req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::UInt64, 3, AttributeMatrix::Category::Any); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Triangle List", SharedTriListArrayPath, FilterParameter::Category::RequiredArray, CreateGeometry, req, 4)); + parameters.push_back(SIMPL_NEW_AM_WITH_LINKED_DC_FP("Vertex Attribute Matrix", VertexAttributeMatrixName2, DataContainerName, FilterParameter::Category::CreatedArray, CreateGeometry, 4)); + parameters.push_back(SIMPL_NEW_AM_WITH_LINKED_DC_FP("Face Attribute Matrix", FaceAttributeMatrixName0, DataContainerName, FilterParameter::Category::CreatedArray, CreateGeometry, 4)); } { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Float, 3, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Shared Vertex List", SharedVertexListArrayPath3, FilterParameter::RequiredArray, CreateGeometry, req, 5)); - req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Int64, 4, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Quadrilateral List", SharedQuadListArrayPath, FilterParameter::RequiredArray, CreateGeometry, req, 5)); - parameters.push_back(SIMPL_NEW_STRING_FP("Vertex Attribute Matrix", VertexAttributeMatrixName3, FilterParameter::CreatedArray, CreateGeometry, 5)); - parameters.push_back(SIMPL_NEW_STRING_FP("Face Attribute Matrix", FaceAttributeMatrixName1, FilterParameter::CreatedArray, CreateGeometry, 5)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Shared Vertex List", SharedVertexListArrayPath3, FilterParameter::Category::RequiredArray, CreateGeometry, req, 5)); + req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::UInt64, 4, AttributeMatrix::Category::Any); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Quadrilateral List", SharedQuadListArrayPath, FilterParameter::Category::RequiredArray, CreateGeometry, req, 5)); + parameters.push_back(SIMPL_NEW_AM_WITH_LINKED_DC_FP("Vertex Attribute Matrix", VertexAttributeMatrixName3, DataContainerName, FilterParameter::Category::CreatedArray, CreateGeometry, 5)); + parameters.push_back(SIMPL_NEW_AM_WITH_LINKED_DC_FP("Face Attribute Matrix", FaceAttributeMatrixName1, DataContainerName, FilterParameter::Category::CreatedArray, CreateGeometry, 5)); } { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Float, 3, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Shared Vertex List", SharedVertexListArrayPath4, FilterParameter::RequiredArray, CreateGeometry, req, 6)); - req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Int64, 4, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Tetrahedral List", SharedTetListArrayPath, FilterParameter::RequiredArray, CreateGeometry, req, 6)); - parameters.push_back(SIMPL_NEW_STRING_FP("Vertex Attribute Matrix", VertexAttributeMatrixName4, FilterParameter::CreatedArray, CreateGeometry, 6)); - parameters.push_back(SIMPL_NEW_STRING_FP("Cell Attribute Matrix", TetCellAttributeMatrixName, FilterParameter::CreatedArray, CreateGeometry, 6)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Shared Vertex List", SharedVertexListArrayPath4, FilterParameter::Category::RequiredArray, CreateGeometry, req, 6)); + req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::UInt64, 4, AttributeMatrix::Category::Any); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Tetrahedral List", SharedTetListArrayPath, FilterParameter::Category::RequiredArray, CreateGeometry, req, 6)); + parameters.push_back(SIMPL_NEW_AM_WITH_LINKED_DC_FP("Vertex Attribute Matrix", VertexAttributeMatrixName4, DataContainerName, FilterParameter::Category::CreatedArray, CreateGeometry, 6)); + parameters.push_back(SIMPL_NEW_AM_WITH_LINKED_DC_FP("Cell Attribute Matrix", TetCellAttributeMatrixName, DataContainerName, FilterParameter::Category::CreatedArray, CreateGeometry, 6)); } { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Float, 3, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Shared Vertex List", SharedVertexListArrayPath5, FilterParameter::RequiredArray, CreateGeometry, req, 7)); - req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Int64, 8, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Hexahedral List", SharedHexListArrayPath, FilterParameter::RequiredArray, CreateGeometry, req, 7)); - parameters.push_back(SIMPL_NEW_STRING_FP("Vertex Attribute Matrix", VertexAttributeMatrixName5, FilterParameter::CreatedArray, CreateGeometry, 7)); - parameters.push_back(SIMPL_NEW_STRING_FP("Cell Attribute Matrix", HexCellAttributeMatrixName, FilterParameter::CreatedArray, CreateGeometry, 7)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Shared Vertex List", SharedVertexListArrayPath5, FilterParameter::Category::RequiredArray, CreateGeometry, req, 7)); + req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::UInt64, 8, AttributeMatrix::Category::Any); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Hexahedral List", SharedHexListArrayPath, FilterParameter::Category::RequiredArray, CreateGeometry, req, 7)); + parameters.push_back(SIMPL_NEW_AM_WITH_LINKED_DC_FP("Vertex Attribute Matrix", VertexAttributeMatrixName5, DataContainerName, FilterParameter::Category::CreatedArray, CreateGeometry, 7)); + parameters.push_back(SIMPL_NEW_AM_WITH_LINKED_DC_FP("Cell Attribute Matrix", HexCellAttributeMatrixName, DataContainerName, FilterParameter::Category::CreatedArray, CreateGeometry, 7)); } setFilterParameters(parameters); } @@ -257,13 +213,13 @@ void CreateGeometry::initialize() // ----------------------------------------------------------------------------- void CreateGeometry::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); initialize(); DataContainer::Pointer dc = getDataContainerArray()->getPrereqDataContainer(this, getDataContainerName()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -271,8 +227,7 @@ void CreateGeometry::dataCheck() if(dc->getGeometry()) { QString ss = QObject::tr("Selected Data Container already contains a Geometry"); - setErrorCondition(-701); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-701, ss); return; } @@ -280,52 +235,53 @@ void CreateGeometry::dataCheck() { case 0: // ImageGeom { - if(getDimensions().x <= 0 || getDimensions().y <= 0 || getDimensions().z <= 0) + if(getDimensions().getX() <= 0 || getDimensions().getY() <= 0 || getDimensions().getZ() <= 0) { QString ss = QObject::tr("One of the dimensions has a size less than or equal to zero; all dimensions must be positive\n" "X Dimension: %1\n" "Y Dimension: %2\n" "Z Dimension: %3\n") - .arg(getDimensions().x) - .arg(getDimensions().y) - .arg(getDimensions().z); - setErrorCondition(-390); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + .arg(getDimensions().getX()) + .arg(getDimensions().getY()) + .arg(getDimensions().getZ()); + setErrorCondition(-390, ss); return; } ImageGeom::Pointer image = ImageGeom::CreateGeometry(SIMPL::Geometry::ImageGeometry); - image->setDimensions(getDimensions().x, getDimensions().y, getDimensions().z); - image->setOrigin(getOrigin().x, getOrigin().y, getOrigin().z); - image->setResolution(getResolution().x, getResolution().y, getResolution().z); + IntVec3Type dims = getDimensions(); + image->setDimensions(SizeVec3Type(dims[0], dims[1], dims[2])); + image->setOrigin(getOrigin()); + image->setSpacing(getSpacing()); dc->setGeometry(image); - QVector tDims = {image->getXPoints(), image->getYPoints(), image->getZPoints()}; - DataArrayPath path(getDataContainerName(), getImageCellAttributeMatrixName(), ""); + std::vector tDims = {image->getXPoints(), image->getYPoints(), image->getZPoints()}; + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getImageCellAttributeMatrixName()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Cell); break; } case 1: // RectGridGeom { - QVector cDims(1, 1); + std::vector cDims(1, 1); - m_XBoundsPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getXBoundsArrayPath(), cDims); + m_XBoundsPtr = getDataContainerArray()->getPrereqArrayFromPath(this, getXBoundsArrayPath(), cDims); if(m_XBoundsPtr.lock()) { m_XBounds = m_XBoundsPtr.lock()->getPointer(0); } - m_YBoundsPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getYBoundsArrayPath(), cDims); + m_YBoundsPtr = getDataContainerArray()->getPrereqArrayFromPath(this, getYBoundsArrayPath(), cDims); if(m_YBoundsPtr.lock()) { m_YBounds = m_YBoundsPtr.lock()->getPointer(0); } - m_ZBoundsPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getZBoundsArrayPath(), cDims); + m_ZBoundsPtr = getDataContainerArray()->getPrereqArrayFromPath(this, getZBoundsArrayPath(), cDims); if(m_ZBoundsPtr.lock()) { m_ZBounds = m_ZBoundsPtr.lock()->getPointer(0); } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -339,8 +295,7 @@ void CreateGeometry::dataCheck() .arg(m_XBoundsPtr.lock()->getNumberOfTuples()) .arg(m_YBoundsPtr.lock()->getNumberOfTuples()) .arg(m_ZBoundsPtr.lock()->getNumberOfTuples()); - setErrorCondition(-390); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-390, ss); return; } @@ -353,29 +308,36 @@ void CreateGeometry::dataCheck() } else { - rectgrid->setXBounds(m_XBoundsPtr.lock()); - rectgrid->setYBounds(m_YBoundsPtr.lock()); - rectgrid->setZBounds(m_ZBoundsPtr.lock()); - getDataContainerArray()->getAttributeMatrix(getXBoundsArrayPath())->removeAttributeArray(getXBoundsArrayPath().getDataArrayName()); - getDataContainerArray()->getAttributeMatrix(getYBoundsArrayPath())->removeAttributeArray(getYBoundsArrayPath().getDataArrayName()); - getDataContainerArray()->getAttributeMatrix(getZBoundsArrayPath())->removeAttributeArray(getZBoundsArrayPath().getDataArrayName()); + DataContainerArray::Pointer dca = getDataContainerArray(); + DataContainer::Pointer dc = dca->getDataContainer(getXBoundsArrayPath()); + AttributeMatrix::Pointer am = dc->getAttributeMatrix(getXBoundsArrayPath()); + + FloatArrayType::Pointer farray = std::dynamic_pointer_cast(am->removeAttributeArray(getXBoundsArrayPath().getDataArrayName())); + rectgrid->setXBounds(farray); + + farray = std::dynamic_pointer_cast(am->removeAttributeArray(getYBoundsArrayPath().getDataArrayName())); + rectgrid->setYBounds(farray); + + farray = std::dynamic_pointer_cast(am->removeAttributeArray(getZBoundsArrayPath().getDataArrayName())); + rectgrid->setZBounds(farray); } - rectgrid->setDimensions(m_XBoundsPtr.lock()->getNumberOfTuples() - 1, m_YBoundsPtr.lock()->getNumberOfTuples() - 1, m_ZBoundsPtr.lock()->getNumberOfTuples() - 1); + rectgrid->setDimensions(SizeVec3Type(m_XBoundsPtr.lock()->getNumberOfTuples() - 1, m_YBoundsPtr.lock()->getNumberOfTuples() - 1, m_ZBoundsPtr.lock()->getNumberOfTuples() - 1)); dc->setGeometry(rectgrid); - QVector tDims = {rectgrid->getXPoints(), rectgrid->getYPoints(), rectgrid->getZPoints()}; - DataArrayPath path(getDataContainerName(), getRectGridCellAttributeMatrixName(), ""); + std::vector tDims = {rectgrid->getXPoints(), rectgrid->getYPoints(), rectgrid->getZPoints()}; + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getRectGridCellAttributeMatrixName()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Cell); break; } case 2: // VertexGeom { - QVector cDims(1, 3); + std::vector cDims(1, 3); - FloatArrayType::Pointer verts = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSharedVertexListArrayPath0(), cDims); + FloatArrayType::Pointer verts = getDataContainerArray()->getPrereqArrayFromPath(this, getSharedVertexListArrayPath0(), cDims); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -387,29 +349,36 @@ void CreateGeometry::dataCheck() } else { - vertex = VertexGeom::CreateGeometry(verts, SIMPL::Geometry::VertexGeometry); - getDataContainerArray()->getAttributeMatrix(getSharedVertexListArrayPath0())->removeAttributeArray(getSharedVertexListArrayPath0().getDataArrayName()); + AttributeMatrix::Pointer am = getDataContainerArray()->getAttributeMatrix(getSharedVertexListArrayPath0()); + if(nullptr != verts.get()) + { + // Remove from the Attribute Matrix FIRST + IDataArray::Pointer vertsToRemove = am->removeAttributeArray(getSharedVertexListArrayPath0().getDataArrayName()); + // Assign the Verts to the newly create VertexGeom + vertex = VertexGeom::CreateGeometry(verts, SIMPL::Geometry::VertexGeometry); + } } dc->setGeometry(vertex); - QVector tDims(1, vertex->getNumberOfVertices()); - DataArrayPath path(getDataContainerName(), getVertexAttributeMatrixName0(), ""); + std::vector tDims(1, vertex->getNumberOfVertices()); + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getVertexAttributeMatrixName0()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Vertex); break; } case 3: // EdgeGeom { - QVector cDims(1, 3); + std::vector cDims(1, 3); - FloatArrayType::Pointer verts = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSharedVertexListArrayPath1(), cDims); + FloatArrayType::Pointer verts = getDataContainerArray()->getPrereqArrayFromPath(this, getSharedVertexListArrayPath1(), cDims); cDims[0] = 2; - m_EdgesPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSharedEdgeListArrayPath(), cDims); + m_EdgesPtr = getDataContainerArray()->getPrereqArrayFromPath(this, getSharedEdgeListArrayPath(), cDims); if(m_EdgesPtr.lock()) { m_Edges = m_EdgesPtr.lock()->getPointer(0); } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -417,38 +386,39 @@ void CreateGeometry::dataCheck() EdgeGeom::Pointer edge = EdgeGeom::NullPointer(); if(static_cast(getArrayHandling()) == k_CopyArrays) { - edge = EdgeGeom::CreateGeometry(std::static_pointer_cast(m_EdgesPtr.lock()->deepCopy(getInPreflight())), + edge = EdgeGeom::CreateGeometry(std::static_pointer_cast(m_EdgesPtr.lock()->deepCopy(getInPreflight())), std::static_pointer_cast(verts->deepCopy(getInPreflight())), SIMPL::Geometry::EdgeGeometry); } else { - edge = EdgeGeom::CreateGeometry(m_EdgesPtr.lock(), verts, SIMPL::Geometry::EdgeGeometry); getDataContainerArray()->getAttributeMatrix(getSharedVertexListArrayPath1())->removeAttributeArray(getSharedVertexListArrayPath1().getDataArrayName()); getDataContainerArray()->getAttributeMatrix(getSharedEdgeListArrayPath())->removeAttributeArray(getSharedEdgeListArrayPath().getDataArrayName()); + edge = EdgeGeom::CreateGeometry(m_EdgesPtr.lock(), verts, SIMPL::Geometry::EdgeGeometry); } dc->setGeometry(edge); m_NumVerts = edge->getNumberOfVertices(); - QVector tDims(1, edge->getNumberOfVertices()); - DataArrayPath path(getDataContainerName(), getVertexAttributeMatrixName1(), ""); + std::vector tDims(1, edge->getNumberOfVertices()); + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getVertexAttributeMatrixName1()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Vertex); tDims[0] = edge->getNumberOfEdges(); - path.update(getDataContainerName(), getEdgeAttributeMatrixName(), ""); + path.setAttributeMatrixName(getEdgeAttributeMatrixName()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Edge); break; } case 4: // TriangleGeom { - QVector cDims(1, 3); + std::vector cDims(1, 3); - FloatArrayType::Pointer verts = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSharedVertexListArrayPath2(), cDims); - m_TrisPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSharedTriListArrayPath(), cDims); + FloatArrayType::Pointer verts = getDataContainerArray()->getPrereqArrayFromPath(this, getSharedVertexListArrayPath2(), cDims); + m_TrisPtr = getDataContainerArray()->getPrereqArrayFromPath(this, getSharedTriListArrayPath(), cDims); if(m_TrisPtr.lock()) { m_Tris = m_TrisPtr.lock()->getPointer(0); } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -456,39 +426,40 @@ void CreateGeometry::dataCheck() TriangleGeom::Pointer triangle = TriangleGeom::NullPointer(); if(static_cast(getArrayHandling()) == k_CopyArrays) { - triangle = TriangleGeom::CreateGeometry(std::static_pointer_cast(m_TrisPtr.lock()->deepCopy(getInPreflight())), + triangle = TriangleGeom::CreateGeometry(std::static_pointer_cast(m_TrisPtr.lock()->deepCopy(getInPreflight())), std::static_pointer_cast(verts->deepCopy(getInPreflight())), SIMPL::Geometry::TriangleGeometry); } else { - triangle = TriangleGeom::CreateGeometry(m_TrisPtr.lock(), verts, SIMPL::Geometry::TriangleGeometry); getDataContainerArray()->getAttributeMatrix(getSharedVertexListArrayPath2())->removeAttributeArray(getSharedVertexListArrayPath2().getDataArrayName()); getDataContainerArray()->getAttributeMatrix(getSharedTriListArrayPath())->removeAttributeArray(getSharedTriListArrayPath().getDataArrayName()); + triangle = TriangleGeom::CreateGeometry(m_TrisPtr.lock(), verts, SIMPL::Geometry::TriangleGeometry); } dc->setGeometry(triangle); m_NumVerts = triangle->getNumberOfVertices(); - QVector tDims(1, triangle->getNumberOfVertices()); - DataArrayPath path(getDataContainerName(), getVertexAttributeMatrixName2(), ""); + std::vector tDims(1, triangle->getNumberOfVertices()); + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getVertexAttributeMatrixName2()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Vertex); tDims[0] = triangle->getNumberOfTris(); - path.update(getDataContainerName(), getFaceAttributeMatrixName0(), ""); + path.setAttributeMatrixName(getFaceAttributeMatrixName0()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Face); break; } case 5: // QuadGeom { - QVector cDims(1, 3); + std::vector cDims(1, 3); - FloatArrayType::Pointer verts = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSharedVertexListArrayPath3(), cDims); + FloatArrayType::Pointer verts = getDataContainerArray()->getPrereqArrayFromPath(this, getSharedVertexListArrayPath3(), cDims); cDims[0] = 4; - m_QuadsPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSharedQuadListArrayPath(), cDims); + m_QuadsPtr = getDataContainerArray()->getPrereqArrayFromPath(this, getSharedQuadListArrayPath(), cDims); if(m_QuadsPtr.lock()) { m_Quads = m_QuadsPtr.lock()->getPointer(0); } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -496,39 +467,40 @@ void CreateGeometry::dataCheck() QuadGeom::Pointer quadrilateral = QuadGeom::NullPointer(); if(static_cast(getArrayHandling()) == k_CopyArrays) { - quadrilateral = QuadGeom::CreateGeometry(std::static_pointer_cast(m_QuadsPtr.lock()->deepCopy(getInPreflight())), + quadrilateral = QuadGeom::CreateGeometry(std::static_pointer_cast(m_QuadsPtr.lock()->deepCopy(getInPreflight())), std::static_pointer_cast(verts->deepCopy(getInPreflight())), SIMPL::Geometry::QuadGeometry); } else { - quadrilateral = QuadGeom::CreateGeometry(m_QuadsPtr.lock(), verts, SIMPL::Geometry::QuadGeometry); getDataContainerArray()->getAttributeMatrix(getSharedVertexListArrayPath3())->removeAttributeArray(getSharedVertexListArrayPath3().getDataArrayName()); getDataContainerArray()->getAttributeMatrix(getSharedQuadListArrayPath())->removeAttributeArray(getSharedQuadListArrayPath().getDataArrayName()); + quadrilateral = QuadGeom::CreateGeometry(m_QuadsPtr.lock(), verts, SIMPL::Geometry::QuadGeometry); } dc->setGeometry(quadrilateral); m_NumVerts = quadrilateral->getNumberOfVertices(); - QVector tDims(1, quadrilateral->getNumberOfVertices()); - DataArrayPath path(getDataContainerName(), getVertexAttributeMatrixName3(), ""); + std::vector tDims(1, quadrilateral->getNumberOfVertices()); + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getVertexAttributeMatrixName3()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Vertex); tDims[0] = quadrilateral->getNumberOfQuads(); - path.update(getDataContainerName(), getFaceAttributeMatrixName1(), ""); + path.setAttributeMatrixName(getFaceAttributeMatrixName1()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Face); break; } case 6: // TetrahedralGeom { - QVector cDims(1, 3); + std::vector cDims(1, 3); - FloatArrayType::Pointer verts = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSharedVertexListArrayPath4(), cDims); + FloatArrayType::Pointer verts = getDataContainerArray()->getPrereqArrayFromPath(this, getSharedVertexListArrayPath4(), cDims); cDims[0] = 4; - m_TetsPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSharedTetListArrayPath(), cDims); + m_TetsPtr = getDataContainerArray()->getPrereqArrayFromPath(this, getSharedTetListArrayPath(), cDims); if(m_TetsPtr.lock()) { m_Tets = m_TetsPtr.lock()->getPointer(0); } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -536,102 +508,85 @@ void CreateGeometry::dataCheck() TetrahedralGeom::Pointer tetrahedral = TetrahedralGeom::NullPointer(); if(static_cast(getArrayHandling()) == k_CopyArrays) { - tetrahedral = TetrahedralGeom::CreateGeometry(std::static_pointer_cast(m_TetsPtr.lock()->deepCopy(getInPreflight())), + tetrahedral = TetrahedralGeom::CreateGeometry(std::static_pointer_cast(m_TetsPtr.lock()->deepCopy(getInPreflight())), std::static_pointer_cast(verts->deepCopy(getInPreflight())), SIMPL::Geometry::TetrahedralGeometry); } else { - tetrahedral = TetrahedralGeom::CreateGeometry(m_TetsPtr.lock(), verts, SIMPL::Geometry::TetrahedralGeometry); getDataContainerArray()->getAttributeMatrix(getSharedVertexListArrayPath4())->removeAttributeArray(getSharedVertexListArrayPath4().getDataArrayName()); getDataContainerArray()->getAttributeMatrix(getSharedTetListArrayPath())->removeAttributeArray(getSharedTetListArrayPath().getDataArrayName()); + tetrahedral = TetrahedralGeom::CreateGeometry(m_TetsPtr.lock(), verts, SIMPL::Geometry::TetrahedralGeometry); } dc->setGeometry(tetrahedral); m_NumVerts = tetrahedral->getNumberOfVertices(); - QVector tDims(1, tetrahedral->getNumberOfVertices()); - DataArrayPath path(getDataContainerName(), getVertexAttributeMatrixName4(), ""); + std::vector tDims(1, tetrahedral->getNumberOfVertices()); + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getVertexAttributeMatrixName4()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Vertex); tDims[0] = tetrahedral->getNumberOfTets(); - path.update(getDataContainerName(), getTetCellAttributeMatrixName(), ""); + path.setAttributeMatrixName(getTetCellAttributeMatrixName()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Cell); break; } case 7: // HexahedralGeom { - QVector cDims(1, 3); + std::vector cDims(1, 3); - FloatArrayType::Pointer verts = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSharedVertexListArrayPath5(), cDims); + FloatArrayType::Pointer verts = getDataContainerArray()->getPrereqArrayFromPath(this, getSharedVertexListArrayPath5(), cDims); cDims[0] = 8; - m_HexesPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSharedHexListArrayPath(), cDims); - if (m_HexesPtr.lock()) + m_HexesPtr = getDataContainerArray()->getPrereqArrayFromPath(this, getSharedHexListArrayPath(), cDims); + if(m_HexesPtr.lock()) { m_Hexes = m_HexesPtr.lock()->getPointer(0); } - if (getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - HexahedralGeom::Pointer hexahedral = HexahedralGeom::NullPointer(); if(static_cast(getArrayHandling()) == k_CopyArrays) { - hexahedral = HexahedralGeom::CreateGeometry(std::static_pointer_cast(m_HexesPtr.lock()->deepCopy(getInPreflight())), - std::static_pointer_cast(verts->deepCopy(getInPreflight())), SIMPL::Geometry::HexahedralGeometry); + hexahedral = HexahedralGeom::CreateGeometry(std::static_pointer_cast(m_HexesPtr.lock()->deepCopy(getInPreflight())), + std::static_pointer_cast(verts->deepCopy(getInPreflight())), SIMPL::Geometry::HexahedralGeometry); } else { - hexahedral = HexahedralGeom::CreateGeometry(m_HexesPtr.lock(), verts, SIMPL::Geometry::HexahedralGeometry); getDataContainerArray()->getAttributeMatrix(getSharedVertexListArrayPath5())->removeAttributeArray(getSharedVertexListArrayPath5().getDataArrayName()); getDataContainerArray()->getAttributeMatrix(getSharedHexListArrayPath())->removeAttributeArray(getSharedHexListArrayPath().getDataArrayName()); + hexahedral = HexahedralGeom::CreateGeometry(m_HexesPtr.lock(), verts, SIMPL::Geometry::HexahedralGeometry); } dc->setGeometry(hexahedral); m_NumVerts = hexahedral->getNumberOfVertices(); - QVector tDims(1, hexahedral->getNumberOfVertices()); - DataArrayPath path(getDataContainerName(), getVertexAttributeMatrixName5(), ""); + std::vector tDims(1, hexahedral->getNumberOfVertices()); + DataArrayPath path = getDataContainerName(); + path.setAttributeMatrixName(getVertexAttributeMatrixName5()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Vertex); tDims[0] = hexahedral->getNumberOfHexas(); - path.update(getDataContainerName(), getHexCellAttributeMatrixName(), ""); + path.setAttributeMatrixName(getHexCellAttributeMatrixName()); dc->createNonPrereqAttributeMatrix(this, path, tDims, AttributeMatrix::Type::Cell); break; } - default: - { + default: { QString ss = QObject::tr("Invalid selection for Geometry type"); - setErrorCondition(-701); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-701, ss); break; } } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void CreateGeometry::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void CreateGeometry::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -659,13 +614,11 @@ void CreateGeometry::execute() .arg(m_XBounds[i]); if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -686,13 +639,11 @@ void CreateGeometry::execute() .arg(m_YBounds[i]); if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -713,13 +664,11 @@ void CreateGeometry::execute() .arg(m_ZBounds[i]); if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -735,7 +684,7 @@ void CreateGeometry::execute() } case 3: // EdgeGeom { - int64_t idx = 0; + size_t idx = 0; for(size_t i = 0; i < m_EdgesPtr.lock()->getSize(); i++) { if(m_Edges[i] > idx) @@ -753,13 +702,11 @@ void CreateGeometry::execute() .arg(m_NumVerts); if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -768,7 +715,7 @@ void CreateGeometry::execute() } case 4: // TriangleGeom { - int64_t idx = 0; + size_t idx = 0; for(size_t i = 0; i < m_TrisPtr.lock()->getSize(); i++) { if(m_Tris[i] > idx) @@ -786,13 +733,11 @@ void CreateGeometry::execute() .arg(m_NumVerts); if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -801,7 +746,7 @@ void CreateGeometry::execute() } case 5: // QuadGeom { - int64_t idx = 0; + size_t idx = 0; for(size_t i = 0; i < m_QuadsPtr.lock()->getSize(); i++) { if(m_Quads[i] > idx) @@ -819,13 +764,11 @@ void CreateGeometry::execute() .arg(m_NumVerts); if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -834,7 +777,7 @@ void CreateGeometry::execute() } case 6: // TetrahedralGeom { - int64_t idx = 0; + size_t idx = 0; for(size_t i = 0; i < m_TetsPtr.lock()->getSize(); i++) { if(m_Tets[i] > idx) @@ -852,13 +795,11 @@ void CreateGeometry::execute() .arg(m_NumVerts); if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } @@ -867,43 +808,39 @@ void CreateGeometry::execute() } case 7: // HexahedralGeom { - int64_t idx = 0; - for (size_t i = 0; i < m_HexesPtr.lock()->getSize(); i++) + size_t idx = 0; + for(size_t i = 0; i < m_HexesPtr.lock()->getSize(); i++) { - if (m_Hexes[i] > idx) + if(m_Hexes[i] > idx) { idx = m_Hexes[i]; } } - if ((idx + 1) > m_NumVerts) + if((idx + 1) > m_NumVerts) { QString ss = QObject::tr("Supplied hexahedra list contains a vertex index larger than the total length of the supplied shared vertex list\n" - "Index Value: %1\n" - "Number of Vertices: %2") - .arg(idx) - .arg(m_NumVerts); - if (m_TreatWarningsAsErrors) + "Index Value: %1\n" + "Number of Vertices: %2") + .arg(idx) + .arg(m_NumVerts); + if(m_TreatWarningsAsErrors) { - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); } else { - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-1, ss); } return; } break; } - default: - { + default: { break; } } - } // ----------------------------------------------------------------------------- @@ -913,16 +850,15 @@ QString CreateGeometry::getBoxDimensions() { QString desc; QTextStream ss(&desc); - float halfRes[3] = {m_Resolution.x / 2.0f, m_Resolution.y / 2.0f, m_Resolution.z / 2.0f}; + float halfRes[3] = {m_Spacing[0] * 0.5f, m_Spacing[1] * 0.5f, m_Spacing[2] * 0.5f}; ss << "Extents:\n" - << "X Extent: 0 to " << m_Dimensions.x - 1 << " (dimension: " << m_Dimensions.x << ")\n" - << "Y Extent: 0 to " << m_Dimensions.y - 1 << " (dimension: " << m_Dimensions.y << ")\n" - << "Z Extent: 0 to " << m_Dimensions.z - 1 << " (dimension: " << m_Dimensions.z << ")\n" + << "X Extent: 0 to " << m_Dimensions[0] - 1 << " (dimension: " << m_Dimensions[0] << ")\n" + << "Y Extent: 0 to " << m_Dimensions[1] - 1 << " (dimension: " << m_Dimensions[1] << ")\n" + << "Z Extent: 0 to " << m_Dimensions[2] - 1 << " (dimension: " << m_Dimensions[2] << ")\n" << "Bounds:\n" - << "X Range: " << (m_Origin.x - halfRes[0]) << " to " << (m_Origin.x - halfRes[0] + m_Dimensions.x * m_Resolution.x) << " (delta: " << (m_Dimensions.x * m_Resolution.x) << ")\n" - << "Y Range: " << (m_Origin.y - halfRes[1]) << " to " << (m_Origin.y - halfRes[1] + m_Dimensions.y * m_Resolution.y) << " (delta: " << (m_Dimensions.y * m_Resolution.y) << ")\n" - << "Z Range: " << (m_Origin.z - halfRes[2]) << " to " << (m_Origin.z - halfRes[2] + m_Dimensions.z * m_Resolution.z) << " (delta: " << (m_Dimensions.z * m_Resolution.z) << ")\n"; - return desc; + << "X Range: " << (m_Origin[0] - halfRes[0]) << " to " << (m_Origin[0] - halfRes[0] + m_Dimensions[0] * m_Spacing[0]) << " (delta: " << (m_Dimensions[0] * m_Spacing[0]) << ")\n" + << "Y Range: " << (m_Origin[1] - halfRes[1]) << " to " << (m_Origin[1] - halfRes[1] + m_Dimensions[1] * m_Spacing[1]) << " (delta: " << (m_Dimensions[1] * m_Spacing[1]) << ")\n" + << "Z Range: " << (m_Origin[2] - halfRes[2]) << " to " << (m_Origin[2] - halfRes[2] + m_Dimensions[2] * m_Spacing[2]) << " (delta: " << (m_Dimensions[2] * m_Spacing[2]) << ")\n"; return desc; } @@ -942,7 +878,7 @@ AbstractFilter::Pointer CreateGeometry::newFilterInstance(bool copyFilterParamet // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateGeometry::getCompiledLibraryName() const +QString CreateGeometry::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -950,7 +886,7 @@ const QString CreateGeometry::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateGeometry::getBrandingString() const +QString CreateGeometry::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -958,7 +894,7 @@ const QString CreateGeometry::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateGeometry::getFilterVersion() const +QString CreateGeometry::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -969,7 +905,7 @@ const QString CreateGeometry::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateGeometry::getGroupName() const +QString CreateGeometry::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -977,7 +913,7 @@ const QString CreateGeometry::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid CreateGeometry::getUuid() +QUuid CreateGeometry::getUuid() const { return QUuid("{9ac220b9-14f9-581a-9bac-5714467589cc}"); } @@ -985,7 +921,7 @@ const QUuid CreateGeometry::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateGeometry::getSubGroupName() const +QString CreateGeometry::getSubGroupName() const { return SIMPL::FilterSubGroups::GeometryFilters; } @@ -993,7 +929,444 @@ const QString CreateGeometry::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateGeometry::getHumanLabel() const +QString CreateGeometry::getHumanLabel() const { return "Create Geometry"; } + +// ----------------------------------------------------------------------------- +CreateGeometry::Pointer CreateGeometry::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr CreateGeometry::New() +{ + struct make_shared_enabler : public CreateGeometry + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::getNameOfClass() const +{ + return QString("CreateGeometry"); +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::ClassName() +{ + return QString("CreateGeometry"); +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setGeometryType(int value) +{ + m_GeometryType = value; +} + +// ----------------------------------------------------------------------------- +int CreateGeometry::getGeometryType() const +{ + return m_GeometryType; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setDataContainerName(const DataArrayPath& value) +{ + m_DataContainerName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getDataContainerName() const +{ + return m_DataContainerName; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setSharedVertexListArrayPath0(const DataArrayPath& value) +{ + m_SharedVertexListArrayPath0 = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getSharedVertexListArrayPath0() const +{ + return m_SharedVertexListArrayPath0; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setSharedVertexListArrayPath1(const DataArrayPath& value) +{ + m_SharedVertexListArrayPath1 = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getSharedVertexListArrayPath1() const +{ + return m_SharedVertexListArrayPath1; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setSharedVertexListArrayPath2(const DataArrayPath& value) +{ + m_SharedVertexListArrayPath2 = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getSharedVertexListArrayPath2() const +{ + return m_SharedVertexListArrayPath2; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setSharedVertexListArrayPath3(const DataArrayPath& value) +{ + m_SharedVertexListArrayPath3 = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getSharedVertexListArrayPath3() const +{ + return m_SharedVertexListArrayPath3; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setSharedVertexListArrayPath4(const DataArrayPath& value) +{ + m_SharedVertexListArrayPath4 = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getSharedVertexListArrayPath4() const +{ + return m_SharedVertexListArrayPath4; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setSharedVertexListArrayPath5(const DataArrayPath& value) +{ + m_SharedVertexListArrayPath5 = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getSharedVertexListArrayPath5() const +{ + return m_SharedVertexListArrayPath5; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setSharedEdgeListArrayPath(const DataArrayPath& value) +{ + m_SharedEdgeListArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getSharedEdgeListArrayPath() const +{ + return m_SharedEdgeListArrayPath; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setSharedTriListArrayPath(const DataArrayPath& value) +{ + m_SharedTriListArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getSharedTriListArrayPath() const +{ + return m_SharedTriListArrayPath; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setSharedQuadListArrayPath(const DataArrayPath& value) +{ + m_SharedQuadListArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getSharedQuadListArrayPath() const +{ + return m_SharedQuadListArrayPath; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setSharedTetListArrayPath(const DataArrayPath& value) +{ + m_SharedTetListArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getSharedTetListArrayPath() const +{ + return m_SharedTetListArrayPath; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setSharedHexListArrayPath(const DataArrayPath& value) +{ + m_SharedHexListArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getSharedHexListArrayPath() const +{ + return m_SharedHexListArrayPath; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setXBoundsArrayPath(const DataArrayPath& value) +{ + m_XBoundsArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getXBoundsArrayPath() const +{ + return m_XBoundsArrayPath; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setYBoundsArrayPath(const DataArrayPath& value) +{ + m_YBoundsArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getYBoundsArrayPath() const +{ + return m_YBoundsArrayPath; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setZBoundsArrayPath(const DataArrayPath& value) +{ + m_ZBoundsArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateGeometry::getZBoundsArrayPath() const +{ + return m_ZBoundsArrayPath; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setDimensions(const IntVec3Type& value) +{ + m_Dimensions = value; +} + +// ----------------------------------------------------------------------------- +IntVec3Type CreateGeometry::getDimensions() const +{ + return m_Dimensions; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setOrigin(const FloatVec3Type& value) +{ + m_Origin = value; +} + +// ----------------------------------------------------------------------------- +FloatVec3Type CreateGeometry::getOrigin() const +{ + return m_Origin; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setSpacing(const FloatVec3Type& value) +{ + m_Spacing = value; +} + +// ----------------------------------------------------------------------------- +FloatVec3Type CreateGeometry::getSpacing() const +{ + return m_Spacing; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setImageCellAttributeMatrixName(const QString& value) +{ + m_ImageCellAttributeMatrixName = value; +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::getImageCellAttributeMatrixName() const +{ + return m_ImageCellAttributeMatrixName; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setRectGridCellAttributeMatrixName(const QString& value) +{ + m_RectGridCellAttributeMatrixName = value; +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::getRectGridCellAttributeMatrixName() const +{ + return m_RectGridCellAttributeMatrixName; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setVertexAttributeMatrixName0(const QString& value) +{ + m_VertexAttributeMatrixName0 = value; +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::getVertexAttributeMatrixName0() const +{ + return m_VertexAttributeMatrixName0; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setVertexAttributeMatrixName1(const QString& value) +{ + m_VertexAttributeMatrixName1 = value; +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::getVertexAttributeMatrixName1() const +{ + return m_VertexAttributeMatrixName1; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setVertexAttributeMatrixName2(const QString& value) +{ + m_VertexAttributeMatrixName2 = value; +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::getVertexAttributeMatrixName2() const +{ + return m_VertexAttributeMatrixName2; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setVertexAttributeMatrixName3(const QString& value) +{ + m_VertexAttributeMatrixName3 = value; +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::getVertexAttributeMatrixName3() const +{ + return m_VertexAttributeMatrixName3; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setVertexAttributeMatrixName4(const QString& value) +{ + m_VertexAttributeMatrixName4 = value; +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::getVertexAttributeMatrixName4() const +{ + return m_VertexAttributeMatrixName4; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setVertexAttributeMatrixName5(const QString& value) +{ + m_VertexAttributeMatrixName5 = value; +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::getVertexAttributeMatrixName5() const +{ + return m_VertexAttributeMatrixName5; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setEdgeAttributeMatrixName(const QString& value) +{ + m_EdgeAttributeMatrixName = value; +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::getEdgeAttributeMatrixName() const +{ + return m_EdgeAttributeMatrixName; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setFaceAttributeMatrixName0(const QString& value) +{ + m_FaceAttributeMatrixName0 = value; +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::getFaceAttributeMatrixName0() const +{ + return m_FaceAttributeMatrixName0; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setFaceAttributeMatrixName1(const QString& value) +{ + m_FaceAttributeMatrixName1 = value; +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::getFaceAttributeMatrixName1() const +{ + return m_FaceAttributeMatrixName1; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setTetCellAttributeMatrixName(const QString& value) +{ + m_TetCellAttributeMatrixName = value; +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::getTetCellAttributeMatrixName() const +{ + return m_TetCellAttributeMatrixName; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setHexCellAttributeMatrixName(const QString& value) +{ + m_HexCellAttributeMatrixName = value; +} + +// ----------------------------------------------------------------------------- +QString CreateGeometry::getHexCellAttributeMatrixName() const +{ + return m_HexCellAttributeMatrixName; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setTreatWarningsAsErrors(bool value) +{ + m_TreatWarningsAsErrors = value; +} + +// ----------------------------------------------------------------------------- +bool CreateGeometry::getTreatWarningsAsErrors() const +{ + return m_TreatWarningsAsErrors; +} + +// ----------------------------------------------------------------------------- +void CreateGeometry::setArrayHandling(bool value) +{ + m_ArrayHandling = value; +} + +// ----------------------------------------------------------------------------- +bool CreateGeometry::getArrayHandling() const +{ + return m_ArrayHandling; +} diff --git a/Source/SIMPLib/CoreFilters/CreateGeometry.h b/Source/SIMPLib/CoreFilters/CreateGeometry.h index 5f7bddc61d..64dd3d38f3 100644 --- a/Source/SIMPLib/CoreFilters/CreateGeometry.h +++ b/Source/SIMPLib/CoreFilters/CreateGeometry.h @@ -26,18 +26,20 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" #include "SIMPLib/FilterParameters/IntVec3FilterParameter.h" #include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/SIMPLib.h" /** * @brief The CreateGeometry class. See [Filter documentation](@ref creategeometry) for details. @@ -45,9 +47,14 @@ class SIMPLib_EXPORT CreateGeometry : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(CreateGeometry SUPERCLASS AbstractFilter) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(CreateGeometry SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(CreateGeometry) + PYB11_FILTER_NEW_MACRO(CreateGeometry) PYB11_PROPERTY(int GeometryType READ getGeometryType WRITE setGeometryType) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) PYB11_PROPERTY(DataArrayPath SharedVertexListArrayPath0 READ getSharedVertexListArrayPath0 WRITE setSharedVertexListArrayPath0) PYB11_PROPERTY(DataArrayPath SharedVertexListArrayPath1 READ getSharedVertexListArrayPath1 WRITE setSharedVertexListArrayPath1) PYB11_PROPERTY(DataArrayPath SharedVertexListArrayPath2 READ getSharedVertexListArrayPath2 WRITE setSharedVertexListArrayPath2) @@ -60,9 +67,9 @@ class SIMPLib_EXPORT CreateGeometry : public AbstractFilter PYB11_PROPERTY(DataArrayPath XBoundsArrayPath READ getXBoundsArrayPath WRITE setXBoundsArrayPath) PYB11_PROPERTY(DataArrayPath YBoundsArrayPath READ getYBoundsArrayPath WRITE setYBoundsArrayPath) PYB11_PROPERTY(DataArrayPath ZBoundsArrayPath READ getZBoundsArrayPath WRITE setZBoundsArrayPath) - PYB11_PROPERTY(IntVec3_t Dimensions READ getDimensions WRITE setDimensions) - PYB11_PROPERTY(FloatVec3_t Origin READ getOrigin WRITE setOrigin) - PYB11_PROPERTY(FloatVec3_t Resolution READ getResolution WRITE setResolution) + PYB11_PROPERTY(IntVec3Type Dimensions READ getDimensions WRITE setDimensions) + PYB11_PROPERTY(FloatVec3Type Origin READ getOrigin WRITE setOrigin) + PYB11_PROPERTY(FloatVec3Type Spacing READ getSpacing WRITE setSpacing) PYB11_PROPERTY(QString ImageCellAttributeMatrixName READ getImageCellAttributeMatrixName WRITE setImageCellAttributeMatrixName) PYB11_PROPERTY(QString RectGridCellAttributeMatrixName READ getRectGridCellAttributeMatrixName WRITE setRectGridCellAttributeMatrixName) PYB11_PROPERTY(QString VertexAttributeMatrixName0 READ getVertexAttributeMatrixName0 WRITE setVertexAttributeMatrixName0) @@ -76,117 +83,448 @@ class SIMPLib_EXPORT CreateGeometry : public AbstractFilter PYB11_PROPERTY(QString TetCellAttributeMatrixName READ getTetCellAttributeMatrixName WRITE setTetCellAttributeMatrixName) PYB11_PROPERTY(bool TreatWarningsAsErrors READ getTreatWarningsAsErrors WRITE setTreatWarningsAsErrors) PYB11_PROPERTY(bool ArrayHandling READ getArrayHandling WRITE setArrayHandling) + PYB11_END_BINDINGS() + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(CreateGeometry) - SIMPL_FILTER_NEW_MACRO(CreateGeometry) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(CreateGeometry, AbstractFilter) + using Self = CreateGeometry; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for CreateGeometry + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for CreateGeometry + */ + static QString ClassName(); ~CreateGeometry() override; static const int k_CopyArrays = 0; static const int k_MoveArrays = 1; - SIMPL_FILTER_PARAMETER(int, GeometryType) + /** + * @brief Setter property for GeometryType + */ + void setGeometryType(int value); + /** + * @brief Getter property for GeometryType + * @return Value of GeometryType + */ + int getGeometryType() const; + Q_PROPERTY(int GeometryType READ getGeometryType WRITE setGeometryType) - SIMPL_FILTER_PARAMETER(QString, DataContainerName) - Q_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + /** + * @brief Setter property for DataContainerName + */ + void setDataContainerName(const DataArrayPath& value); + /** + * @brief Getter property for DataContainerName + * @return Value of DataContainerName + */ + DataArrayPath getDataContainerName() const; + + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + + /** + * @brief Setter property for SharedVertexListArrayPath0 + */ + void setSharedVertexListArrayPath0(const DataArrayPath& value); + /** + * @brief Getter property for SharedVertexListArrayPath0 + * @return Value of SharedVertexListArrayPath0 + */ + DataArrayPath getSharedVertexListArrayPath0() const; - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedVertexListArrayPath0) Q_PROPERTY(DataArrayPath SharedVertexListArrayPath0 READ getSharedVertexListArrayPath0 WRITE setSharedVertexListArrayPath0) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedVertexListArrayPath1) + /** + * @brief Setter property for SharedVertexListArrayPath1 + */ + void setSharedVertexListArrayPath1(const DataArrayPath& value); + /** + * @brief Getter property for SharedVertexListArrayPath1 + * @return Value of SharedVertexListArrayPath1 + */ + DataArrayPath getSharedVertexListArrayPath1() const; + Q_PROPERTY(DataArrayPath SharedVertexListArrayPath1 READ getSharedVertexListArrayPath1 WRITE setSharedVertexListArrayPath1) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedVertexListArrayPath2) + /** + * @brief Setter property for SharedVertexListArrayPath2 + */ + void setSharedVertexListArrayPath2(const DataArrayPath& value); + /** + * @brief Getter property for SharedVertexListArrayPath2 + * @return Value of SharedVertexListArrayPath2 + */ + DataArrayPath getSharedVertexListArrayPath2() const; + Q_PROPERTY(DataArrayPath SharedVertexListArrayPath2 READ getSharedVertexListArrayPath2 WRITE setSharedVertexListArrayPath2) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedVertexListArrayPath3) + /** + * @brief Setter property for SharedVertexListArrayPath3 + */ + void setSharedVertexListArrayPath3(const DataArrayPath& value); + /** + * @brief Getter property for SharedVertexListArrayPath3 + * @return Value of SharedVertexListArrayPath3 + */ + DataArrayPath getSharedVertexListArrayPath3() const; + Q_PROPERTY(DataArrayPath SharedVertexListArrayPath3 READ getSharedVertexListArrayPath3 WRITE setSharedVertexListArrayPath3) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedVertexListArrayPath4) + /** + * @brief Setter property for SharedVertexListArrayPath4 + */ + void setSharedVertexListArrayPath4(const DataArrayPath& value); + /** + * @brief Getter property for SharedVertexListArrayPath4 + * @return Value of SharedVertexListArrayPath4 + */ + DataArrayPath getSharedVertexListArrayPath4() const; + Q_PROPERTY(DataArrayPath SharedVertexListArrayPath4 READ getSharedVertexListArrayPath4 WRITE setSharedVertexListArrayPath4) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedVertexListArrayPath5) + /** + * @brief Setter property for SharedVertexListArrayPath5 + */ + void setSharedVertexListArrayPath5(const DataArrayPath& value); + /** + * @brief Getter property for SharedVertexListArrayPath5 + * @return Value of SharedVertexListArrayPath5 + */ + DataArrayPath getSharedVertexListArrayPath5() const; + Q_PROPERTY(DataArrayPath SharedVertexListArrayPath5 READ getSharedVertexListArrayPath5 WRITE setSharedVertexListArrayPath5) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedEdgeListArrayPath) + /** + * @brief Setter property for SharedEdgeListArrayPath + */ + void setSharedEdgeListArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SharedEdgeListArrayPath + * @return Value of SharedEdgeListArrayPath + */ + DataArrayPath getSharedEdgeListArrayPath() const; + Q_PROPERTY(DataArrayPath SharedEdgeListArrayPath READ getSharedEdgeListArrayPath WRITE setSharedEdgeListArrayPath) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedTriListArrayPath) + /** + * @brief Setter property for SharedTriListArrayPath + */ + void setSharedTriListArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SharedTriListArrayPath + * @return Value of SharedTriListArrayPath + */ + DataArrayPath getSharedTriListArrayPath() const; + Q_PROPERTY(DataArrayPath SharedTriListArrayPath READ getSharedTriListArrayPath WRITE setSharedTriListArrayPath) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedQuadListArrayPath) + /** + * @brief Setter property for SharedQuadListArrayPath + */ + void setSharedQuadListArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SharedQuadListArrayPath + * @return Value of SharedQuadListArrayPath + */ + DataArrayPath getSharedQuadListArrayPath() const; + Q_PROPERTY(DataArrayPath SharedQuadListArrayPath READ getSharedQuadListArrayPath WRITE setSharedQuadListArrayPath) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedTetListArrayPath) + /** + * @brief Setter property for SharedTetListArrayPath + */ + void setSharedTetListArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SharedTetListArrayPath + * @return Value of SharedTetListArrayPath + */ + DataArrayPath getSharedTetListArrayPath() const; + Q_PROPERTY(DataArrayPath SharedTetListArrayPath READ getSharedTetListArrayPath WRITE setSharedTetListArrayPath) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedHexListArrayPath) + /** + * @brief Setter property for SharedHexListArrayPath + */ + void setSharedHexListArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SharedHexListArrayPath + * @return Value of SharedHexListArrayPath + */ + DataArrayPath getSharedHexListArrayPath() const; + Q_PROPERTY(DataArrayPath SharedHexListArrayPath READ getSharedHexListArrayPath WRITE setSharedHexListArrayPath) - SIMPL_FILTER_PARAMETER(DataArrayPath, XBoundsArrayPath) + /** + * @brief Setter property for XBoundsArrayPath + */ + void setXBoundsArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for XBoundsArrayPath + * @return Value of XBoundsArrayPath + */ + DataArrayPath getXBoundsArrayPath() const; + Q_PROPERTY(DataArrayPath XBoundsArrayPath READ getXBoundsArrayPath WRITE setXBoundsArrayPath) - SIMPL_FILTER_PARAMETER(DataArrayPath, YBoundsArrayPath) + /** + * @brief Setter property for YBoundsArrayPath + */ + void setYBoundsArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for YBoundsArrayPath + * @return Value of YBoundsArrayPath + */ + DataArrayPath getYBoundsArrayPath() const; + Q_PROPERTY(DataArrayPath YBoundsArrayPath READ getYBoundsArrayPath WRITE setYBoundsArrayPath) - SIMPL_FILTER_PARAMETER(DataArrayPath, ZBoundsArrayPath) + /** + * @brief Setter property for ZBoundsArrayPath + */ + void setZBoundsArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for ZBoundsArrayPath + * @return Value of ZBoundsArrayPath + */ + DataArrayPath getZBoundsArrayPath() const; + Q_PROPERTY(DataArrayPath ZBoundsArrayPath READ getZBoundsArrayPath WRITE setZBoundsArrayPath) - SIMPL_FILTER_PARAMETER(IntVec3_t, Dimensions) - Q_PROPERTY(IntVec3_t Dimensions READ getDimensions WRITE setDimensions) + /** + * @brief Setter property for Dimensions + */ + void setDimensions(const IntVec3Type& value); + /** + * @brief Getter property for Dimensions + * @return Value of Dimensions + */ + IntVec3Type getDimensions() const; + + Q_PROPERTY(IntVec3Type Dimensions READ getDimensions WRITE setDimensions) - SIMPL_FILTER_PARAMETER(FloatVec3_t, Origin) - Q_PROPERTY(FloatVec3_t Origin READ getOrigin WRITE setOrigin) + /** + * @brief Setter property for Origin + */ + void setOrigin(const FloatVec3Type& value); + /** + * @brief Getter property for Origin + * @return Value of Origin + */ + FloatVec3Type getOrigin() const; + + Q_PROPERTY(FloatVec3Type Origin READ getOrigin WRITE setOrigin) - SIMPL_FILTER_PARAMETER(FloatVec3_t, Resolution) - Q_PROPERTY(FloatVec3_t Resolution READ getResolution WRITE setResolution) + /** + * @brief Setter property for Spacing + */ + void setSpacing(const FloatVec3Type& value); + /** + * @brief Getter property for Spacing + * @return Value of Spacing + */ + FloatVec3Type getSpacing() const; + + Q_PROPERTY(FloatVec3Type Spacing READ getSpacing WRITE setSpacing) + + /** + * @brief Setter property for ImageCellAttributeMatrixName + */ + void setImageCellAttributeMatrixName(const QString& value); + /** + * @brief Getter property for ImageCellAttributeMatrixName + * @return Value of ImageCellAttributeMatrixName + */ + QString getImageCellAttributeMatrixName() const; - SIMPL_FILTER_PARAMETER(QString, ImageCellAttributeMatrixName) Q_PROPERTY(QString ImageCellAttributeMatrixName READ getImageCellAttributeMatrixName WRITE setImageCellAttributeMatrixName) - SIMPL_FILTER_PARAMETER(QString, RectGridCellAttributeMatrixName) + /** + * @brief Setter property for RectGridCellAttributeMatrixName + */ + void setRectGridCellAttributeMatrixName(const QString& value); + /** + * @brief Getter property for RectGridCellAttributeMatrixName + * @return Value of RectGridCellAttributeMatrixName + */ + QString getRectGridCellAttributeMatrixName() const; + Q_PROPERTY(QString RectGridCellAttributeMatrixName READ getRectGridCellAttributeMatrixName WRITE setRectGridCellAttributeMatrixName) - SIMPL_FILTER_PARAMETER(QString, VertexAttributeMatrixName0) + /** + * @brief Setter property for VertexAttributeMatrixName0 + */ + void setVertexAttributeMatrixName0(const QString& value); + /** + * @brief Getter property for VertexAttributeMatrixName0 + * @return Value of VertexAttributeMatrixName0 + */ + QString getVertexAttributeMatrixName0() const; + Q_PROPERTY(QString VertexAttributeMatrixName0 READ getVertexAttributeMatrixName0 WRITE setVertexAttributeMatrixName0) - SIMPL_FILTER_PARAMETER(QString, VertexAttributeMatrixName1) + /** + * @brief Setter property for VertexAttributeMatrixName1 + */ + void setVertexAttributeMatrixName1(const QString& value); + /** + * @brief Getter property for VertexAttributeMatrixName1 + * @return Value of VertexAttributeMatrixName1 + */ + QString getVertexAttributeMatrixName1() const; + Q_PROPERTY(QString VertexAttributeMatrixName1 READ getVertexAttributeMatrixName1 WRITE setVertexAttributeMatrixName1) - SIMPL_FILTER_PARAMETER(QString, VertexAttributeMatrixName2) + /** + * @brief Setter property for VertexAttributeMatrixName2 + */ + void setVertexAttributeMatrixName2(const QString& value); + /** + * @brief Getter property for VertexAttributeMatrixName2 + * @return Value of VertexAttributeMatrixName2 + */ + QString getVertexAttributeMatrixName2() const; + Q_PROPERTY(QString VertexAttributeMatrixName2 READ getVertexAttributeMatrixName2 WRITE setVertexAttributeMatrixName2) - SIMPL_FILTER_PARAMETER(QString, VertexAttributeMatrixName3) + /** + * @brief Setter property for VertexAttributeMatrixName3 + */ + void setVertexAttributeMatrixName3(const QString& value); + /** + * @brief Getter property for VertexAttributeMatrixName3 + * @return Value of VertexAttributeMatrixName3 + */ + QString getVertexAttributeMatrixName3() const; + Q_PROPERTY(QString VertexAttributeMatrixName3 READ getVertexAttributeMatrixName3 WRITE setVertexAttributeMatrixName3) - SIMPL_FILTER_PARAMETER(QString, VertexAttributeMatrixName4) + /** + * @brief Setter property for VertexAttributeMatrixName4 + */ + void setVertexAttributeMatrixName4(const QString& value); + /** + * @brief Getter property for VertexAttributeMatrixName4 + * @return Value of VertexAttributeMatrixName4 + */ + QString getVertexAttributeMatrixName4() const; + Q_PROPERTY(QString VertexAttributeMatrixName4 READ getVertexAttributeMatrixName4 WRITE setVertexAttributeMatrixName4) - SIMPL_FILTER_PARAMETER(QString, VertexAttributeMatrixName5) + /** + * @brief Setter property for VertexAttributeMatrixName5 + */ + void setVertexAttributeMatrixName5(const QString& value); + /** + * @brief Getter property for VertexAttributeMatrixName5 + * @return Value of VertexAttributeMatrixName5 + */ + QString getVertexAttributeMatrixName5() const; + Q_PROPERTY(QString VertexAttributeMatrixName5 READ getVertexAttributeMatrixName5 WRITE setVertexAttributeMatrixName5) - SIMPL_FILTER_PARAMETER(QString, EdgeAttributeMatrixName) + /** + * @brief Setter property for EdgeAttributeMatrixName + */ + void setEdgeAttributeMatrixName(const QString& value); + /** + * @brief Getter property for EdgeAttributeMatrixName + * @return Value of EdgeAttributeMatrixName + */ + QString getEdgeAttributeMatrixName() const; + Q_PROPERTY(QString EdgeAttributeMatrixName READ getEdgeAttributeMatrixName WRITE setEdgeAttributeMatrixName) - SIMPL_FILTER_PARAMETER(QString, FaceAttributeMatrixName0) + /** + * @brief Setter property for FaceAttributeMatrixName0 + */ + void setFaceAttributeMatrixName0(const QString& value); + /** + * @brief Getter property for FaceAttributeMatrixName0 + * @return Value of FaceAttributeMatrixName0 + */ + QString getFaceAttributeMatrixName0() const; + Q_PROPERTY(QString FaceAttributeMatrixName0 READ getFaceAttributeMatrixName0 WRITE setFaceAttributeMatrixName0) - SIMPL_FILTER_PARAMETER(QString, FaceAttributeMatrixName1) + /** + * @brief Setter property for FaceAttributeMatrixName1 + */ + void setFaceAttributeMatrixName1(const QString& value); + /** + * @brief Getter property for FaceAttributeMatrixName1 + * @return Value of FaceAttributeMatrixName1 + */ + QString getFaceAttributeMatrixName1() const; + Q_PROPERTY(QString FaceAttributeMatrixName1 READ getFaceAttributeMatrixName1 WRITE setFaceAttributeMatrixName1) - SIMPL_FILTER_PARAMETER(QString, TetCellAttributeMatrixName) + /** + * @brief Setter property for TetCellAttributeMatrixName + */ + void setTetCellAttributeMatrixName(const QString& value); + /** + * @brief Getter property for TetCellAttributeMatrixName + * @return Value of TetCellAttributeMatrixName + */ + QString getTetCellAttributeMatrixName() const; + Q_PROPERTY(QString TetCellAttributeMatrixName READ getTetCellAttributeMatrixName WRITE setTetCellAttributeMatrixName) - SIMPL_FILTER_PARAMETER(QString, HexCellAttributeMatrixName) + /** + * @brief Setter property for HexCellAttributeMatrixName + */ + void setHexCellAttributeMatrixName(const QString& value); + /** + * @brief Getter property for HexCellAttributeMatrixName + * @return Value of HexCellAttributeMatrixName + */ + QString getHexCellAttributeMatrixName() const; + Q_PROPERTY(QString HexCellAttributeMatrixName READ getHexCellAttributeMatrixName WRITE setHexCellAttributeMatrixName) - SIMPL_FILTER_PARAMETER(bool, TreatWarningsAsErrors) + /** + * @brief Setter property for TreatWarningsAsErrors + */ + void setTreatWarningsAsErrors(bool value); + /** + * @brief Getter property for TreatWarningsAsErrors + * @return Value of TreatWarningsAsErrors + */ + bool getTreatWarningsAsErrors() const; + Q_PROPERTY(bool TreatWarningsAsErrors READ getTreatWarningsAsErrors WRITE setTreatWarningsAsErrors) - SIMPL_FILTER_PARAMETER(bool, ArrayHandling) + /** + * @brief Setter property for ArrayHandling + */ + void setArrayHandling(bool value); + /** + * @brief Getter property for ArrayHandling + * @return Value of ArrayHandling + */ + bool getArrayHandling() const; + Q_PROPERTY(bool ArrayHandling READ getArrayHandling WRITE setArrayHandling) QString getBoxDimensions(); @@ -195,21 +533,21 @@ class SIMPLib_EXPORT CreateGeometry : public AbstractFilter /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class */ - const QString getCompiledLibraryName() const override; + QString getCompiledLibraryName() const override; /** * @brief getBrandingString Returns the branding string for the filter, which is a tag * used to denote the filter's association with specific plugins * @return Branding string */ - const QString getBrandingString() const override; + QString getBrandingString() const override; /** * @brief getFilterVersion Returns a version string for this filter. Default * value is an empty string. * @return */ - const QString getFilterVersion() const override; + QString getFilterVersion() const override; /** * @brief newFilterInstance Reimplemented from @see AbstractFilter class @@ -219,23 +557,23 @@ class SIMPLib_EXPORT CreateGeometry : public AbstractFilter /** * @brief getGroupName Reimplemented from @see AbstractFilter class */ - const QString getGroupName() const override; + QString getGroupName() const override; /** * @brief getSubGroupName Reimplemented from @see AbstractFilter class */ - const QString getSubGroupName() const override; + QString getSubGroupName() const override; /** * @brief getUuid Return the unique identifier for this filter. * @return A QUuid object. */ - const QUuid getUuid() override; + QUuid getUuid() const override; /** * @brief getHumanLabel Reimplemented from @see AbstractFilter class */ - const QString getHumanLabel() const override; + QString getHumanLabel() const override; /** * @brief setupFilterParameters Reimplemented from @see AbstractFilter class @@ -247,40 +585,12 @@ class SIMPLib_EXPORT CreateGeometry : public AbstractFilter */ void execute() override; - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - -signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - protected: CreateGeometry(); /** * @brief dataCheck Checks for the appropriate parameter values and availability of arrays */ - void dataCheck(); + void dataCheck() override; /** * @brief Initializes all the private instance variables. @@ -288,16 +598,59 @@ class SIMPLib_EXPORT CreateGeometry : public AbstractFilter void initialize(); private: - DEFINE_DATAARRAY_VARIABLE(float, XBounds) - DEFINE_DATAARRAY_VARIABLE(float, YBounds) - DEFINE_DATAARRAY_VARIABLE(float, ZBounds) - DEFINE_DATAARRAY_VARIABLE(int64_t, Edges) - DEFINE_DATAARRAY_VARIABLE(int64_t, Tris) - DEFINE_DATAARRAY_VARIABLE(int64_t, Quads) - DEFINE_DATAARRAY_VARIABLE(int64_t, Tets) - DEFINE_DATAARRAY_VARIABLE(int64_t, Hexes) - - int64_t m_NumVerts; + std::weak_ptr> m_XBoundsPtr; + float* m_XBounds = nullptr; + std::weak_ptr> m_YBoundsPtr; + float* m_YBounds = nullptr; + std::weak_ptr> m_ZBoundsPtr; + float* m_ZBounds = nullptr; + std::weak_ptr> m_EdgesPtr; + size_t* m_Edges = nullptr; + std::weak_ptr> m_TrisPtr; + size_t* m_Tris = nullptr; + std::weak_ptr> m_QuadsPtr; + size_t* m_Quads = nullptr; + std::weak_ptr> m_TetsPtr; + size_t* m_Tets = nullptr; + std::weak_ptr> m_HexesPtr; + size_t* m_Hexes = nullptr; + + int m_GeometryType = {0}; + DataArrayPath m_DataContainerName = {"", "", ""}; + DataArrayPath m_SharedVertexListArrayPath0 = {"", "", ""}; + DataArrayPath m_SharedVertexListArrayPath1 = {"", "", ""}; + DataArrayPath m_SharedVertexListArrayPath2 = {"", "", ""}; + DataArrayPath m_SharedVertexListArrayPath3 = {"", "", ""}; + DataArrayPath m_SharedVertexListArrayPath4 = {"", "", ""}; + DataArrayPath m_SharedVertexListArrayPath5 = {"", "", ""}; + DataArrayPath m_SharedEdgeListArrayPath = {"", "", ""}; + DataArrayPath m_SharedTriListArrayPath = {"", "", ""}; + DataArrayPath m_SharedQuadListArrayPath = {"", "", ""}; + DataArrayPath m_SharedTetListArrayPath = {"", "", ""}; + DataArrayPath m_SharedHexListArrayPath = {"", "", ""}; + DataArrayPath m_XBoundsArrayPath = {"", "", ""}; + DataArrayPath m_YBoundsArrayPath = {"", "", ""}; + DataArrayPath m_ZBoundsArrayPath = {"", "", ""}; + IntVec3Type m_Dimensions = {0, 0, 0}; + FloatVec3Type m_Origin = {0.0f, 0.0f, 0.0f}; + FloatVec3Type m_Spacing = {1.0f, 1.0f, 1.0f}; + QString m_ImageCellAttributeMatrixName = {SIMPL::Defaults::CellAttributeMatrixName}; + QString m_RectGridCellAttributeMatrixName = {SIMPL::Defaults::CellAttributeMatrixName}; + QString m_VertexAttributeMatrixName0 = {SIMPL::Defaults::VertexAttributeMatrixName}; + QString m_VertexAttributeMatrixName1 = {SIMPL::Defaults::VertexAttributeMatrixName}; + QString m_VertexAttributeMatrixName2 = {SIMPL::Defaults::VertexAttributeMatrixName}; + QString m_VertexAttributeMatrixName3 = {SIMPL::Defaults::VertexAttributeMatrixName}; + QString m_VertexAttributeMatrixName4 = {SIMPL::Defaults::VertexAttributeMatrixName}; + QString m_VertexAttributeMatrixName5 = {SIMPL::Defaults::VertexAttributeMatrixName}; + QString m_EdgeAttributeMatrixName = {SIMPL::Defaults::EdgeAttributeMatrixName}; + QString m_FaceAttributeMatrixName0 = {SIMPL::Defaults::FaceAttributeMatrixName}; + QString m_FaceAttributeMatrixName1 = {SIMPL::Defaults::FaceAttributeMatrixName}; + QString m_TetCellAttributeMatrixName = {SIMPL::Defaults::CellAttributeMatrixName}; + QString m_HexCellAttributeMatrixName = {SIMPL::Defaults::CellAttributeMatrixName}; + bool m_TreatWarningsAsErrors = {false}; + bool m_ArrayHandling = {false}; + + size_t m_NumVerts = {0}; public: CreateGeometry(const CreateGeometry&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SIMPLib/CoreFilters/CreateGridMontage.cpp b/Source/SIMPLib/CoreFilters/CreateGridMontage.cpp new file mode 100644 index 0000000000..251de94b8e --- /dev/null +++ b/Source/SIMPLib/CoreFilters/CreateGridMontage.cpp @@ -0,0 +1,279 @@ +/* ============================================================================ + * Copyright (c) 2019-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "CreateGridMontage.h" + +#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" +#include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" +#include "SIMPLib/FilterParameters/DataContainerGridSelectionFilterParameter.h" +#include "SIMPLib/FilterParameters/StringFilterParameter.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + DataContainerID = 1 +}; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +CreateGridMontage::CreateGridMontage() + + = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +CreateGridMontage::~CreateGridMontage() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void CreateGridMontage::setupFilterParameters() +{ + FilterParameterVectorType parameters; + parameters.push_back(SIMPL_NEW_DC_GRID_SELECTION_FP("Data Container Grid", GridSelection, FilterParameter::Category::Parameter, CreateGridMontage)); + parameters.push_back(SIMPL_NEW_STRING_FP("Created Montage Name", MontageName, FilterParameter::Category::CreatedArray, CreateGridMontage)); + setFilterParameters(parameters); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void CreateGridMontage::readFilterParameters(AbstractFilterParametersReader* reader, int index) +{ + reader->openFilterGroup(this, index); + reader->closeFilterGroup(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void CreateGridMontage::initialize() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void CreateGridMontage::dataCheck() +{ + clearErrorCode(); + clearWarningCode(); + + getDataContainerArray()->createNonPrereqGridMontage(this, getMontageName(), m_GridSelection.getDimensions(), m_GridSelection.getDataContainerNames()); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void CreateGridMontage::execute() +{ + dataCheck(); + if(getErrorCode() < 0) + { + return; + } + + if(getCancel()) + { + return; + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AbstractFilter::Pointer CreateGridMontage::newFilterInstance(bool copyFilterParameters) const +{ + CreateGridMontage::Pointer filter = CreateGridMontage::New(); + if(copyFilterParameters) + { + copyFilterParameterInstanceVariables(filter.get()); + } + return filter; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString CreateGridMontage::getCompiledLibraryName() const +{ + return Core::CoreBaseName; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString CreateGridMontage::getBrandingString() const +{ + return "SIMPLib Core Filter"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString CreateGridMontage::getFilterVersion() const +{ + QString version; + QTextStream vStream(&version); + vStream << SIMPLib::Version::Major() << "." << SIMPLib::Version::Minor() << "." << SIMPLib::Version::Patch(); + return version; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString CreateGridMontage::getGroupName() const +{ + return SIMPL::FilterGroups::CoreFilters; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString CreateGridMontage::getHumanLabel() const +{ + return "Create Grid Montage"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QUuid CreateGridMontage::getUuid() const +{ + return QUuid("{c5bb92df-c1bb-5e57-a2bf-280303a81935}"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString CreateGridMontage::getSubGroupName() const +{ + return SIMPL::FilterSubGroups::GenerationFilters; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString CreateGridMontage::getMontageName() const +{ + return m_MontageName; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void CreateGridMontage::setMontageName(const QString& value) +{ + m_MontageName = value; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainerGrid CreateGridMontage::getGridSelection() const +{ + return m_GridSelection; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void CreateGridMontage::setGridSelection(const DataContainerGrid& value) +{ + m_GridSelection = value; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QStringList CreateGridMontage::getDataContainerNameList() const +{ + return m_DataContainerNameList; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void CreateGridMontage::setDataContainerNameList(const QStringList& value) +{ + m_DataContainerNameList = value; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString CreateGridMontage::getNameOfClass() const +{ + return QString("CreateGridMontage"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString CreateGridMontage::ClassName() +{ + return QString("CreateGridMontage"); +} + +#if 0 +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +int CreateGridMontage::IsTypeOf(const char* type) +{ + if(!strcmp("CreateGridMontage", type)) + { + return 1; + } + return AbstractFilter::IsTypeOf(type); +} +#endif + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +CreateGridMontage::Pointer CreateGridMontage::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +CreateGridMontage::Pointer CreateGridMontage::New() +{ + Pointer sharedPtr(new(CreateGridMontage)); + return sharedPtr; +} diff --git a/Source/SIMPLib/CoreFilters/CreateGridMontage.h b/Source/SIMPLib/CoreFilters/CreateGridMontage.h new file mode 100644 index 0000000000..2a00fbd70d --- /dev/null +++ b/Source/SIMPLib/CoreFilters/CreateGridMontage.h @@ -0,0 +1,201 @@ +/* ============================================================================ + * Copyright (c) 2019-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/Filtering/AbstractFilter.h" +#include "SIMPLib/Montages/DataContainerGrid.h" + +/** + * @brief The CreateGridMontage class. See [Filter documentation](@ref CreateGridMontage) for details. + */ +class SIMPLib_EXPORT CreateGridMontage : public AbstractFilter +{ + Q_OBJECT + + // clang-format off + PYB11_BEGIN_BINDINGS(CreateGridMontage SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(CreateGridMontage) + PYB11_FILTER_NEW_MACRO(CreateGridMontage) + + PYB11_PROPERTY(QString MontageName READ getMontageName WRITE setMontageName) + PYB11_PROPERTY(DataContainerGrid GridSelection READ getGridSelection WRITE setGridSelection) + PYB11_PROPERTY(QStringList DataContainerNameList READ getDataContainerNameList WRITE setDataContainerNameList) + PYB11_END_BINDINGS() + // clang-format on + +public: + using Self = CreateGridMontage; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + QString getNameOfClass() const override; + static QString ClassName(); + // static int CreateGridMontage::IsTypeOf(const char* type); + + ~CreateGridMontage() override; + + /** + * @brief Getter for the MontageName property + * @return + */ + QString getMontageName() const; + + /** + * @brief Setter for the MontageName property + * @param value + */ + void setMontageName(const QString& value); + + Q_PROPERTY(QString MontageName READ getMontageName WRITE setMontageName) + + /** + * @brief Getter for the GridSelection property. + * @return + */ + DataContainerGrid getGridSelection() const; + + /** + * @brief Setter for the GridSelection property. + * @param value + */ + void setGridSelection(const DataContainerGrid& value); + + Q_PROPERTY(DataContainerGrid GridSelection READ getGridSelection WRITE setGridSelection) + + /** + * @brief Getter for the DataContainerNameList property + * @return + */ + QStringList getDataContainerNameList() const; + + /** + * @brief Setter for the DataContainerNameList property + * @param value + */ + void setDataContainerNameList(const QStringList& value); + + Q_PROPERTY(QStringList DataContainerNameList READ getDataContainerNameList WRITE setDataContainerNameList) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + CreateGridMontage(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + QString m_MontageName = {"Grid Montage"}; + DataContainerGrid m_GridSelection; + QStringList m_DataContainerNameList; + +public: + CreateGridMontage(const CreateGridMontage&) = delete; // Copy Constructor Not Implemented + CreateGridMontage(CreateGridMontage&&) = delete; // Move Constructor Not Implemented + CreateGridMontage& operator=(const CreateGridMontage&) = delete; // Copy Assignment Not Implemented + CreateGridMontage& operator=(CreateGridMontage&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/CoreFilters/CreateImageGeometry.cpp b/Source/SIMPLib/CoreFilters/CreateImageGeometry.cpp index b9e9b5c53d..90faaf4bf2 100644 --- a/Source/SIMPLib/CoreFilters/CreateImageGeometry.cpp +++ b/Source/SIMPLib/CoreFilters/CreateImageGeometry.cpp @@ -1,42 +1,47 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + #include "CreateImageGeometry.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" -#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" #include "SIMPLib/FilterParameters/IntVec3FilterParameter.h" @@ -48,20 +53,18 @@ // // ----------------------------------------------------------------------------- CreateImageGeometry::CreateImageGeometry() -: m_SelectedDataContainer("ImageGeomDataContainer") { - m_Dimensions.x = 0; - m_Dimensions.y = 0; - m_Dimensions.z = 0; + m_Dimensions[0] = 0; + m_Dimensions[1] = 0; + m_Dimensions[2] = 0; - m_Origin.x = 0.0f; - m_Origin.y = 0.0f; - m_Origin.z = 0.0f; - - m_Resolution.x = 1.0f; - m_Resolution.y = 1.0f; - m_Resolution.z = 1.0f; + m_Origin[0] = 0.0f; + m_Origin[1] = 0.0f; + m_Origin[2] = 0.0f; + m_Spacing[0] = 1.0f; + m_Spacing[1] = 1.0f; + m_Spacing[2] = 1.0f; } // ----------------------------------------------------------------------------- @@ -74,18 +77,18 @@ CreateImageGeometry::~CreateImageGeometry() = default; // ----------------------------------------------------------------------------- void CreateImageGeometry::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { DataContainerSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container Destination", SelectedDataContainer, FilterParameter::Parameter, CreateImageGeometry, req)); + parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container Destination", SelectedDataContainer, FilterParameter::Category::Parameter, CreateImageGeometry, req)); } - parameters.push_back(SIMPL_NEW_INT_VEC3_FP("Dimensions", Dimensions, FilterParameter::Parameter, CreateImageGeometry)); - parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Origin", Origin, FilterParameter::Parameter, CreateImageGeometry)); + parameters.push_back(SIMPL_NEW_INT_VEC3_FP("Dimensions", Dimensions, FilterParameter::Category::Parameter, CreateImageGeometry)); + parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Origin", Origin, FilterParameter::Category::Parameter, CreateImageGeometry)); - parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Resolution", Resolution, FilterParameter::Parameter, CreateImageGeometry)); + parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Spacing", Spacing, FilterParameter::Category::Parameter, CreateImageGeometry)); + parameters.back()->setLegacyPropertyName("Resolution"); - PreflightUpdatedValueFilterParameter::Pointer param = - SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP("Box Size in Length Units", BoxDimensions, FilterParameter::Parameter, CreateImageGeometry); + PreflightUpdatedValueFilterParameter::Pointer param = SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP("Box Size in Length Units", BoxDimensions, FilterParameter::Category::Parameter, CreateImageGeometry); param->setReadOnly(true); parameters.push_back(param); @@ -100,8 +103,8 @@ void CreateImageGeometry::readFilterParameters(AbstractFilterParametersReader* r reader->openFilterGroup(this, index); setDimensions(reader->readIntVec3("Dimensions", getDimensions())); setOrigin(reader->readFloatVec3("Origin", getOrigin())); - setResolution(reader->readFloatVec3("Resolution", getResolution())); - setSelectedDataContainer(reader->readString("SelectedDataContainer", getSelectedDataContainer())); + setSpacing(reader->readFloatVec3("Spacing", getSpacing())); + setSelectedDataContainer(reader->readDataArrayPath("SelectedDataContainer", getSelectedDataContainer())); reader->closeFilterGroup(); } @@ -117,62 +120,44 @@ void CreateImageGeometry::initialize() // ----------------------------------------------------------------------------- void CreateImageGeometry::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - if(m_Dimensions.x == 0 || m_Dimensions.y == 0 || m_Dimensions.z == 0) + if(m_Dimensions[0] == 0 || m_Dimensions[1] == 0 || m_Dimensions[2] == 0) { QString ss = QObject::tr("One of the dimensions has a size less than or equal to zero. The minimum size must be postive"); - setErrorCondition(-390); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-390, ss); } if(getSelectedDataContainer().isEmpty()) { QString ss = QObject::tr("The Data Container must have a name"); - setErrorCondition(-391); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-391, ss); return; } DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, getSelectedDataContainer()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } ImageGeom::Pointer image = ImageGeom::CreateGeometry("ImageGeometry"); - image->setDimensions(std::make_tuple(m_Dimensions.x, m_Dimensions.y, m_Dimensions.z)); - image->setResolution(std::make_tuple(m_Resolution.x, m_Resolution.y, m_Resolution.z)); - image->setOrigin(std::make_tuple(m_Origin.x, m_Origin.y, m_Origin.z)); + image->setDimensions(m_Dimensions.convertType()); + image->setSpacing(m_Spacing); + image->setOrigin(m_Origin); m->setGeometry(image); } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void CreateImageGeometry::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void CreateImageGeometry::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - } // ----------------------------------------------------------------------------- @@ -182,15 +167,15 @@ QString CreateImageGeometry::getBoxDimensions() { QString desc; QTextStream ss(&desc); - float halfRes[3] = {m_Resolution.x / 2.0f, m_Resolution.y / 2.0f, m_Resolution.z / 2.0f}; + float halfRes[3] = {m_Spacing[0] / 2.0f, m_Spacing[1] / 2.0f, m_Spacing[2] / 2.0f}; ss << "Extents:\n" - << "X Extent: 0 to " << m_Dimensions.x - 1 << " (dimension: " << m_Dimensions.x << ")\n" - << "Y Extent: 0 to " << m_Dimensions.y - 1 << " (dimension: " << m_Dimensions.y << ")\n" - << "Z Extent: 0 to " << m_Dimensions.z - 1 << " (dimension: " << m_Dimensions.z << ")\n" + << "X Extent: 0 to " << m_Dimensions[0] - 1 << " (dimension: " << m_Dimensions[0] << ")\n" + << "Y Extent: 0 to " << m_Dimensions[1] - 1 << " (dimension: " << m_Dimensions[1] << ")\n" + << "Z Extent: 0 to " << m_Dimensions[2] - 1 << " (dimension: " << m_Dimensions[2] << ")\n" << "Bounds:\n" - << "X Range: " << (m_Origin.x - halfRes[0]) << " to " << (m_Origin.x - halfRes[0] + m_Dimensions.x * m_Resolution.x) << " (delta: " << (m_Dimensions.x * m_Resolution.x) << ")\n" - << "Y Range: " << (m_Origin.y - halfRes[1]) << " to " << (m_Origin.y - halfRes[1] + m_Dimensions.y * m_Resolution.y) << " (delta: " << (m_Dimensions.y * m_Resolution.y) << ")\n" - << "Z Range: " << (m_Origin.z - halfRes[2]) << " to " << (m_Origin.z - halfRes[2] + m_Dimensions.z * m_Resolution.z) << " (delta: " << (m_Dimensions.z * m_Resolution.z) << ")\n"; + << "X Range: " << (m_Origin[0] - halfRes[0]) << " to " << (m_Origin[0] - halfRes[0] + m_Dimensions[0] * m_Spacing[0]) << " (delta: " << (m_Dimensions[0] * m_Spacing[0]) << ")\n" + << "Y Range: " << (m_Origin[1] - halfRes[1]) << " to " << (m_Origin[1] - halfRes[1] + m_Dimensions[1] * m_Spacing[1]) << " (delta: " << (m_Dimensions[1] * m_Spacing[1]) << ")\n" + << "Z Range: " << (m_Origin[2] - halfRes[2]) << " to " << (m_Origin[2] - halfRes[2] + m_Dimensions[2] * m_Spacing[2]) << " (delta: " << (m_Dimensions[2] * m_Spacing[2]) << ")\n"; return desc; } @@ -210,7 +195,7 @@ AbstractFilter::Pointer CreateImageGeometry::newFilterInstance(bool copyFilterPa // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateImageGeometry::getCompiledLibraryName() const +QString CreateImageGeometry::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -218,7 +203,7 @@ const QString CreateImageGeometry::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateImageGeometry::getBrandingString() const +QString CreateImageGeometry::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -226,7 +211,7 @@ const QString CreateImageGeometry::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateImageGeometry::getFilterVersion() const +QString CreateImageGeometry::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -237,7 +222,7 @@ const QString CreateImageGeometry::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateImageGeometry::getGroupName() const +QString CreateImageGeometry::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -245,7 +230,7 @@ const QString CreateImageGeometry::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid CreateImageGeometry::getUuid() +QUuid CreateImageGeometry::getUuid() const { return QUuid("{f2132744-3abb-5d66-9cd9-c9a233b5c4aa}"); } @@ -253,7 +238,7 @@ const QUuid CreateImageGeometry::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateImageGeometry::getSubGroupName() const +QString CreateImageGeometry::getSubGroupName() const { return SIMPL::FilterSubGroups::GenerationFilters; } @@ -261,7 +246,84 @@ const QString CreateImageGeometry::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateImageGeometry::getHumanLabel() const +QString CreateImageGeometry::getHumanLabel() const { return "Create Geometry (Image)"; } + +// ----------------------------------------------------------------------------- +CreateImageGeometry::Pointer CreateImageGeometry::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr CreateImageGeometry::New() +{ + struct make_shared_enabler : public CreateImageGeometry + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString CreateImageGeometry::getNameOfClass() const +{ + return QString("CreateImageGeometry"); +} + +// ----------------------------------------------------------------------------- +QString CreateImageGeometry::ClassName() +{ + return QString("CreateImageGeometry"); +} + +// ----------------------------------------------------------------------------- +void CreateImageGeometry::setSelectedDataContainer(const DataArrayPath& value) +{ + m_SelectedDataContainer = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateImageGeometry::getSelectedDataContainer() const +{ + return m_SelectedDataContainer; +} + +// ----------------------------------------------------------------------------- +void CreateImageGeometry::setDimensions(const IntVec3Type& value) +{ + m_Dimensions = value; +} + +// ----------------------------------------------------------------------------- +IntVec3Type CreateImageGeometry::getDimensions() const +{ + return m_Dimensions; +} + +// ----------------------------------------------------------------------------- +void CreateImageGeometry::setOrigin(const FloatVec3Type& value) +{ + m_Origin = value; +} + +// ----------------------------------------------------------------------------- +FloatVec3Type CreateImageGeometry::getOrigin() const +{ + return m_Origin; +} + +// ----------------------------------------------------------------------------- +void CreateImageGeometry::setSpacing(const FloatVec3Type& value) +{ + m_Spacing = value; +} + +// ----------------------------------------------------------------------------- +FloatVec3Type CreateImageGeometry::getSpacing() const +{ + return m_Spacing; +} diff --git a/Source/SIMPLib/CoreFilters/CreateImageGeometry.h b/Source/SIMPLib/CoreFilters/CreateImageGeometry.h old mode 100755 new mode 100644 index 3fc8aebab2..fced371d53 --- a/Source/SIMPLib/CoreFilters/CreateImageGeometry.h +++ b/Source/SIMPLib/CoreFilters/CreateImageGeometry.h @@ -1,192 +1,225 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" #include "SIMPLib/FilterParameters/IntVec3FilterParameter.h" #include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/SIMPLib.h" /** * @brief The CreateImageGeometry class. See [Filter documentation](@ref adjustvolumeorigin) for details. */ class SIMPLib_EXPORT CreateImageGeometry : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(CreateImageGeometry SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString SelectedDataContainer READ getSelectedDataContainer WRITE setSelectedDataContainer) - PYB11_PROPERTY(IntVec3_t Dimensions READ getDimensions WRITE setDimensions) - PYB11_PROPERTY(FloatVec3_t Origin READ getOrigin WRITE setOrigin) - PYB11_PROPERTY(FloatVec3_t Resolution READ getResolution WRITE setResolution) - - public: - SIMPL_SHARED_POINTERS(CreateImageGeometry) - SIMPL_FILTER_NEW_MACRO(CreateImageGeometry) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(CreateImageGeometry, AbstractFilter) - - ~CreateImageGeometry() override; - - SIMPL_FILTER_PARAMETER(QString, SelectedDataContainer) - Q_PROPERTY(QString SelectedDataContainer READ getSelectedDataContainer WRITE setSelectedDataContainer) - - SIMPL_FILTER_PARAMETER(IntVec3_t, Dimensions) - Q_PROPERTY(IntVec3_t Dimensions READ getDimensions WRITE setDimensions) - - SIMPL_FILTER_PARAMETER(FloatVec3_t, Origin) - Q_PROPERTY(FloatVec3_t Origin READ getOrigin WRITE setOrigin) - - SIMPL_FILTER_PARAMETER(FloatVec3_t, Resolution) - Q_PROPERTY(FloatVec3_t Resolution READ getResolution WRITE setResolution) - - QString getBoxDimensions(); - Q_PROPERTY(QString BoxDimensions READ getBoxDimensions) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - CreateImageGeometry(); - - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - /** - * @brief updateSurfaceMesh Updates the mesh coordinates - */ - void updateSurfaceMesh(); - - public: - CreateImageGeometry(const CreateImageGeometry&) = delete; // Copy Constructor Not Implemented - CreateImageGeometry(CreateImageGeometry&&) = delete; // Move Constructor Not Implemented - CreateImageGeometry& operator=(const CreateImageGeometry&) = delete; // Copy Assignment Not Implemented - CreateImageGeometry& operator=(CreateImageGeometry&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(CreateImageGeometry SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(CreateImageGeometry) + PYB11_FILTER_NEW_MACRO(CreateImageGeometry) + PYB11_PROPERTY(DataArrayPath SelectedDataContainer READ getSelectedDataContainer WRITE setSelectedDataContainer) + PYB11_PROPERTY(IntVec3Type Dimensions READ getDimensions WRITE setDimensions) + PYB11_PROPERTY(FloatVec3Type Origin READ getOrigin WRITE setOrigin) + PYB11_PROPERTY(FloatVec3Type Spacing READ getSpacing WRITE setSpacing) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = CreateImageGeometry; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for CreateImageGeometry + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for CreateImageGeometry + */ + static QString ClassName(); + + ~CreateImageGeometry() override; + + /** + * @brief Setter property for SelectedDataContainer + */ + void setSelectedDataContainer(const DataArrayPath& value); + /** + * @brief Getter property for SelectedDataContainer + * @return Value of SelectedDataContainer + */ + DataArrayPath getSelectedDataContainer() const; + + Q_PROPERTY(DataArrayPath SelectedDataContainer READ getSelectedDataContainer WRITE setSelectedDataContainer) + + /** + * @brief Setter property for Dimensions + */ + void setDimensions(const IntVec3Type& value); + /** + * @brief Getter property for Dimensions + * @return Value of Dimensions + */ + IntVec3Type getDimensions() const; + + Q_PROPERTY(IntVec3Type Dimensions READ getDimensions WRITE setDimensions) + + /** + * @brief Setter property for Origin + */ + void setOrigin(const FloatVec3Type& value); + /** + * @brief Getter property for Origin + * @return Value of Origin + */ + FloatVec3Type getOrigin() const; + + Q_PROPERTY(FloatVec3Type Origin READ getOrigin WRITE setOrigin) + + /** + * @brief Setter property for Spacing + */ + void setSpacing(const FloatVec3Type& value); + /** + * @brief Getter property for Spacing + * @return Value of Spacing + */ + FloatVec3Type getSpacing() const; + + Q_PROPERTY(FloatVec3Type Spacing READ getSpacing WRITE setSpacing) + + QString getBoxDimensions(); + Q_PROPERTY(QString BoxDimensions READ getBoxDimensions) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + CreateImageGeometry(); + + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + + /** + * @brief updateSurfaceMesh Updates the mesh coordinates + */ + void updateSurfaceMesh(); + +public: + CreateImageGeometry(const CreateImageGeometry&) = delete; // Copy Constructor Not Implemented + CreateImageGeometry(CreateImageGeometry&&) = delete; // Move Constructor Not Implemented + CreateImageGeometry& operator=(const CreateImageGeometry&) = delete; // Copy Assignment Not Implemented + CreateImageGeometry& operator=(CreateImageGeometry&&) = delete; // Move Assignment Not Implemented + +private: + DataArrayPath m_SelectedDataContainer = {"ImageGeomDataContainer", "", ""}; + IntVec3Type m_Dimensions = {}; + FloatVec3Type m_Origin = {}; + FloatVec3Type m_Spacing = {}; }; - diff --git a/Source/SIMPLib/CoreFilters/CreateStringArray.cpp b/Source/SIMPLib/CoreFilters/CreateStringArray.cpp index dbeab50795..b2c070e384 100644 --- a/Source/SIMPLib/CoreFilters/CreateStringArray.cpp +++ b/Source/SIMPLib/CoreFilters/CreateStringArray.cpp @@ -1,44 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CreateStringArray.h" -#include +#include +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataArrays/StringDataArray.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/ChoiceFilterParameter.h" #include "SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h" @@ -46,32 +47,29 @@ #include "SIMPLib/FilterParameters/IntFilterParameter.h" #include "SIMPLib/FilterParameters/LinkedChoicesFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + StringArrayID = 1 +}; /** -* @brief initializeArrayWithInts Initializes the array p with integers, either from the -* manual value entered in the filter, or with a random number. This function does not -* check that the template type actually is an integer, so it will most likely cause -* unexpected results when passing anything other than an integer as a template parameter. -* @param p The array that will be initialized -*/ + * @brief initializeArrayWithInts Initializes the array p with integers, either from the + * manual value entered in the filter, or with a random number. This function does not + * check that the template type actually is an integer, so it will most likely cause + * unexpected results when passing anything other than an integer as a template parameter. + * @param p The array that will be initialized + */ void initializeArray(IDataArray::Pointer outputArrayPtr, const QString& initializationValue) { StringDataArray::Pointer array = std::dynamic_pointer_cast(outputArrayPtr); array->initializeWithValue(initializationValue); } - - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -CreateStringArray::CreateStringArray() -: m_NumberOfComponents(0) -, m_NewArray("", "", "") -, m_InitializationValue("Text") -{ -} +CreateStringArray::CreateStringArray() = default; // ----------------------------------------------------------------------------- // @@ -83,15 +81,15 @@ CreateStringArray::~CreateStringArray() = default; // ----------------------------------------------------------------------------- void CreateStringArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; // Do not let the user change the number of components in a StringDataArray setNumberOfComponents(1); - parameters.push_back(SIMPL_NEW_STRING_FP("Initialization Value", InitializationValue, FilterParameter::Parameter, CreateStringArray)); + parameters.push_back(SIMPL_NEW_STRING_FP("Initialization Value", InitializationValue, FilterParameter::Category::Parameter, CreateStringArray)); { DataArrayCreationFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Created Attribute Array", NewArray, FilterParameter::CreatedArray, CreateStringArray, req)); + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Created Attribute Array", NewArray, FilterParameter::Category::CreatedArray, CreateStringArray, req)); } setFilterParameters(parameters); @@ -121,59 +119,42 @@ void CreateStringArray::initialize() // ----------------------------------------------------------------------------- void CreateStringArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } if(getNumberOfComponents() < 0) { - setErrorCondition(-8150); QString ss = QObject::tr("The number of components must non-negative"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-8150, ss); } if(getNumberOfComponents() == 0) { - setErrorCondition(-8151); QString ss = QObject::tr("The number of components is Zero. This will result in an array that has no memory allocated. Are you sure you wanted to do this?"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-8151, ss); } if(!getNewArray().isValid()) { - setErrorCondition(-8152); QString ss = QObject::tr("The Created DataArrayPath is invalid. Please select the Data Container, Attribute Matrix and set an output DataArray name."); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-8152, ss); } - if (m_InitializationValue.isEmpty()) + if(m_InitializationValue.isEmpty()) { QString ss = "Empty initialization value."; - setErrorCondition(-5759); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5759, ss); } - QVector cDims(1, getNumberOfComponents()); - if(getErrorCondition() < 0) + std::vector cDims(1, getNumberOfComponents()); + if(getErrorCode() < 0) { return; } - - // Create the data array and initialize it to a placeholder value - m_OutputArrayPtr = getDataContainerArray()->createNonPrereqArrayFromPath(this, getNewArray(), m_InitializationValue, cDims); -} -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void CreateStringArray::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); + // Create the data array and initialize it to a placeholder value + m_OutputArrayPtr = getDataContainerArray()->createNonPrereqArrayFromPath(this, getNewArray(), m_InitializationValue, cDims, "", StringArrayID); } // ----------------------------------------------------------------------------- @@ -181,10 +162,8 @@ void CreateStringArray::preflight() // ----------------------------------------------------------------------------- void CreateStringArray::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -208,7 +187,7 @@ AbstractFilter::Pointer CreateStringArray::newFilterInstance(bool copyFilterPara // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateStringArray::getCompiledLibraryName() const +QString CreateStringArray::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -216,7 +195,7 @@ const QString CreateStringArray::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateStringArray::getBrandingString() const +QString CreateStringArray::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -224,7 +203,7 @@ const QString CreateStringArray::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateStringArray::getFilterVersion() const +QString CreateStringArray::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -235,7 +214,7 @@ const QString CreateStringArray::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateStringArray::getGroupName() const +QString CreateStringArray::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -243,7 +222,7 @@ const QString CreateStringArray::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid CreateStringArray::getUuid() +QUuid CreateStringArray::getUuid() const { return QUuid("{e6b9a566-c5eb-5e3a-87de-7fe65d1d12b6}"); } @@ -251,7 +230,7 @@ const QUuid CreateStringArray::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateStringArray::getSubGroupName() const +QString CreateStringArray::getSubGroupName() const { return SIMPL::FilterSubGroups::GenerationFilters; } @@ -259,7 +238,72 @@ const QString CreateStringArray::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CreateStringArray::getHumanLabel() const +QString CreateStringArray::getHumanLabel() const { return "Create String Array"; } + +// ----------------------------------------------------------------------------- +CreateStringArray::Pointer CreateStringArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr CreateStringArray::New() +{ + struct make_shared_enabler : public CreateStringArray + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString CreateStringArray::getNameOfClass() const +{ + return QString("CreateStringArray"); +} + +// ----------------------------------------------------------------------------- +QString CreateStringArray::ClassName() +{ + return QString("CreateStringArray"); +} + +// ----------------------------------------------------------------------------- +void CreateStringArray::setNumberOfComponents(int value) +{ + m_NumberOfComponents = value; +} + +// ----------------------------------------------------------------------------- +int CreateStringArray::getNumberOfComponents() const +{ + return m_NumberOfComponents; +} + +// ----------------------------------------------------------------------------- +void CreateStringArray::setNewArray(const DataArrayPath& value) +{ + m_NewArray = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CreateStringArray::getNewArray() const +{ + return m_NewArray; +} + +// ----------------------------------------------------------------------------- +void CreateStringArray::setInitializationValue(const QString& value) +{ + m_InitializationValue = value; +} + +// ----------------------------------------------------------------------------- +QString CreateStringArray::getInitializationValue() const +{ + return m_InitializationValue; +} diff --git a/Source/SIMPLib/CoreFilters/CreateStringArray.h b/Source/SIMPLib/CoreFilters/CreateStringArray.h index 55700ec9ec..1bf81f18e7 100644 --- a/Source/SIMPLib/CoreFilters/CreateStringArray.h +++ b/Source/SIMPLib/CoreFilters/CreateStringArray.h @@ -1,180 +1,203 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/IDataArray.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The CreateStringArray class. See [Filter documentation](@ref CreateStringArray) for details. */ class SIMPLib_EXPORT CreateStringArray : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(CreateStringArray SUPERCLASS AbstractFilter) - PYB11_PROPERTY(int NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) - PYB11_PROPERTY(DataArrayPath NewArray READ getNewArray WRITE setNewArray) - PYB11_PROPERTY(QString InitializationValue READ getInitializationValue WRITE setInitializationValue) - - public: - SIMPL_SHARED_POINTERS(CreateStringArray) - SIMPL_FILTER_NEW_MACRO(CreateStringArray) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(CreateStringArray, AbstractFilter) - - ~CreateStringArray() override; - - SIMPL_FILTER_PARAMETER(int, NumberOfComponents) - Q_PROPERTY(int NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) - - SIMPL_FILTER_PARAMETER(DataArrayPath, NewArray) - Q_PROPERTY(DataArrayPath NewArray READ getNewArray WRITE setNewArray) - - SIMPL_FILTER_PARAMETER(QString, InitializationValue) - Q_PROPERTY(QString InitializationValue READ getInitializationValue WRITE setInitializationValue) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - CreateStringArray(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - IDataArray::WeakPointer m_OutputArrayPtr; - - public: - CreateStringArray(const CreateStringArray&) = delete; // Copy Constructor Not Implemented - CreateStringArray(CreateStringArray&&) = delete; // Move Constructor Not Implemented - CreateStringArray& operator=(const CreateStringArray&) = delete; // Copy Assignment Not Implemented - CreateStringArray& operator=(CreateStringArray&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(CreateStringArray SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(CreateStringArray) + PYB11_FILTER_NEW_MACRO(CreateStringArray) + PYB11_PROPERTY(int NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) + PYB11_PROPERTY(DataArrayPath NewArray READ getNewArray WRITE setNewArray) + PYB11_PROPERTY(QString InitializationValue READ getInitializationValue WRITE setInitializationValue) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = CreateStringArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for CreateStringArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for CreateStringArray + */ + static QString ClassName(); + + ~CreateStringArray() override; + + /** + * @brief Setter property for NumberOfComponents + */ + void setNumberOfComponents(int value); + /** + * @brief Getter property for NumberOfComponents + * @return Value of NumberOfComponents + */ + int getNumberOfComponents() const; + + Q_PROPERTY(int NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) + + /** + * @brief Setter property for NewArray + */ + void setNewArray(const DataArrayPath& value); + /** + * @brief Getter property for NewArray + * @return Value of NewArray + */ + DataArrayPath getNewArray() const; + + Q_PROPERTY(DataArrayPath NewArray READ getNewArray WRITE setNewArray) + + /** + * @brief Setter property for InitializationValue + */ + void setInitializationValue(const QString& value); + /** + * @brief Getter property for InitializationValue + * @return Value of InitializationValue + */ + QString getInitializationValue() const; + + Q_PROPERTY(QString InitializationValue READ getInitializationValue WRITE setInitializationValue) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + CreateStringArray(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + int m_NumberOfComponents = {0}; + DataArrayPath m_NewArray = {"", "", ""}; + QString m_InitializationValue = {"Text"}; + + IDataArray::WeakPointer m_OutputArrayPtr; + +public: + CreateStringArray(const CreateStringArray&) = delete; // Copy Constructor Not Implemented + CreateStringArray(CreateStringArray&&) = delete; // Move Constructor Not Implemented + CreateStringArray& operator=(const CreateStringArray&) = delete; // Copy Assignment Not Implemented + CreateStringArray& operator=(CreateStringArray&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/CropVertexGeometry.cpp b/Source/SIMPLib/CoreFilters/CropVertexGeometry.cpp index 14c9fce899..efcf08a15f 100644 --- a/Source/SIMPLib/CoreFilters/CropVertexGeometry.cpp +++ b/Source/SIMPLib/CoreFilters/CropVertexGeometry.cpp @@ -26,40 +26,39 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - #include "CropVertexGeometry.h" #include +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" +#include "SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h" #include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/FloatFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/Geometry/VertexGeom.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + DataContainerID = 1 +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -CropVertexGeometry::CropVertexGeometry() -: m_DataContainerName(SIMPL::Defaults::VertexDataContainerName) -, m_CroppedDataContainerName("CroppedDataContainer") -, m_XMin(0) -, m_YMin(0) -, m_ZMin(0) -, m_XMax(0) -, m_YMax(0) -, m_ZMax(0) -{ -} +CropVertexGeometry::CropVertexGeometry() = default; // ----------------------------------------------------------------------------- // @@ -71,18 +70,18 @@ CropVertexGeometry::~CropVertexGeometry() = default; // ----------------------------------------------------------------------------- void CropVertexGeometry::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; DataContainerSelectionFilterParameter::RequirementType req; IGeometry::Types reqGeom = {IGeometry::Type::Vertex}; req.dcGeometryTypes = reqGeom; - parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Vertex Geometry to Crop", DataContainerName, FilterParameter::RequiredArray, CropVertexGeometry, req)); - parameters.push_back(SIMPL_NEW_FLOAT_FP("X Min", XMin, FilterParameter::Parameter, CropVertexGeometry)); - parameters.push_back(SIMPL_NEW_FLOAT_FP("Y Min", YMin, FilterParameter::Parameter, CropVertexGeometry)); - parameters.push_back(SIMPL_NEW_FLOAT_FP("Z Min", ZMin, FilterParameter::Parameter, CropVertexGeometry)); - parameters.push_back(SIMPL_NEW_FLOAT_FP("X Max", XMax, FilterParameter::Parameter, CropVertexGeometry)); - parameters.push_back(SIMPL_NEW_FLOAT_FP("Y Max", YMax, FilterParameter::Parameter, CropVertexGeometry)); - parameters.push_back(SIMPL_NEW_FLOAT_FP("Z Max", ZMax, FilterParameter::Parameter, CropVertexGeometry)); - parameters.push_back(SIMPL_NEW_STRING_FP("Cropped Data Container", CroppedDataContainerName, FilterParameter::CreatedArray, CropVertexGeometry)); + parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Vertex Geometry to Crop", DataContainerName, FilterParameter::Category::RequiredArray, CropVertexGeometry, req)); + parameters.push_back(SIMPL_NEW_FLOAT_FP("X Min", XMin, FilterParameter::Category::Parameter, CropVertexGeometry)); + parameters.push_back(SIMPL_NEW_FLOAT_FP("Y Min", YMin, FilterParameter::Category::Parameter, CropVertexGeometry)); + parameters.push_back(SIMPL_NEW_FLOAT_FP("Z Min", ZMin, FilterParameter::Category::Parameter, CropVertexGeometry)); + parameters.push_back(SIMPL_NEW_FLOAT_FP("X Max", XMax, FilterParameter::Category::Parameter, CropVertexGeometry)); + parameters.push_back(SIMPL_NEW_FLOAT_FP("Y Max", YMax, FilterParameter::Category::Parameter, CropVertexGeometry)); + parameters.push_back(SIMPL_NEW_FLOAT_FP("Z Max", ZMax, FilterParameter::Category::Parameter, CropVertexGeometry)); + parameters.push_back(SIMPL_NEW_DC_CREATION_FP("Cropped Data Container", CroppedDataContainerName, FilterParameter::Category::CreatedArray, CropVertexGeometry)); setFilterParameters(parameters); } @@ -92,14 +91,14 @@ void CropVertexGeometry::setupFilterParameters() void CropVertexGeometry::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); - setDataContainerName(reader->readString("DataContainerName", getDataContainerName())); + setDataContainerName(reader->readDataArrayPath("DataContainerName", getDataContainerName())); setXMin(reader->readValue("XMin", getXMin())); setYMin(reader->readValue("YMin", getYMin())); setZMin(reader->readValue("ZMin", getZMin())); setXMax(reader->readValue("XMax", getXMax())); setYMax(reader->readValue("YMax", getYMax())); setZMax(reader->readValue("ZMax", getZMax())); - setCroppedDataContainerName(reader->readString("CroppedDataContainerName", getCroppedDataContainerName())); + setCroppedDataContainerName(reader->readDataArrayPath("CroppedDataContainerName", getCroppedDataContainerName())); reader->closeFilterGroup(); } @@ -108,8 +107,8 @@ void CropVertexGeometry::readFilterParameters(AbstractFilterParametersReader* re // ----------------------------------------------------------------------------- void CropVertexGeometry::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); m_AttrMatList.clear(); } @@ -119,34 +118,31 @@ void CropVertexGeometry::initialize() // ----------------------------------------------------------------------------- void CropVertexGeometry::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); initialize(); - getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getDataContainerName()); + getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getDataContainerName()); if(getXMax() < getXMin()) { QString ss = QObject::tr("X Max (%1) less than X Min (%2)").arg(getXMax()).arg(getXMin()); - setErrorCondition(-5550); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5550, ss); } if(getYMax() < getYMin()) { QString ss = QObject::tr("Y Max (%1) less than Y Min (%2)").arg(getYMax()).arg(getYMin()); - setErrorCondition(-5550); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5550, ss); } if(getZMax() < getZMin()) { QString ss = QObject::tr("Z Max (%1) less than Z Min (%2)").arg(getZMax()).arg(getZMin()); - setErrorCondition(-5550); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5550, ss); } - DataContainer::Pointer dc = getDataContainerArray()->createNonPrereqDataContainer(this, getCroppedDataContainerName()); + DataContainer::Pointer dc = getDataContainerArray()->createNonPrereqDataContainer(this, getCroppedDataContainerName(), DataContainerID); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -156,12 +152,12 @@ void CropVertexGeometry::dataCheck() DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getDataContainerName()); m_AttrMatList = m->getAttributeMatrixNames(); - QVector tDims(1, 0); + std::vector tDims(1, 0); QList tempDataArrayList; DataArrayPath tempPath; AttributeMatrix::Type tempAttrMatType = AttributeMatrix::Type::Vertex; - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -169,13 +165,13 @@ void CropVertexGeometry::dataCheck() for(auto&& attr_mat : m_AttrMatList) { AttributeMatrix::Pointer tmpAttrMat = m->getPrereqAttributeMatrix(this, attr_mat, -301); - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { tempAttrMatType = tmpAttrMat->getType(); if(tempAttrMatType != AttributeMatrix::Type::Vertex) { AttributeMatrix::Pointer attrMat = tmpAttrMat->deepCopy(getInPreflight()); - dc->addAttributeMatrix(attr_mat, attrMat); + dc->addOrReplaceAttributeMatrix(attrMat); } else { @@ -183,11 +179,11 @@ void CropVertexGeometry::dataCheck() tempDataArrayList = tmpAttrMat->getAttributeArrayNames(); for(auto&& data_array : tempDataArrayList) { - tempPath.update(getCroppedDataContainerName(), tmpAttrMat->getName(), data_array); - IDataArray::Pointer tmpDataArray = tmpAttrMat->getPrereqIDataArray(this, data_array, -90002); - if(getErrorCondition() >= 0) + tempPath.update(getCroppedDataContainerName().getDataContainerName(), tmpAttrMat->getName(), data_array); + IDataArray::Pointer tmpDataArray = tmpAttrMat->getPrereqIDataArray(this, data_array, -90002); + if(getErrorCode() >= 0) { - QVector cDims = tmpDataArray->getComponentDimensions(); + std::vector cDims = tmpDataArray->getComponentDimensions(); TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, tmpDataArray); } } @@ -199,21 +195,8 @@ void CropVertexGeometry::dataCheck() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void CropVertexGeometry::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -template void copyDataToCroppedGeometry(IDataArray::Pointer inDataPtr, IDataArray::Pointer outDataPtr, std::vector& croppedPoints) +template +void copyDataToCroppedGeometry(IDataArray::Pointer inDataPtr, IDataArray::Pointer outDataPtr, std::vector& croppedPoints) { typename DataArray::Pointer inputDataPtr = std::dynamic_pointer_cast>(inDataPtr); T* inputData = static_cast(inputDataPtr->getPointer(0)); @@ -240,10 +223,8 @@ template void copyDataToCroppedGeometry(IDataArray::Pointer inDataP // ----------------------------------------------------------------------------- void CropVertexGeometry::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -285,12 +266,12 @@ void CropVertexGeometry::execute() crop->setCoords(i, coords); } - QVector tDims(1, croppedPoints.size()); + std::vector tDims(1, croppedPoints.size()); for(auto&& attr_mat : m_AttrMatList) { AttributeMatrix::Pointer tmpAttrMat = dc->getPrereqAttributeMatrix(this, attr_mat, -301); - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { AttributeMatrix::Type tempAttrMatType = tmpAttrMat->getType(); if(tempAttrMatType == AttributeMatrix::Type::Vertex) @@ -314,7 +295,6 @@ void CropVertexGeometry::execute() } } } - } // ----------------------------------------------------------------------------- @@ -333,7 +313,7 @@ AbstractFilter::Pointer CropVertexGeometry::newFilterInstance(bool copyFilterPar // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CropVertexGeometry::getCompiledLibraryName() const +QString CropVertexGeometry::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -341,7 +321,7 @@ const QString CropVertexGeometry::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CropVertexGeometry::getBrandingString() const +QString CropVertexGeometry::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -349,7 +329,7 @@ const QString CropVertexGeometry::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CropVertexGeometry::getFilterVersion() const +QString CropVertexGeometry::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -360,7 +340,7 @@ const QString CropVertexGeometry::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CropVertexGeometry::getGroupName() const +QString CropVertexGeometry::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -368,7 +348,7 @@ const QString CropVertexGeometry::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid CropVertexGeometry::getUuid() +QUuid CropVertexGeometry::getUuid() const { return QUuid("{f28cbf07-f15a-53ca-8c7f-b41a11dae6cc}"); } @@ -376,7 +356,7 @@ const QUuid CropVertexGeometry::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CropVertexGeometry::getSubGroupName() const +QString CropVertexGeometry::getSubGroupName() const { return SIMPL::FilterSubGroups::CropCutFilters; } @@ -384,7 +364,132 @@ const QString CropVertexGeometry::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString CropVertexGeometry::getHumanLabel() const +QString CropVertexGeometry::getHumanLabel() const { return "Crop Geometry (Vertex)"; } + +// ----------------------------------------------------------------------------- +CropVertexGeometry::Pointer CropVertexGeometry::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr CropVertexGeometry::New() +{ + struct make_shared_enabler : public CropVertexGeometry + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString CropVertexGeometry::getNameOfClass() const +{ + return QString("CropVertexGeometry"); +} + +// ----------------------------------------------------------------------------- +QString CropVertexGeometry::ClassName() +{ + return QString("CropVertexGeometry"); +} + +// ----------------------------------------------------------------------------- +void CropVertexGeometry::setDataContainerName(const DataArrayPath& value) +{ + m_DataContainerName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CropVertexGeometry::getDataContainerName() const +{ + return m_DataContainerName; +} + +// ----------------------------------------------------------------------------- +void CropVertexGeometry::setCroppedDataContainerName(const DataArrayPath& value) +{ + m_CroppedDataContainerName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath CropVertexGeometry::getCroppedDataContainerName() const +{ + return m_CroppedDataContainerName; +} + +// ----------------------------------------------------------------------------- +void CropVertexGeometry::setXMin(float value) +{ + m_XMin = value; +} + +// ----------------------------------------------------------------------------- +float CropVertexGeometry::getXMin() const +{ + return m_XMin; +} + +// ----------------------------------------------------------------------------- +void CropVertexGeometry::setYMin(float value) +{ + m_YMin = value; +} + +// ----------------------------------------------------------------------------- +float CropVertexGeometry::getYMin() const +{ + return m_YMin; +} + +// ----------------------------------------------------------------------------- +void CropVertexGeometry::setZMin(float value) +{ + m_ZMin = value; +} + +// ----------------------------------------------------------------------------- +float CropVertexGeometry::getZMin() const +{ + return m_ZMin; +} + +// ----------------------------------------------------------------------------- +void CropVertexGeometry::setXMax(float value) +{ + m_XMax = value; +} + +// ----------------------------------------------------------------------------- +float CropVertexGeometry::getXMax() const +{ + return m_XMax; +} + +// ----------------------------------------------------------------------------- +void CropVertexGeometry::setYMax(float value) +{ + m_YMax = value; +} + +// ----------------------------------------------------------------------------- +float CropVertexGeometry::getYMax() const +{ + return m_YMax; +} + +// ----------------------------------------------------------------------------- +void CropVertexGeometry::setZMax(float value) +{ + m_ZMax = value; +} + +// ----------------------------------------------------------------------------- +float CropVertexGeometry::getZMax() const +{ + return m_ZMax; +} diff --git a/Source/SIMPLib/CoreFilters/CropVertexGeometry.h b/Source/SIMPLib/CoreFilters/CropVertexGeometry.h index aa190086fd..4ab8d9e375 100644 --- a/Source/SIMPLib/CoreFilters/CropVertexGeometry.h +++ b/Source/SIMPLib/CoreFilters/CropVertexGeometry.h @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,9 +35,11 @@ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The CropVertexGeometry class. See [Filter documentation](@ref cropvertexgeometry) for details. @@ -45,65 +47,167 @@ class SIMPLib_EXPORT CropVertexGeometry : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(CropVertexGeometry SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) - PYB11_PROPERTY(QString CroppedDataContainerName READ getCroppedDataContainerName WRITE setCroppedDataContainerName) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(CropVertexGeometry SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(CropVertexGeometry) + PYB11_FILTER_NEW_MACRO(CropVertexGeometry) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_PROPERTY(DataArrayPath CroppedDataContainerName READ getCroppedDataContainerName WRITE setCroppedDataContainerName) PYB11_PROPERTY(float XMin READ getXMin WRITE setXMin) PYB11_PROPERTY(float YMin READ getYMin WRITE setYMin) PYB11_PROPERTY(float ZMin READ getZMin WRITE setZMin) PYB11_PROPERTY(float XMax READ getXMax WRITE setXMax) PYB11_PROPERTY(float YMax READ getYMax WRITE setYMax) PYB11_PROPERTY(float ZMax READ getZMax WRITE setZMax) + PYB11_END_BINDINGS() + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(CropVertexGeometry) - SIMPL_FILTER_NEW_MACRO(CropVertexGeometry) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(CropVertexGeometry, AbstractFilter) + using Self = CropVertexGeometry; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for CropVertexGeometry + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for CropVertexGeometry + */ + static QString ClassName(); ~CropVertexGeometry() override; - SIMPL_FILTER_PARAMETER(QString, DataContainerName) - Q_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + /** + * @brief Setter property for DataContainerName + */ + void setDataContainerName(const DataArrayPath& value); + /** + * @brief Getter property for DataContainerName + * @return Value of DataContainerName + */ + DataArrayPath getDataContainerName() const; + + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + + /** + * @brief Setter property for CroppedDataContainerName + */ + void setCroppedDataContainerName(const DataArrayPath& value); + /** + * @brief Getter property for CroppedDataContainerName + * @return Value of CroppedDataContainerName + */ + DataArrayPath getCroppedDataContainerName() const; + + Q_PROPERTY(DataArrayPath CroppedDataContainerName READ getCroppedDataContainerName WRITE setCroppedDataContainerName) - SIMPL_FILTER_PARAMETER(QString, CroppedDataContainerName) - Q_PROPERTY(QString CroppedDataContainerName READ getCroppedDataContainerName WRITE setCroppedDataContainerName) + /** + * @brief Setter property for XMin + */ + void setXMin(float value); + /** + * @brief Getter property for XMin + * @return Value of XMin + */ + float getXMin() const; - SIMPL_FILTER_PARAMETER(float, XMin) Q_PROPERTY(float XMin READ getXMin WRITE setXMin) - SIMPL_FILTER_PARAMETER(float, YMin) + /** + * @brief Setter property for YMin + */ + void setYMin(float value); + /** + * @brief Getter property for YMin + * @return Value of YMin + */ + float getYMin() const; + Q_PROPERTY(float YMin READ getYMin WRITE setYMin) - SIMPL_FILTER_PARAMETER(float, ZMin) + /** + * @brief Setter property for ZMin + */ + void setZMin(float value); + /** + * @brief Getter property for ZMin + * @return Value of ZMin + */ + float getZMin() const; + Q_PROPERTY(float ZMin READ getZMin WRITE setZMin) - SIMPL_FILTER_PARAMETER(float, XMax) + /** + * @brief Setter property for XMax + */ + void setXMax(float value); + /** + * @brief Getter property for XMax + * @return Value of XMax + */ + float getXMax() const; + Q_PROPERTY(float XMax READ getXMax WRITE setXMax) - SIMPL_FILTER_PARAMETER(float, YMax) + /** + * @brief Setter property for YMax + */ + void setYMax(float value); + /** + * @brief Getter property for YMax + * @return Value of YMax + */ + float getYMax() const; + Q_PROPERTY(float YMax READ getYMax WRITE setYMax) - SIMPL_FILTER_PARAMETER(float, ZMax) + /** + * @brief Setter property for ZMax + */ + void setZMax(float value); + /** + * @brief Getter property for ZMax + * @return Value of ZMax + */ + float getZMax() const; + Q_PROPERTY(float ZMax READ getZMax WRITE setZMax) /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class */ - const QString getCompiledLibraryName() const override; + QString getCompiledLibraryName() const override; /** * @brief getBrandingString Returns the branding string for the filter, which is a tag * used to denote the filter's association with specific plugins * @return Branding string */ - const QString getBrandingString() const override; + QString getBrandingString() const override; /** * @brief getFilterVersion Returns a version string for this filter. Default * value is an empty string. * @return */ - const QString getFilterVersion() const override; + QString getFilterVersion() const override; /** * @brief newFilterInstance Reimplemented from @see AbstractFilter class @@ -113,23 +217,23 @@ class SIMPLib_EXPORT CropVertexGeometry : public AbstractFilter /** * @brief getGroupName Reimplemented from @see AbstractFilter class */ - const QString getGroupName() const override; + QString getGroupName() const override; /** * @brief getSubGroupName Reimplemented from @see AbstractFilter class */ - const QString getSubGroupName() const override; + QString getSubGroupName() const override; /** * @brief getUuid Return the unique identifier for this filter. * @return A QUuid object. */ - const QUuid getUuid() override; + QUuid getUuid() const override; /** * @brief getHumanLabel Reimplemented from @see AbstractFilter class */ - const QString getHumanLabel() const override; + QString getHumanLabel() const override; /** * @brief setupFilterParameters Reimplemented from @see AbstractFilter class @@ -146,40 +250,12 @@ class SIMPLib_EXPORT CropVertexGeometry : public AbstractFilter */ void execute() override; - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - -signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - protected: CropVertexGeometry(); /** * @brief dataCheck Checks for the appropriate parameter values and availability of arrays */ - void dataCheck(); + void dataCheck() override; /** * @brief Initializes all the private instance variables. @@ -187,6 +263,15 @@ class SIMPLib_EXPORT CropVertexGeometry : public AbstractFilter void initialize(); private: + DataArrayPath m_DataContainerName = {SIMPL::Defaults::VertexDataContainerName, "", ""}; + DataArrayPath m_CroppedDataContainerName = {"CroppedDataContainer", "", ""}; + float m_XMin = {0}; + float m_YMin = {0}; + float m_ZMin = {0}; + float m_XMax = {0}; + float m_YMax = {0}; + float m_ZMax = {0}; + QList m_AttrMatList; public: @@ -195,4 +280,3 @@ class SIMPLib_EXPORT CropVertexGeometry : public AbstractFilter CropVertexGeometry& operator=(const CropVertexGeometry&) = delete; // Copy Assignment Not Implemented CropVertexGeometry& operator=(CropVertexGeometry&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/DataContainerReader.cpp b/Source/SIMPLib/CoreFilters/DataContainerReader.cpp index 12845d314a..aa89455eb9 100644 --- a/Source/SIMPLib/CoreFilters/DataContainerReader.cpp +++ b/Source/SIMPLib/CoreFilters/DataContainerReader.cpp @@ -1,54 +1,58 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DataContainerReader.h" +#include #include +#include #include "H5Support/H5ScopedSentinel.h" +#include "H5Support/QH5Lite.h" #include "H5Support/QH5Utilities.h" +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/DataContainers/DataContainerBundle.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/BooleanFilterParameter.h" #include "SIMPLib/FilterParameters/DataContainerReaderFilterParameter.h" #include "SIMPLib/FilterParameters/H5FilterParametersReader.h" #include "SIMPLib/Filtering/FilterManager.h" -#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Montages/MontageSupport.h" #include "SIMPLib/Utilities/SIMPLH5DataReader.h" #include "SIMPLib/Utilities/SIMPLH5DataReaderRequirements.h" @@ -56,10 +60,6 @@ // // ----------------------------------------------------------------------------- DataContainerReader::DataContainerReader() -: m_InputFile("") -, m_OverwriteExistingDataContainers(false) -, m_LastFileRead("") -, m_LastRead(QDateTime::currentDateTime()) { m_PipelineFromFile = FilterPipeline::New(); } @@ -74,16 +74,16 @@ DataContainerReader::~DataContainerReader() = default; // ----------------------------------------------------------------------------- void DataContainerReader::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(SIMPL_NEW_BOOL_FP("Overwrite Existing Data Containers", OverwriteExistingDataContainers, FilterParameter::Parameter, DataContainerReader)); + parameters.push_back(SIMPL_NEW_BOOL_FP("Overwrite Existing Data Containers", OverwriteExistingDataContainers, FilterParameter::Category::Parameter, DataContainerReader)); { DataContainerReaderFilterParameter::Pointer parameter = DataContainerReaderFilterParameter::New(); parameter->setHumanLabel("Select Arrays from Input File"); parameter->setPropertyName("InputFileDataContainerArrayProxy"); parameter->setDefaultFlagValue(Qt::Checked); parameter->setInputFileProperty("InputFile"); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameter->setFilter(this); parameters.push_back(parameter); } @@ -141,6 +141,9 @@ void DataContainerReader::initialize() // ----------------------------------------------------------------------------- void DataContainerReader::dataCheck() { + clearErrorCode(); + clearWarningCode(); + // Sync the file proxy and cached proxy if the time stamps are different QFileInfo fi(getInputFile()); if(getInputFile() == getLastFileRead() && getLastRead() < fi.lastModified()) @@ -155,17 +158,15 @@ void DataContainerReader::dataCheck() if(getInputFile().isEmpty()) { ss = QObject::tr("The input file must be set"); - setErrorCondition(-387); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-387, ss); } else if(!fi.exists()) { ss = QObject::tr("The input file %1 does not exist").arg(getInputFile()); - setErrorCondition(-388); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-388, ss); } - if(getErrorCondition() != 0) + if(getErrorCode() != 0) { // something has gone wrong and errors were logged already so just return return; @@ -173,6 +174,16 @@ void DataContainerReader::dataCheck() DataContainerArray::Pointer dca = getDataContainerArray(); + if(m_InputFileDataContainerArrayProxy.getDataContainers().empty()) + { + QString msg = "The DataContainerArrayProxy object is empty. Nothing will be read from the input file. If you are programmatically calling " + getNameOfClass() + + " you may need to insert a line such as \n\ + DataContainerArrayProxy proxy = reader->readDataContainerArrayStructure(inputFile);\n\ + reader->setInputFileDataContainerArrayProxy(proxy);\n" + " into your code before calling preflight or execute on the filter or pipeline"; + setWarningCondition(1000, msg); + } + // Read either the structure or all the data depending on the preflight status DataContainerArray::Pointer tempDCA = readData(m_InputFileDataContainerArrayProxy); if(tempDCA.get() == nullptr) @@ -180,56 +191,38 @@ void DataContainerReader::dataCheck() return; } - QList& tempContainers = tempDCA->getDataContainers(); - - QListIterator iter(tempContainers); - while(iter.hasNext()) + DataContainerArray::Container tempContainers = tempDCA->getDataContainers(); + for(DataContainer::Pointer container : tempContainers) { - DataContainer::Pointer container = iter.next(); - if(getOverwriteExistingDataContainers()) { if(dca->doesDataContainerExist(container->getName())) { dca->removeDataContainer(container->getName()); } - dca->addDataContainer(container); + dca->addOrReplaceDataContainer(container); } else { if(dca->doesDataContainerExist(container->getName())) { ss = QObject::tr("The input file has a DataContainer with a name (%1) that already exists in the current DataContainerArray structure").arg(container->getName()); - setErrorCondition(-390); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-390, ss); } else { - dca->addDataContainer(container); + dca->addOrReplaceDataContainer(container); } } } QMap bundles = tempDCA->getDataContainerBundles(); dca->setDataContainerBundles(bundles); -} -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void DataContainerReader::preflight() -{ - setInPreflight(true); - // Annouce we are about to preflight - // The GUI will pick up the structure - emit preflightAboutToExecute(); - // The Gui sends down any changes to the Proxy (which for preflight we don't care about) - emit updateFilterParameters(this); - // to the read here because this will populate the DataContainerArray with our DataContainer - dataCheck(); - // The GUI needs to send down the selections that were made by the user and we need to update - // DataContainerArray->DataContainer object so the rest of the pipeline has the proper information - emit preflightExecuted(); // Done executing - setInPreflight(false); + DataContainerArray::MontageCollection montageGroup = readMontageGroup(dca); + for(const auto& montage : montageGroup) + { + dca->addMontage(montage); + } } // ----------------------------------------------------------------------------- @@ -242,7 +235,6 @@ void DataContainerReader::execute() * will be passed up the chain if something goes wrong. */ dataCheck(); - } // ----------------------------------------------------------------------------- @@ -250,16 +242,13 @@ void DataContainerReader::execute() // ----------------------------------------------------------------------------- DataContainerArray::Pointer DataContainerReader::readData(DataContainerArrayProxy& proxy) { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); SIMPLH5DataReader::Pointer simplReader = SIMPLH5DataReader::New(); - connect(simplReader.get(), &SIMPLH5DataReader::errorGenerated, [=](const QString& title, const QString& msg, const int& code) { - setErrorCondition(code); - notifyErrorMessage(getHumanLabel(), msg, getErrorCondition()); - }); + connect(simplReader.get(), &SIMPLH5DataReader::errorGenerated, [=](const QString& title, const QString& msg, int code) { setErrorCondition(code, msg); }); - if (!simplReader->openFile(getInputFile())) + if(!simplReader->openFile(getInputFile())) { return DataContainerArray::New(); } @@ -273,21 +262,19 @@ DataContainerArray::Pointer DataContainerReader::readData(DataContainerArrayProx hid_t fileId = QH5Utilities::openFile(getInputFile(), true); // Open the file Read Only if(fileId < 0) { - setErrorCondition(-150); QString ss = QObject::tr("Error opening input file '%1'").arg(getInputFile()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-150, ss); return DataContainerArray::NullPointer(); } - H5ScopedFileSentinel sentinel(&fileId, true); + H5ScopedFileSentinel sentinel(fileId, true); if(!getInPreflight()) { int32_t err = readExistingPipelineFromFile(fileId); if(err < 0) { - setErrorCondition(err); QString ss = QObject::tr("Error trying to read the existing pipeline from the file '%1'").arg(getInputFile()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(err, ss); return DataContainerArray::New(); } } @@ -295,6 +282,32 @@ DataContainerArray::Pointer DataContainerReader::readData(DataContainerArrayProx return dca; } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainerArray::MontageCollection DataContainerReader::readMontageGroup(const DataContainerArray::Pointer& dca) +{ + hid_t fileId = QH5Utilities::openFile(getInputFile(), true); // Open the file Read Only + if(fileId < 0) + { + QString ss = QObject::tr("Error opening input file '%1'").arg(getInputFile()); + setErrorCondition(-155, ss); + return DataContainerArray::MontageCollection(); + } + H5ScopedFileSentinel sentinel(fileId, true); + + hid_t groupId = QH5Utilities::openHDF5Object(fileId, SIMPL::StringConstants::MontageGroupName); + sentinel.addGroupId(groupId); + int err = 0; + DataContainerArray::MontageCollection montages = MontageSupport::IO::ReadMontagesFromHDF5(groupId, dca, err); + if(err < 0) + { + QString ss = QObject::tr("Error reading montage collection"); + setErrorCondition(-160, ss); + } + return montages; +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -342,7 +355,7 @@ int DataContainerReader::readExistingPipelineFromFile(hid_t fileId) // Use QH5Lite to ask how many "groups" are in the "Pipeline Group" QList groupList; - err = QH5Utilities::getGroupObjects(pipelineGroupId, H5Utilities::H5Support_GROUP, groupList); + err = QH5Utilities::getGroupObjects(pipelineGroupId, H5Utilities::CustomHDFDataTypes::Group, groupList); // Loop over the items getting the "ClassName" attribute from each group QString classNameStr = ""; @@ -417,10 +430,7 @@ bool DataContainerReader::syncProxies() SIMPLH5DataReaderRequirements req(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, AttributeMatrix::Type::Any, IGeometry::Type::Any); SIMPLH5DataReader::Pointer simplReader = SIMPLH5DataReader::New(); - connect(simplReader.get(), &SIMPLH5DataReader::errorGenerated, [=](const QString& title, const QString& msg, const int& code) { - setErrorCondition(code); - notifyErrorMessage(getHumanLabel(), msg, getErrorCondition()); - }); + connect(simplReader.get(), &SIMPLH5DataReader::errorGenerated, [=](const QString& title, const QString& msg, int code) { setErrorCondition(code, msg); }); if(!simplReader->openFile(getInputFile())) { @@ -468,7 +478,7 @@ AbstractFilter::Pointer DataContainerReader::newFilterInstance(bool copyFilterPa { copyFilterParameterInstanceVariables(filter.get()); - SIMPL_COPY_INSTANCEVAR(InputFile) + filter->setInputFile(getInputFile()); filter->setInputFile(getInputFile()); #if 0 @@ -482,7 +492,7 @@ AbstractFilter::Pointer DataContainerReader::newFilterInstance(bool copyFilterPa // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString DataContainerReader::getCompiledLibraryName() const +QString DataContainerReader::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -490,7 +500,7 @@ const QString DataContainerReader::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString DataContainerReader::getBrandingString() const +QString DataContainerReader::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -498,7 +508,7 @@ const QString DataContainerReader::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString DataContainerReader::getFilterVersion() const +QString DataContainerReader::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -509,7 +519,7 @@ const QString DataContainerReader::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString DataContainerReader::getGroupName() const +QString DataContainerReader::getGroupName() const { return SIMPL::FilterGroups::IOFilters; } @@ -517,7 +527,7 @@ const QString DataContainerReader::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid DataContainerReader::getUuid() +QUuid DataContainerReader::getUuid() const { return QUuid("{043cbde5-3878-5718-958f-ae75714df0df}"); } @@ -525,7 +535,7 @@ const QUuid DataContainerReader::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString DataContainerReader::getSubGroupName() const +QString DataContainerReader::getSubGroupName() const { return SIMPL::FilterSubGroups::InputFilters; } @@ -533,7 +543,7 @@ const QString DataContainerReader::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString DataContainerReader::getHumanLabel() const +QString DataContainerReader::getHumanLabel() const { return "Read DREAM.3D Data File"; } @@ -545,3 +555,92 @@ void DataContainerReader::cleanupFilter() { m_PipelineFromFile->clear(); } + +// ----------------------------------------------------------------------------- +DataContainerReader::Pointer DataContainerReader::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr DataContainerReader::New() +{ + struct make_shared_enabler : public DataContainerReader + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString DataContainerReader::getNameOfClass() const +{ + return QString("DataContainerReader"); +} + +// ----------------------------------------------------------------------------- +QString DataContainerReader::ClassName() +{ + return QString("DataContainerReader"); +} + +// ----------------------------------------------------------------------------- +void DataContainerReader::setInputFile(const QString& value) +{ + m_InputFile = value; +} + +// ----------------------------------------------------------------------------- +QString DataContainerReader::getInputFile() const +{ + return m_InputFile; +} + +// ----------------------------------------------------------------------------- +void DataContainerReader::setOverwriteExistingDataContainers(bool value) +{ + m_OverwriteExistingDataContainers = value; +} + +// ----------------------------------------------------------------------------- +bool DataContainerReader::getOverwriteExistingDataContainers() const +{ + return m_OverwriteExistingDataContainers; +} + +// ----------------------------------------------------------------------------- +void DataContainerReader::setLastFileRead(const QString& value) +{ + m_LastFileRead = value; +} + +// ----------------------------------------------------------------------------- +QString DataContainerReader::getLastFileRead() const +{ + return m_LastFileRead; +} + +// ----------------------------------------------------------------------------- +void DataContainerReader::setLastRead(const QDateTime& value) +{ + m_LastRead = value; +} + +// ----------------------------------------------------------------------------- +QDateTime DataContainerReader::getLastRead() const +{ + return m_LastRead; +} + +// ----------------------------------------------------------------------------- +void DataContainerReader::setInputFileDataContainerArrayProxy(const DataContainerArrayProxy& value) +{ + m_InputFileDataContainerArrayProxy = value; +} + +// ----------------------------------------------------------------------------- +DataContainerArrayProxy DataContainerReader::getInputFileDataContainerArrayProxy() const +{ + return m_InputFileDataContainerArrayProxy; +} diff --git a/Source/SIMPLib/CoreFilters/DataContainerReader.h b/Source/SIMPLib/CoreFilters/DataContainerReader.h old mode 100755 new mode 100644 index b0d46acc77..8dec280523 --- a/Source/SIMPLib/CoreFilters/DataContainerReader.h +++ b/Source/SIMPLib/CoreFilters/DataContainerReader.h @@ -1,49 +1,52 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Utilities/SIMPLH5DataReader.h" -#include "SIMPLib/SIMPLib.h" +class DataContainerArray; +using DataContainerArrayShPtrType = std::shared_ptr; class SIMPLH5DataReader; @@ -52,208 +55,255 @@ class SIMPLH5DataReader; */ class SIMPLib_EXPORT DataContainerReader : public AbstractFilter { - Q_OBJECT - - // This line MUST be first when exposing a class and properties to Python - PYB11_CREATE_BINDINGS(DataContainerReader SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString InputFile READ getInputFile WRITE setInputFile) - PYB11_PROPERTY(bool OverwriteExistingDataContainers READ getOverwriteExistingDataContainers WRITE setOverwriteExistingDataContainers) - PYB11_PROPERTY(QString LastFileRead READ getLastFileRead WRITE setLastFileRead) - PYB11_PROPERTY(QDateTime LastRead READ getLastRead WRITE setLastRead) - PYB11_PROPERTY(DataContainerArrayProxy InputFileDataContainerArrayProxy READ getInputFileDataContainerArrayProxy WRITE setInputFileDataContainerArrayProxy) - - PYB11_METHOD(DataContainerArrayProxy readDataContainerArrayStructure ARGS path) - - public: - SIMPL_SHARED_POINTERS(DataContainerReader) - SIMPL_FILTER_NEW_MACRO(DataContainerReader) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DataContainerReader, AbstractFilter) - - ~DataContainerReader() override; - - SIMPL_FILTER_PARAMETER(QString, InputFile) - Q_PROPERTY(QString InputFile READ getInputFile WRITE setInputFile) - - SIMPL_FILTER_PARAMETER(bool, OverwriteExistingDataContainers) - Q_PROPERTY(bool OverwriteExistingDataContainers READ getOverwriteExistingDataContainers WRITE setOverwriteExistingDataContainers) - - SIMPL_FILTER_PARAMETER(QString, LastFileRead) - Q_PROPERTY(QString LastFileRead READ getLastFileRead WRITE setLastFileRead) - - SIMPL_FILTER_PARAMETER(QDateTime, LastRead) - Q_PROPERTY(QDateTime LastRead READ getLastRead WRITE setLastRead) - - SIMPL_FILTER_PARAMETER(DataContainerArrayProxy, InputFileDataContainerArrayProxy) - Q_PROPERTY(DataContainerArrayProxy InputFileDataContainerArrayProxy READ getInputFileDataContainerArrayProxy WRITE setInputFileDataContainerArrayProxy) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief This method is called just before the writeFilterParameters() completes - * @param obj The json object to add the filter parameters into - * @param rootObject The parent object of **obj** - */ - void preWriteFilterParameters(QJsonObject& obj, QJsonObject& rootObject) override; - - /** - * @brief writeFilterParameters Reimplemented from @see AbstractFilter class - */ - void writeFilterParameters(QJsonObject& obj) const override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(QJsonObject& obj) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - /** - * @brief readExistingPipelineFromFile Reads the existing pipeline that is stored in the file and store it - * in the class instance for later writing to another SIMPLView data file - * @param fileId HDF5 group Id for pipeline - * @return Integer error value - */ - int readExistingPipelineFromFile(hid_t fileId); - - /** - * @brief writeExistingPipelineToFile Writes the filter parameters of the existing pipline to a - * SIMPLView file - * @param obj json object - * @param index The index that the inserted pipeline should start at. - * @return - */ - int writeExistingPipelineToFile(QJsonObject &obj, int index); - - /** - * @brief readDataContainerArrayStructure Reads the structure of the DataContainerArray from the HDF5 based .dream3d file. For this method to work - * the member variable for the file path should have been set prior to calling this method. - * @param path The file path to the SIMPLView file - * @return DataContainerArrayProxy instance - */ - DataContainerArrayProxy readDataContainerArrayStructure(const QString& path); - - /** - * @brief syncProxies Combines the file and cached proxies if they are out-of-sync - * @return - */ - bool syncProxies(); - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - DataContainerReader(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - /** - * @brief readData - * @param proxy - * @return - */ - DataContainerArray::Pointer readData(DataContainerArrayProxy& proxy); - - protected slots: - /** - * @brief Cleans up the filter after execution - */ - void cleanupFilter() override; - - private: - FilterPipeline::Pointer m_PipelineFromFile; - - public: - DataContainerReader(const DataContainerReader&) = delete; // Copy Constructor Not Implemented - DataContainerReader(DataContainerReader&&) = delete; // Move Constructor Not Implemented - DataContainerReader& operator=(const DataContainerReader&) = delete; // Copy Assignment Not Implemented - DataContainerReader& operator=(DataContainerReader&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // This line MUST be first when exposing a class and properties to Python + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(DataContainerReader SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(DataContainerReader) + PYB11_FILTER_NEW_MACRO(DataContainerReader) + PYB11_PROPERTY(QString InputFile READ getInputFile WRITE setInputFile) + PYB11_PROPERTY(bool OverwriteExistingDataContainers READ getOverwriteExistingDataContainers WRITE setOverwriteExistingDataContainers) + PYB11_PROPERTY(DataContainerArrayProxy InputFileDataContainerArrayProxy READ getInputFileDataContainerArrayProxy WRITE setInputFileDataContainerArrayProxy) + PYB11_METHOD(DataContainerArrayProxy readDataContainerArrayStructure ARGS path) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = DataContainerReader; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for DataContainerReader + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for DataContainerReader + */ + static QString ClassName(); + + ~DataContainerReader() override; + + /** + * @brief Setter property for InputFile + */ + void setInputFile(const QString& value); + /** + * @brief Getter property for InputFile + * @return Value of InputFile + */ + QString getInputFile() const; + + Q_PROPERTY(QString InputFile READ getInputFile WRITE setInputFile) + + /** + * @brief Setter property for OverwriteExistingDataContainers + */ + void setOverwriteExistingDataContainers(bool value); + /** + * @brief Getter property for OverwriteExistingDataContainers + * @return Value of OverwriteExistingDataContainers + */ + bool getOverwriteExistingDataContainers() const; + + Q_PROPERTY(bool OverwriteExistingDataContainers READ getOverwriteExistingDataContainers WRITE setOverwriteExistingDataContainers) + + /** + * @brief Setter property for LastFileRead + */ + void setLastFileRead(const QString& value); + /** + * @brief Getter property for LastFileRead + * @return Value of LastFileRead + */ + QString getLastFileRead() const; + + Q_PROPERTY(QString LastFileRead READ getLastFileRead WRITE setLastFileRead) + + /** + * @brief Setter property for LastRead + */ + void setLastRead(const QDateTime& value); + /** + * @brief Getter property for LastRead + * @return Value of LastRead + */ + QDateTime getLastRead() const; + + Q_PROPERTY(QDateTime LastRead READ getLastRead WRITE setLastRead) + + /** + * @brief Setter property for InputFileDataContainerArrayProxy + */ + void setInputFileDataContainerArrayProxy(const DataContainerArrayProxy& value); + /** + * @brief Getter property for InputFileDataContainerArrayProxy + * @return Value of InputFileDataContainerArrayProxy + */ + DataContainerArrayProxy getInputFileDataContainerArrayProxy() const; + + Q_PROPERTY(DataContainerArrayProxy InputFileDataContainerArrayProxy READ getInputFileDataContainerArrayProxy WRITE setInputFileDataContainerArrayProxy) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief This method is called just before the writeFilterParameters() completes + * @param obj The json object to add the filter parameters into + * @param rootObject The parent object of **obj** + */ + void preWriteFilterParameters(QJsonObject& obj, QJsonObject& rootObject) override; + + /** + * @brief writeFilterParameters Reimplemented from @see AbstractFilter class + */ + void writeFilterParameters(QJsonObject& obj) const override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(QJsonObject& obj) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + + /** + * @brief readExistingPipelineFromFile Reads the existing pipeline that is stored in the file and store it + * in the class instance for later writing to another SIMPLView data file + * @param fileId HDF5 group Id for pipeline + * @return Integer error value + */ + int readExistingPipelineFromFile(hid_t fileId); + + /** + * @brief writeExistingPipelineToFile Writes the filter parameters of the existing pipline to a + * SIMPLView file + * @param obj json object + * @param index The index that the inserted pipeline should start at. + * @return + */ + int writeExistingPipelineToFile(QJsonObject& obj, int index); + + /** + * @brief readDataContainerArrayStructure Reads the structure of the DataContainerArray from the HDF5 based .dream3d file. For this method to work + * the member variable for the file path should have been set prior to calling this method. + * @param path The file path to the SIMPLView file + * @return DataContainerArrayProxy instance + */ + DataContainerArrayProxy readDataContainerArrayStructure(const QString& path); + + /** + * @brief syncProxies Combines the file and cached proxies if they are out-of-sync + * @return + */ + bool syncProxies(); + +protected: + DataContainerReader(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + + /** + * @brief readData + * @param proxy + * @return + */ + DataContainerArrayShPtrType readData(DataContainerArrayProxy& proxy); + + /** + * @brief readMontageGroup + * @param dca + * @return + */ + DataContainerArray::MontageCollection readMontageGroup(const DataContainerArray::Pointer& dca); + +protected Q_SLOTS: + /** + * @brief Cleans up the filter after execution + */ + void cleanupFilter() override; + +private: + QString m_InputFile = {""}; + bool m_OverwriteExistingDataContainers = {false}; + QString m_LastFileRead = {""}; + QDateTime m_LastRead = {QDateTime::currentDateTime()}; + DataContainerArrayProxy m_InputFileDataContainerArrayProxy = {}; + + FilterPipeline::Pointer m_PipelineFromFile; + +public: + DataContainerReader(const DataContainerReader&) = delete; // Copy Constructor Not Implemented + DataContainerReader(DataContainerReader&&) = delete; // Move Constructor Not Implemented + DataContainerReader& operator=(const DataContainerReader&) = delete; // Copy Assignment Not Implemented + DataContainerReader& operator=(DataContainerReader&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/DataContainerWriter.cpp b/Source/SIMPLib/CoreFilters/DataContainerWriter.cpp index 6f6ef64ba8..6061136697 100644 --- a/Source/SIMPLib/CoreFilters/DataContainerWriter.cpp +++ b/Source/SIMPLib/CoreFilters/DataContainerWriter.cpp @@ -1,93 +1,82 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DataContainerWriter.h" +#include #include +#include +#include "H5Support/H5ScopedSentinel.h" #include "H5Support/H5Utilities.h" +#include "H5Support/QH5Lite.h" #include "H5Support/QH5Utilities.h" -#include "H5Support/H5ScopedSentinel.h" +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/BooleanFilterParameter.h" #include "SIMPLib/FilterParameters/H5FilterParametersWriter.h" #include "SIMPLib/FilterParameters/OutputFileFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Utilities/FileSystemPathHelper.h" - #ifdef _WIN32 extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; #endif -#define APPEND_DATA_TRUE 1 -#define APPEND_DATA_FALSE 0 - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataContainerWriter::DataContainerWriter() -: m_OutputFile(QDir::toNativeSeparators(QDir::homePath() + "/Desktop/Untitled.dream3d")) -, m_WritePipeline(true) -, m_WriteXdmfFile(true) -, m_WriteTimeSeries(false) -, m_AppendToExisting(false) -, m_FileId(-1) -{ -} +DataContainerWriter::DataContainerWriter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataContainerWriter::~DataContainerWriter() -{ - closeFile(); -} +DataContainerWriter::~DataContainerWriter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void DataContainerWriter::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(SIMPL_NEW_OUTPUT_FILE_FP("Output File", OutputFile, FilterParameter::Parameter, DataContainerWriter, "*.dream3d", "")); - parameters.push_back(SIMPL_NEW_BOOL_FP("Write Xdmf File", WriteXdmfFile, FilterParameter::Parameter, DataContainerWriter)); - parameters.push_back(SIMPL_NEW_BOOL_FP("Include Xdmf Time Markers", WriteTimeSeries, FilterParameter::Parameter, DataContainerWriter)); + parameters.push_back(SIMPL_NEW_OUTPUT_FILE_FP("Output File", OutputFile, FilterParameter::Category::Parameter, DataContainerWriter, "*.dream3d", "")); + parameters.push_back(SIMPL_NEW_BOOL_FP("Write Xdmf File", WriteXdmfFile, FilterParameter::Category::Parameter, DataContainerWriter)); + parameters.push_back(SIMPL_NEW_BOOL_FP("Include Xdmf Time Markers", WriteTimeSeries, FilterParameter::Category::Parameter, DataContainerWriter)); setFilterParameters(parameters); } @@ -108,7 +97,6 @@ void DataContainerWriter::readFilterParameters(AbstractFilterParametersReader* r // ----------------------------------------------------------------------------- void DataContainerWriter::initialize() { - m_FileId = -1; } // ----------------------------------------------------------------------------- @@ -116,8 +104,8 @@ void DataContainerWriter::initialize() // ----------------------------------------------------------------------------- void DataContainerWriter::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QString ss; QFileInfo fi(m_OutputFile); @@ -126,20 +114,6 @@ void DataContainerWriter::dataCheck() m_OutputFile.append(".dream3d"); } FileSystemPathHelper::CheckOutputFile(this, "Output File Path", getOutputFile(), true); - -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void DataContainerWriter::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); } // ----------------------------------------------------------------------------- @@ -147,16 +121,12 @@ void DataContainerWriter::preflight() // ----------------------------------------------------------------------------- void DataContainerWriter::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - int err = 0; - // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path QFileInfo fi(m_OutputFile); @@ -165,27 +135,37 @@ void DataContainerWriter::execute() if(!dir.mkpath(parentPath)) { QString ss = QObject::tr("Error creating parent path '%1'").arg(parentPath); - setErrorCondition(-11110); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11110, ss); return; } - err = openFile(m_AppendToExisting); // Do NOT append to any existing file - if(err < 0) + hid_t fileId = -1; + + // Try to open a file to append data into + if(m_AppendToExisting) + { + fileId = QH5Utilities::openFile(m_OutputFile, false); + } + // No file was found or we are writing new data only to a clean file + if(!m_AppendToExisting || fileId < 0) + { + fileId = QH5Utilities::createFile(m_OutputFile); + } + + if(fileId < 0) { QString ss = QObject::tr("The HDF5 file could not be opened or created.\n The given filename was:\n\t[%1]").arg(m_OutputFile); - setErrorCondition(-11112); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11112, ss); return; } // qDebug() << "DREAM3D File: " << m_OutputFile; // This will make sure if we return early from this method that the HDF5 File is properly closed. - H5ScopedFileSentinel scopedFileSentinel(&m_FileId, true); + H5ScopedFileSentinel scopedFileSentinel(fileId, true); // Write our File Version string to the Root "/" group - QH5Lite::writeStringAttribute(m_FileId, "/", SIMPL::HDF5::FileVersionName, SIMPL::HDF5::FileVersion); - QH5Lite::writeStringAttribute(m_FileId, "/", SIMPL::HDF5::DREAM3DVersion, SIMPLib::Version::Complete()); + QH5Lite::writeStringAttribute(fileId, "/", SIMPL::HDF5::FileVersionName, SIMPL::HDF5::FileVersion); + QH5Lite::writeStringAttribute(fileId, "/", SIMPL::HDF5::DREAM3DVersion, SIMPLib::Version::Complete()); QFile xdmfFile; QTextStream xdmfOut(&xdmfFile); if(m_WriteXdmfFile) @@ -208,18 +188,17 @@ void DataContainerWriter::execute() } // Write the Pipeline to the File - err = writePipeline(); + int err = writePipeline(); - err = H5Utilities::createGroupsFromPath(SIMPL::StringConstants::DataContainerGroupName.toLatin1().data(), m_FileId); + err = H5Utilities::createGroupsFromPath(SIMPL::StringConstants::DataContainerGroupName.toLatin1().data(), fileId); if(err < 0) { QString ss = QObject::tr("Error creating HDF5 Group '%1'").arg(SIMPL::StringConstants::DataContainerGroupName); - setErrorCondition(-60); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-60, ss); return; } - hid_t dcaGid = H5Gopen(m_FileId, SIMPL::StringConstants::DataContainerGroupName.toLatin1().data(), H5P_DEFAULT); - scopedFileSentinel.addGroupId(&dcaGid); + hid_t dcaGid = H5Gopen(fileId, SIMPL::StringConstants::DataContainerGroupName.toLatin1().data(), H5P_DEFAULT); + scopedFileSentinel.addGroupId(dcaGid); QList dcNames = getDataContainerArray()->getDataContainerNames(); for(int iter = 0; iter < getDataContainerArray()->getNumDataContainers(); iter++) @@ -230,26 +209,25 @@ void DataContainerWriter::execute() if(err < 0) { QString ss = QObject::tr("Error creating HDF5 Group '%1'").arg(dcNames[iter]); - setErrorCondition(-60); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-60, ss); return; } hid_t dcGid = H5Gopen(dcaGid, dcNames[iter].toLatin1().data(), H5P_DEFAULT); - H5ScopedGroupSentinel groupSentinel(&dcGid, false); - // QString ss = QObject::tr("%1 |--> Writing %2 DataContainer ").arg(getMessagePrefix()).arg(dcNames[iter]); + H5ScopedGroupSentinel groupSentinel(dcGid, false); + // QString ss = QObject::tr("Writing %2 DataContainer").arg(dcNames[iter]); // Have the DataContainer write all of its Attribute Matrices and its Mesh err = dc->writeAttributeMatricesToHDF5(dcGid); if(err < 0) { - notifyErrorMessage(getHumanLabel(), "Error writing DataContainer AttributeMatrices", -803); + setErrorCondition(err, "Error writing DataContainer AttributeMatrices"); return; } err = dc->writeMeshToHDF5(dcGid, m_WriteXdmfFile); if(err < 0) { - notifyErrorMessage(getHumanLabel(), "Error writing DataContainer Geometry", -804); + setErrorCondition(err, "Error writing DataContainer Geometry"); return; } if(m_WriteXdmfFile && geometry.get() != nullptr) @@ -261,27 +239,35 @@ void DataContainerWriter::execute() dc->getGeometry()->setTimeValue(static_cast(iter)); } #if 0 - dc->getGeometry()->addAttributeMatrix(SIMPL::StringConstants::MetaData, dc->getAttributeMatrix(SIMPL::StringConstants::MetaData)); + dc->getGeometry()->addOrReplaceAttributeMatrix(SIMPL::StringConstants::MetaData, dc->getAttributeMatrix(SIMPL::StringConstants::MetaData)); dc->getGeometry()->setTemporalDataPath(DataArrayPath(dc->getName(), SIMPL::StringConstants::MetaData, "Step #")); #endif - QString hdfFileName = QH5Utilities::fileNameFromFileId(m_FileId); + QString hdfFileName = QH5Utilities::fileNameFromFileId(fileId); err = dc->writeXdmf(xdmfOut, hdfFileName); if(err < 0) { - notifyErrorMessage(getHumanLabel(), "Error writing Xdmf File", -805); + setErrorCondition(err, "Error writing Xdmf File"); return; } } } // Write the Data ContainerBundles - err = writeDataContainerBundles(m_FileId); + err = writeDataContainerBundles(fileId); if(err < 0) { QString ss = QObject::tr("Error writing DataContainerBundles"); - setErrorCondition(-11113); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11113, ss); + return; + } + + // Write Montages + err = writeMontages(fileId); + if(err < 0) + { + QString ss = QObject::tr("Error writing montages"); + setErrorCondition(-11113, ss); return; } @@ -290,11 +276,6 @@ void DataContainerWriter::execute() { writeXdmfFooter(xdmfOut); } - - H5Gclose(dcaGid); - - dcaGid = -1; - } // ----------------------------------------------------------------------------- @@ -302,17 +283,16 @@ void DataContainerWriter::execute() // ----------------------------------------------------------------------------- int DataContainerWriter::writeDataContainerBundles(hid_t fileId) { - int err = QH5Utilities::createGroupsFromPath(SIMPL::StringConstants::DataContainerBundleGroupName, m_FileId); + int err = QH5Utilities::createGroupsFromPath(SIMPL::StringConstants::DataContainerBundleGroupName, fileId); if(err < 0) { QString ss = QObject::tr("Error creating HDF5 Group '%1'").arg(SIMPL::StringConstants::DataContainerBundleGroupName); - setErrorCondition(-61); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-61, ss); return -1; } - hid_t dcbGid = H5Gopen(m_FileId, SIMPL::StringConstants::DataContainerBundleGroupName.toLatin1().data(), H5P_DEFAULT); + hid_t dcbGid = H5Gopen(fileId, SIMPL::StringConstants::DataContainerBundleGroupName.toLatin1().data(), H5P_DEFAULT); - H5GroupAutoCloser groupCloser(&dcbGid); + H5GroupAutoCloser groupCloser(dcbGid); QMap& bundles = getDataContainerArray()->getDataContainerBundles(); QMapIterator iter(bundles); @@ -326,8 +306,35 @@ int DataContainerWriter::writeDataContainerBundles(hid_t fileId) return err; } } - H5Gclose(dcbGid); - dcbGid = -1; + return 0; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +int DataContainerWriter::writeMontages(hid_t fileId) +{ + int err = QH5Utilities::createGroupsFromPath(SIMPL::StringConstants::MontageGroupName, fileId); + if(err < 0) + { + QString ss = QObject::tr("Error creating HDF5 Group '%1'").arg(SIMPL::StringConstants::MontageGroupName); + setErrorCondition(-62, ss); + return -1; + } + hid_t dcbGid = H5Gopen(fileId, SIMPL::StringConstants::MontageGroupName.toLatin1().data(), H5P_DEFAULT); + + H5GroupAutoCloser groupCloser(dcbGid); + + DataContainerArray::MontageCollection montages = getDataContainerArray()->getMontageCollection(); + for(const auto& montage : montages) + { + err = montage->writeH5Data(dcbGid); + if(err < 0) + { + return err; + } + } + return 0; } @@ -358,7 +365,8 @@ void DataContainerWriter::writeXdmfFooter(QTextStream& xdmf) { if(getWriteTimeSeries()) { - xdmf << " " << "\n"; + xdmf << " " + << "\n"; } xdmf << " " << "\n"; @@ -382,8 +390,7 @@ int DataContainerWriter::writePipeline() { break; } - - previousFilter = previousFilter->getPreviousFilter().lock(); + previousFilter = previousFilter->getPreviousFilter().lock(); } FilterPipeline::Pointer pipeline = FilterPipeline::New(); @@ -398,38 +405,7 @@ int DataContainerWriter::writePipeline() currentFilter = nextFilter; } - return writer->writePipelineToFile(pipeline, m_OutputFile, SIMPL::StringConstants::PipelineGroupName); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -hid_t DataContainerWriter::openFile(bool appendData) -{ - // Try to open a file to append data into - if(APPEND_DATA_TRUE == static_cast(appendData)) - { - m_FileId = QH5Utilities::openFile(m_OutputFile, false); - } - // No file was found or we are writing new data only to a clean file - if(APPEND_DATA_FALSE == static_cast(appendData) || m_FileId < 0) - { - m_FileId = QH5Utilities::createFile(m_OutputFile); - } - return m_FileId; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -herr_t DataContainerWriter::closeFile() -{ - // Close the file when we are finished with it - if(m_FileId > 0) - { - return QH5Utilities::closeFile(m_FileId); - } - return 1; + return writer->writePipelineToFile(pipeline, m_OutputFile, SIMPL::StringConstants::PipelineGroupName, true); } // ----------------------------------------------------------------------------- @@ -448,7 +424,7 @@ AbstractFilter::Pointer DataContainerWriter::newFilterInstance(bool copyFilterPa // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString DataContainerWriter::getCompiledLibraryName() const +QString DataContainerWriter::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -456,7 +432,7 @@ const QString DataContainerWriter::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString DataContainerWriter::getBrandingString() const +QString DataContainerWriter::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -464,7 +440,7 @@ const QString DataContainerWriter::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString DataContainerWriter::getFilterVersion() const +QString DataContainerWriter::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -475,7 +451,7 @@ const QString DataContainerWriter::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString DataContainerWriter::getGroupName() const +QString DataContainerWriter::getGroupName() const { return SIMPL::FilterGroups::IOFilters; } @@ -483,7 +459,7 @@ const QString DataContainerWriter::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid DataContainerWriter::getUuid() +QUuid DataContainerWriter::getUuid() const { return QUuid("{3fcd4c43-9d75-5b86-aad4-4441bc914f37}"); } @@ -491,7 +467,7 @@ const QUuid DataContainerWriter::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString DataContainerWriter::getSubGroupName() const +QString DataContainerWriter::getSubGroupName() const { return SIMPL::FilterSubGroups::OutputFilters; } @@ -499,7 +475,96 @@ const QString DataContainerWriter::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString DataContainerWriter::getHumanLabel() const +QString DataContainerWriter::getHumanLabel() const { return "Write DREAM.3D Data File"; } + +// ----------------------------------------------------------------------------- +DataContainerWriter::Pointer DataContainerWriter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr DataContainerWriter::New() +{ + struct make_shared_enabler : public DataContainerWriter + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString DataContainerWriter::getNameOfClass() const +{ + return QString("DataContainerWriter"); +} + +// ----------------------------------------------------------------------------- +QString DataContainerWriter::ClassName() +{ + return QString("DataContainerWriter"); +} + +// ----------------------------------------------------------------------------- +void DataContainerWriter::setOutputFile(const QString& value) +{ + m_OutputFile = value; +} + +// ----------------------------------------------------------------------------- +QString DataContainerWriter::getOutputFile() const +{ + return m_OutputFile; +} + +// ----------------------------------------------------------------------------- +void DataContainerWriter::setWritePipeline(bool value) +{ + m_WritePipeline = value; +} + +// ----------------------------------------------------------------------------- +bool DataContainerWriter::getWritePipeline() const +{ + return m_WritePipeline; +} + +// ----------------------------------------------------------------------------- +void DataContainerWriter::setWriteXdmfFile(bool value) +{ + m_WriteXdmfFile = value; +} + +// ----------------------------------------------------------------------------- +bool DataContainerWriter::getWriteXdmfFile() const +{ + return m_WriteXdmfFile; +} + +// ----------------------------------------------------------------------------- +void DataContainerWriter::setWriteTimeSeries(bool value) +{ + m_WriteTimeSeries = value; +} + +// ----------------------------------------------------------------------------- +bool DataContainerWriter::getWriteTimeSeries() const +{ + return m_WriteTimeSeries; +} + +// ----------------------------------------------------------------------------- +void DataContainerWriter::setAppendToExisting(bool value) +{ + m_AppendToExisting = value; +} + +// ----------------------------------------------------------------------------- +bool DataContainerWriter::getAppendToExisting() const +{ + return m_AppendToExisting; +} diff --git a/Source/SIMPLib/CoreFilters/DataContainerWriter.h b/Source/SIMPLib/CoreFilters/DataContainerWriter.h old mode 100755 new mode 100644 index b6fd0a4548..d2720a1e38 --- a/Source/SIMPLib/CoreFilters/DataContainerWriter.h +++ b/Source/SIMPLib/CoreFilters/DataContainerWriter.h @@ -1,224 +1,260 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + +#include + +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The DataContainerWriter class. See [Filter documentation](@ref datacontainerwriter) for details. */ class SIMPLib_EXPORT DataContainerWriter : public AbstractFilter { - Q_OBJECT - - // This line MUST be first when exposing a class and properties to Python - PYB11_CREATE_BINDINGS(DataContainerWriter SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString OutputFile READ getOutputFile WRITE setOutputFile) - PYB11_PROPERTY(bool WriteXdmfFile READ getWriteXdmfFile WRITE setWriteXdmfFile) - PYB11_PROPERTY(bool WriteTimeSeries READ getWriteTimeSeries WRITE setWriteTimeSeries) - - public: - SIMPL_SHARED_POINTERS(DataContainerWriter) - SIMPL_FILTER_NEW_MACRO(DataContainerWriter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DataContainerWriter, AbstractFilter) - - ~DataContainerWriter() override; - - SIMPL_FILTER_PARAMETER(QString, OutputFile) - Q_PROPERTY(QString OutputFile READ getOutputFile WRITE setOutputFile) - - SIMPL_INSTANCE_PROPERTY(bool, WritePipeline) - - SIMPL_FILTER_PARAMETER(bool, WriteXdmfFile) - Q_PROPERTY(bool WriteXdmfFile READ getWriteXdmfFile WRITE setWriteXdmfFile) - - SIMPL_FILTER_PARAMETER(bool, WriteTimeSeries) - Q_PROPERTY(bool WriteTimeSeries READ getWriteTimeSeries WRITE setWriteTimeSeries) - - SIMPL_INSTANCE_PROPERTY(bool, AppendToExisting) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - DataContainerWriter(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - /** - * @brief openFile Opens or creates an HDF5 file to write data into - * @param append Should a new file be created or append data to a currently existing file - * @return - */ - hid_t openFile(bool append = false); - - /** - * @brief closeFile Closes the currently open file - * @return Integer error value - */ - herr_t closeFile(); - - /** - * @brief writePipeline Writes the existing pipeline to the HDF5 file - * @return - */ - int writePipeline(); - - /** - * @brief writeDataContainerBundles Writes any existing DataContainerBundles to the HDF5 file - * @param fileId Group Id for the DataContainerBundles - * @return - */ - int writeDataContainerBundles(hid_t fileId); - - /** - * @brief writeXdmfHeader Writes the Xdmf header - * @param out QTextStream for output - */ - void writeXdmfHeader(QTextStream& out); - - /** - * @brief writeXdmfFooter Writes the Xdmf footer - * @param out QTextStream for output - */ - void writeXdmfFooter(QTextStream& out); - - private: - hid_t m_FileId; - - public: - DataContainerWriter(const DataContainerWriter&) = delete; // Copy Constructor Not Implemented - DataContainerWriter(DataContainerWriter&&) = delete; // Move Constructor Not Implemented - DataContainerWriter& operator=(const DataContainerWriter&) = delete; // Copy Assignment Not Implemented - DataContainerWriter& operator=(DataContainerWriter&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // This line MUST be first when exposing a class and properties to Python + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(DataContainerWriter SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(DataContainerWriter) + PYB11_FILTER_NEW_MACRO(DataContainerWriter) + PYB11_PROPERTY(QString OutputFile READ getOutputFile WRITE setOutputFile) + PYB11_PROPERTY(bool WriteXdmfFile READ getWriteXdmfFile WRITE setWriteXdmfFile) + PYB11_PROPERTY(bool WriteTimeSeries READ getWriteTimeSeries WRITE setWriteTimeSeries) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = DataContainerWriter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for DataContainerWriter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for DataContainerWriter + */ + static QString ClassName(); + + ~DataContainerWriter() override; + + /** + * @brief Setter property for OutputFile + */ + void setOutputFile(const QString& value); + /** + * @brief Getter property for OutputFile + * @return Value of OutputFile + */ + QString getOutputFile() const; + + Q_PROPERTY(QString OutputFile READ getOutputFile WRITE setOutputFile) + + /** + * @brief Setter property for WritePipeline + */ + void setWritePipeline(bool value); + /** + * @brief Getter property for WritePipeline + * @return Value of WritePipeline + */ + bool getWritePipeline() const; + + /** + * @brief Setter property for WriteXdmfFile + */ + void setWriteXdmfFile(bool value); + /** + * @brief Getter property for WriteXdmfFile + * @return Value of WriteXdmfFile + */ + bool getWriteXdmfFile() const; + + Q_PROPERTY(bool WriteXdmfFile READ getWriteXdmfFile WRITE setWriteXdmfFile) + + /** + * @brief Setter property for WriteTimeSeries + */ + void setWriteTimeSeries(bool value); + /** + * @brief Getter property for WriteTimeSeries + * @return Value of WriteTimeSeries + */ + bool getWriteTimeSeries() const; + + Q_PROPERTY(bool WriteTimeSeries READ getWriteTimeSeries WRITE setWriteTimeSeries) + + /** + * @brief Setter property for AppendToExisting + */ + void setAppendToExisting(bool value); + /** + * @brief Getter property for AppendToExisting + * @return Value of AppendToExisting + */ + bool getAppendToExisting() const; + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + DataContainerWriter(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + + /** + * @brief writePipeline Writes the existing pipeline to the HDF5 file + * @return + */ + int writePipeline(); + + /** + * @brief writeDataContainerBundles Writes any existing DataContainerBundles to the HDF5 file + * @param fileId Group Id for the DataContainerBundles + * @return + */ + int writeDataContainerBundles(hid_t fileId); + + /** + * @brief writeMontages Writes any existing Montages to the HDF5 file + * @param fileId Group Id for the Montages + * @return + */ + int writeMontages(hid_t fileId); + + /** + * @brief writeXdmfHeader Writes the Xdmf header + * @param out QTextStream for output + */ + void writeXdmfHeader(QTextStream& out); + + /** + * @brief writeXdmfFooter Writes the Xdmf footer + * @param out QTextStream for output + */ + void writeXdmfFooter(QTextStream& out); + +private: + QString m_OutputFile = {}; + bool m_WritePipeline = {true}; + bool m_WriteXdmfFile = {true}; + bool m_WriteTimeSeries = {false}; + bool m_AppendToExisting = {false}; + +public: + DataContainerWriter(const DataContainerWriter&) = delete; // Copy Constructor Not Implemented + DataContainerWriter(DataContainerWriter&&) = delete; // Move Constructor Not Implemented + DataContainerWriter& operator=(const DataContainerWriter&) = delete; // Copy Assignment Not Implemented + DataContainerWriter& operator=(DataContainerWriter&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/EmptyFilter.cpp b/Source/SIMPLib/CoreFilters/EmptyFilter.cpp index d3c0a82498..8f880b8423 100644 --- a/Source/SIMPLib/CoreFilters/EmptyFilter.cpp +++ b/Source/SIMPLib/CoreFilters/EmptyFilter.cpp @@ -1,52 +1,50 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "EmptyFilter.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/UnknownFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EmptyFilter::EmptyFilter() -: m_HumanLabel("Unknown Filter") -{ -} +EmptyFilter::EmptyFilter() = default; // ----------------------------------------------------------------------------- // @@ -58,14 +56,14 @@ EmptyFilter::~EmptyFilter() = default; // ----------------------------------------------------------------------------- void EmptyFilter::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; QString str; QTextStream ss(&str); ss << "The original filter '" << getOriginalFilterName() << "' was not loaded. "; ss << "Either a plugin with the original filter was not loaded or the original "; ss << "filter has been renamed."; - parameters.push_back(UnknownFilterParameter::New(str, "OriginalFilterName", getOriginalFilterName(), FilterParameter::Parameter)); + parameters.push_back(UnknownFilterParameter::Create(str, "OriginalFilterName", getOriginalFilterName(), FilterParameter::Category::Parameter)); setFilterParameters(parameters); } @@ -100,17 +98,7 @@ void EmptyFilter::initialize() void EmptyFilter::dataCheck() { QString ss = QObject::tr("This filter does nothing and was inserted as a place holder for filter '%1' that does not exist anymore.").arg(getOriginalFilterName()); - setErrorCondition(-9999); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void EmptyFilter::preflight() -{ - setInPreflight(true); - dataCheck(); + setErrorCondition(-9999, ss); } // ----------------------------------------------------------------------------- @@ -138,7 +126,7 @@ AbstractFilter::Pointer EmptyFilter::newFilterInstance(bool copyFilterParameters // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString EmptyFilter::getCompiledLibraryName() const +QString EmptyFilter::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -146,7 +134,7 @@ const QString EmptyFilter::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString EmptyFilter::getBrandingString() const +QString EmptyFilter::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -154,7 +142,7 @@ const QString EmptyFilter::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString EmptyFilter::getFilterVersion() const +QString EmptyFilter::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -165,7 +153,7 @@ const QString EmptyFilter::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString EmptyFilter::getGroupName() const +QString EmptyFilter::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -173,7 +161,7 @@ const QString EmptyFilter::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid EmptyFilter::getUuid() +QUuid EmptyFilter::getUuid() const { return QUuid("{0af0e81f-1f98-5734-a38a-74cfccd6e6f8}"); } @@ -181,7 +169,7 @@ const QUuid EmptyFilter::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString EmptyFilter::getSubGroupName() const +QString EmptyFilter::getSubGroupName() const { return SIMPL::FilterSubGroups::MiscFilters; } @@ -189,7 +177,7 @@ const QString EmptyFilter::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString EmptyFilter::getHumanLabel() const +QString EmptyFilter::getHumanLabel() const { if(m_HumanLabel.isEmpty()) { @@ -206,3 +194,44 @@ void EmptyFilter::setHumanLabel(const QString& humanLabel) { m_HumanLabel = humanLabel; } + +// ----------------------------------------------------------------------------- +EmptyFilter::Pointer EmptyFilter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr EmptyFilter::New() +{ + struct make_shared_enabler : public EmptyFilter + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString EmptyFilter::getNameOfClass() const +{ + return QString("EmptyFilter"); +} + +// ----------------------------------------------------------------------------- +QString EmptyFilter::ClassName() +{ + return QString("EmptyFilter"); +} + +// ----------------------------------------------------------------------------- +void EmptyFilter::setOriginalFilterName(const QString& value) +{ + m_OriginalFilterName = value; +} + +// ----------------------------------------------------------------------------- +QString EmptyFilter::getOriginalFilterName() const +{ + return m_OriginalFilterName; +} diff --git a/Source/SIMPLib/CoreFilters/EmptyFilter.h b/Source/SIMPLib/CoreFilters/EmptyFilter.h old mode 100755 new mode 100644 index 9091308cdd..836dc86a2f --- a/Source/SIMPLib/CoreFilters/EmptyFilter.h +++ b/Source/SIMPLib/CoreFilters/EmptyFilter.h @@ -1,177 +1,178 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The EmptyFilter class serves as an empty, non-functional filter */ class SIMPLib_EXPORT EmptyFilter : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(EmptyFilter SUPERCLASS AbstractFilter) - - public: - SIMPL_SHARED_POINTERS(EmptyFilter) - SIMPL_FILTER_NEW_MACRO(EmptyFilter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(EmptyFilter, AbstractFilter) - - ~EmptyFilter() override; - - SIMPL_INSTANCE_STRING_PROPERTY(OriginalFilterName) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - /** - * @brief This is overloaded from the super class for this particular filter. - * All other filters do NOT overload this filter - * @param humanLabel - */ - void setHumanLabel(const QString& humanLabel); - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - EmptyFilter(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - QString m_HumanLabel; - - public: - EmptyFilter(const EmptyFilter&) = delete; // Copy Constructor Not Implemented - EmptyFilter(EmptyFilter&&) = delete; // Move Constructor Not Implemented - EmptyFilter& operator=(const EmptyFilter&) = delete; // Copy Assignment Not Implemented - EmptyFilter& operator=(EmptyFilter&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(EmptyFilter SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(EmptyFilter) + PYB11_FILTER_NEW_MACRO(EmptyFilter) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = EmptyFilter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for EmptyFilter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for EmptyFilter + */ + static QString ClassName(); + + ~EmptyFilter() override; + + /** + * @brief Setter property for OriginalFilterName + */ + void setOriginalFilterName(const QString& value); + /** + * @brief Getter property for OriginalFilterName + * @return Value of OriginalFilterName + */ + QString getOriginalFilterName() const; + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + + /** + * @brief This is overloaded from the super class for this particular filter. + * All other filters do NOT overload this filter + * @param humanLabel + */ + void setHumanLabel(const QString& humanLabel); + +protected: + EmptyFilter(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + QString m_OriginalFilterName = {}; + + QString m_HumanLabel = {"Unknown Filter"}; + +public: + EmptyFilter(const EmptyFilter&) = delete; // Copy Constructor Not Implemented + EmptyFilter(EmptyFilter&&) = delete; // Move Constructor Not Implemented + EmptyFilter& operator=(const EmptyFilter&) = delete; // Copy Assignment Not Implemented + EmptyFilter& operator=(EmptyFilter&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/ExecuteProcess.cpp b/Source/SIMPLib/CoreFilters/ExecuteProcess.cpp index be63ac1554..053e80adab 100644 --- a/Source/SIMPLib/CoreFilters/ExecuteProcess.cpp +++ b/Source/SIMPLib/CoreFilters/ExecuteProcess.cpp @@ -1,49 +1,49 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ExecuteProcess.h" #include #include #include +#include +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/InputFileFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- // @@ -60,9 +60,9 @@ ExecuteProcess::~ExecuteProcess() = default; // ----------------------------------------------------------------------------- void ExecuteProcess::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(SIMPL_NEW_STRING_FP("Command Line Arguments", Arguments, FilterParameter::Parameter, ExecuteProcess)); + parameters.push_back(SIMPL_NEW_STRING_FP("Command Line Arguments", Arguments, FilterParameter::Category::Parameter, ExecuteProcess)); setFilterParameters(parameters); } @@ -91,15 +91,14 @@ void ExecuteProcess::initialize() // ----------------------------------------------------------------------------- void ExecuteProcess::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QStringList arguments = splitArgumentsString(m_Arguments); if(arguments.empty()) { QString ss = QObject::tr("No command line arguments have been specified."); - setErrorCondition(-4001); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4001, ss); return; } @@ -109,35 +108,18 @@ void ExecuteProcess::dataCheck() // if( !fi.exists()) // { // QString ss = QObject::tr("The executable at %1 does not exist.").arg(prog); - // setErrorCondition(-4000); - // notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + // setErrorCondition(-4000, ss); // return; // } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void ExecuteProcess::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ExecuteProcess::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -222,16 +204,14 @@ void ExecuteProcess::processHasFinished(int exitCode, QProcess::ExitStatus exitS else if(exitStatus == QProcess::CrashExit) { QString ss = QObject::tr("The process crashed during its exit."); - setErrorCondition(-4003); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4003, ss); } else if(exitCode < 0) { QString ss = QObject::tr("The process finished with exit code %1.").arg(QString::number(exitCode)); - setErrorCondition(-4004); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4004, ss); } - else if(getErrorCondition() >= 0) + else if(getErrorCode() >= 0) { } @@ -247,8 +227,7 @@ void ExecuteProcess::processHasErroredOut(QProcess::ProcessError error) if(getCancel()) { QString ss = QObject::tr("The process was killed by the user."); - setWarningCondition(-4004); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-4004, ss); } else if(error == QProcess::FailedToStart) { @@ -258,38 +237,32 @@ void ExecuteProcess::processHasErroredOut(QProcess::ProcessError error) QString ss = QObject::tr("The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program \ or the path containing the executble is not in the system's environment path. PATH=%1.\n Try using the absolute path to the executable.") .arg(pathEnv); - setErrorCondition(-4005); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4005, ss); } else if(error == QProcess::Crashed) { QString ss = QObject::tr("The process crashed some time after starting successfully."); - setErrorCondition(-4006); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4006, ss); } else if(error == QProcess::Timedout) { QString ss = QObject::tr("The process timed out."); - setErrorCondition(-4007); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4007, ss); } else if(error == QProcess::WriteError) { QString ss = QObject::tr("An error occurred when attempting to write to the process."); - setErrorCondition(-4008); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4008, ss); } else if(error == QProcess::ReadError) { QString ss = QObject::tr("An error occurred when attempting to read from the process."); - setErrorCondition(-4009); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4009, ss); } else { QString ss = QObject::tr("An unknown error occurred."); - setErrorCondition(-4010); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4010, ss); } m_Pause = false; @@ -308,7 +281,7 @@ void ExecuteProcess::sendErrorOutput() { error.chop(1); } - notifyStandardOutputMessage(getHumanLabel(), getPipelineIndex() + 1, error); + notifyStatusMessage(error); m_WaitCondition.wakeAll(); } } @@ -320,7 +293,7 @@ void ExecuteProcess::sendStandardOutput() { if(m_ProcessPtr.data() != nullptr) { - notifyStandardOutputMessage(getHumanLabel(), getPipelineIndex() + 1, m_ProcessPtr->readAllStandardOutput()); + notifyStatusMessage(m_ProcessPtr->readAllStandardOutput()); m_WaitCondition.wakeAll(); } } @@ -341,7 +314,7 @@ AbstractFilter::Pointer ExecuteProcess::newFilterInstance(bool copyFilterParamet // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExecuteProcess::getCompiledLibraryName() const +QString ExecuteProcess::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -349,7 +322,7 @@ const QString ExecuteProcess::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExecuteProcess::getBrandingString() const +QString ExecuteProcess::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -357,7 +330,7 @@ const QString ExecuteProcess::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExecuteProcess::getFilterVersion() const +QString ExecuteProcess::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -368,7 +341,7 @@ const QString ExecuteProcess::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExecuteProcess::getGroupName() const +QString ExecuteProcess::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -376,7 +349,7 @@ const QString ExecuteProcess::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid ExecuteProcess::getUuid() +QUuid ExecuteProcess::getUuid() const { return QUuid("{8a2308ec-86cd-5636-9a0a-6c7d383e9e7f}"); } @@ -384,7 +357,7 @@ const QUuid ExecuteProcess::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExecuteProcess::getSubGroupName() const +QString ExecuteProcess::getSubGroupName() const { return SIMPL::FilterSubGroups::MiscFilters; } @@ -392,7 +365,48 @@ const QString ExecuteProcess::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExecuteProcess::getHumanLabel() const +QString ExecuteProcess::getHumanLabel() const { return "Execute Process"; } + +// ----------------------------------------------------------------------------- +ExecuteProcess::Pointer ExecuteProcess::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr ExecuteProcess::New() +{ + struct make_shared_enabler : public ExecuteProcess + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString ExecuteProcess::getNameOfClass() const +{ + return QString("ExecuteProcess"); +} + +// ----------------------------------------------------------------------------- +QString ExecuteProcess::ClassName() +{ + return QString("ExecuteProcess"); +} + +// ----------------------------------------------------------------------------- +void ExecuteProcess::setArguments(const QString& value) +{ + m_Arguments = value; +} + +// ----------------------------------------------------------------------------- +QString ExecuteProcess::getArguments() const +{ + return m_Arguments; +} diff --git a/Source/SIMPLib/CoreFilters/ExecuteProcess.h b/Source/SIMPLib/CoreFilters/ExecuteProcess.h index 786c044d2b..66b8dad86a 100644 --- a/Source/SIMPLib/CoreFilters/ExecuteProcess.h +++ b/Source/SIMPLib/CoreFilters/ExecuteProcess.h @@ -1,48 +1,49 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include -#include +#include + #include +#include #include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" class QProcess; @@ -52,143 +53,154 @@ class QProcess; class SIMPLib_EXPORT ExecuteProcess : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(ExecuteProcess SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString Arguments READ getArguments WRITE setArguments) - - public: - SIMPL_SHARED_POINTERS(ExecuteProcess) - SIMPL_FILTER_NEW_MACRO(ExecuteProcess) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ExecuteProcess, AbstractFilter) - - SIMPL_FILTER_PARAMETER(QString, Arguments) - Q_PROPERTY(QString Arguments READ getArguments WRITE setArguments) - - ~ExecuteProcess() override; - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - ExecuteProcess(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - protected slots: - void processHasFinished(int exitCode, QProcess::ExitStatus exitStatus); - void processHasErroredOut(QProcess::ProcessError error); - void sendErrorOutput(); - void sendStandardOutput(); - - private: - QWaitCondition m_WaitCondition; - QMutex m_Mutex; - bool m_Pause; - QSharedPointer m_ProcessPtr; - - /** - * @brief splitArgumentsString - * @param arguments - * @return - */ - QStringList splitArgumentsString(QString arguments); - - public: - ExecuteProcess(const ExecuteProcess&) = delete; // Copy Constructor Not Implemented - ExecuteProcess(ExecuteProcess&&) = delete; // Move Constructor Not Implemented - ExecuteProcess& operator=(const ExecuteProcess&) = delete; // Copy Assignment Not Implemented - ExecuteProcess& operator=(ExecuteProcess&&) = delete; // Move Assignment Not Implemented -}; + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ExecuteProcess SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(ExecuteProcess) + PYB11_FILTER_NEW_MACRO(ExecuteProcess) + PYB11_PROPERTY(QString Arguments READ getArguments WRITE setArguments) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = ExecuteProcess; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for ExecuteProcess + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ExecuteProcess + */ + static QString ClassName(); + + /** + * @brief Setter property for Arguments + */ + void setArguments(const QString& value); + /** + * @brief Getter property for Arguments + * @return Value of Arguments + */ + QString getArguments() const; + + Q_PROPERTY(QString Arguments READ getArguments WRITE setArguments) + + ~ExecuteProcess() override; + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + ExecuteProcess(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +protected Q_SLOTS: + void processHasFinished(int exitCode, QProcess::ExitStatus exitStatus); + void processHasErroredOut(QProcess::ProcessError error); + void sendErrorOutput(); + void sendStandardOutput(); + +private: + QString m_Arguments = {}; + + QWaitCondition m_WaitCondition; + QMutex m_Mutex; + bool m_Pause = false; + QSharedPointer m_ProcessPtr; + + /** + * @brief splitArgumentsString + * @param arguments + * @return + */ + QStringList splitArgumentsString(QString arguments); + +public: + ExecuteProcess(const ExecuteProcess&) = delete; // Copy Constructor Not Implemented + ExecuteProcess(ExecuteProcess&&) = delete; // Move Constructor Not Implemented + ExecuteProcess& operator=(const ExecuteProcess&) = delete; // Copy Assignment Not Implemented + ExecuteProcess& operator=(ExecuteProcess&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.cpp b/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.cpp index d2eec9d1ca..36026ffbe9 100644 --- a/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.cpp +++ b/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.cpp @@ -26,19 +26,22 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - #include "ExtractAttributeArraysFromGeometry.h" #include #include +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h" #include "SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.h" @@ -50,27 +53,29 @@ #include "SIMPLib/Geometry/TetrahedralGeom.h" #include "SIMPLib/Geometry/TriangleGeom.h" #include "SIMPLib/Geometry/VertexGeom.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + RectGrid_XBoundsID = 1, + RectGrid_YBoundsID, + RectGrid_ZBoundsID, + Vert_SharedVertexID, + Edge_SharedVertexID, + Edge_SharedEdgeID, + Tri_SharedVertexID, + Tri_SharedTriangleID, + Quad_SharedVertexID, + Quad_SharedQuadID, + Tet_SharedVertexID, + Tet_SharedTetID, + Hex_SharedVertexID, + Hex_SharedHexID +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- ExtractAttributeArraysFromGeometry::ExtractAttributeArraysFromGeometry() -: m_DataContainerName("") -, m_SharedVertexListArrayPath0(SIMPL::Defaults::VertexDataContainerName, SIMPL::Defaults::VertexAttributeMatrixName, "VertexCoordinates") -, m_SharedVertexListArrayPath1(SIMPL::Defaults::EdgeDataContainerName, SIMPL::Defaults::VertexAttributeMatrixName, "VertexCoordinates") -, m_SharedVertexListArrayPath2(SIMPL::Defaults::TriangleDataContainerName, SIMPL::Defaults::VertexAttributeMatrixName, "VertexCoordinates") -, m_SharedVertexListArrayPath3(SIMPL::Defaults::QuadDataContainerName, SIMPL::Defaults::VertexAttributeMatrixName, "VertexCoordinates") -, m_SharedVertexListArrayPath4(SIMPL::Defaults::TetrahedralDataContainerName, SIMPL::Defaults::VertexAttributeMatrixName, "VertexCoordinates") -, m_SharedVertexListArrayPath5(SIMPL::Defaults::HexahedralDataContainerName, SIMPL::Defaults::VertexAttributeMatrixName, "VertexCoordinates") -, m_SharedEdgeListArrayPath(SIMPL::Defaults::EdgeDataContainerName, SIMPL::Defaults::EdgeAttributeMatrixName, "EdgeConnectivity") -, m_SharedTriListArrayPath(SIMPL::Defaults::TriangleDataContainerName, SIMPL::Defaults::FaceAttributeMatrixName, "TriangleConnectivity") -, m_SharedQuadListArrayPath(SIMPL::Defaults::QuadDataContainerName, SIMPL::Defaults::FaceAttributeMatrixName, "QuadConnectivity") -, m_SharedTetListArrayPath(SIMPL::Defaults::TetrahedralDataContainerName, SIMPL::Defaults::CellAttributeMatrixName, "TetConnectivity") -, m_SharedHexListArrayPath(SIMPL::Defaults::HexahedralDataContainerName, SIMPL::Defaults::CellAttributeMatrixName, "HexConnectivity") -, m_XBoundsArrayPath("", "", "XBounds") -, m_YBoundsArrayPath("", "", "YBounds") -, m_ZBoundsArrayPath("", "", "ZBounds") { initialize(); } @@ -85,8 +90,8 @@ ExtractAttributeArraysFromGeometry::~ExtractAttributeArraysFromGeometry() = defa // ----------------------------------------------------------------------------- void ExtractAttributeArraysFromGeometry::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -95,14 +100,14 @@ void ExtractAttributeArraysFromGeometry::initialize() // ----------------------------------------------------------------------------- void ExtractAttributeArraysFromGeometry::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { LinkedDataContainerSelectionFilterParameter::Pointer parameter = LinkedDataContainerSelectionFilterParameter::New(); parameter->setHumanLabel("Geometry"); parameter->setPropertyName("DataContainerName"); parameter->setSetterCallback(SIMPL_BIND_SETTER(ExtractAttributeArraysFromGeometry, this, DataContainerName)); parameter->setGetterCallback(SIMPL_BIND_GETTER(ExtractAttributeArraysFromGeometry, this, DataContainerName)); - QStringList linkedProps = { + std::vector linkedProps = { "XBoundsArrayPath", "YBoundsArrayPath", "ZBoundsArrayPath", // RectGridGeom "SharedVertexListArrayPath0", // VertexGeom "SharedVertexListArrayPath1", "SharedEdgeListArrayPath", // EdgeGeom @@ -110,66 +115,67 @@ void ExtractAttributeArraysFromGeometry::setupFilterParameters() "SharedVertexListArrayPath3", "SharedQuadListArrayPath", // QuadGeom "SharedVertexListArrayPath4", "SharedTetListArrayPath", // TetrahedralGeom "SharedVertexListArrayPath5", "SharedHexListArrayPath" // HexahedralGeom - }; + }; parameter->setLinkedProperties(linkedProps); - parameter->setCategory(FilterParameter::Parameter); - IGeometry::Types geomTypes = {IGeometry::Type::RectGrid, IGeometry::Type::Vertex, IGeometry::Type::Edge, IGeometry::Type::Triangle, IGeometry::Type::Quad, IGeometry::Type::Tetrahedral, IGeometry::Type::Hexahedral}; + parameter->setCategory(FilterParameter::Category::Parameter); + IGeometry::Types geomTypes = {IGeometry::Type::RectGrid, IGeometry::Type::Vertex, IGeometry::Type::Edge, IGeometry::Type::Triangle, + IGeometry::Type::Quad, IGeometry::Type::Tetrahedral, IGeometry::Type::Hexahedral}; parameter->setDefaultGeometryTypes(geomTypes); parameters.push_back(parameter); } { DataArrayCreationFilterParameter::RequirementType req = DataArrayCreationFilterParameter::CreateRequirement(AttributeMatrix::Type::Any, IGeometry::Type::RectGrid); parameters.push_back( - SIMPL_NEW_DA_CREATION_FP("X Bounds", XBoundsArrayPath, FilterParameter::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::RectGrid))); + SIMPL_NEW_DA_CREATION_FP("X Bounds", XBoundsArrayPath, FilterParameter::Category::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::RectGrid))); parameters.push_back( - SIMPL_NEW_DA_CREATION_FP("Y Bounds", YBoundsArrayPath, FilterParameter::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::RectGrid))); + SIMPL_NEW_DA_CREATION_FP("Y Bounds", YBoundsArrayPath, FilterParameter::Category::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::RectGrid))); parameters.push_back( - SIMPL_NEW_DA_CREATION_FP("Z Bounds", ZBoundsArrayPath, FilterParameter::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::RectGrid))); + SIMPL_NEW_DA_CREATION_FP("Z Bounds", ZBoundsArrayPath, FilterParameter::Category::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::RectGrid))); } { DataArrayCreationFilterParameter::RequirementType req = DataArrayCreationFilterParameter::CreateRequirement(AttributeMatrix::Type::Vertex, IGeometry::Type::Vertex); - parameters.push_back( - SIMPL_NEW_DA_CREATION_FP("Vertex List", SharedVertexListArrayPath0, FilterParameter::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::Vertex))); + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Vertex List", SharedVertexListArrayPath0, FilterParameter::Category::RequiredArray, ExtractAttributeArraysFromGeometry, req, + static_cast(IGeometry::Type::Vertex))); } { DataArrayCreationFilterParameter::RequirementType req = DataArrayCreationFilterParameter::CreateRequirement(AttributeMatrix::Type::Vertex, IGeometry::Type::Edge); - parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Shared Vertex List", SharedVertexListArrayPath1, FilterParameter::RequiredArray, ExtractAttributeArraysFromGeometry, req, + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Shared Vertex List", SharedVertexListArrayPath1, FilterParameter::Category::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::Edge))); req = DataArrayCreationFilterParameter::CreateRequirement(AttributeMatrix::Type::Edge, IGeometry::Type::Edge); parameters.push_back( - SIMPL_NEW_DA_CREATION_FP("Edge List", SharedEdgeListArrayPath, FilterParameter::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::Edge))); + SIMPL_NEW_DA_CREATION_FP("Edge List", SharedEdgeListArrayPath, FilterParameter::Category::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::Edge))); } { DataArrayCreationFilterParameter::RequirementType req = DataArrayCreationFilterParameter::CreateRequirement(AttributeMatrix::Type::Vertex, IGeometry::Type::Triangle); - parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Shared Vertex List", SharedVertexListArrayPath2, FilterParameter::RequiredArray, ExtractAttributeArraysFromGeometry, req, + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Shared Vertex List", SharedVertexListArrayPath2, FilterParameter::Category::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::Triangle))); req = DataArrayCreationFilterParameter::CreateRequirement(AttributeMatrix::Type::Face, IGeometry::Type::Triangle); - parameters.push_back( - SIMPL_NEW_DA_CREATION_FP("Triangle List", SharedTriListArrayPath, FilterParameter::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::Triangle))); + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Triangle List", SharedTriListArrayPath, FilterParameter::Category::RequiredArray, ExtractAttributeArraysFromGeometry, req, + static_cast(IGeometry::Type::Triangle))); } { DataArrayCreationFilterParameter::RequirementType req = DataArrayCreationFilterParameter::CreateRequirement(AttributeMatrix::Type::Vertex, IGeometry::Type::Quad); - parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Shared Vertex List", SharedVertexListArrayPath3, FilterParameter::RequiredArray, ExtractAttributeArraysFromGeometry, req, + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Shared Vertex List", SharedVertexListArrayPath3, FilterParameter::Category::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::Quad))); req = DataArrayCreationFilterParameter::CreateRequirement(AttributeMatrix::Type::Face, IGeometry::Type::Quad); - parameters.push_back( - SIMPL_NEW_DA_CREATION_FP("Quadrilateral List", SharedQuadListArrayPath, FilterParameter::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::Quad))); + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Quadrilateral List", SharedQuadListArrayPath, FilterParameter::Category::RequiredArray, ExtractAttributeArraysFromGeometry, req, + static_cast(IGeometry::Type::Quad))); } { DataArrayCreationFilterParameter::RequirementType req = DataArrayCreationFilterParameter::CreateRequirement(AttributeMatrix::Type::Vertex, IGeometry::Type::Tetrahedral); - parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Shared Vertex List", SharedVertexListArrayPath4, FilterParameter::RequiredArray, ExtractAttributeArraysFromGeometry, req, + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Shared Vertex List", SharedVertexListArrayPath4, FilterParameter::Category::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::Tetrahedral))); req = DataArrayCreationFilterParameter::CreateRequirement(AttributeMatrix::Type::Cell, IGeometry::Type::Tetrahedral); - parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Tetrahedral List", SharedTetListArrayPath, FilterParameter::RequiredArray, ExtractAttributeArraysFromGeometry, req, + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Tetrahedral List", SharedTetListArrayPath, FilterParameter::Category::RequiredArray, ExtractAttributeArraysFromGeometry, req, static_cast(IGeometry::Type::Tetrahedral))); } { DataArrayCreationFilterParameter::RequirementType req = DataArrayCreationFilterParameter::CreateRequirement(AttributeMatrix::Type::Vertex, IGeometry::Type::Hexahedral); - parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Shared Vertex List", SharedVertexListArrayPath5, FilterParameter::RequiredArray, ExtractAttributeArraysFromGeometry, req, - static_cast(IGeometry::Type::Hexahedral))); + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Shared Vertex List", SharedVertexListArrayPath5, FilterParameter::Category::RequiredArray, ExtractAttributeArraysFromGeometry, req, + static_cast(IGeometry::Type::Hexahedral))); req = DataArrayCreationFilterParameter::CreateRequirement(AttributeMatrix::Type::Cell, IGeometry::Type::Hexahedral); - parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Hexahedral List", SharedHexListArrayPath, FilterParameter::RequiredArray, ExtractAttributeArraysFromGeometry, req, - static_cast(IGeometry::Type::Hexahedral))); + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Hexahedral List", SharedHexListArrayPath, FilterParameter::Category::RequiredArray, ExtractAttributeArraysFromGeometry, req, + static_cast(IGeometry::Type::Hexahedral))); } setFilterParameters(parameters); } @@ -180,7 +186,7 @@ void ExtractAttributeArraysFromGeometry::setupFilterParameters() void ExtractAttributeArraysFromGeometry::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); - setDataContainerName(reader->readString("DataContainerName", getDataContainerName())); + setDataContainerName(reader->readDataArrayPath("DataContainerName", getDataContainerName())); setSharedVertexListArrayPath0(reader->readDataArrayPath("SharedVertexListArrayPath0", getSharedVertexListArrayPath0())); setSharedVertexListArrayPath1(reader->readDataArrayPath("SharedVertexListArrayPath1", getSharedVertexListArrayPath1())); setSharedVertexListArrayPath2(reader->readDataArrayPath("SharedVertexListArrayPath2", getSharedVertexListArrayPath2())); @@ -203,13 +209,13 @@ void ExtractAttributeArraysFromGeometry::readFilterParameters(AbstractFilterPara // ----------------------------------------------------------------------------- void ExtractAttributeArraysFromGeometry::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); initialize(); - IGeometry::Pointer igeom = getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getDataContainerName()); + IGeometry::Pointer igeom = getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getDataContainerName()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -229,41 +235,41 @@ void ExtractAttributeArraysFromGeometry::dataCheck() yarrays.push_back(rectgrid->getYBounds()); zarrays.push_back(rectgrid->getZBounds()); - QVector cDims(1, 1); + std::vector cDims(1, 1); - m_XBoundsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getXBoundsArrayPath(), 0, cDims); + m_XBoundsPtr = getDataContainerArray()->createNonPrereqArrayFromPath>(this, getXBoundsArrayPath(), 0, cDims, "", RectGrid_XBoundsID); if(m_XBoundsPtr.lock()) { m_XBounds = m_XBoundsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { xarrays.push_back(m_XBoundsPtr.lock()); } - m_YBoundsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getYBoundsArrayPath(), 0, cDims); + m_YBoundsPtr = getDataContainerArray()->createNonPrereqArrayFromPath>(this, getYBoundsArrayPath(), 0, cDims, "", RectGrid_YBoundsID); if(m_YBoundsPtr.lock()) { m_YBounds = m_YBoundsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { yarrays.push_back(m_YBoundsPtr.lock()); } - m_ZBoundsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getZBoundsArrayPath(), 0, cDims); + m_ZBoundsPtr = getDataContainerArray()->createNonPrereqArrayFromPath>(this, getZBoundsArrayPath(), 0, cDims, "", RectGrid_ZBoundsID); if(m_ZBoundsPtr.lock()) { m_ZBounds = m_ZBoundsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { zarrays.push_back(m_ZBoundsPtr.lock()); } - getDataContainerArray()->validateNumberOfTuples(this, xarrays); - getDataContainerArray()->validateNumberOfTuples(this, yarrays); - getDataContainerArray()->validateNumberOfTuples(this, zarrays); + getDataContainerArray()->validateNumberOfTuples(this, xarrays); + getDataContainerArray()->validateNumberOfTuples(this, yarrays); + getDataContainerArray()->validateNumberOfTuples(this, zarrays); break; } @@ -274,19 +280,19 @@ void ExtractAttributeArraysFromGeometry::dataCheck() QVector arrays; arrays.push_back(vertex->getVertices()); - QVector cDims(1, 3); + std::vector cDims(1, 3); - m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath0(), 0, cDims); + m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath>(this, getSharedVertexListArrayPath0(), 0, cDims, "", Vert_SharedVertexID); if(m_VertsPtr.lock()) { m_Verts = m_VertsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { arrays.push_back(m_VertsPtr.lock()); } - getDataContainerArray()->validateNumberOfTuples(this, arrays); + getDataContainerArray()->validateNumberOfTuples(this, arrays); break; } @@ -299,32 +305,32 @@ void ExtractAttributeArraysFromGeometry::dataCheck() varrays.push_back(edge->getVertices()); earrays.push_back(edge->getEdges()); - QVector cDims(1, 3); + std::vector cDims(1, 3); - m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath1(), 0, cDims); + m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath>(this, getSharedVertexListArrayPath1(), 0, cDims, "", Edge_SharedVertexID); if(m_VertsPtr.lock()) { m_Verts = m_VertsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { varrays.push_back(m_VertsPtr.lock()); } cDims[0] = 2; - m_EdgesPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedEdgeListArrayPath(), 0, cDims); + m_EdgesPtr = getDataContainerArray()->createNonPrereqArrayFromPath(this, getSharedEdgeListArrayPath(), 0, cDims, "", Edge_SharedEdgeID); if(m_EdgesPtr.lock()) { m_Edges = m_EdgesPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { earrays.push_back(m_EdgesPtr.lock()); } - getDataContainerArray()->validateNumberOfTuples(this, varrays); - getDataContainerArray()->validateNumberOfTuples(this, earrays); + getDataContainerArray()->validateNumberOfTuples(this, varrays); + getDataContainerArray()->validateNumberOfTuples(this, earrays); break; } @@ -337,30 +343,30 @@ void ExtractAttributeArraysFromGeometry::dataCheck() varrays.push_back(triangle->getVertices()); earrays.push_back(triangle->getTriangles()); - QVector cDims(1, 3); + std::vector cDims(1, 3); - m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath2(), 0, cDims); + m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath>(this, getSharedVertexListArrayPath2(), 0, cDims, "", Tri_SharedVertexID); if(m_VertsPtr.lock()) { m_Verts = m_VertsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { varrays.push_back(m_VertsPtr.lock()); } - m_TrisPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedTriListArrayPath(), 0, cDims); + m_TrisPtr = getDataContainerArray()->createNonPrereqArrayFromPath(this, getSharedTriListArrayPath(), 0, cDims, "", Tri_SharedTriangleID); if(m_TrisPtr.lock()) { m_Tris = m_TrisPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { earrays.push_back(m_TrisPtr.lock()); } - getDataContainerArray()->validateNumberOfTuples(this, varrays); - getDataContainerArray()->validateNumberOfTuples(this, earrays); + getDataContainerArray()->validateNumberOfTuples(this, varrays); + getDataContainerArray()->validateNumberOfTuples(this, earrays); break; } @@ -373,32 +379,32 @@ void ExtractAttributeArraysFromGeometry::dataCheck() varrays.push_back(quad->getVertices()); earrays.push_back(quad->getQuads()); - QVector cDims(1, 3); + std::vector cDims(1, 3); - m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath3(), 0, cDims); + m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath>(this, getSharedVertexListArrayPath3(), 0, cDims, "", Quad_SharedVertexID); if(m_VertsPtr.lock()) { m_Verts = m_VertsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { varrays.push_back(m_VertsPtr.lock()); } cDims[0] = 4; - m_QuadsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedQuadListArrayPath(), 0, cDims); + m_QuadsPtr = getDataContainerArray()->createNonPrereqArrayFromPath(this, getSharedQuadListArrayPath(), 0, cDims, "", Quad_SharedQuadID); if(m_QuadsPtr.lock()) { m_Quads = m_QuadsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { earrays.push_back(m_QuadsPtr.lock()); } - getDataContainerArray()->validateNumberOfTuples(this, varrays); - getDataContainerArray()->validateNumberOfTuples(this, earrays); + getDataContainerArray()->validateNumberOfTuples(this, varrays); + getDataContainerArray()->validateNumberOfTuples(this, earrays); break; } @@ -411,32 +417,32 @@ void ExtractAttributeArraysFromGeometry::dataCheck() varrays.push_back(tet->getVertices()); earrays.push_back(tet->getTetrahedra()); - QVector cDims(1, 3); + std::vector cDims(1, 3); - m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath4(), 0, cDims); + m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath>(this, getSharedVertexListArrayPath4(), 0, cDims, "", Tet_SharedVertexID); if(m_VertsPtr.lock()) { m_Verts = m_VertsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { varrays.push_back(m_VertsPtr.lock()); } cDims[0] = 4; - m_TetsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedTetListArrayPath(), 0, cDims); + m_TetsPtr = getDataContainerArray()->createNonPrereqArrayFromPath(this, getSharedTetListArrayPath(), 0, cDims, "", Tet_SharedTetID); if(m_TetsPtr.lock()) { m_Tets = m_TetsPtr.lock()->getPointer(0); } - if(getErrorCondition() >= 0) + if(getErrorCode() >= 0) { earrays.push_back(m_TetsPtr.lock()); } - getDataContainerArray()->validateNumberOfTuples(this, varrays); - getDataContainerArray()->validateNumberOfTuples(this, earrays); + getDataContainerArray()->validateNumberOfTuples(this, varrays); + getDataContainerArray()->validateNumberOfTuples(this, earrays); break; } @@ -449,63 +455,47 @@ void ExtractAttributeArraysFromGeometry::dataCheck() varrays.push_back(hex->getVertices()); earrays.push_back(hex->getHexahedra()); - QVector cDims(1, 3); + std::vector cDims(1, 3); - m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, float>(this, getSharedVertexListArrayPath5(), 0, cDims); - if (m_VertsPtr.lock()) + m_VertsPtr = getDataContainerArray()->createNonPrereqArrayFromPath>(this, getSharedVertexListArrayPath5(), 0, cDims, "", Hex_SharedVertexID); + if(m_VertsPtr.lock()) { m_Verts = m_VertsPtr.lock()->getPointer(0); } - if (getErrorCondition() >= 0) + if(getErrorCode() >= 0) { varrays.push_back(m_VertsPtr.lock()); } cDims[0] = 8; - m_TetsPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, int64_t>(this, getSharedHexListArrayPath(), 0, cDims); - if (m_TetsPtr.lock()) + m_TetsPtr = getDataContainerArray()->createNonPrereqArrayFromPath(this, getSharedHexListArrayPath(), 0, cDims, "", Hex_SharedHexID); + if(m_TetsPtr.lock()) { m_Tets = m_TetsPtr.lock()->getPointer(0); } - if (getErrorCondition() >= 0) + if(getErrorCode() >= 0) { earrays.push_back(m_TetsPtr.lock()); } - getDataContainerArray()->validateNumberOfTuples(this, varrays); - getDataContainerArray()->validateNumberOfTuples(this, earrays); + getDataContainerArray()->validateNumberOfTuples(this, varrays); + getDataContainerArray()->validateNumberOfTuples(this, earrays); break; } - default: - { + default: { QString ss = QObject::tr("Selected Data Container (%1) does not contain a valid geometry\n" "Geometry Type: %2\n" "Valid Geometry Types: Rectilinear Grid, Vertex, Edge, Triangle, Quadrilateral, Tetrahedral") - .arg(getDataContainerName()) + .arg(getDataContainerName().getDataContainerName()) .arg(igeom->getGeometryTypeAsString()); - setErrorCondition(-701); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-701, ss); break; } } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void ExtractAttributeArraysFromGeometry::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -513,12 +503,12 @@ void ExtractAttributeArraysFromGeometry::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - IGeometry::Pointer igeom = getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getDataContainerName()); + IGeometry::Pointer igeom = getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getDataContainerName()); IGeometry::Type geomType = igeom->getGeometryType(); switch(geomType) @@ -628,12 +618,10 @@ void ExtractAttributeArraysFromGeometry::execute() break; } - default: - { + default: { break; } } - } // ----------------------------------------------------------------------------- @@ -652,7 +640,7 @@ AbstractFilter::Pointer ExtractAttributeArraysFromGeometry::newFilterInstance(bo // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractAttributeArraysFromGeometry::getCompiledLibraryName() const +QString ExtractAttributeArraysFromGeometry::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -660,7 +648,7 @@ const QString ExtractAttributeArraysFromGeometry::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractAttributeArraysFromGeometry::getBrandingString() const +QString ExtractAttributeArraysFromGeometry::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -668,7 +656,7 @@ const QString ExtractAttributeArraysFromGeometry::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractAttributeArraysFromGeometry::getFilterVersion() const +QString ExtractAttributeArraysFromGeometry::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -679,7 +667,7 @@ const QString ExtractAttributeArraysFromGeometry::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractAttributeArraysFromGeometry::getGroupName() const +QString ExtractAttributeArraysFromGeometry::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -687,7 +675,7 @@ const QString ExtractAttributeArraysFromGeometry::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid ExtractAttributeArraysFromGeometry::getUuid() +QUuid ExtractAttributeArraysFromGeometry::getUuid() const { return QUuid("{2060a933-b6f5-50fd-9382-a008a5cef17f}"); } @@ -695,7 +683,7 @@ const QUuid ExtractAttributeArraysFromGeometry::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractAttributeArraysFromGeometry::getSubGroupName() const +QString ExtractAttributeArraysFromGeometry::getSubGroupName() const { return SIMPL::FilterSubGroups::GeometryFilters; } @@ -703,7 +691,216 @@ const QString ExtractAttributeArraysFromGeometry::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractAttributeArraysFromGeometry::getHumanLabel() const +QString ExtractAttributeArraysFromGeometry::getHumanLabel() const { return "Extract Attribute Arrays from Geometry"; } + +// ----------------------------------------------------------------------------- +ExtractAttributeArraysFromGeometry::Pointer ExtractAttributeArraysFromGeometry::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr ExtractAttributeArraysFromGeometry::New() +{ + struct make_shared_enabler : public ExtractAttributeArraysFromGeometry + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString ExtractAttributeArraysFromGeometry::getNameOfClass() const +{ + return QString("ExtractAttributeArraysFromGeometry"); +} + +// ----------------------------------------------------------------------------- +QString ExtractAttributeArraysFromGeometry::ClassName() +{ + return QString("ExtractAttributeArraysFromGeometry"); +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setDataContainerName(const DataArrayPath& value) +{ + m_DataContainerName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getDataContainerName() const +{ + return m_DataContainerName; +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setSharedVertexListArrayPath0(const DataArrayPath& value) +{ + m_SharedVertexListArrayPath0 = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getSharedVertexListArrayPath0() const +{ + return m_SharedVertexListArrayPath0; +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setSharedVertexListArrayPath1(const DataArrayPath& value) +{ + m_SharedVertexListArrayPath1 = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getSharedVertexListArrayPath1() const +{ + return m_SharedVertexListArrayPath1; +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setSharedVertexListArrayPath2(const DataArrayPath& value) +{ + m_SharedVertexListArrayPath2 = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getSharedVertexListArrayPath2() const +{ + return m_SharedVertexListArrayPath2; +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setSharedVertexListArrayPath3(const DataArrayPath& value) +{ + m_SharedVertexListArrayPath3 = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getSharedVertexListArrayPath3() const +{ + return m_SharedVertexListArrayPath3; +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setSharedVertexListArrayPath4(const DataArrayPath& value) +{ + m_SharedVertexListArrayPath4 = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getSharedVertexListArrayPath4() const +{ + return m_SharedVertexListArrayPath4; +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setSharedVertexListArrayPath5(const DataArrayPath& value) +{ + m_SharedVertexListArrayPath5 = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getSharedVertexListArrayPath5() const +{ + return m_SharedVertexListArrayPath5; +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setSharedEdgeListArrayPath(const DataArrayPath& value) +{ + m_SharedEdgeListArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getSharedEdgeListArrayPath() const +{ + return m_SharedEdgeListArrayPath; +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setSharedTriListArrayPath(const DataArrayPath& value) +{ + m_SharedTriListArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getSharedTriListArrayPath() const +{ + return m_SharedTriListArrayPath; +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setSharedQuadListArrayPath(const DataArrayPath& value) +{ + m_SharedQuadListArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getSharedQuadListArrayPath() const +{ + return m_SharedQuadListArrayPath; +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setSharedTetListArrayPath(const DataArrayPath& value) +{ + m_SharedTetListArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getSharedTetListArrayPath() const +{ + return m_SharedTetListArrayPath; +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setSharedHexListArrayPath(const DataArrayPath& value) +{ + m_SharedHexListArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getSharedHexListArrayPath() const +{ + return m_SharedHexListArrayPath; +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setXBoundsArrayPath(const DataArrayPath& value) +{ + m_XBoundsArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getXBoundsArrayPath() const +{ + return m_XBoundsArrayPath; +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setYBoundsArrayPath(const DataArrayPath& value) +{ + m_YBoundsArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getYBoundsArrayPath() const +{ + return m_YBoundsArrayPath; +} + +// ----------------------------------------------------------------------------- +void ExtractAttributeArraysFromGeometry::setZBoundsArrayPath(const DataArrayPath& value) +{ + m_ZBoundsArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractAttributeArraysFromGeometry::getZBoundsArrayPath() const +{ + return m_ZBoundsArrayPath; +} diff --git a/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.h b/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.h index f1b70737e3..877f9e4db4 100644 --- a/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.h +++ b/Source/SIMPLib/CoreFilters/ExtractAttributeArraysFromGeometry.h @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,9 +35,14 @@ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/Filtering/AbstractFilter.h" +#include "SIMPLib/Geometry/IGeometry.h" + +using MeshIndexType = size_t; /** * @brief The ExtractAttributeArraysFromGeometry class. See [Filter documentation](@ref ExtractAttributeArraysFromGeometry) for details. @@ -45,8 +50,13 @@ class SIMPLib_EXPORT ExtractAttributeArraysFromGeometry : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(ExtractAttributeArraysFromGeometry SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ExtractAttributeArraysFromGeometry SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(ExtractAttributeArraysFromGeometry) + PYB11_FILTER_NEW_MACRO(ExtractAttributeArraysFromGeometry) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) PYB11_PROPERTY(DataArrayPath SharedVertexListArrayPath0 READ getSharedVertexListArrayPath0 WRITE setSharedVertexListArrayPath0) PYB11_PROPERTY(DataArrayPath SharedVertexListArrayPath1 READ getSharedVertexListArrayPath1 WRITE setSharedVertexListArrayPath1) PYB11_PROPERTY(DataArrayPath SharedVertexListArrayPath2 READ getSharedVertexListArrayPath2 WRITE setSharedVertexListArrayPath2) @@ -59,77 +69,237 @@ class SIMPLib_EXPORT ExtractAttributeArraysFromGeometry : public AbstractFilter PYB11_PROPERTY(DataArrayPath XBoundsArrayPath READ getXBoundsArrayPath WRITE setXBoundsArrayPath) PYB11_PROPERTY(DataArrayPath YBoundsArrayPath READ getYBoundsArrayPath WRITE setYBoundsArrayPath) PYB11_PROPERTY(DataArrayPath ZBoundsArrayPath READ getZBoundsArrayPath WRITE setZBoundsArrayPath) + PYB11_END_BINDINGS() + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(ExtractAttributeArraysFromGeometry) - SIMPL_FILTER_NEW_MACRO(ExtractAttributeArraysFromGeometry) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ExtractAttributeArraysFromGeometry, AbstractFilter) + using Self = ExtractAttributeArraysFromGeometry; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for ExtractAttributeArraysFromGeometry + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ExtractAttributeArraysFromGeometry + */ + static QString ClassName(); ~ExtractAttributeArraysFromGeometry() override; - SIMPL_FILTER_PARAMETER(QString, DataContainerName) - Q_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + /** + * @brief Setter property for DataContainerName + */ + void setDataContainerName(const DataArrayPath& value); + /** + * @brief Getter property for DataContainerName + * @return Value of DataContainerName + */ + DataArrayPath getDataContainerName() const; + + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + + /** + * @brief Setter property for SharedVertexListArrayPath0 + */ + void setSharedVertexListArrayPath0(const DataArrayPath& value); + /** + * @brief Getter property for SharedVertexListArrayPath0 + * @return Value of SharedVertexListArrayPath0 + */ + DataArrayPath getSharedVertexListArrayPath0() const; - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedVertexListArrayPath0) Q_PROPERTY(DataArrayPath SharedVertexListArrayPath0 READ getSharedVertexListArrayPath0 WRITE setSharedVertexListArrayPath0) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedVertexListArrayPath1) + /** + * @brief Setter property for SharedVertexListArrayPath1 + */ + void setSharedVertexListArrayPath1(const DataArrayPath& value); + /** + * @brief Getter property for SharedVertexListArrayPath1 + * @return Value of SharedVertexListArrayPath1 + */ + DataArrayPath getSharedVertexListArrayPath1() const; + Q_PROPERTY(DataArrayPath SharedVertexListArrayPath1 READ getSharedVertexListArrayPath1 WRITE setSharedVertexListArrayPath1) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedVertexListArrayPath2) + /** + * @brief Setter property for SharedVertexListArrayPath2 + */ + void setSharedVertexListArrayPath2(const DataArrayPath& value); + /** + * @brief Getter property for SharedVertexListArrayPath2 + * @return Value of SharedVertexListArrayPath2 + */ + DataArrayPath getSharedVertexListArrayPath2() const; + Q_PROPERTY(DataArrayPath SharedVertexListArrayPath2 READ getSharedVertexListArrayPath2 WRITE setSharedVertexListArrayPath2) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedVertexListArrayPath3) + /** + * @brief Setter property for SharedVertexListArrayPath3 + */ + void setSharedVertexListArrayPath3(const DataArrayPath& value); + /** + * @brief Getter property for SharedVertexListArrayPath3 + * @return Value of SharedVertexListArrayPath3 + */ + DataArrayPath getSharedVertexListArrayPath3() const; + Q_PROPERTY(DataArrayPath SharedVertexListArrayPath3 READ getSharedVertexListArrayPath3 WRITE setSharedVertexListArrayPath3) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedVertexListArrayPath4) + /** + * @brief Setter property for SharedVertexListArrayPath4 + */ + void setSharedVertexListArrayPath4(const DataArrayPath& value); + /** + * @brief Getter property for SharedVertexListArrayPath4 + * @return Value of SharedVertexListArrayPath4 + */ + DataArrayPath getSharedVertexListArrayPath4() const; + Q_PROPERTY(DataArrayPath SharedVertexListArrayPath4 READ getSharedVertexListArrayPath4 WRITE setSharedVertexListArrayPath4) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedVertexListArrayPath5) + /** + * @brief Setter property for SharedVertexListArrayPath5 + */ + void setSharedVertexListArrayPath5(const DataArrayPath& value); + /** + * @brief Getter property for SharedVertexListArrayPath5 + * @return Value of SharedVertexListArrayPath5 + */ + DataArrayPath getSharedVertexListArrayPath5() const; + Q_PROPERTY(DataArrayPath SharedVertexListArrayPath5 READ getSharedVertexListArrayPath5 WRITE setSharedVertexListArrayPath5) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedEdgeListArrayPath) + /** + * @brief Setter property for SharedEdgeListArrayPath + */ + void setSharedEdgeListArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SharedEdgeListArrayPath + * @return Value of SharedEdgeListArrayPath + */ + DataArrayPath getSharedEdgeListArrayPath() const; + Q_PROPERTY(DataArrayPath SharedEdgeListArrayPath READ getSharedEdgeListArrayPath WRITE setSharedEdgeListArrayPath) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedTriListArrayPath) + /** + * @brief Setter property for SharedTriListArrayPath + */ + void setSharedTriListArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SharedTriListArrayPath + * @return Value of SharedTriListArrayPath + */ + DataArrayPath getSharedTriListArrayPath() const; + Q_PROPERTY(DataArrayPath SharedTriListArrayPath READ getSharedTriListArrayPath WRITE setSharedTriListArrayPath) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedQuadListArrayPath) + /** + * @brief Setter property for SharedQuadListArrayPath + */ + void setSharedQuadListArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SharedQuadListArrayPath + * @return Value of SharedQuadListArrayPath + */ + DataArrayPath getSharedQuadListArrayPath() const; + Q_PROPERTY(DataArrayPath SharedQuadListArrayPath READ getSharedQuadListArrayPath WRITE setSharedQuadListArrayPath) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedTetListArrayPath) + /** + * @brief Setter property for SharedTetListArrayPath + */ + void setSharedTetListArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SharedTetListArrayPath + * @return Value of SharedTetListArrayPath + */ + DataArrayPath getSharedTetListArrayPath() const; + Q_PROPERTY(DataArrayPath SharedTetListArrayPath READ getSharedTetListArrayPath WRITE setSharedTetListArrayPath) - SIMPL_FILTER_PARAMETER(DataArrayPath, SharedHexListArrayPath) + /** + * @brief Setter property for SharedHexListArrayPath + */ + void setSharedHexListArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SharedHexListArrayPath + * @return Value of SharedHexListArrayPath + */ + DataArrayPath getSharedHexListArrayPath() const; + Q_PROPERTY(DataArrayPath SharedHexListArrayPath READ getSharedHexListArrayPath WRITE setSharedHexListArrayPath) - SIMPL_FILTER_PARAMETER(DataArrayPath, XBoundsArrayPath) + /** + * @brief Setter property for XBoundsArrayPath + */ + void setXBoundsArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for XBoundsArrayPath + * @return Value of XBoundsArrayPath + */ + DataArrayPath getXBoundsArrayPath() const; + Q_PROPERTY(DataArrayPath XBoundsArrayPath READ getXBoundsArrayPath WRITE setXBoundsArrayPath) - SIMPL_FILTER_PARAMETER(DataArrayPath, YBoundsArrayPath) + /** + * @brief Setter property for YBoundsArrayPath + */ + void setYBoundsArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for YBoundsArrayPath + * @return Value of YBoundsArrayPath + */ + DataArrayPath getYBoundsArrayPath() const; + Q_PROPERTY(DataArrayPath YBoundsArrayPath READ getYBoundsArrayPath WRITE setYBoundsArrayPath) - SIMPL_FILTER_PARAMETER(DataArrayPath, ZBoundsArrayPath) + /** + * @brief Setter property for ZBoundsArrayPath + */ + void setZBoundsArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for ZBoundsArrayPath + * @return Value of ZBoundsArrayPath + */ + DataArrayPath getZBoundsArrayPath() const; + Q_PROPERTY(DataArrayPath ZBoundsArrayPath READ getZBoundsArrayPath WRITE setZBoundsArrayPath) /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class */ - const QString getCompiledLibraryName() const override; + QString getCompiledLibraryName() const override; /** * @brief getBrandingString Returns the branding string for the filter, which is a tag * used to denote the filter's association with specific plugins * @return Branding string */ - const QString getBrandingString() const override; + QString getBrandingString() const override; /** * @brief getFilterVersion Returns a version string for this filter. Default * value is an empty string. * @return */ - const QString getFilterVersion() const override; + QString getFilterVersion() const override; /** * @brief newFilterInstance Reimplemented from @see AbstractFilter class @@ -139,23 +309,23 @@ class SIMPLib_EXPORT ExtractAttributeArraysFromGeometry : public AbstractFilter /** * @brief getGroupName Reimplemented from @see AbstractFilter class */ - const QString getGroupName() const override; + QString getGroupName() const override; /** * @brief getSubGroupName Reimplemented from @see AbstractFilter class */ - const QString getSubGroupName() const override; + QString getSubGroupName() const override; /** * @brief getUuid Return the unique identifier for this filter. * @return A QUuid object. */ - const QUuid getUuid() override; + QUuid getUuid() const override; /** * @brief getHumanLabel Reimplemented from @see AbstractFilter class */ - const QString getHumanLabel() const override; + QString getHumanLabel() const override; /** * @brief setupFilterParameters Reimplemented from @see AbstractFilter class @@ -172,41 +342,13 @@ class SIMPLib_EXPORT ExtractAttributeArraysFromGeometry : public AbstractFilter */ void execute() override; - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - -signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - protected: ExtractAttributeArraysFromGeometry(); /** * @brief dataCheck Checks for the appropriate parameter values and availability of arrays */ - void dataCheck(); + void dataCheck() override; /** * @brief Initializes all the private instance variables. @@ -214,14 +356,38 @@ class SIMPLib_EXPORT ExtractAttributeArraysFromGeometry : public AbstractFilter void initialize(); private: - DEFINE_DATAARRAY_VARIABLE(float, XBounds) - DEFINE_DATAARRAY_VARIABLE(float, YBounds) - DEFINE_DATAARRAY_VARIABLE(float, ZBounds) - DEFINE_DATAARRAY_VARIABLE(float, Verts) - DEFINE_DATAARRAY_VARIABLE(int64_t, Edges) - DEFINE_DATAARRAY_VARIABLE(int64_t, Tris) - DEFINE_DATAARRAY_VARIABLE(int64_t, Quads) - DEFINE_DATAARRAY_VARIABLE(int64_t, Tets) + std::weak_ptr> m_XBoundsPtr; + float* m_XBounds = nullptr; + std::weak_ptr> m_YBoundsPtr; + float* m_YBounds = nullptr; + std::weak_ptr> m_ZBoundsPtr; + float* m_ZBounds = nullptr; + std::weak_ptr> m_VertsPtr; + float* m_Verts = nullptr; + std::weak_ptr> m_EdgesPtr; + MeshIndexType* m_Edges = nullptr; + std::weak_ptr> m_TrisPtr; + MeshIndexType* m_Tris = nullptr; + std::weak_ptr> m_QuadsPtr; + MeshIndexType* m_Quads = nullptr; + std::weak_ptr> m_TetsPtr; + MeshIndexType* m_Tets = nullptr; + + DataArrayPath m_DataContainerName = {"", "", ""}; + DataArrayPath m_SharedVertexListArrayPath0 = {SIMPL::Defaults::VertexDataContainerName, SIMPL::Defaults::VertexAttributeMatrixName, "VertexCoordinates"}; + DataArrayPath m_SharedVertexListArrayPath1 = {SIMPL::Defaults::EdgeDataContainerName, SIMPL::Defaults::VertexAttributeMatrixName, "VertexCoordinates"}; + DataArrayPath m_SharedVertexListArrayPath2 = {SIMPL::Defaults::TriangleDataContainerName, SIMPL::Defaults::VertexAttributeMatrixName, "VertexCoordinates"}; + DataArrayPath m_SharedVertexListArrayPath3 = {SIMPL::Defaults::QuadDataContainerName, SIMPL::Defaults::VertexAttributeMatrixName, "VertexCoordinates"}; + DataArrayPath m_SharedVertexListArrayPath4 = {SIMPL::Defaults::TetrahedralDataContainerName, SIMPL::Defaults::VertexAttributeMatrixName, "VertexCoordinates"}; + DataArrayPath m_SharedVertexListArrayPath5 = {SIMPL::Defaults::HexahedralDataContainerName, SIMPL::Defaults::VertexAttributeMatrixName, "VertexCoordinates"}; + DataArrayPath m_SharedEdgeListArrayPath = {SIMPL::Defaults::EdgeDataContainerName, SIMPL::Defaults::EdgeAttributeMatrixName, "EdgeConnectivity"}; + DataArrayPath m_SharedTriListArrayPath = {SIMPL::Defaults::TriangleDataContainerName, SIMPL::Defaults::FaceAttributeMatrixName, "TriangleConnectivity"}; + DataArrayPath m_SharedQuadListArrayPath = {SIMPL::Defaults::QuadDataContainerName, SIMPL::Defaults::FaceAttributeMatrixName, "QuadConnectivity"}; + DataArrayPath m_SharedTetListArrayPath = {SIMPL::Defaults::TetrahedralDataContainerName, SIMPL::Defaults::CellAttributeMatrixName, "TetConnectivity"}; + DataArrayPath m_SharedHexListArrayPath = {SIMPL::Defaults::HexahedralDataContainerName, SIMPL::Defaults::CellAttributeMatrixName, "HexConnectivity"}; + DataArrayPath m_XBoundsArrayPath = {"", "", "XBounds"}; + DataArrayPath m_YBoundsArrayPath = {"", "", "YBounds"}; + DataArrayPath m_ZBoundsArrayPath = {"", "", "ZBounds"}; public: ExtractAttributeArraysFromGeometry(const ExtractAttributeArraysFromGeometry&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SIMPLib/CoreFilters/ExtractComponentAsArray.cpp b/Source/SIMPLib/CoreFilters/ExtractComponentAsArray.cpp index 1f1c982c58..e8fd742773 100644 --- a/Source/SIMPLib/CoreFilters/ExtractComponentAsArray.cpp +++ b/Source/SIMPLib/CoreFilters/ExtractComponentAsArray.cpp @@ -1,58 +1,61 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ExtractComponentAsArray.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/IntFilterParameter.h" +#include "SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.h" #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + DataArrayID = 1 +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ExtractComponentAsArray::ExtractComponentAsArray() -: m_SelectedArrayPath("", "", "") -, m_CompNumber(0) -, m_NewArrayArrayName("") -{ -} +ExtractComponentAsArray::ExtractComponentAsArray() = default; // ----------------------------------------------------------------------------- // @@ -64,16 +67,17 @@ ExtractComponentAsArray::~ExtractComponentAsArray() = default; // ----------------------------------------------------------------------------- void ExtractComponentAsArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(SIMPL_NEW_INTEGER_FP("Component Number to Extract", CompNumber, FilterParameter::Parameter, ExtractComponentAsArray)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Component Number to Extract", CompNumber, FilterParameter::Category::Parameter, ExtractComponentAsArray)); { DataArraySelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Multicomponent Attribute Array", SelectedArrayPath, FilterParameter::RequiredArray, ExtractComponentAsArray, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Multicomponent Attribute Array", SelectedArrayPath, FilterParameter::Category::RequiredArray, ExtractComponentAsArray, req)); } - parameters.push_back(SIMPL_NEW_STRING_FP("Scalar Attribute Array", NewArrayArrayName, FilterParameter::CreatedArray, ExtractComponentAsArray)); + parameters.push_back( + SIMPL_NEW_DA_WITH_LINKED_AM_FP("Scalar Attribute Array", NewArrayArrayName, SelectedArrayPath, SelectedArrayPath, FilterParameter::Category::CreatedArray, ExtractComponentAsArray)); setFilterParameters(parameters); } @@ -102,19 +106,18 @@ void ExtractComponentAsArray::initialize() // ----------------------------------------------------------------------------- void ExtractComponentAsArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - m_InArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArrayPath()); + m_InArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArrayPath()); if(m_NewArrayArrayName.isEmpty()) { - setErrorCondition(-11003); - notifyErrorMessage(getHumanLabel(), "New array name must be set.", getErrorCondition()); + setErrorCondition(-11003, "New array name must be set."); return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -124,53 +127,37 @@ void ExtractComponentAsArray::dataCheck() QString ss = QObject::tr("Selected array '%1' must have more than 1 component. The number of components is %2") .arg(getSelectedArrayPath().getDataArrayName()) .arg(m_InArrayPtr.lock()->getNumberOfComponents()); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); return; } if(m_CompNumber >= m_InArrayPtr.lock()->getNumberOfComponents()) { - setErrorCondition(-11004); QString ss = QObject::tr("Error extracting component from DataArray '%3', Component to extract (%1) is greater than or equal to the number of components (%2).") .arg(m_CompNumber) .arg(m_InArrayPtr.lock()->getNumberOfComponents()) .arg(getSelectedArrayPath().getDataArrayName()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11004, ss); return; } if(m_CompNumber < 0) { - setErrorCondition(-11005); - QString ss = QObject::tr("Component to extract (%1) is a negative value and this is not allowed. Value must be Zero (0) or greater.") - .arg(m_CompNumber); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + QString ss = QObject::tr("Component to extract (%1) is a negative value and this is not allowed. Value must be Zero (0) or greater.").arg(m_CompNumber); + setErrorCondition(-11005, ss); return; } - QVector cDims(1, 1); + std::vector cDims(1, 1); DataArrayPath tempPath(getSelectedArrayPath().getDataContainerName(), getSelectedArrayPath().getAttributeMatrixName(), getNewArrayArrayName()); - m_NewArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, m_InArrayPtr.lock()); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void ExtractComponentAsArray::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); + m_NewArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, m_InArrayPtr.lock(), DataArrayID); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void extractComponent(IDataArray::Pointer inputData, IDataArray::Pointer newData, int compNumber) +template +void extractComponent(IDataArray::Pointer inputData, IDataArray::Pointer newData, int compNumber) { typename DataArray::Pointer inputArrayPtr = std::dynamic_pointer_cast>(inputData); typename DataArray::Pointer newArrayPtr = std::dynamic_pointer_cast>(newData); @@ -196,16 +183,13 @@ template void extractComponent(IDataArray::Pointer inputData, IData // ----------------------------------------------------------------------------- void ExtractComponentAsArray::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } EXECUTE_FUNCTION_TEMPLATE(this, extractComponent, m_InArrayPtr.lock(), m_InArrayPtr.lock(), m_NewArrayPtr.lock(), m_CompNumber) - } // ----------------------------------------------------------------------------- @@ -224,7 +208,7 @@ AbstractFilter::Pointer ExtractComponentAsArray::newFilterInstance(bool copyFilt // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractComponentAsArray::getCompiledLibraryName() const +QString ExtractComponentAsArray::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -232,7 +216,7 @@ const QString ExtractComponentAsArray::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractComponentAsArray::getBrandingString() const +QString ExtractComponentAsArray::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -240,7 +224,7 @@ const QString ExtractComponentAsArray::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractComponentAsArray::getFilterVersion() const +QString ExtractComponentAsArray::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -251,7 +235,7 @@ const QString ExtractComponentAsArray::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractComponentAsArray::getGroupName() const +QString ExtractComponentAsArray::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -259,7 +243,7 @@ const QString ExtractComponentAsArray::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid ExtractComponentAsArray::getUuid() +QUuid ExtractComponentAsArray::getUuid() const { return QUuid("{79d59b85-01e8-5c4a-a6e1-3fd3e2ceffb4}"); } @@ -267,7 +251,7 @@ const QUuid ExtractComponentAsArray::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractComponentAsArray::getSubGroupName() const +QString ExtractComponentAsArray::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -275,7 +259,72 @@ const QString ExtractComponentAsArray::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractComponentAsArray::getHumanLabel() const +QString ExtractComponentAsArray::getHumanLabel() const { return "Extract Component as Attribute Array"; } + +// ----------------------------------------------------------------------------- +ExtractComponentAsArray::Pointer ExtractComponentAsArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr ExtractComponentAsArray::New() +{ + struct make_shared_enabler : public ExtractComponentAsArray + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString ExtractComponentAsArray::getNameOfClass() const +{ + return QString("ExtractComponentAsArray"); +} + +// ----------------------------------------------------------------------------- +QString ExtractComponentAsArray::ClassName() +{ + return QString("ExtractComponentAsArray"); +} + +// ----------------------------------------------------------------------------- +void ExtractComponentAsArray::setSelectedArrayPath(const DataArrayPath& value) +{ + m_SelectedArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractComponentAsArray::getSelectedArrayPath() const +{ + return m_SelectedArrayPath; +} + +// ----------------------------------------------------------------------------- +void ExtractComponentAsArray::setCompNumber(int value) +{ + m_CompNumber = value; +} + +// ----------------------------------------------------------------------------- +int ExtractComponentAsArray::getCompNumber() const +{ + return m_CompNumber; +} + +// ----------------------------------------------------------------------------- +void ExtractComponentAsArray::setNewArrayArrayName(const QString& value) +{ + m_NewArrayArrayName = value; +} + +// ----------------------------------------------------------------------------- +QString ExtractComponentAsArray::getNewArrayArrayName() const +{ + return m_NewArrayArrayName; +} diff --git a/Source/SIMPLib/CoreFilters/ExtractComponentAsArray.h b/Source/SIMPLib/CoreFilters/ExtractComponentAsArray.h old mode 100755 new mode 100644 index 0f52d499ad..71fba57037 --- a/Source/SIMPLib/CoreFilters/ExtractComponentAsArray.h +++ b/Source/SIMPLib/CoreFilters/ExtractComponentAsArray.h @@ -1,181 +1,208 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +class IDataArray; +using IDataArrayWkPtrType = std::weak_ptr; + +class IDataArray; /** * @brief The ExtractComponentAsArray class. See [Filter documentation](@ref extractcomponentasarray) for details. */ class SIMPLib_EXPORT ExtractComponentAsArray : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(ExtractComponentAsArray SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) - PYB11_PROPERTY(int CompNumber READ getCompNumber WRITE setCompNumber) - PYB11_PROPERTY(QString NewArrayArrayName READ getNewArrayArrayName WRITE setNewArrayArrayName) - - public: - SIMPL_SHARED_POINTERS(ExtractComponentAsArray) - SIMPL_FILTER_NEW_MACRO(ExtractComponentAsArray) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ExtractComponentAsArray, AbstractFilter) - - ~ExtractComponentAsArray() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedArrayPath) - Q_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) - - SIMPL_FILTER_PARAMETER(int, CompNumber) - Q_PROPERTY(int CompNumber READ getCompNumber WRITE setCompNumber) - - SIMPL_FILTER_PARAMETER(QString, NewArrayArrayName) - Q_PROPERTY(QString NewArrayArrayName READ getNewArrayArrayName WRITE setNewArrayArrayName) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - ExtractComponentAsArray(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - DEFINE_IDATAARRAY_WEAKPTR(InArray) - DEFINE_IDATAARRAY_WEAKPTR(NewArray) - - public: - ExtractComponentAsArray(const ExtractComponentAsArray&) = delete; // Copy Constructor Not Implemented - ExtractComponentAsArray(ExtractComponentAsArray&&) = delete; // Move Constructor Not Implemented - ExtractComponentAsArray& operator=(const ExtractComponentAsArray&) = delete; // Copy Assignment Not Implemented - ExtractComponentAsArray& operator=(ExtractComponentAsArray&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ExtractComponentAsArray SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(ExtractComponentAsArray) + PYB11_FILTER_NEW_MACRO(ExtractComponentAsArray) + PYB11_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) + PYB11_PROPERTY(int CompNumber READ getCompNumber WRITE setCompNumber) + PYB11_PROPERTY(QString NewArrayArrayName READ getNewArrayArrayName WRITE setNewArrayArrayName) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = ExtractComponentAsArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for ExtractComponentAsArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ExtractComponentAsArray + */ + static QString ClassName(); + + ~ExtractComponentAsArray() override; + + /** + * @brief Setter property for SelectedArrayPath + */ + void setSelectedArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SelectedArrayPath + * @return Value of SelectedArrayPath + */ + DataArrayPath getSelectedArrayPath() const; + + Q_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) + + /** + * @brief Setter property for CompNumber + */ + void setCompNumber(int value); + /** + * @brief Getter property for CompNumber + * @return Value of CompNumber + */ + int getCompNumber() const; + + Q_PROPERTY(int CompNumber READ getCompNumber WRITE setCompNumber) + + /** + * @brief Setter property for NewArrayArrayName + */ + void setNewArrayArrayName(const QString& value); + /** + * @brief Getter property for NewArrayArrayName + * @return Value of NewArrayArrayName + */ + QString getNewArrayArrayName() const; + + Q_PROPERTY(QString NewArrayArrayName READ getNewArrayArrayName WRITE setNewArrayArrayName) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + ExtractComponentAsArray(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + IDataArrayWkPtrType m_InArrayPtr; + IDataArrayWkPtrType m_NewArrayPtr; + + DataArrayPath m_SelectedArrayPath = {"", "", ""}; + int m_CompNumber = {0}; + QString m_NewArrayArrayName = {""}; + +public: + ExtractComponentAsArray(const ExtractComponentAsArray&) = delete; // Copy Constructor Not Implemented + ExtractComponentAsArray(ExtractComponentAsArray&&) = delete; // Move Constructor Not Implemented + ExtractComponentAsArray& operator=(const ExtractComponentAsArray&) = delete; // Copy Assignment Not Implemented + ExtractComponentAsArray& operator=(ExtractComponentAsArray&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.cpp b/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.cpp index 9d15a10aeb..5f538250ad 100644 --- a/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.cpp +++ b/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.cpp @@ -26,32 +26,38 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - #include "ExtractVertexGeometry.h" #include +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/BooleanFilterParameter.h" #include "SIMPLib/FilterParameters/ChoiceFilterParameter.h" #include "SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h" #include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + DataContainerID = 1, + AttributeMatrixID +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- ExtractVertexGeometry::ExtractVertexGeometry() -: m_ArrayHandling(static_cast(ArrayHandlingType::MoveArrays)) -, m_SelectedDataContainerName() -, m_VertexDataContainerName("VertexDataContainer") { initialize(); } @@ -66,8 +72,8 @@ ExtractVertexGeometry::~ExtractVertexGeometry() = default; // ----------------------------------------------------------------------------- void ExtractVertexGeometry::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -79,36 +85,34 @@ void ExtractVertexGeometry::setupFilterParameters() m_NewDCGeometryChoices.clear(); m_ArrayHandlingChoices.clear(); - FilterParameterVector parameters; + FilterParameterVectorType parameters; // { // m_NewDCGeometryChoices.push_back("Vertex Geometry"); // // Create the Choice Filter Parameter and add it to the list of parameters - // parameters.push_back(SIMPL_NEW_CHOICE_FP("New Data Container Geometry", NewDataContainerGeometry, FilterParameter::Parameter, ExtractVertexGeometry, m_NewDCGeometryChoices, false)); + // parameters.push_back(SIMPL_NEW_CHOICE_FP("New Data Container Geometry", NewDataContainerGeometry, FilterParameter::Category::Parameter, ExtractVertexGeometry, m_NewDCGeometryChoices, false)); // } { m_ArrayHandlingChoices.push_back("Move Attribute Arrays"); m_ArrayHandlingChoices.push_back("Copy Attribute Arrays"); // Create the Choice Filter Parameter and add it to the list of parameters - parameters.push_back(SIMPL_NEW_CHOICE_FP("Array Handling", ArrayHandling, FilterParameter::Parameter, ExtractVertexGeometry, m_ArrayHandlingChoices, false)); + parameters.push_back(SIMPL_NEW_CHOICE_FP("Array Handling", ArrayHandling, FilterParameter::Category::Parameter, ExtractVertexGeometry, m_ArrayHandlingChoices, false)); } { DataContainerSelectionFilterParameter::RequirementType req; - req.dcGeometryTypes = IGeometry::Types(2); - req.dcGeometryTypes[0] = IGeometry::Type::Image; - req.dcGeometryTypes[0] = IGeometry::Type::RectGrid; - parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container with Input Geometry", SelectedDataContainerName, FilterParameter::RequiredArray, ExtractVertexGeometry, req)); + req.dcGeometryTypes = {IGeometry::Type::Image, IGeometry::Type::RectGrid}; + parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container with Input Geometry", SelectedDataContainerName, FilterParameter::Category::RequiredArray, ExtractVertexGeometry, req)); } { MultiDataArraySelectionFilterParameter::RequirementType req; req.amTypes = AttributeMatrix::Types(1, AttributeMatrix::Type::Cell); - parameters.push_back(SIMPL_NEW_MDA_SELECTION_FP("Included Attribute Arrays", IncludedDataArrayPaths, FilterParameter::RequiredArray, ExtractVertexGeometry, req)); + parameters.push_back(SIMPL_NEW_MDA_SELECTION_FP("Included Attribute Arrays", IncludedDataArrayPaths, FilterParameter::Category::RequiredArray, ExtractVertexGeometry, req)); } - parameters.push_back(SIMPL_NEW_DC_CREATION_FP("Vertex Data Container Name", VertexDataContainerName, FilterParameter::CreatedArray, ExtractVertexGeometry)); + parameters.push_back(SIMPL_NEW_DC_CREATION_FP("Vertex Data Container Name", VertexDataContainerName, FilterParameter::Category::CreatedArray, ExtractVertexGeometry)); setFilterParameters(parameters); } @@ -118,35 +122,32 @@ void ExtractVertexGeometry::setupFilterParameters() // ----------------------------------------------------------------------------- void ExtractVertexGeometry::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(m_ArrayHandling < 0) { QString ss = QObject::tr("'Array Handling' has not been selected."); - setErrorCondition(-2002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-2002, ss); return; } if(m_ArrayHandling > m_ArrayHandlingChoices.size() - 1) { QString ss = QObject::tr("'Array Handling' index is out of bounds. Valid values are 0 or 1."); - setErrorCondition(-2003); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-2003, ss); return; } if(m_SelectedDataContainerName.isEmpty()) { QString ss = QObject::tr("The name of the input DataContainer is empty. Please specify a value."); - setErrorCondition(-2004); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-2004, ss); return; } - DataContainer::Pointer dc = getDataContainerArray()->getPrereqDataContainer(this, m_SelectedDataContainerName); - if(getErrorCondition() < 0) + DataContainer::Pointer dc = getDataContainerArray()->getPrereqDataContainer(this, getSelectedDataContainerName()); + if(getErrorCode() < 0) { return; } @@ -154,16 +155,14 @@ void ExtractVertexGeometry::dataCheck() if(getVertexDataContainerName().isEmpty()) { QString ss = QObject::tr("The name of the created Vertex DataContainer is empty. Please specify a value."); - setErrorCondition(-2006); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-2006, ss); return; } if(getDataContainerArray()->doesDataContainerExist(getVertexDataContainerName())) { - QString ss = QObject::tr("A Data Container with name '%1' already exists.").arg(getVertexDataContainerName()); - setErrorCondition(-2007); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + QString ss = QObject::tr("A Data Container with name '%1' already exists.").arg(getVertexDataContainerName().getDataContainerName()); + setErrorCondition(-2007, ss); return; } @@ -172,26 +171,24 @@ void ExtractVertexGeometry::dataCheck() if(nullptr == fromGeometry.get()) { QString ss = QObject::tr("Selected input DataContainer must contain either an Image Geometry or RectLinearGrid Geometry. The DataContainer did not contain a Geometry object."); - setErrorCondition(-2008); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-2008, ss); return; } IGeometry::Type geomType = fromGeometry->getGeometryType(); size_t elementCount = 0; if(IGeometry::Type::Image == geomType || IGeometry::Type::RectGrid == geomType) { - vertexDataContainer = getDataContainerArray()->createNonPrereqDataContainer(this, getVertexDataContainerName()); + vertexDataContainer = getDataContainerArray()->createNonPrereqDataContainer(this, getVertexDataContainerName(), DataContainerID); IGeometryGrid::Pointer imageGeom = std::dynamic_pointer_cast(fromGeometry); - SIMPL::Tuple3SVec imageDims = imageGeom->getDimensions(); - VertexGeom::Pointer vertexGeom = VertexGeom::CreateGeometry(static_cast(std::get<0>(imageDims) * std::get<1>(imageDims) * std::get<2>(imageDims)), "VertexGeometry", !getInPreflight()); + SizeVec3Type imageDims = imageGeom->getDimensions(); + VertexGeom::Pointer vertexGeom = VertexGeom::CreateGeometry(imageDims[0] * imageDims[1] * imageDims[2], "VertexGeometry", !getInPreflight()); vertexDataContainer->setGeometry(vertexGeom); - elementCount = std::get<0>(imageDims) * std::get<1>(imageDims) * std::get<2>(imageDims); + elementCount = imageDims[0] * imageDims[1] * imageDims[2]; } else { QString ss = QObject::tr("Data Container's Geometry type must be either an Image Geometry or RectLinearGrid Geometry. The Geomerty is of type %1").arg(fromGeometry->getGeometryTypeAsString()); - setErrorCondition(-2010); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-2010, ss); return; } @@ -199,11 +196,11 @@ void ExtractVertexGeometry::dataCheck() for(int i = 0; i < selectedArraysSize; i++) { DataArrayPath dap = m_IncludedDataArrayPaths[i]; - dc = getDataContainerArray()->getPrereqDataContainer(this, dap.getDataContainerName()); + dc = getDataContainerArray()->getPrereqDataContainer(this, dap.getDataContainerName()); int err = 0; AttributeMatrix::Pointer sourceCellAttrMat = dc->getPrereqAttributeMatrix(this, dap.getAttributeMatrixName(), err); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -215,14 +212,13 @@ void ExtractVertexGeometry::dataCheck() .arg(dap.serialize("/")) .arg(sourceCellAttrMat->getNumberOfTuples()) .arg(elementCount) - .arg(m_VertexDataContainerName); - setErrorCondition(-2009); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + .arg(m_VertexDataContainerName.getDataContainerName()); + setErrorCondition(-2009, ss); return; } - IDataArray::Pointer iDataArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, dap); - if(getErrorCondition() < 0) + IDataArray::Pointer iDataArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, dap); + if(getErrorCode() < 0) { return; } @@ -237,34 +233,21 @@ void ExtractVertexGeometry::dataCheck() newArrayPtr = sourceCellAttrMat->removeAttributeArray(dap.getDataArrayName()); } - DataArrayPath newDap(m_VertexDataContainerName); + DataArrayPath newDap = m_VertexDataContainerName; newDap.setAttributeMatrixName(sourceCellAttrMat->getName()); newDap.setDataArrayName(""); AttributeMatrix::Pointer vertexCellAttrMat = vertexDataContainer->getAttributeMatrix(newDap); if(vertexCellAttrMat == nullptr) { - vertexCellAttrMat = vertexDataContainer->createNonPrereqAttributeMatrix(this, sourceCellAttrMat->getName(), sourceCellAttrMat->getTupleDimensions(), AttributeMatrix::Type::Vertex); + vertexCellAttrMat = + vertexDataContainer->createNonPrereqAttributeMatrix(this, sourceCellAttrMat->getName(), sourceCellAttrMat->getTupleDimensions(), AttributeMatrix::Type::Vertex, AttributeMatrixID); } - vertexCellAttrMat->addAttributeArray(newArrayPtr->getName(), newArrayPtr); + vertexCellAttrMat->insertOrAssign(newArrayPtr); } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void ExtractVertexGeometry::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -272,7 +255,7 @@ void ExtractVertexGeometry::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -280,12 +263,9 @@ void ExtractVertexGeometry::execute() IGeometryGrid::Pointer sourceGeometry = getDataContainerArray()->getDataContainer(getSelectedDataContainerName())->getGeometryAs(); float coords[3] = {0.0f, 0.0f, 0.0f}; - size_t xPoints = 0; - size_t yPoints = 0; - size_t zPoints = 0; - std::tie(xPoints, yPoints, zPoints) = sourceGeometry->getDimensions(); - size_t cellCount = xPoints * yPoints * zPoints; + SizeVec3Type dims = sourceGeometry->getDimensions(); + size_t cellCount = std::accumulate(dims.begin(), dims.end(), static_cast(1), std::multiplies()); VertexGeom::Pointer vertexGeom = getDataContainerArray()->getDataContainer(getVertexDataContainerName())->getGeometryAs(); SharedVertexList::Pointer vertices = vertexGeom->getVertices(); @@ -297,9 +277,6 @@ void ExtractVertexGeometry::execute() sourceGeometry->getCoords(idx, coords); vertices->setTuple(idx, coords); } - - // The moving or copying of the Cell DataArrays was already handled in the dataCheck() method. - } // ----------------------------------------------------------------------------- @@ -318,7 +295,7 @@ AbstractFilter::Pointer ExtractVertexGeometry::newFilterInstance(bool copyFilter // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractVertexGeometry::getCompiledLibraryName() const +QString ExtractVertexGeometry::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -326,7 +303,7 @@ const QString ExtractVertexGeometry::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractVertexGeometry::getBrandingString() const +QString ExtractVertexGeometry::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -334,7 +311,7 @@ const QString ExtractVertexGeometry::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractVertexGeometry::getFilterVersion() const +QString ExtractVertexGeometry::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -345,7 +322,7 @@ const QString ExtractVertexGeometry::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractVertexGeometry::getGroupName() const +QString ExtractVertexGeometry::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -353,7 +330,7 @@ const QString ExtractVertexGeometry::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractVertexGeometry::getSubGroupName() const +QString ExtractVertexGeometry::getSubGroupName() const { return SIMPL::FilterSubGroups::ConversionFilters; } @@ -361,7 +338,7 @@ const QString ExtractVertexGeometry::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ExtractVertexGeometry::getHumanLabel() const +QString ExtractVertexGeometry::getHumanLabel() const { return "Extract Vertex Geometry"; } @@ -369,7 +346,84 @@ const QString ExtractVertexGeometry::getHumanLabel() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid ExtractVertexGeometry::getUuid() +QUuid ExtractVertexGeometry::getUuid() const { return QUuid("{bc8a91ca-0cee-59c6-b5cb-acc1aab8617f}"); } + +// ----------------------------------------------------------------------------- +ExtractVertexGeometry::Pointer ExtractVertexGeometry::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr ExtractVertexGeometry::New() +{ + struct make_shared_enabler : public ExtractVertexGeometry + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString ExtractVertexGeometry::getNameOfClass() const +{ + return QString("ExtractVertexGeometry"); +} + +// ----------------------------------------------------------------------------- +QString ExtractVertexGeometry::ClassName() +{ + return QString("ExtractVertexGeometry"); +} + +// ----------------------------------------------------------------------------- +void ExtractVertexGeometry::setArrayHandling(int value) +{ + m_ArrayHandling = value; +} + +// ----------------------------------------------------------------------------- +int ExtractVertexGeometry::getArrayHandling() const +{ + return m_ArrayHandling; +} + +// ----------------------------------------------------------------------------- +void ExtractVertexGeometry::setSelectedDataContainerName(const DataArrayPath& value) +{ + m_SelectedDataContainerName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractVertexGeometry::getSelectedDataContainerName() const +{ + return m_SelectedDataContainerName; +} + +// ----------------------------------------------------------------------------- +void ExtractVertexGeometry::setIncludedDataArrayPaths(const std::vector& value) +{ + m_IncludedDataArrayPaths = value; +} + +// ----------------------------------------------------------------------------- +std::vector ExtractVertexGeometry::getIncludedDataArrayPaths() const +{ + return m_IncludedDataArrayPaths; +} + +// ----------------------------------------------------------------------------- +void ExtractVertexGeometry::setVertexDataContainerName(const DataArrayPath& value) +{ + m_VertexDataContainerName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ExtractVertexGeometry::getVertexDataContainerName() const +{ + return m_VertexDataContainerName; +} diff --git a/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.h b/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.h index 366c38ddc2..9cb24cceae 100644 --- a/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.h +++ b/Source/SIMPLib/CoreFilters/ExtractVertexGeometry.h @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,12 +35,13 @@ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/Geometry/ImageGeom.h" #include "SIMPLib/Geometry/RectGridGeom.h" #include "SIMPLib/Geometry/VertexGeom.h" -#include "SIMPLib/SIMPLib.h" /** * @brief The ExtractVertexGeometry class. See [Filter documentation](@ref convertdatacontainergeometry) for details. @@ -49,28 +50,93 @@ class SIMPLib_EXPORT ExtractVertexGeometry : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(ExtractVertexGeometry SUPERCLASS AbstractFilter) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ExtractVertexGeometry SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(ExtractVertexGeometry) + PYB11_FILTER_NEW_MACRO(ExtractVertexGeometry) PYB11_PROPERTY(int ArrayHandling READ getArrayHandling WRITE setArrayHandling) - PYB11_PROPERTY(QString SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) - PYB11_PROPERTY(QVector IncludedDataArrayPaths READ getIncludedDataArrayPaths WRITE setIncludedDataArrayPaths) - PYB11_PROPERTY(QString VertexDataContainerName READ getVertexDataContainerName WRITE setVertexDataContainerName) + PYB11_PROPERTY(DataArrayPath SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) + PYB11_PROPERTY(std::vector IncludedDataArrayPaths READ getIncludedDataArrayPaths WRITE setIncludedDataArrayPaths) + PYB11_PROPERTY(DataArrayPath VertexDataContainerName READ getVertexDataContainerName WRITE setVertexDataContainerName) + PYB11_END_BINDINGS() + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(ExtractVertexGeometry) - SIMPL_FILTER_NEW_MACRO(ExtractVertexGeometry) - SIMPL_TYPE_MACRO_SUPER(ExtractVertexGeometry, AbstractFilter) + using Self = ExtractVertexGeometry; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for ExtractVertexGeometry + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ExtractVertexGeometry + */ + static QString ClassName(); + + /** + * @brief Setter property for ArrayHandling + */ + void setArrayHandling(int value); + /** + * @brief Getter property for ArrayHandling + * @return Value of ArrayHandling + */ + int getArrayHandling() const; - SIMPL_FILTER_PARAMETER(int, ArrayHandling) Q_PROPERTY(int ArrayHandling READ getArrayHandling WRITE setArrayHandling) - SIMPL_FILTER_PARAMETER(QString, SelectedDataContainerName) - Q_PROPERTY(QString SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) + /** + * @brief Setter property for SelectedDataContainerName + */ + void setSelectedDataContainerName(const DataArrayPath& value); + /** + * @brief Getter property for SelectedDataContainerName + * @return Value of SelectedDataContainerName + */ + DataArrayPath getSelectedDataContainerName() const; + + Q_PROPERTY(DataArrayPath SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) - SIMPL_FILTER_PARAMETER(QVector, IncludedDataArrayPaths) - Q_PROPERTY(QVector IncludedDataArrayPaths READ getIncludedDataArrayPaths WRITE setIncludedDataArrayPaths) + /** + * @brief Setter property for IncludedDataArrayPaths + */ + void setIncludedDataArrayPaths(const std::vector& value); + /** + * @brief Getter property for IncludedDataArrayPaths + * @return Value of IncludedDataArrayPaths + */ + std::vector getIncludedDataArrayPaths() const; - SIMPL_FILTER_PARAMETER(QString, VertexDataContainerName) - Q_PROPERTY(QString VertexDataContainerName READ getVertexDataContainerName WRITE setVertexDataContainerName) + Q_PROPERTY(DataArrayPathVec IncludedDataArrayPaths READ getIncludedDataArrayPaths WRITE setIncludedDataArrayPaths) + + /** + * @brief Setter property for VertexDataContainerName + */ + void setVertexDataContainerName(const DataArrayPath& value); + /** + * @brief Getter property for VertexDataContainerName + * @return Value of VertexDataContainerName + */ + DataArrayPath getVertexDataContainerName() const; + + Q_PROPERTY(DataArrayPath VertexDataContainerName READ getVertexDataContainerName WRITE setVertexDataContainerName) ~ExtractVertexGeometry() override; @@ -83,21 +149,21 @@ class SIMPLib_EXPORT ExtractVertexGeometry : public AbstractFilter /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class */ - const QString getCompiledLibraryName() const override; + QString getCompiledLibraryName() const override; /** * @brief getBrandingString Returns the branding string for the filter, which is a tag * used to denote the filter's association with specific plugins * @return Branding string */ - const QString getBrandingString() const override; + QString getBrandingString() const override; /** * @brief getFilterVersion Returns a version string for this filter. Default * value is an empty string. * @return */ - const QString getFilterVersion() const override; + QString getFilterVersion() const override; /** * @brief newFilterInstance Reimplemented from @see AbstractFilter class @@ -107,23 +173,23 @@ class SIMPLib_EXPORT ExtractVertexGeometry : public AbstractFilter /** * @brief getGroupName Reimplemented from @see AbstractFilter class */ - const QString getGroupName() const override; + QString getGroupName() const override; /** * @brief getSubGroupName Reimplemented from @see AbstractFilter class */ - const QString getSubGroupName() const override; + QString getSubGroupName() const override; /** * @brief getUuid Return the unique identifier for this filter. * @return A QUuid object. */ - const QUuid getUuid() override; + QUuid getUuid() const override; /** * @brief getHumanLabel Reimplemented from @see AbstractFilter class */ - const QString getHumanLabel() const override; + QString getHumanLabel() const override; /** * @brief setupFilterParameters Reimplemented from @see AbstractFilter class @@ -135,41 +201,13 @@ class SIMPLib_EXPORT ExtractVertexGeometry : public AbstractFilter */ void execute() override; - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - -signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - protected: ExtractVertexGeometry(); /** * @brief dataCheck Checks for the appropriate parameter values and availability of arrays */ - void dataCheck(); + void dataCheck() override; /** * @brief Initializes all the private instance variables. @@ -177,8 +215,13 @@ class SIMPLib_EXPORT ExtractVertexGeometry : public AbstractFilter void initialize(); private: - QVector m_NewDCGeometryChoices; - QVector m_ArrayHandlingChoices; + int m_ArrayHandling = {static_cast(ArrayHandlingType::MoveArrays)}; + DataArrayPath m_SelectedDataContainerName = {}; + std::vector m_IncludedDataArrayPaths = {}; + DataArrayPath m_VertexDataContainerName = {"VertexDataContainer", "", ""}; + + std::vector m_NewDCGeometryChoices; + std::vector m_ArrayHandlingChoices; public: ExtractVertexGeometry(const ExtractVertexGeometry&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SIMPLib/CoreFilters/FeatureCountDecision.cpp b/Source/SIMPLib/CoreFilters/FeatureCountDecision.cpp index 87d763ca0d..24973f1b0e 100644 --- a/Source/SIMPLib/CoreFilters/FeatureCountDecision.cpp +++ b/Source/SIMPLib/CoreFilters/FeatureCountDecision.cpp @@ -1,43 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "FeatureCountDecision.h" +#include #include #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/IntFilterParameter.h" @@ -48,10 +50,8 @@ // // ----------------------------------------------------------------------------- FeatureCountDecision::FeatureCountDecision() -: m_FeatureIdsArrayPath("", "", "") -, m_MaxGrains(0) -{ -} + + = default; // ----------------------------------------------------------------------------- // @@ -63,14 +63,14 @@ FeatureCountDecision::~FeatureCountDecision() = default; // ----------------------------------------------------------------------------- void FeatureCountDecision::setupFilterParameters() { - FilterParameterVector parameters = getFilterParameters(); - parameters.push_back(SeparatorFilterParameter::New("Cell Ensemble Data", FilterParameter::RequiredArray)); + FilterParameterVectorType parameters = getFilterParameters(); + parameters.push_back(SeparatorFilterParameter::Create("Cell Ensemble Data", FilterParameter::Category::RequiredArray)); { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateRequirement(SIMPL::TypeNames::Int32, 1, AttributeMatrix::Type::CellEnsemble, IGeometry::Type::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Feature Ids", FeatureIdsArrayPath, FilterParameter::RequiredArray, FeatureCountDecision, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Feature Ids", FeatureIdsArrayPath, FilterParameter::Category::RequiredArray, FeatureCountDecision, req)); } - parameters.push_back(SIMPL_NEW_INTEGER_FP("Maximum Number of Features", MaxGrains, FilterParameter::Parameter, FeatureCountDecision, 0)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Maximum Number of Features", MaxGrains, FilterParameter::Category::Parameter, FeatureCountDecision, 0)); setFilterParameters(parameters); } @@ -98,43 +98,27 @@ void FeatureCountDecision::initialize() // ----------------------------------------------------------------------------- void FeatureCountDecision::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getFeatureIdsArrayPath().getDataContainerName()); + getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getFeatureIdsArrayPath().getDataContainerName()); - QVector cDims(1, 1); + std::vector cDims(1, 1); - m_FeatureIdsPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getFeatureIdsArrayPath(), - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ - if(nullptr != m_FeatureIdsPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ + m_FeatureIdsPtr = getDataContainerArray()->getPrereqArrayFromPath>(this, getFeatureIdsArrayPath(), cDims); + if(nullptr != m_FeatureIdsPtr.lock()) { m_FeatureIds = m_FeatureIdsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void FeatureCountDecision::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FeatureCountDecision::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -150,9 +134,8 @@ void FeatureCountDecision::execute() dm = false; } - emit decisionMade(dm); - emit targetValue(m_FeatureIds[1]); - + Q_EMIT decisionMade(dm); + Q_EMIT targetValue(m_FeatureIds[1]); } // ----------------------------------------------------------------------------- @@ -201,7 +184,7 @@ AbstractFilter::Pointer FeatureCountDecision::newFilterInstance(bool copyFilterP // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FeatureCountDecision::getCompiledLibraryName() const +QString FeatureCountDecision::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -209,7 +192,7 @@ const QString FeatureCountDecision::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FeatureCountDecision::getGroupName() const +QString FeatureCountDecision::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -217,7 +200,7 @@ const QString FeatureCountDecision::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid FeatureCountDecision::getUuid() +QUuid FeatureCountDecision::getUuid() const { return QUuid("{64d1df13-17a2-56a2-90a5-4dfda442b144}"); } @@ -225,7 +208,7 @@ const QUuid FeatureCountDecision::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FeatureCountDecision::getSubGroupName() const +QString FeatureCountDecision::getSubGroupName() const { return SIMPL::FilterSubGroups::MiscFilters; } @@ -233,7 +216,56 @@ const QString FeatureCountDecision::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FeatureCountDecision::getHumanLabel() const +QString FeatureCountDecision::getHumanLabel() const { return "Feature Count Decision"; } + +// ----------------------------------------------------------------------------- +FeatureCountDecision::Pointer FeatureCountDecision::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +FeatureCountDecision::Pointer FeatureCountDecision::New() +{ + Pointer sharedPtr(new(FeatureCountDecision)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString FeatureCountDecision::getNameOfClass() const +{ + return QString("FeatureCountDecision"); +} + +// ----------------------------------------------------------------------------- +QString FeatureCountDecision::ClassName() +{ + return QString("FeatureCountDecision"); +} + +// ----------------------------------------------------------------------------- +void FeatureCountDecision::setFeatureIdsArrayPath(const DataArrayPath& value) +{ + m_FeatureIdsArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath FeatureCountDecision::getFeatureIdsArrayPath() const +{ + return m_FeatureIdsArrayPath; +} + +// ----------------------------------------------------------------------------- +void FeatureCountDecision::setMaxGrains(int value) +{ + m_MaxGrains = value; +} + +// ----------------------------------------------------------------------------- +int FeatureCountDecision::getMaxGrains() const +{ + return m_MaxGrains; +} diff --git a/Source/SIMPLib/CoreFilters/FeatureCountDecision.h b/Source/SIMPLib/CoreFilters/FeatureCountDecision.h old mode 100755 new mode 100644 index 8266dc9f13..2bf32e52ee --- a/Source/SIMPLib/CoreFilters/FeatureCountDecision.h +++ b/Source/SIMPLib/CoreFilters/FeatureCountDecision.h @@ -1,147 +1,183 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/SIMPLib.h" +#include +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/AbstractDecisionFilter.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The FeatureCountDecision class. See [Filter documentation](@ref featurecountdecision) for details. */ class SIMPLib_EXPORT FeatureCountDecision : public AbstractDecisionFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(FeatureCountDecision SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath) - PYB11_PROPERTY(int MaxGrains READ getMaxGrains WRITE setMaxGrains) - - public: - SIMPL_SHARED_POINTERS(FeatureCountDecision) - SIMPL_STATIC_NEW_MACRO(FeatureCountDecision) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(FeatureCountDecision, AbstractDecisionFilter) - - ~FeatureCountDecision() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, FeatureIdsArrayPath) - Q_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath) - - SIMPL_FILTER_PARAMETER(int, MaxGrains) - Q_PROPERTY(int MaxGrains READ getMaxGrains WRITE setMaxGrains) - - /** - * @brief - * @param jsonDoc - */ - void extractProperties(const QJsonDocument &jsonDoc) override; - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - protected: - FeatureCountDecision(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - DEFINE_DATAARRAY_VARIABLE(int32_t, FeatureIds) - - public: - FeatureCountDecision(const FeatureCountDecision&) = delete; // Copy Constructor Not Implemented - FeatureCountDecision(FeatureCountDecision&&) = delete; // Move Constructor Not Implemented - FeatureCountDecision& operator=(const FeatureCountDecision&) = delete; // Copy Assignment Not Implemented - FeatureCountDecision& operator=(FeatureCountDecision&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(FeatureCountDecision SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(FeatureCountDecision) + PYB11_STATIC_NEW_MACRO(FeatureCountDecision) + PYB11_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath) + PYB11_PROPERTY(int MaxGrains READ getMaxGrains WRITE setMaxGrains) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = FeatureCountDecision; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for FeatureCountDecision + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for FeatureCountDecision + */ + static QString ClassName(); + + ~FeatureCountDecision() override; + + /** + * @brief Setter property for FeatureIdsArrayPath + */ + void setFeatureIdsArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for FeatureIdsArrayPath + * @return Value of FeatureIdsArrayPath + */ + DataArrayPath getFeatureIdsArrayPath() const; + + Q_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath) + + /** + * @brief Setter property for MaxGrains + */ + void setMaxGrains(int value); + /** + * @brief Getter property for MaxGrains + * @return Value of MaxGrains + */ + int getMaxGrains() const; + + Q_PROPERTY(int MaxGrains READ getMaxGrains WRITE setMaxGrains) + + /** + * @brief + * @param jsonDoc + */ + void extractProperties(const QJsonDocument& jsonDoc) override; + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + FeatureCountDecision(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + std::weak_ptr m_FeatureIdsPtr; + int32_t* m_FeatureIds = nullptr; + + DataArrayPath m_FeatureIdsArrayPath = {"", "", ""}; + int m_MaxGrains = {0}; + +public: + FeatureCountDecision(const FeatureCountDecision&) = delete; // Copy Constructor Not Implemented + FeatureCountDecision(FeatureCountDecision&&) = delete; // Move Constructor Not Implemented + FeatureCountDecision& operator=(const FeatureCountDecision&) = delete; // Copy Assignment Not Implemented + FeatureCountDecision& operator=(FeatureCountDecision&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/FeatureDataCSVWriter.cpp b/Source/SIMPLib/CoreFilters/FeatureDataCSVWriter.cpp index dcdcd55607..0295236fbb 100644 --- a/Source/SIMPLib/CoreFilters/FeatureDataCSVWriter.cpp +++ b/Source/SIMPLib/CoreFilters/FeatureDataCSVWriter.cpp @@ -1,65 +1,58 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "FeatureDataCSVWriter.h" #include +#include +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataArrays/NeighborList.hpp" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/BooleanFilterParameter.h" #include "SIMPLib/FilterParameters/ChoiceFilterParameter.h" #include "SIMPLib/FilterParameters/OutputFileFilterParameter.h" #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Utilities/FileSystemPathHelper.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FeatureDataCSVWriter::FeatureDataCSVWriter() -: m_CellFeatureAttributeMatrixPath("", "", "") -, m_FeatureDataFile("") -, m_WriteNeighborListData(false) -, m_DelimiterChoice(SIMPL::DelimiterTypes::Type::Comma) -, m_WriteNumFeaturesLine(true) -, m_Delimiter(',') -{ -} +FeatureDataCSVWriter::FeatureDataCSVWriter() = default; // ----------------------------------------------------------------------------- // @@ -70,26 +63,26 @@ FeatureDataCSVWriter::~FeatureDataCSVWriter() = default; // ----------------------------------------------------------------------------- void FeatureDataCSVWriter::setupFilterParameters() { - FilterParameterVector parameters; - parameters.push_back(SIMPL_NEW_OUTPUT_FILE_FP("Output File", FeatureDataFile, FilterParameter::Parameter, FeatureDataCSVWriter, "*.csv", "Comma Separated Data")); - parameters.push_back(SIMPL_NEW_BOOL_FP("Write Neighbor Data", WriteNeighborListData, FilterParameter::Parameter, FeatureDataCSVWriter)); - parameters.push_back(SIMPL_NEW_BOOL_FP("Write Number of Features Line", WriteNumFeaturesLine, FilterParameter::Parameter, FeatureDataCSVWriter)); + FilterParameterVectorType parameters; + parameters.push_back(SIMPL_NEW_OUTPUT_FILE_FP("Output File", FeatureDataFile, FilterParameter::Category::Parameter, FeatureDataCSVWriter, "*.csv", "Comma Separated Data")); + parameters.push_back(SIMPL_NEW_BOOL_FP("Write Neighbor Data", WriteNeighborListData, FilterParameter::Category::Parameter, FeatureDataCSVWriter)); + parameters.push_back(SIMPL_NEW_BOOL_FP("Write Number of Features Line", WriteNumFeaturesLine, FilterParameter::Category::Parameter, FeatureDataCSVWriter)); { - QVector choices; + std::vector choices; choices.push_back(","); choices.push_back(";"); choices.push_back(":"); choices.push_back("Tab"); choices.push_back("Space"); - parameters.push_back(SIMPL_NEW_CHOICE_FP("Delimiter", DelimiterChoiceInt, FilterParameter::Parameter, FeatureDataCSVWriter, choices, false)); + parameters.push_back(SIMPL_NEW_CHOICE_FP("Delimiter", DelimiterChoiceInt, FilterParameter::Category::Parameter, FeatureDataCSVWriter, choices, false)); } - parameters.push_back(SeparatorFilterParameter::New("Feature Data", FilterParameter::RequiredArray)); + parameters.push_back(SeparatorFilterParameter::Create("Feature Data", FilterParameter::Category::RequiredArray)); { AttributeMatrixSelectionFilterParameter::RequirementType req = AttributeMatrixSelectionFilterParameter::CreateRequirement(AttributeMatrix::Category::Feature); - parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Feature Attribute Matrix", CellFeatureAttributeMatrixPath, FilterParameter::RequiredArray, FeatureDataCSVWriter, req)); + parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Feature Attribute Matrix", CellFeatureAttributeMatrixPath, FilterParameter::Category::RequiredArray, FeatureDataCSVWriter, req)); } setFilterParameters(parameters); @@ -119,10 +112,10 @@ void FeatureDataCSVWriter::initialize() // ----------------------------------------------------------------------------- void FeatureDataCSVWriter::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getCellFeatureAttributeMatrixPath(), -301); + getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getCellFeatureAttributeMatrixPath(), -301); QFileInfo fi(getFeatureDataFile()); if(fi.suffix().compare("") == 0) @@ -131,8 +124,8 @@ void FeatureDataCSVWriter::dataCheck() } FileSystemPathHelper::CheckOutputFile(this, "Output File Name", getFeatureDataFile(), true); - - switch (getDelimiterChoice()) + SIMPL::DelimiterTypes::Type delim = static_cast(getDelimiterChoice()); + switch(delim) { case SIMPL::DelimiterTypes::Type::Comma: setDelimiter(','); @@ -155,28 +148,13 @@ void FeatureDataCSVWriter::dataCheck() } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void FeatureDataCSVWriter::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FeatureDataCSVWriter::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -188,8 +166,7 @@ void FeatureDataCSVWriter::execute() if(!parentPath.mkpath(".")) { QString ss = QObject::tr("Error creating parent path '%1'").arg(parentPath.absolutePath()); - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); return; } @@ -197,8 +174,7 @@ void FeatureDataCSVWriter::execute() if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QString ss = QObject::tr("Output file could not be opened: %1").arg(getFeatureDataFile()); - setErrorCondition(-100); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-100, ss); return; } @@ -217,7 +193,7 @@ void FeatureDataCSVWriter::execute() std::vector data; // For checking if an array is a neighborlist - NeighborList::Pointer neighborlistPtr = NeighborList::CreateArray(0, "_INTERNAL_USE_ONLY_JunkNeighborList", false); + NeighborList::Pointer neighborlistPtr = NeighborList::CreateArray(0, std::string("_INTERNAL_USE_ONLY_JunkNeighborList"), false); // Print the FeatureIds Header before the rest of the headers outFile << SIMPL::FeatureData::FeatureID; @@ -261,7 +237,7 @@ void FeatureDataCSVWriter::execute() if(percentIncrement > threshold) { QString ss = QObject::tr("Writing Feature Data || %1% Complete").arg(static_cast(percentIncrement)); - notifyStatusMessage(getMessagePrefix(), getHumanLabel(), ss); + notifyStatusMessage(ss); threshold = threshold + 5.0f; if(threshold < percentIncrement) { @@ -315,9 +291,9 @@ void FeatureDataCSVWriter::execute() AbstractFilter::Pointer FeatureDataCSVWriter::newFilterInstance(bool copyFilterParameters) const { /* - * FeatureDataFile - * WriteNeighborListData - */ + * FeatureDataFile + * WriteNeighborListData + */ FeatureDataCSVWriter::Pointer filter = FeatureDataCSVWriter::New(); if(copyFilterParameters) { @@ -329,7 +305,7 @@ AbstractFilter::Pointer FeatureDataCSVWriter::newFilterInstance(bool copyFilterP // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FeatureDataCSVWriter::getCompiledLibraryName() const +QString FeatureDataCSVWriter::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -337,7 +313,7 @@ const QString FeatureDataCSVWriter::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FeatureDataCSVWriter::getBrandingString() const +QString FeatureDataCSVWriter::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -345,7 +321,7 @@ const QString FeatureDataCSVWriter::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FeatureDataCSVWriter::getFilterVersion() const +QString FeatureDataCSVWriter::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -356,7 +332,7 @@ const QString FeatureDataCSVWriter::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FeatureDataCSVWriter::getGroupName() const +QString FeatureDataCSVWriter::getGroupName() const { return SIMPL::FilterGroups::IOFilters; } @@ -364,7 +340,7 @@ const QString FeatureDataCSVWriter::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid FeatureDataCSVWriter::getUuid() +QUuid FeatureDataCSVWriter::getUuid() const { return QUuid("{737b8d5a-8622-50f9-9a8a-bfdb57608891}"); } @@ -372,7 +348,7 @@ const QUuid FeatureDataCSVWriter::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FeatureDataCSVWriter::getSubGroupName() const +QString FeatureDataCSVWriter::getSubGroupName() const { return SIMPL::FilterSubGroups::OutputFilters; } @@ -380,7 +356,7 @@ const QString FeatureDataCSVWriter::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FeatureDataCSVWriter::getHumanLabel() const +QString FeatureDataCSVWriter::getHumanLabel() const { return "Export Feature Data as CSV File"; } @@ -396,12 +372,113 @@ int FeatureDataCSVWriter::getDelimiterChoiceInt() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FeatureDataCSVWriter::setDelimiterChoiceInt(const int& value) +void FeatureDataCSVWriter::setDelimiterChoiceInt(int value) { + this->m_DelimiterChoice = 0; // Set the default and if the value falls within the correct range, use that. // Allowed integer values of the enum SIMPL::DelimiterTypes::Type; see defintion in Constants.h - if (value >= 0 && value <= 4) + if(value >= 0 && value <= 4) { - this->m_DelimiterChoice = static_cast(value); + this->m_DelimiterChoice = value; } } +// ----------------------------------------------------------------------------- +FeatureDataCSVWriter::Pointer FeatureDataCSVWriter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr FeatureDataCSVWriter::New() +{ + struct make_shared_enabler : public FeatureDataCSVWriter + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString FeatureDataCSVWriter::getNameOfClass() const +{ + return QString("FeatureDataCSVWriter"); +} + +// ----------------------------------------------------------------------------- +QString FeatureDataCSVWriter::ClassName() +{ + return QString("FeatureDataCSVWriter"); +} + +// ----------------------------------------------------------------------------- +void FeatureDataCSVWriter::setCellFeatureAttributeMatrixPath(const DataArrayPath& value) +{ + m_CellFeatureAttributeMatrixPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath FeatureDataCSVWriter::getCellFeatureAttributeMatrixPath() const +{ + return m_CellFeatureAttributeMatrixPath; +} + +// ----------------------------------------------------------------------------- +void FeatureDataCSVWriter::setFeatureDataFile(const QString& value) +{ + m_FeatureDataFile = value; +} + +// ----------------------------------------------------------------------------- +QString FeatureDataCSVWriter::getFeatureDataFile() const +{ + return m_FeatureDataFile; +} + +// ----------------------------------------------------------------------------- +void FeatureDataCSVWriter::setWriteNeighborListData(bool value) +{ + m_WriteNeighborListData = value; +} + +// ----------------------------------------------------------------------------- +bool FeatureDataCSVWriter::getWriteNeighborListData() const +{ + return m_WriteNeighborListData; +} + +// ----------------------------------------------------------------------------- +void FeatureDataCSVWriter::setDelimiterChoice(int value) +{ + m_DelimiterChoice = value; +} + +// ----------------------------------------------------------------------------- +int FeatureDataCSVWriter::getDelimiterChoice() const +{ + return m_DelimiterChoice; +} + +// ----------------------------------------------------------------------------- +void FeatureDataCSVWriter::setWriteNumFeaturesLine(bool value) +{ + m_WriteNumFeaturesLine = value; +} + +// ----------------------------------------------------------------------------- +bool FeatureDataCSVWriter::getWriteNumFeaturesLine() const +{ + return m_WriteNumFeaturesLine; +} + +// ----------------------------------------------------------------------------- +void FeatureDataCSVWriter::setDelimiter(char value) +{ + m_Delimiter = value; +} + +// ----------------------------------------------------------------------------- +char FeatureDataCSVWriter::getDelimiter() const +{ + return m_Delimiter; +} diff --git a/Source/SIMPLib/CoreFilters/FeatureDataCSVWriter.h b/Source/SIMPLib/CoreFilters/FeatureDataCSVWriter.h index 7d517416d1..0c34641f08 100644 --- a/Source/SIMPLib/CoreFilters/FeatureDataCSVWriter.h +++ b/Source/SIMPLib/CoreFilters/FeatureDataCSVWriter.h @@ -1,198 +1,250 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/SIMPLib.h" +#include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The FeatureDataCSVWriter class. See [Filter documentation](@ref featuredatacsvwriter) for details. */ -class SIMPLib_EXPORT FeatureDataCSVWriter : public AbstractFilter +class SIMPLib_EXPORT FeatureDataCSVWriter : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(FeatureDataCSVWriter SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath CellFeatureAttributeMatrixPath READ getCellFeatureAttributeMatrixPath WRITE setCellFeatureAttributeMatrixPath) - PYB11_PROPERTY(QString FeatureDataFile READ getFeatureDataFile WRITE setFeatureDataFile) - PYB11_PROPERTY(bool WriteNeighborListData READ getWriteNeighborListData WRITE setWriteNeighborListData) - PYB11_PROPERTY(int DelimiterChoice READ getDelimiterChoice WRITE setDelimiterChoice) - PYB11_PROPERTY(bool WriteNumFeaturesLine READ getWriteNumFeaturesLine WRITE setWriteNumFeaturesLine) - - public: - SIMPL_SHARED_POINTERS(FeatureDataCSVWriter) - SIMPL_FILTER_NEW_MACRO(FeatureDataCSVWriter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(FeatureDataCSVWriter, AbstractFilter) - - ~FeatureDataCSVWriter() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, CellFeatureAttributeMatrixPath) - Q_PROPERTY(DataArrayPath CellFeatureAttributeMatrixPath READ getCellFeatureAttributeMatrixPath WRITE setCellFeatureAttributeMatrixPath) - - SIMPL_FILTER_PARAMETER(QString, FeatureDataFile) - Q_PROPERTY(QString FeatureDataFile READ getFeatureDataFile WRITE setFeatureDataFile) - - SIMPL_FILTER_PARAMETER(bool, WriteNeighborListData) - Q_PROPERTY(bool WriteNeighborListData READ getWriteNeighborListData WRITE setWriteNeighborListData) - - SIMPL_FILTER_PARAMETER(SIMPL::DelimiterTypes::Type, DelimiterChoice) - Q_PROPERTY(SIMPL::DelimiterTypes::Type DelimiterChoice READ getDelimiterChoice WRITE setDelimiterChoice) - Q_PROPERTY(int DelimiterChoiceInt READ getDelimiterChoiceInt WRITE setDelimiterChoiceInt) - - SIMPL_FILTER_PARAMETER(bool, WriteNumFeaturesLine) - Q_PROPERTY(bool WriteNumFeaturesLine READ getWriteNumFeaturesLine WRITE setWriteNumFeaturesLine) - - SIMPL_INSTANCE_PROPERTY(char, Delimiter) - - /** - * @brief getDelimiterChoiceInt Returns the corresponding int from the enum SIMPL::DelimiterTypes::Type for DelimiterChoice - */ - int getDelimiterChoiceInt() const; - - /** - * @brief setDelimiterChoiceInt Sets DelimiterChoice to the enum type from SIMPL::DelimiterTypes::Type corresponding to the int parameter - */ - void setDelimiterChoiceInt(const int& value); - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - FeatureDataCSVWriter(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - public: - FeatureDataCSVWriter(const FeatureDataCSVWriter&) = delete; // Copy Constructor Not Implemented - FeatureDataCSVWriter(FeatureDataCSVWriter&&) = delete; // Move Constructor Not Implemented - FeatureDataCSVWriter& operator=(const FeatureDataCSVWriter&) = delete; // Copy Assignment Not Implemented - FeatureDataCSVWriter& operator=(FeatureDataCSVWriter&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(FeatureDataCSVWriter SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(FeatureDataCSVWriter) + PYB11_FILTER_NEW_MACRO(FeatureDataCSVWriter) + PYB11_PROPERTY(DataArrayPath CellFeatureAttributeMatrixPath READ getCellFeatureAttributeMatrixPath WRITE setCellFeatureAttributeMatrixPath) + PYB11_PROPERTY(QString FeatureDataFile READ getFeatureDataFile WRITE setFeatureDataFile) + PYB11_PROPERTY(bool WriteNeighborListData READ getWriteNeighborListData WRITE setWriteNeighborListData) + PYB11_PROPERTY(int DelimiterChoice READ getDelimiterChoice WRITE setDelimiterChoice) + PYB11_PROPERTY(bool WriteNumFeaturesLine READ getWriteNumFeaturesLine WRITE setWriteNumFeaturesLine) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = FeatureDataCSVWriter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for FeatureDataCSVWriter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for FeatureDataCSVWriter + */ + static QString ClassName(); + + ~FeatureDataCSVWriter() override; + + /** + * @brief Setter property for CellFeatureAttributeMatrixPath + */ + void setCellFeatureAttributeMatrixPath(const DataArrayPath& value); + /** + * @brief Getter property for CellFeatureAttributeMatrixPath + * @return Value of CellFeatureAttributeMatrixPath + */ + DataArrayPath getCellFeatureAttributeMatrixPath() const; + + Q_PROPERTY(DataArrayPath CellFeatureAttributeMatrixPath READ getCellFeatureAttributeMatrixPath WRITE setCellFeatureAttributeMatrixPath) + + /** + * @brief Setter property for FeatureDataFile + */ + void setFeatureDataFile(const QString& value); + /** + * @brief Getter property for FeatureDataFile + * @return Value of FeatureDataFile + */ + QString getFeatureDataFile() const; + + Q_PROPERTY(QString FeatureDataFile READ getFeatureDataFile WRITE setFeatureDataFile) + + /** + * @brief Setter property for WriteNeighborListData + */ + void setWriteNeighborListData(bool value); + /** + * @brief Getter property for WriteNeighborListData + * @return Value of WriteNeighborListData + */ + bool getWriteNeighborListData() const; + + Q_PROPERTY(bool WriteNeighborListData READ getWriteNeighborListData WRITE setWriteNeighborListData) + + /** + * @brief Setter property for DelimiterChoice + */ + void setDelimiterChoice(int value); + /** + * @brief Getter property for DelimiterChoice + * @return Value of DelimiterChoice + */ + int getDelimiterChoice() const; + + Q_PROPERTY(int DelimiterChoice READ getDelimiterChoice WRITE setDelimiterChoice) + + /** + * @brief Setter property for WriteNumFeaturesLine + */ + void setWriteNumFeaturesLine(bool value); + /** + * @brief Getter property for WriteNumFeaturesLine + * @return Value of WriteNumFeaturesLine + */ + bool getWriteNumFeaturesLine() const; + + Q_PROPERTY(bool WriteNumFeaturesLine READ getWriteNumFeaturesLine WRITE setWriteNumFeaturesLine) + + /** + * @brief Setter property for Delimiter + */ + void setDelimiter(char value); + /** + * @brief Getter property for Delimiter + * @return Value of Delimiter + */ + char getDelimiter() const; + + /** + * @brief getDelimiterChoiceInt Returns the corresponding int from the enum SIMPL::DelimiterTypes::Type for DelimiterChoice + */ + int getDelimiterChoiceInt() const; + + /** + * @brief setDelimiterChoiceInt Sets DelimiterChoice to the enum type from SIMPL::DelimiterTypes::Type corresponding to the int parameter + */ + void setDelimiterChoiceInt(int value); + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + FeatureDataCSVWriter(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +public: + FeatureDataCSVWriter(const FeatureDataCSVWriter&) = delete; // Copy Constructor Not Implemented + FeatureDataCSVWriter(FeatureDataCSVWriter&&) = delete; // Move Constructor Not Implemented + FeatureDataCSVWriter& operator=(const FeatureDataCSVWriter&) = delete; // Copy Assignment Not Implemented + FeatureDataCSVWriter& operator=(FeatureDataCSVWriter&&) = delete; // Move Assignment Not Implemented + +private: + DataArrayPath m_CellFeatureAttributeMatrixPath = {"", "", ""}; + QString m_FeatureDataFile = {""}; + bool m_WriteNeighborListData = {false}; + int m_DelimiterChoice = {0}; + bool m_WriteNumFeaturesLine = {true}; + char m_Delimiter = {','}; }; diff --git a/Source/SIMPLib/CoreFilters/FileReader.cpp b/Source/SIMPLib/CoreFilters/FileReader.cpp index 138a03143c..75364965c2 100644 --- a/Source/SIMPLib/CoreFilters/FileReader.cpp +++ b/Source/SIMPLib/CoreFilters/FileReader.cpp @@ -1,42 +1,41 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "FileReader.h" -#include "SIMPLib/Common/Constants.h" #include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Common/Constants.h" // ----------------------------------------------------------------------------- // @@ -62,26 +61,6 @@ void FileReader::dataCheck() { } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -int32_t FileReader::readHeader() -{ - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), "FileReader should be subclassed and functionality implemented there", -1); - return -1; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -int32_t FileReader::readFile() -{ - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), "FileReader should be subclassed and functionality implemented there", -1); - return -1; -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -99,3 +78,21 @@ void FileReader::execute() return; } } + +// ----------------------------------------------------------------------------- +FileReader::Pointer FileReader::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString FileReader::getNameOfClass() const +{ + return QString("FileReader"); +} + +// ----------------------------------------------------------------------------- +QString FileReader::ClassName() +{ + return QString("FileReader"); +} diff --git a/Source/SIMPLib/CoreFilters/FileReader.h b/Source/SIMPLib/CoreFilters/FileReader.h old mode 100755 new mode 100644 index a8b0e16c18..acb9bb154a --- a/Source/SIMPLib/CoreFilters/FileReader.h +++ b/Source/SIMPLib/CoreFilters/FileReader.h @@ -1,118 +1,107 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The FileReader class serves as a superclass for reader filters. */ class SIMPLib_EXPORT FileReader : public AbstractFilter { - Q_OBJECT - - public: - SIMPL_SHARED_POINTERS(FileReader) - SIMPL_FILTER_NEW_MACRO(FileReader) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(FileReader, AbstractFilter) - - ~FileReader() override; - - /* This will internally call readHeader() and readFile() with appropriate - * error checkes after each one. Subclasses should just implement the readHeader - * and readFile methods unless special setups are needed. - */ - void execute() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - FileReader(); - - /** - * @brief readHeader Reads the header of the input file - * @return Integer error value - */ - virtual int32_t readHeader(); - - /** - * @brief readFile Reads the contents of the input file - * @return Integer error value - */ - virtual int32_t readFile(); - - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - virtual void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - public: - FileReader(const FileReader&) = delete; // Copy Constructor Not Implemented - FileReader(FileReader&&) = delete; // Move Constructor Not Implemented - FileReader& operator=(const FileReader&) = delete; // Copy Assignment Not Implemented - FileReader& operator=(FileReader&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + +public: + using Self = FileReader; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for FileReader + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for FileReader + */ + static QString ClassName(); + + ~FileReader() override; + + /* This will internally call readHeader() and readFile() with appropriate + * error checkes after each one. Subclasses should just implement the readHeader + * and readFile methods unless special setups are needed. + */ + void execute() override; + +protected: + FileReader(); + + /** + * @brief readHeader Reads the header of the input file + * @return Integer error value + */ + virtual int32_t readHeader() = 0; + + /** + * @brief readFile Reads the contents of the input file + * @return Integer error value + */ + virtual int32_t readFile() = 0; + + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +public: + FileReader(const FileReader&) = delete; // Copy Constructor Not Implemented + FileReader(FileReader&&) = delete; // Move Constructor Not Implemented + FileReader& operator=(const FileReader&) = delete; // Copy Assignment Not Implemented + FileReader& operator=(FileReader&&) = delete; // Move Assignment Not Implemented + +private: }; - diff --git a/Source/SIMPLib/CoreFilters/FileWriter.cpp b/Source/SIMPLib/CoreFilters/FileWriter.cpp index e321096c09..d6156f7da9 100644 --- a/Source/SIMPLib/CoreFilters/FileWriter.cpp +++ b/Source/SIMPLib/CoreFilters/FileWriter.cpp @@ -1,85 +1,61 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "FileWriter.h" #include -#include "SIMPLib/Common/Constants.h" #include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Common/Constants.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FileWriter::FileWriter() -: m_OutputFile("") -{ -} +FileWriter::FileWriter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- FileWriter::~FileWriter() = default; -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -int32_t FileWriter::writeHeader() -{ - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), "FileWriter should be subclassed and functionality implemented there", -1); - return -1; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -int32_t FileWriter::writeFile() -{ - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), "FileWriter should be subclassed and functionality implemented there", -1); - return -1; -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FileWriter::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path @@ -88,9 +64,8 @@ void FileWriter::execute() QDir dir; if(!dir.mkpath(parentPath)) { - setErrorCondition(-200); QString ss = QObject::tr("Error creating parent path '%1'").arg(parentPath); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-200, ss); return; } @@ -98,16 +73,44 @@ void FileWriter::execute() if(err < 0) { QString ss = QObject::tr("Error writing the header portion of the file"); - setErrorCondition(err); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(err, ss); return; } err = writeFile(); if(err < 0) { QString ss = QObject::tr("Error writing the data to the file"); - setErrorCondition(err); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(err, ss); return; } } + +// ----------------------------------------------------------------------------- +FileWriter::Pointer FileWriter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString FileWriter::getNameOfClass() const +{ + return QString("FileWriter"); +} + +// ----------------------------------------------------------------------------- +QString FileWriter::ClassName() +{ + return QString("FileWriter"); +} + +// ----------------------------------------------------------------------------- +void FileWriter::setOutputFile(const QString& value) +{ + m_OutputFile = value; +} + +// ----------------------------------------------------------------------------- +QString FileWriter::getOutputFile() const +{ + return m_OutputFile; +} diff --git a/Source/SIMPLib/CoreFilters/FileWriter.h b/Source/SIMPLib/CoreFilters/FileWriter.h old mode 100755 new mode 100644 index 5cc87554c1..fdf63ce790 --- a/Source/SIMPLib/CoreFilters/FileWriter.h +++ b/Source/SIMPLib/CoreFilters/FileWriter.h @@ -1,107 +1,113 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The FileWriter class serves as a superclass for writer filters */ class SIMPLib_EXPORT FileWriter : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(FileWriter SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString OutputFile READ getOutputFile WRITE setOutputFile) - - public: - SIMPL_SHARED_POINTERS(FileWriter) - SIMPL_FILTER_NEW_MACRO(FileWriter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(FileWriter, AbstractFilter) - - ~FileWriter() override; - - SIMPL_FILTER_PARAMETER(QString, OutputFile) - Q_PROPERTY(QString OutputFile READ getOutputFile WRITE setOutputFile) - - void execute() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - FileWriter(); - - /** - * @brief writeHeader Writes the header of the output file - * @return Integer error value - */ - virtual int32_t writeHeader(); - - /** - * @brief writeFile Writes the contents of the output file - * @return Integer error value - */ - virtual int32_t writeFile(); - - public: - FileWriter(const FileWriter&) = delete; // Copy Constructor Not Implemented - FileWriter(FileWriter&&) = delete; // Move Constructor Not Implemented - FileWriter& operator=(const FileWriter&) = delete; // Copy Assignment Not Implemented - FileWriter& operator=(FileWriter&&) = delete; // Move Assignment Not Implemented -}; + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(FileWriter SUPERCLASS AbstractFilter) + PYB11_SHARED_POINTERS(FileWriter) + PYB11_PROPERTY(QString OutputFile READ getOutputFile WRITE setOutputFile) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = FileWriter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for FileWriter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for FileWriter + */ + static QString ClassName(); + + ~FileWriter() override; + /** + * @brief Setter property for OutputFile + */ + void setOutputFile(const QString& value); + /** + * @brief Getter property for OutputFile + * @return Value of OutputFile + */ + QString getOutputFile() const; + + Q_PROPERTY(QString OutputFile READ getOutputFile WRITE setOutputFile) + + void execute() override; + +protected: + FileWriter(); + + /** + * @brief writeHeader Writes the header of the output file + * @return Integer error value + */ + virtual int32_t writeHeader() = 0; + + /** + * @brief writeFile Writes the contents of the output file + * @return Integer error value + */ + virtual int32_t writeFile() = 0; + +public: + FileWriter(const FileWriter&) = delete; // Copy Constructor Not Implemented + FileWriter(FileWriter&&) = delete; // Move Constructor Not Implemented + FileWriter& operator=(const FileWriter&) = delete; // Copy Assignment Not Implemented + FileWriter& operator=(FileWriter&&) = delete; // Move Assignment Not Implemented + +private: + QString m_OutputFile = {""}; +}; diff --git a/Source/SIMPLib/CoreFilters/FindDerivatives.cpp b/Source/SIMPLib/CoreFilters/FindDerivatives.cpp index eff98128c8..891440267a 100644 --- a/Source/SIMPLib/CoreFilters/FindDerivatives.cpp +++ b/Source/SIMPLib/CoreFilters/FindDerivatives.cpp @@ -1,41 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "FindDerivatives.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/TemplateHelpers.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" @@ -47,17 +51,72 @@ #include "SIMPLib/Geometry/TetrahedralGeom.h" #include "SIMPLib/Geometry/TriangleGeom.h" #include "SIMPLib/Math/SIMPLibRandom.h" -#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Messages/AbstractMessageHandler.h" +#include "SIMPLib/Messages/GenericErrorMessage.h" +#include "SIMPLib/Messages/GenericProgressMessage.h" +#include "SIMPLib/Messages/GenericStatusMessage.h" +#include "SIMPLib/Messages/GenericWarningMessage.h" + +/** + * @brief This message handler is used by the FindDerivatives filter to re-emit incoming generic + * messages from geometry classes as filter messages. It also prepends text to status messages to show that it is + * computing derivatives. + */ +class FilterMessageHandler : public AbstractMessageHandler +{ +public: + explicit FilterMessageHandler(FindDerivatives* filter) + : m_Filter(filter) + { + } + + /** + * @brief Re-emits incoming GenericProgressMessages as FilterProgressMessages. + */ + void processMessage(const GenericProgressMessage* msg) const override + { + Q_EMIT m_Filter->notifyProgressMessage(msg->getProgressValue(), msg->getMessageText()); + } + + /** + * @brief Re-emits incoming GenericStatusMessages as FilterStatusMessages. Prepends text to the + * message text that explains that we are computing the derivatives + */ + void processMessage(const GenericStatusMessage* msg) const override + { + QString messageText = QObject::tr("Computing Derivatives || %1").arg(msg->getMessageText()); + Q_EMIT m_Filter->notifyStatusMessage(messageText); + } + + /** + * @brief Re-emits incoming GenericErrorMessages as FilterErrorMessages. + */ + void processMessage(const GenericErrorMessage* msg) const override + { + Q_EMIT m_Filter->setErrorCondition(msg->getCode(), msg->getMessageText()); + } + + /** + * @brief Re-emits incoming GenericWarningMessages as FilterWarningMessages. + */ + void processMessage(const GenericWarningMessage* msg) const override + { + Q_EMIT m_Filter->setWarningCondition(msg->getCode(), msg->getMessageText()); + } + +private: + FindDerivatives* m_Filter = nullptr; +}; + +enum createdPathID : RenameDataPath::DataID_t +{ + DerivativesArrayID = 1 +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FindDerivatives::FindDerivatives() -: m_SelectedArrayPath("", "", "") -, m_DerivativesArrayPath(SIMPL::Defaults::DataContainerName, SIMPL::Defaults::CellAttributeMatrixName, "Derivatives") -, m_Interpolate(false) -{ -} +FindDerivatives::FindDerivatives() = default; // ----------------------------------------------------------------------------- // @@ -69,7 +128,7 @@ FindDerivatives::~FindDerivatives() = default; // ----------------------------------------------------------------------------- void FindDerivatives::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateRequirement(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, AttributeMatrix::Type::Any, IGeometry::Type::Any); @@ -79,7 +138,7 @@ void FindDerivatives::setupFilterParameters() amTypes.push_back(AttributeMatrix::Type::Edge); amTypes.push_back(AttributeMatrix::Type::Vertex); req.amTypes = amTypes; - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Data Array to Process", SelectedArrayPath, FilterParameter::RequiredArray, FindDerivatives, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Data Array to Process", SelectedArrayPath, FilterParameter::Category::RequiredArray, FindDerivatives, req)); } { DataArrayCreationFilterParameter::RequirementType req = DataArrayCreationFilterParameter::CreateRequirement(AttributeMatrix::Category::Unknown); @@ -89,7 +148,7 @@ void FindDerivatives::setupFilterParameters() amTypes.push_back(AttributeMatrix::Type::Edge); amTypes.push_back(AttributeMatrix::Type::Vertex); req.amTypes = amTypes; - parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Derivatives Array", DerivativesArrayPath, FilterParameter::CreatedArray, FindDerivatives, req)); + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Derivatives Array", DerivativesArrayPath, FilterParameter::Category::CreatedArray, FindDerivatives, req)); } setFilterParameters(parameters); } @@ -108,11 +167,12 @@ void FindDerivatives::readFilterParameters(AbstractFilterParametersReader* reade // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void findDerivs(IDataArray::Pointer inDataPtr, DoubleArrayType::Pointer derivs, DataContainer::Pointer m, Observable* observable) +template +void findDerivs(IDataArray::Pointer inDataPtr, DoubleArrayType::Pointer derivs, DataContainer::Pointer m, Observable* observable) { typename DataArray::Pointer inputDataPtr = std::dynamic_pointer_cast>(inDataPtr); IGeometry::Pointer geom = m->getGeometry(); - DoubleArrayType::Pointer dblInArray = DoubleArrayType::CreateArray(inputDataPtr->getNumberOfTuples(), inputDataPtr->getComponentDimensions(), "FIND_DERIVS_INTERNAL_USE_ONLY"); + DoubleArrayType::Pointer dblInArray = DoubleArrayType::CreateArray(inputDataPtr->getNumberOfTuples(), inputDataPtr->getComponentDimensions(), "FIND_DERIVS_INTERNAL_USE_ONLY", true); size_t size = inputDataPtr->getSize(); @@ -127,7 +187,8 @@ template void findDerivs(IDataArray::Pointer inDataPtr, Doub // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void interpolateCellValues(IDataArray::Pointer inDataPtr, DoubleArrayType::Pointer outDataPtr, DataContainer::Pointer m) +template +void interpolateCellValues(IDataArray::Pointer inDataPtr, DoubleArrayType::Pointer outDataPtr, DataContainer::Pointer m) { typename DataArray::Pointer inputDataPtr = std::dynamic_pointer_cast>(inDataPtr); IGeometry::Pointer geom = m->getGeometry(); @@ -147,48 +208,42 @@ template void interpolateCellValues(IDataArray::Pointer inDa switch(geomType) { - case IGeometry::Type::Edge: - { + case IGeometry::Type::Edge: { EdgeGeom::Pointer edgeGeom = m->getGeometryAs(); SharedVertexList::Pointer verts = edgeGeom->getVertices(); - outDataPtr->resize(edgeGeom->getNumberOfVertices()); - GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); + outDataPtr->resizeTuples(edgeGeom->getNumberOfVertices()); + GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); break; } - case IGeometry::Type::Triangle: - { + case IGeometry::Type::Triangle: { TriangleGeom::Pointer triGeom = m->getGeometryAs(); SharedVertexList::Pointer verts = triGeom->getVertices(); - outDataPtr->resize(triGeom->getNumberOfVertices()); - GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); + outDataPtr->resizeTuples(triGeom->getNumberOfVertices()); + GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); break; } - case IGeometry::Type::Quad: - { + case IGeometry::Type::Quad: { QuadGeom::Pointer quadGeom = m->getGeometryAs(); SharedVertexList::Pointer verts = quadGeom->getVertices(); - outDataPtr->resize(quadGeom->getNumberOfVertices()); - GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); + outDataPtr->resizeTuples(quadGeom->getNumberOfVertices()); + GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); break; } - case IGeometry::Type::Tetrahedral: - { + case IGeometry::Type::Tetrahedral: { TetrahedralGeom::Pointer tets = m->getGeometryAs(); SharedVertexList::Pointer verts = tets->getVertices(); - outDataPtr->resize(tets->getNumberOfVertices()); - GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); + outDataPtr->resizeTuples(tets->getNumberOfVertices()); + GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); break; } - case IGeometry::Type::Hexahedral: - { + case IGeometry::Type::Hexahedral: { HexahedralGeom::Pointer hexas = m->getGeometryAs(); SharedVertexList::Pointer verts = hexas->getVertices(); - outDataPtr->resize(hexas->getNumberOfVertices()); - GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); + outDataPtr->resizeTuples(hexas->getNumberOfVertices()); + GeometryHelpers::Generic::AverageCellArrayValues(elemsContainingVert, verts, inputDataPtr, outDataPtr); break; } - default: - { + default: { break; } } @@ -207,24 +262,24 @@ void FindDerivatives::initialize() // ----------------------------------------------------------------------------- void FindDerivatives::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); initialize(); DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, m_SelectedArrayPath.getDataContainerName(), false); - if(getErrorCondition() < 0 || nullptr == m.get()) + if(getErrorCode() < 0 || nullptr == m.get()) { return; } IGeometry::Pointer geom = m->getPrereqGeometry(this); - if(getErrorCondition() < 0 || nullptr == geom.get()) + if(getErrorCode() < 0 || nullptr == geom.get()) { return; } - AttributeMatrix::Pointer inAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedArrayPath, -301); + AttributeMatrix::Pointer inAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedArrayPath, -301); AttributeMatrix::Pointer destAttrMat = m->getPrereqAttributeMatrix(this, getDerivativesArrayPath().getAttributeMatrixName(), -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -240,15 +295,13 @@ void FindDerivatives::dataCheck() if(inAttrMatType != AttributeMatrix::Type::Cell) { ss = QObject::tr("The Geometry type is %1, but the selected DataArray does not belong to a CellAttributeMatrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); return; } if(destAttrMatType != AttributeMatrix::Type::Cell) { ss = QObject::tr("The Geometry type is %1, but the selected destination AttributeMatrix is not a CellAttributeMatrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } } else if(geomType == IGeometry::Type::Vertex) // validate AttributeMatrices for VertexGeom @@ -256,14 +309,12 @@ void FindDerivatives::dataCheck() if(inAttrMatType != AttributeMatrix::Type::Vertex) { ss = QObject::tr("The Geometry type is %1, but the selected DataArray does not belong to a VertexAttributeMatrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } if(destAttrMatType != AttributeMatrix::Type::Vertex) { ss = QObject::tr("The Geometry type is %1, but the selected destination AttributeMatrix is not a VertexAttributeMatrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } } else // validate AttributeMatrices for all other geometries @@ -273,20 +324,17 @@ void FindDerivatives::dataCheck() { m_Interpolate = true; } - if(inAttrMatType != AttributeMatrix::Type::Vertex && inAttrMatType != AttributeMatrix::Type::Edge && inAttrMatType != AttributeMatrix::Type::Face && - inAttrMatType != AttributeMatrix::Type::Cell) + if(inAttrMatType != AttributeMatrix::Type::Vertex && inAttrMatType != AttributeMatrix::Type::Edge && inAttrMatType != AttributeMatrix::Type::Face && inAttrMatType != AttributeMatrix::Type::Cell) { ss = QObject::tr("The Geometry type is %1, but the selected DataArray does not belong to a Cell, Face, Edge or Vertex AttributeMatrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } if(geomName == SIMPL::Geometry::QuadGeometry || geomName == SIMPL::Geometry::TriangleGeometry) { if(destAttrMatType != AttributeMatrix::Type::Face) { ss = QObject::tr("The Geometry type is %1, but the selected destination Attribute Matrix is not a Face Attribute Matrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } } else if(geomName == SIMPL::Geometry::TetrahedralGeometry || geomName == SIMPL::Geometry::HexahedralGeometry) @@ -294,8 +342,7 @@ void FindDerivatives::dataCheck() if(destAttrMatType != AttributeMatrix::Type::Cell) { ss = QObject::tr("The Geometry type is %1, but the selected destination Attribute Matrix is not an Cell Attribute Matrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } } else if(geomName == SIMPL::Geometry::EdgeGeometry) @@ -303,52 +350,35 @@ void FindDerivatives::dataCheck() if(destAttrMatType != AttributeMatrix::Type::Edge) { ss = QObject::tr("The Geometry type is %1, but the selected destination Attribute Matrix is not an Edge Attribute Matrix").arg(geomName); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); } } } - m_InArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArrayPath()); - if(getErrorCondition() < 0) + m_InArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArrayPath()); + if(getErrorCode() < 0) { return; } int cDims = m_InArrayPtr.lock()->getNumberOfComponents(); cDims *= 3; - QVector dims(1, cDims); + std::vector dims(1, cDims); - m_DerivativesArrayPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, double>( - this, getDerivativesArrayPath(), 0, dims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ - if(nullptr != m_DerivativesArrayPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ + m_DerivativesArrayPtr = getDataContainerArray()->createNonPrereqArrayFromPath>(this, getDerivativesArrayPath(), 0, dims, "", DerivativesArrayID); + if(nullptr != m_DerivativesArrayPtr.lock()) { m_DerivativesArray = m_DerivativesArrayPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void FindDerivatives::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FindDerivatives::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -356,23 +386,27 @@ void FindDerivatives::execute() DataContainer::Pointer m = getDataContainerArray()->getDataContainer(m_SelectedArrayPath.getDataContainerName()); IGeometry::Pointer geom = m->getGeometry(); - geom->setMessagePrefix(getMessagePrefix()); - geom->setMessageTitle("Computing Derivatives"); - if(m_Interpolate) { DoubleArrayType::Pointer interpolatedValues = - DoubleArrayType::CreateArray(m_InArrayPtr.lock()->getNumberOfTuples(), m_InArrayPtr.lock()->getComponentDimensions(), "FIND_DERIVATIVES_INTERNAL_USE_ONLY"); + DoubleArrayType::CreateArray(m_InArrayPtr.lock()->getNumberOfTuples(), m_InArrayPtr.lock()->getComponentDimensions(), "FIND_DERIVATIVES_INTERNAL_USE_ONLY", true); EXECUTE_FUNCTION_TEMPLATE(this, interpolateCellValues, m_InArrayPtr.lock(), m_InArrayPtr.lock(), interpolatedValues, m) + geom->findDerivatives(interpolatedValues, m_DerivativesArrayPtr.lock(), this); } else { EXECUTE_FUNCTION_TEMPLATE(this, findDerivs, m_InArrayPtr.lock(), m_InArrayPtr.lock(), m_DerivativesArrayPtr.lock(), m, this); } +} - geom->setMessagePrefix(""); - geom->setMessageTitle(""); +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FindDerivatives::processDerivativesMessage(const AbstractMessage::Pointer& msg) +{ + FilterMessageHandler msgHandler(this); + msg->visit(&msgHandler); } // ----------------------------------------------------------------------------- @@ -391,7 +425,7 @@ AbstractFilter::Pointer FindDerivatives::newFilterInstance(bool copyFilterParame // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FindDerivatives::getCompiledLibraryName() const +QString FindDerivatives::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -399,7 +433,7 @@ const QString FindDerivatives::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FindDerivatives::getBrandingString() const +QString FindDerivatives::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -407,7 +441,7 @@ const QString FindDerivatives::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FindDerivatives::getFilterVersion() const +QString FindDerivatives::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -418,7 +452,7 @@ const QString FindDerivatives::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FindDerivatives::getGroupName() const +QString FindDerivatives::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -426,7 +460,7 @@ const QString FindDerivatives::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid FindDerivatives::getUuid() +QUuid FindDerivatives::getUuid() const { return QUuid("{8ec1fc8e-6484-5412-a898-8079986c0a26}"); } @@ -434,7 +468,7 @@ const QUuid FindDerivatives::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FindDerivatives::getSubGroupName() const +QString FindDerivatives::getSubGroupName() const { return SIMPL::FilterSubGroups::GeometryFilters; } @@ -442,7 +476,60 @@ const QString FindDerivatives::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString FindDerivatives::getHumanLabel() const +QString FindDerivatives::getHumanLabel() const { return "Find Derivatives"; } + +// ----------------------------------------------------------------------------- +FindDerivatives::Pointer FindDerivatives::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr FindDerivatives::New() +{ + struct make_shared_enabler : public FindDerivatives + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString FindDerivatives::getNameOfClass() const +{ + return QString("FindDerivatives"); +} + +// ----------------------------------------------------------------------------- +QString FindDerivatives::ClassName() +{ + return QString("FindDerivatives"); +} + +// ----------------------------------------------------------------------------- +void FindDerivatives::setSelectedArrayPath(const DataArrayPath& value) +{ + m_SelectedArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath FindDerivatives::getSelectedArrayPath() const +{ + return m_SelectedArrayPath; +} + +// ----------------------------------------------------------------------------- +void FindDerivatives::setDerivativesArrayPath(const DataArrayPath& value) +{ + m_DerivativesArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath FindDerivatives::getDerivativesArrayPath() const +{ + return m_DerivativesArrayPath; +} diff --git a/Source/SIMPLib/CoreFilters/FindDerivatives.h b/Source/SIMPLib/CoreFilters/FindDerivatives.h index 5122c69ce3..d2c0a422f7 100644 --- a/Source/SIMPLib/CoreFilters/FindDerivatives.h +++ b/Source/SIMPLib/CoreFilters/FindDerivatives.h @@ -1,46 +1,50 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/Filtering/AbstractFilter.h" + +class IDataArray; +using IDataArrayWkPtrType = std::weak_ptr; /** * @brief The FindDerivatives class. See [Filter documentation](@ref findderivatives) for details. @@ -48,113 +52,132 @@ class SIMPLib_EXPORT FindDerivatives : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(FindDerivatives SUPERCLASS AbstractFilter) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(FindDerivatives SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(FindDerivatives) + PYB11_FILTER_NEW_MACRO(FindDerivatives) PYB11_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) PYB11_PROPERTY(DataArrayPath DerivativesArrayPath READ getDerivativesArrayPath WRITE setDerivativesArrayPath) + PYB11_END_BINDINGS() + // End Python bindings declarations - public: - SIMPL_SHARED_POINTERS(FindDerivatives) - SIMPL_FILTER_NEW_MACRO(FindDerivatives) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(FindDerivatives, AbstractFilter) +public: + using Self = FindDerivatives; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; - ~FindDerivatives() override; + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); - SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedArrayPath) - Q_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); - SIMPL_FILTER_PARAMETER(DataArrayPath, DerivativesArrayPath) - Q_PROPERTY(DataArrayPath DerivativesArrayPath READ getDerivativesArrayPath WRITE setDerivativesArrayPath) + /** + * @brief Returns the name of the class for FindDerivatives + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for FindDerivatives + */ + static QString ClassName(); - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; + ~FindDerivatives() override; - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; + /** + * @brief Setter property for SelectedArrayPath + */ + void setSelectedArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SelectedArrayPath + * @return Value of SelectedArrayPath + */ + DataArrayPath getSelectedArrayPath() const; - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; + Q_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + /** + * @brief Setter property for DerivativesArrayPath + */ + void setDerivativesArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for DerivativesArrayPath + * @return Value of DerivativesArrayPath + */ + DataArrayPath getDerivativesArrayPath() const; - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; + Q_PROPERTY(DataArrayPath DerivativesArrayPath READ getDerivativesArrayPath WRITE setDerivativesArrayPath) - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - /** - * @brief This method will read the options from a file - * @param reader The reader that is used to read the options from a file - * @param index The index to read the information from - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; - /** - * @brief Reimplemented from @see AbstractFilter class - */ - void execute() override; + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; - /** - * @brief This function runs some sanity checks on the DataContainer and inputs - * in an attempt to ensure the filter can process the inputs. - */ - void preflight() override; + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; -signals: /** - * @brief updateFilterParameters This is emitted when the filter requests all the latest Filter Parameters need to be - * pushed from a user facing control such as the FilterParameter Widget - * @param filter The filter to push the values into + * @brief getHumanLabel Reimplemented from @see AbstractFilter class */ - void updateFilterParameters(AbstractFilter* filter); + QString getHumanLabel() const override; /** - * @brief parametersChanged This signal can be emitted when any of the filter parameters are changed internally. + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class */ - void parametersChanged(); + void setupFilterParameters() override; /** - * @brief preflightAboutToExecute Emitted just before the dataCheck() is called. This can change if needed. + * @brief This method will read the options from a file + * @param reader The reader that is used to read the options from a file + * @param index The index to read the information from */ - void preflightAboutToExecute(); + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; /** - * @brief preflightExecuted Emitted just after the dataCheck() is called. Typically. This can change if needed. + * @brief Reimplemented from @see AbstractFilter class */ - void preflightExecuted(); + void execute() override; protected: FindDerivatives(); @@ -162,23 +185,34 @@ class SIMPLib_EXPORT FindDerivatives : public AbstractFilter /** * @brief dataCheck Checks for the appropriate parameter values and availability of arrays */ - void dataCheck(); + void dataCheck() override; /** * @brief Initializes all the private instance variables. */ void initialize(); +protected Q_SLOTS: + /** + * @brief processDerivativesMessage + * @param msg + */ + void processDerivativesMessage(const AbstractMessage::Pointer& msg); + private: - DEFINE_IDATAARRAY_WEAKPTR(InArray) - DEFINE_DATAARRAY_VARIABLE(double, DerivativesArray) + std::weak_ptr> m_DerivativesArrayPtr; + double* m_DerivativesArray = nullptr; - bool m_Interpolate; + IDataArrayWkPtrType m_InArrayPtr; - public: - FindDerivatives(const FindDerivatives&) = delete; // Copy Constructor Not Implemented - FindDerivatives(FindDerivatives&&) = delete; // Move Constructor Not Implemented - FindDerivatives& operator=(const FindDerivatives&) = delete; // Copy Assignment Not Implemented - FindDerivatives& operator=(FindDerivatives&&) = delete; // Move Assignment Not Implemented -}; + DataArrayPath m_SelectedArrayPath = {"", "", ""}; + DataArrayPath m_DerivativesArrayPath = {SIMPL::Defaults::DataContainerName, SIMPL::Defaults::CellAttributeMatrixName, "Derivatives"}; + bool m_Interpolate = {false}; + +public: + FindDerivatives(const FindDerivatives&) = delete; // Copy Constructor Not Implemented + FindDerivatives(FindDerivatives&&) = delete; // Move Constructor Not Implemented + FindDerivatives& operator=(const FindDerivatives&) = delete; // Copy Assignment Not Implemented + FindDerivatives& operator=(FindDerivatives&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/CoreFilters/GenerateColorTable.cpp b/Source/SIMPLib/CoreFilters/GenerateColorTable.cpp index bc2b467a4e..7669185bf1 100644 --- a/Source/SIMPLib/CoreFilters/GenerateColorTable.cpp +++ b/Source/SIMPLib/CoreFilters/GenerateColorTable.cpp @@ -4,30 +4,33 @@ #include "GenerateColorTable.h" -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS -#include -#include -#include -#include -#endif +#include +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" -#include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/FilterParameters/GenerateColorTableFilterParameter.h" +#include "SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.h" +#include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/Utilities/ColorTable.h" -#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Utilities/ParallelDataAlgorithm.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + ColorArrayID = 1 +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- template -int findRightBinIndex(T nValue, QVector binPoints) +int findRightBinIndex(T nValue, std::vector binPoints) { /* This is a brute-force way of finding the proper bins. We will need to change this method to a binary search. */ int rightBinIndex = 0; - while (binPoints[rightBinIndex] < nValue) + while(binPoints[rightBinIndex] < nValue) { rightBinIndex++; } @@ -38,13 +41,13 @@ int findRightBinIndex(T nValue, QVector binPoints) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int findRightBinIndex_Binary(float nValue, QVector binPoints) +int findRightBinIndex_Binary(float nValue, std::vector binPoints) { int min = 0, max = binPoints.size() - 1; - while (min < max) + while(min < max) { int middle = (min + max) / 2; - if (nValue > binPoints[middle]) + if(nValue > binPoints[middle]) { min = middle + 1; } @@ -64,27 +67,33 @@ template class GenerateColorTableImpl { public: - GenerateColorTableImpl(typename DataArray::Pointer arrayPtr, QVector binPoints, - std::vector > controlPoints, int numControlColors, UInt8ArrayType::Pointer colorArray) : - m_ArrayPtr(arrayPtr), - m_BinPoints(binPoints), - m_NumControlColors(numControlColors), - m_ControlPoints(controlPoints), - m_ColorArray(colorArray) + GenerateColorTableImpl(typename DataArray::Pointer arrayPtr, std::vector binPoints, std::vector> controlPoints, int numControlColors, + UInt8ArrayType::Pointer colorArray) + : m_ArrayPtr(arrayPtr) + , m_BinPoints(std::move(binPoints)) + , m_NumControlColors(numControlColors) + , m_ControlPoints(std::move(controlPoints)) + , m_ColorArray(std::move(colorArray)) { m_ArrayMin = arrayPtr->getValue(0); m_ArrayMax = arrayPtr->getValue(0); - for (int i=1; igetNumberOfTuples(); i++) + for(int i = 1; i < arrayPtr->getNumberOfTuples(); i++) { - if (arrayPtr->getValue(i) < m_ArrayMin) { m_ArrayMin = arrayPtr->getValue(i); } - if (arrayPtr->getValue(i) > m_ArrayMax) { m_ArrayMax = arrayPtr->getValue(i); } + if(arrayPtr->getValue(i) < m_ArrayMin) + { + m_ArrayMin = arrayPtr->getValue(i); + } + if(arrayPtr->getValue(i) > m_ArrayMax) + { + m_ArrayMax = arrayPtr->getValue(i); + } } } virtual ~GenerateColorTableImpl() = default; void convert(size_t start, size_t end) const { - for (size_t i = start; i < end; i++) + for(size_t i = start; i < end; i++) { // Normalize value float nValue = (static_cast(m_ArrayPtr->getValue(i) - m_ArrayMin)) / static_cast((m_ArrayMax - m_ArrayMin)); @@ -92,7 +101,7 @@ class GenerateColorTableImpl int rightBinIndex = findRightBinIndex_Binary(nValue, m_BinPoints); int leftBinIndex = rightBinIndex - 1; - if (leftBinIndex < 0) + if(leftBinIndex < 0) { leftBinIndex = 0; rightBinIndex = 1; @@ -100,7 +109,7 @@ class GenerateColorTableImpl // Find the fractional distance traveled between the beginning and end of the current color bin float currFraction = 0.0f; - if (rightBinIndex < m_BinPoints.size()) + if(rightBinIndex < m_BinPoints.size()) { currFraction = (nValue - m_BinPoints[leftBinIndex]) / (m_BinPoints[rightBinIndex] - m_BinPoints[leftBinIndex]); } @@ -127,20 +136,19 @@ class GenerateColorTableImpl } } -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - void operator()(const tbb::blocked_range& r) const + void operator()(const SIMPLRange& r) const { - convert(r.begin(), r.end()); + convert(r.min(), r.max()); } -#endif + private: - typename DataArray::Pointer m_ArrayPtr; - QVector m_BinPoints; - T m_ArrayMin; - T m_ArrayMax; - int m_NumControlColors; - std::vector > m_ControlPoints; - UInt8ArrayType::Pointer m_ColorArray; + typename DataArray::Pointer m_ArrayPtr; + std::vector m_BinPoints; + T m_ArrayMin; + T m_ArrayMax; + int m_NumControlColors; + std::vector> m_ControlPoints; + UInt8ArrayType::Pointer m_ColorArray; }; // ----------------------------------------------------------------------------- @@ -149,7 +157,10 @@ class GenerateColorTableImpl template void generateColorArray(typename DataArray::Pointer arrayPtr, QJsonArray presetControlPoints, DataArrayPath selectedDAP, QString rgbArrayName, DataContainerArray::Pointer dca) { - if (arrayPtr->getNumberOfTuples() <= 0) { return; } + if(arrayPtr->getNumberOfTuples() <= 0) + { + return; + } if(presetControlPoints.empty()) { @@ -158,16 +169,16 @@ void generateColorArray(typename DataArray::Pointer arrayPtr, QJsonArray pres int numControlColors = presetControlPoints.count() / 4; int numComponents = 4; - std::vector > controlPoints(numControlColors, std::vector(numComponents)); + std::vector> controlPoints(numControlColors, std::vector(numComponents)); // Migrate colorControlPoints values from QJsonArray to 2D array. Store A-values in binPoints vector. - QVector binPoints; - for (int i=0; i binPoints; + for(int i = 0; i < numControlColors; i++) { - for (int j=0; j(presetControlPoints[numComponents*i + j].toDouble()); - if (j == 0) + controlPoints[i][j] = static_cast(presetControlPoints[numComponents * i + j].toDouble()); + if(j == 0) { binPoints.push_back(controlPoints[i][j]); } @@ -177,7 +188,7 @@ void generateColorArray(typename DataArray::Pointer arrayPtr, QJsonArray pres // Normalize binPoints values float binMin = binPoints[0]; float binMax = binPoints[binPoints.size() - 1]; - for (int i=0; i::Pointer arrayPtr, QJsonArray pres DataArrayPath tmpPath = selectedDAP; tmpPath.setDataArrayName(rgbArrayName); - UInt8ArrayType::Pointer colorArray = dca->getPrereqArrayFromPath(nullptr, tmpPath, QVector(1, 3)); - if (colorArray.get() == nullptr) { return; } - -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - bool doParallel = true; -#endif - -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - if(doParallel) + UInt8ArrayType::Pointer colorArray = dca->getPrereqArrayFromPath(nullptr, tmpPath, std::vector(1, 3)); + if(colorArray.get() == nullptr) { - tbb::parallel_for(tbb::blocked_range(0, arrayPtr->getNumberOfTuples()), GenerateColorTableImpl(arrayPtr, binPoints, controlPoints, numControlColors, colorArray), - tbb::auto_partitioner()); - } - else -#endif - { - GenerateColorTableImpl serial(arrayPtr, binPoints, controlPoints, numControlColors, colorArray); - serial.convert(0, arrayPtr->getNumberOfTuples()); + return; } + + ParallelDataAlgorithm dataAlg; + dataAlg.setRange(0, arrayPtr->getNumberOfTuples()); + dataAlg.execute(GenerateColorTableImpl(arrayPtr, binPoints, controlPoints, numControlColors, colorArray)); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- GenerateColorTable::GenerateColorTable() -: m_SelectedPresetName("") -, m_SelectedPresetControlPoints(QJsonArray()) -, m_SelectedDataArrayPath(DataArrayPath("", "", "")) -, m_RgbArrayName("") { initialize(); } @@ -228,8 +225,8 @@ GenerateColorTable::~GenerateColorTable() = default; // ----------------------------------------------------------------------------- void GenerateColorTable::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -238,12 +235,12 @@ void GenerateColorTable::initialize() // ----------------------------------------------------------------------------- void GenerateColorTable::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { GenerateColorTableFilterParameter::Pointer parameter = GenerateColorTableFilterParameter::New(); parameter->setHumanLabel("Select Preset..."); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameter->setPropertyName("SelectedPresetName"); parameter->setFilter(this); parameters.push_back(parameter); @@ -251,10 +248,10 @@ void GenerateColorTable::setupFilterParameters() { DataArraySelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Data Array", SelectedDataArrayPath, FilterParameter::RequiredArray, GenerateColorTable, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Data Array", SelectedDataArrayPath, FilterParameter::Category::RequiredArray, GenerateColorTable, req)); } - parameters.push_back(SIMPL_NEW_STRING_FP("RGB Array Name", RgbArrayName, FilterParameter::CreatedArray, GenerateColorTable)); + parameters.push_back(SIMPL_NEW_DA_WITH_LINKED_AM_FP("RGB Array Name", RgbArrayName, SelectedDataArrayPath, SelectedDataArrayPath, FilterParameter::Category::CreatedArray, GenerateColorTable)); setFilterParameters(parameters); } @@ -264,29 +261,15 @@ void GenerateColorTable::setupFilterParameters() // ----------------------------------------------------------------------------- void GenerateColorTable::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedDataArrayPath()); + getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedDataArrayPath()); DataArrayPath tmpPath = getSelectedDataArrayPath(); tmpPath.setDataArrayName(getRgbArrayName()); - getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, uint8_t>(this, tmpPath, 0, QVector(1, 3)); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void GenerateColorTable::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. + getDataContainerArray()->createNonPrereqArrayFromPath>(this, tmpPath, 0, std::vector(1, 3), "", ColorArrayID); } // ----------------------------------------------------------------------------- @@ -296,71 +279,72 @@ void GenerateColorTable::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) { return; } + if(getErrorCode() < 0) + { + return; + } - if (getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), QVector(1, 1)).get() != nullptr) + if(getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), {static_cast(1)}).get() != nullptr) { - Int8ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), QVector(1, 1)); + Int8ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), {static_cast(1)}); generateColorArray(ptr, getSelectedPresetControlPoints(), getSelectedDataArrayPath(), getRgbArrayName(), getDataContainerArray()); } - else if (getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), QVector(1, 1)).get() != nullptr) + else if(getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), {static_cast(1)}).get() != nullptr) { - UInt8ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), QVector(1, 1)); + UInt8ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), {static_cast(1)}); generateColorArray(ptr, getSelectedPresetControlPoints(), getSelectedDataArrayPath(), getRgbArrayName(), getDataContainerArray()); } - else if (getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), QVector(1, 1)).get() != nullptr) + else if(getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), {static_cast(1)}).get() != nullptr) { - Int16ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), QVector(1, 1)); + Int16ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), {static_cast(1)}); generateColorArray(ptr, getSelectedPresetControlPoints(), getSelectedDataArrayPath(), getRgbArrayName(), getDataContainerArray()); } - else if (getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), QVector(1, 1)).get() != nullptr) + else if(getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), {static_cast(1)}).get() != nullptr) { - UInt16ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), QVector(1, 1)); + UInt16ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), {static_cast(1)}); generateColorArray(ptr, getSelectedPresetControlPoints(), getSelectedDataArrayPath(), getRgbArrayName(), getDataContainerArray()); } - else if (getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), QVector(1, 1)).get() != nullptr) + else if(getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), {static_cast(1)}).get() != nullptr) { - Int32ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), QVector(1, 1)); + Int32ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), {static_cast(1)}); generateColorArray(ptr, getSelectedPresetControlPoints(), getSelectedDataArrayPath(), getRgbArrayName(), getDataContainerArray()); } - else if (getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), QVector(1, 1)).get() != nullptr) + else if(getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), {static_cast(1)}).get() != nullptr) { - UInt32ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), QVector(1, 1)); + UInt32ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), {static_cast(1)}); generateColorArray(ptr, getSelectedPresetControlPoints(), getSelectedDataArrayPath(), getRgbArrayName(), getDataContainerArray()); } - else if (getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), QVector(1, 1)).get() != nullptr) + else if(getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), {static_cast(1)}).get() != nullptr) { - Int64ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), QVector(1, 1)); + Int64ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), {static_cast(1)}); generateColorArray(ptr, getSelectedPresetControlPoints(), getSelectedDataArrayPath(), getRgbArrayName(), getDataContainerArray()); } - else if (getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), QVector(1, 1)).get() != nullptr) + else if(getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), {static_cast(1)}).get() != nullptr) { - UInt64ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), QVector(1, 1)); + UInt64ArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), {static_cast(1)}); generateColorArray(ptr, getSelectedPresetControlPoints(), getSelectedDataArrayPath(), getRgbArrayName(), getDataContainerArray()); } - else if (getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), QVector(1, 1)).get() != nullptr) + else if(getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), {static_cast(1)}).get() != nullptr) { - DoubleArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), QVector(1, 1)); + DoubleArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), {static_cast(1)}); generateColorArray(ptr, getSelectedPresetControlPoints(), getSelectedDataArrayPath(), getRgbArrayName(), getDataContainerArray()); } - else if (getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), QVector(1, 1)).get() != nullptr) + else if(getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), {static_cast(1)}).get() != nullptr) { - FloatArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), QVector(1, 1)); + FloatArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), {static_cast(1)}); generateColorArray(ptr, getSelectedPresetControlPoints(), getSelectedDataArrayPath(), getRgbArrayName(), getDataContainerArray()); } - else if (getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), QVector(1, 1)).get() != nullptr) + else if(getDataContainerArray()->getPrereqArrayFromPath(nullptr, getSelectedDataArrayPath(), {static_cast(1)}).get() != nullptr) { - BoolArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), QVector(1, 1)); + BoolArrayType::Pointer ptr = getDataContainerArray()->getPrereqArrayFromPath(this, getSelectedDataArrayPath(), {static_cast(1)}); generateColorArray(ptr, getSelectedPresetControlPoints(), getSelectedDataArrayPath(), getRgbArrayName(), getDataContainerArray()); } else { QString ss = QObject::tr("The selected array '%1' does not have a compatible type.").arg(getSelectedDataArrayPath().getDataArrayName()); - setErrorCondition(-10000); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-10000, ss); return; } - } // ----------------------------------------------------------------------------- @@ -379,13 +363,15 @@ AbstractFilter::Pointer GenerateColorTable::newFilterInstance(bool copyFilterPar // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString GenerateColorTable::getCompiledLibraryName() const -{ return Core::CoreBaseName; } +QString GenerateColorTable::getCompiledLibraryName() const +{ + return Core::CoreBaseName; +} // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString GenerateColorTable::getBrandingString() const +QString GenerateColorTable::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -393,24 +379,26 @@ const QString GenerateColorTable::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString GenerateColorTable::getFilterVersion() const +QString GenerateColorTable::getFilterVersion() const { QString version; QTextStream vStream(&version); - vStream << SIMPLib::Version::Major() << "." << SIMPLib::Version::Minor() << "." << SIMPLib::Version::Patch(); + vStream << SIMPLib::Version::Major() << "." << SIMPLib::Version::Minor() << "." << SIMPLib::Version::Patch(); return version; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString GenerateColorTable::getGroupName() const -{ return SIMPL::FilterGroups::CoreFilters; } +QString GenerateColorTable::getGroupName() const +{ + return SIMPL::FilterGroups::CoreFilters; +} // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid GenerateColorTable::getUuid() +QUuid GenerateColorTable::getUuid() const { return QUuid("{0d0a6535-6565-51c5-a3fc-fbc00008606d}"); } @@ -418,12 +406,92 @@ const QUuid GenerateColorTable::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString GenerateColorTable::getSubGroupName() const -{ return SIMPL::FilterSubGroups::ImageFilters; } +QString GenerateColorTable::getSubGroupName() const +{ + return SIMPL::FilterSubGroups::ImageFilters; +} // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString GenerateColorTable::getHumanLabel() const -{ return "Generate Color Table"; } +QString GenerateColorTable::getHumanLabel() const +{ + return "Generate Color Table"; +} + +// ----------------------------------------------------------------------------- +GenerateColorTable::Pointer GenerateColorTable::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr GenerateColorTable::New() +{ + struct make_shared_enabler : public GenerateColorTable + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString GenerateColorTable::getNameOfClass() const +{ + return QString("GenerateColorTable"); +} + +// ----------------------------------------------------------------------------- +QString GenerateColorTable::ClassName() +{ + return QString("GenerateColorTable"); +} + +// ----------------------------------------------------------------------------- +void GenerateColorTable::setSelectedPresetName(const QString& value) +{ + m_SelectedPresetName = value; +} + +// ----------------------------------------------------------------------------- +QString GenerateColorTable::getSelectedPresetName() const +{ + return m_SelectedPresetName; +} + +// ----------------------------------------------------------------------------- +void GenerateColorTable::setSelectedPresetControlPoints(const QJsonArray& value) +{ + m_SelectedPresetControlPoints = value; +} + +// ----------------------------------------------------------------------------- +QJsonArray GenerateColorTable::getSelectedPresetControlPoints() const +{ + return m_SelectedPresetControlPoints; +} + +// ----------------------------------------------------------------------------- +void GenerateColorTable::setSelectedDataArrayPath(const DataArrayPath& value) +{ + m_SelectedDataArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath GenerateColorTable::getSelectedDataArrayPath() const +{ + return m_SelectedDataArrayPath; +} +// ----------------------------------------------------------------------------- +void GenerateColorTable::setRgbArrayName(const QString& value) +{ + m_RgbArrayName = value; +} + +// ----------------------------------------------------------------------------- +QString GenerateColorTable::getRgbArrayName() const +{ + return m_RgbArrayName; +} diff --git a/Source/SIMPLib/CoreFilters/GenerateColorTable.h b/Source/SIMPLib/CoreFilters/GenerateColorTable.h index 316be8737d..66a9e5ec87 100644 --- a/Source/SIMPLib/CoreFilters/GenerateColorTable.h +++ b/Source/SIMPLib/CoreFilters/GenerateColorTable.h @@ -4,12 +4,12 @@ #pragma once -#include +#include + #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The GenerateColorTable class. See [Filter documentation](@ref generatecolortable) for details. @@ -17,131 +17,174 @@ class SIMPLib_EXPORT GenerateColorTable : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(GenerateColorTable SUPERCLASS AbstractFilter) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(GenerateColorTable SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(GenerateColorTable) + PYB11_FILTER_NEW_MACRO(GenerateColorTable) PYB11_PROPERTY(QString SelectedPresetName READ getSelectedPresetName WRITE setSelectedPresetName) PYB11_PROPERTY(QJsonArray SelectedPresetControlPoints READ getSelectedPresetControlPoints WRITE setSelectedPresetControlPoints) PYB11_PROPERTY(DataArrayPath SelectedDataArrayPath READ getSelectedDataArrayPath WRITE setSelectedDataArrayPath) PYB11_PROPERTY(QString RgbArrayName READ getRgbArrayName WRITE setRgbArrayName) - - public: - SIMPL_SHARED_POINTERS(GenerateColorTable) - SIMPL_FILTER_NEW_MACRO(GenerateColorTable) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(GenerateColorTable, AbstractFilter) - - ~GenerateColorTable() override; - - SIMPL_INSTANCE_PROPERTY(QString, SelectedPresetName) - Q_PROPERTY(QString SelectedPresetName READ getSelectedPresetName WRITE setSelectedPresetName) - - SIMPL_INSTANCE_PROPERTY(QJsonArray, SelectedPresetControlPoints) - Q_PROPERTY(QJsonArray SelectedPresetControlPoints READ getSelectedPresetControlPoints WRITE setSelectedPresetControlPoints) - - SIMPL_INSTANCE_PROPERTY(DataArrayPath, SelectedDataArrayPath) - Q_PROPERTY(DataArrayPath SelectedDataArrayPath READ getSelectedDataArrayPath WRITE setSelectedDataArrayPath) - - SIMPL_INSTANCE_PROPERTY(QString, RgbArrayName) - Q_PROPERTY(QString RgbArrayName READ getRgbArrayName WRITE setRgbArrayName) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - GenerateColorTable(); - - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - public: - GenerateColorTable(const GenerateColorTable&) = delete; // Copy Constructor Not Implemented - GenerateColorTable(GenerateColorTable&&) = delete; // Move Constructor Not Implemented - GenerateColorTable& operator=(const GenerateColorTable&) = delete; // Copy Assignment Not Implemented - GenerateColorTable& operator=(GenerateColorTable&&) = delete; // Move Assignment Not Implemented + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = GenerateColorTable; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for GenerateColorTable + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for GenerateColorTable + */ + static QString ClassName(); + + ~GenerateColorTable() override; + + /** + * @brief Setter property for SelectedPresetName + */ + void setSelectedPresetName(const QString& value); + /** + * @brief Getter property for SelectedPresetName + * @return Value of SelectedPresetName + */ + QString getSelectedPresetName() const; + + Q_PROPERTY(QString SelectedPresetName READ getSelectedPresetName WRITE setSelectedPresetName) + + /** + * @brief Setter property for SelectedPresetControlPoints + */ + void setSelectedPresetControlPoints(const QJsonArray& value); + /** + * @brief Getter property for SelectedPresetControlPoints + * @return Value of SelectedPresetControlPoints + */ + QJsonArray getSelectedPresetControlPoints() const; + + Q_PROPERTY(QJsonArray SelectedPresetControlPoints READ getSelectedPresetControlPoints WRITE setSelectedPresetControlPoints) + + /** + * @brief Setter property for SelectedDataArrayPath + */ + void setSelectedDataArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SelectedDataArrayPath + * @return Value of SelectedDataArrayPath + */ + DataArrayPath getSelectedDataArrayPath() const; + + Q_PROPERTY(DataArrayPath SelectedDataArrayPath READ getSelectedDataArrayPath WRITE setSelectedDataArrayPath) + + /** + * @brief Setter property for RgbArrayName + */ + void setRgbArrayName(const QString& value); + /** + * @brief Getter property for RgbArrayName + * @return Value of RgbArrayName + */ + QString getRgbArrayName() const; + + Q_PROPERTY(QString RgbArrayName READ getRgbArrayName WRITE setRgbArrayName) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + GenerateColorTable(); + + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +public: + GenerateColorTable(const GenerateColorTable&) = delete; // Copy Constructor Not Implemented + GenerateColorTable(GenerateColorTable&&) = delete; // Move Constructor Not Implemented + GenerateColorTable& operator=(const GenerateColorTable&) = delete; // Copy Assignment Not Implemented + GenerateColorTable& operator=(GenerateColorTable&&) = delete; // Move Assignment Not Implemented + +private: + QString m_SelectedPresetName = {""}; + QJsonArray m_SelectedPresetControlPoints = {QJsonArray()}; + DataArrayPath m_SelectedDataArrayPath = {DataArrayPath("", "", "")}; + QString m_RgbArrayName = {""}; }; - diff --git a/Source/SIMPLib/CoreFilters/GenerateTiltSeries.cpp b/Source/SIMPLib/CoreFilters/GenerateTiltSeries.cpp new file mode 100644 index 0000000000..ccb1b46058 --- /dev/null +++ b/Source/SIMPLib/CoreFilters/GenerateTiltSeries.cpp @@ -0,0 +1,1002 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * United States Air Force Prime Contract FA8650-10-D-5210 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "GenerateTiltSeries.h" + +#include +#include + +#define GTS_GENERATE_DEBUG_ARRAYS 0 +// If we are writing out all the arrays for debugging then we MUST be single threaded. +#if(GTS_GENERATE_DEBUG_ARRAYS == 1) +#undef SIMPL_USE_PARALLEL_ALGORITHMS +#endif + +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS +#include +#endif + +#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Common/SIMPLArray.hpp" +#include "SIMPLib/DataArrays/IDataArray.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" +#include "SIMPLib/FilterParameters/ChoiceFilterParameter.h" +#include "SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h" +#include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" +#include "SIMPLib/FilterParameters/FloatFilterParameter.h" +#include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" +#include "SIMPLib/FilterParameters/StringFilterParameter.h" +#include "SIMPLib/Geometry/ImageGeom.h" +#include "SIMPLib/Geometry/VertexGeom.h" +#include "SIMPLib/Math/SIMPLibMath.h" + +#ifndef DREAM3D_PASSIVE_ROTATION +#define DREAM3D_PASSIVE_ROTATION 1 +#endif + +#ifndef ROTATIONS_CONSTANTS +#define ROTATIONS_CONSTANTS +namespace Rotations +{ +namespace Constants +{ +#if DREAM3D_PASSIVE_ROTATION +constexpr float epsijk = 1.0f; +// static const double epsijkd = 1.0; +#elif DREAM3D_ACTIVE_ROTATION +constexpr float epsijk = -1.0f; +constexpr double epsijkd = -1.0; +#endif +} // namespace Constants +} // namespace Rotations + +#endif + +namespace Detail +{ + +const QString k_AttributeMatrixName("Slice Data"); + +class ResampleGrid +{ +public: + using AxisAngleType = std::array; + using CoordinateType = FloatVec3Type; + using OrientationMatrixType = std::vector; + + ResampleGrid(GenerateTiltSeries* filter, const FloatArrayType::Pointer& inputGrid, const DataContainer::Pointer& outDc, const AxisAngleType& rotationAxis +#if GTS_GENERATE_DEBUG_ARRAYS + , + size_t gridIndex +#endif + ) + : m_Filter(filter) + , m_Coords(inputGrid) + , m_OutputDC(outDc) + , m_RotationAxis(rotationAxis) +#if GTS_GENERATE_DEBUG_ARRAYS + , m_GridIndex(gridIndex) +#endif + { + } + ~ResampleGrid() = default; + + ResampleGrid(const ResampleGrid&) = default; + ResampleGrid(ResampleGrid&&) noexcept = default; + ResampleGrid& operator=(const ResampleGrid&) = delete; // Copy Assignment Not Implemented + ResampleGrid& operator=(ResampleGrid&&) = delete; // Move Assignment Not Implemented + + void operator()() const + { + + //========= Input Data Structure Elements + DataContainerArray::Pointer dca = m_Filter->getDataContainerArray(); + IDataArray::Pointer inputData = dca->getPrereqIDataArrayFromPath(m_Filter, m_Filter->getInputDataArrayPath()); + DataArrayPath inputDataArrayPath = m_Filter->getInputDataArrayPath(); + DataContainer::Pointer inputDC = dca->getDataContainer(inputDataArrayPath.getDataContainerName()); + ImageGeom::Pointer inputImageGeom = inputDC->getGeometryAs(); + FloatVec6Type inBounds = inputImageGeom->getBoundingBox(); + FloatVec3Type inCenter = {(inBounds[1] - inBounds[0]) / 2.0f + inBounds[0], (inBounds[3] - inBounds[2]) / 2.0f + inBounds[2], (inBounds[5] - inBounds[4]) / 2.0f + inBounds[4]}; + + // printf("inCenter %f %f %f\n", inCenter[0], inCenter[1], inCenter[2]); + + //========= Output Data Structure Elements + ImageGeom::Pointer outputImageGeom = m_OutputDC->getGeometryAs(); + FloatVec6Type bounds = outputImageGeom->getBoundingBox(); + FloatVec3Type center = {(bounds[1] - bounds[0]) / 2.0f + bounds[0], (bounds[3] - bounds[2]) / 2.0f + bounds[2], (bounds[5] - bounds[4]) / 2.0f + bounds[4]}; + + // printf("outCenter %f %f %f\n", center[0], center[1], center[2]); + + AttributeMatrix::Pointer attrMat = m_OutputDC->getAttributeMatrix(Detail::k_AttributeMatrixName); + IDataArray::Pointer outputData = attrMat->getAttributeArray(m_Filter->getInputDataArrayPath().getDataArrayName()); + outputData->initializeWithZeros(); +#if GTS_GENERATE_DEBUG_ARRAYS + SizeTArrayType::Pointer inputVoxIndexXYZ = SizeTArrayType::CreateArray(outputData->getNumberOfTuples(), {3}, "Input Voxel XYZ Index", true); + inputVoxIndexXYZ->initializeWithZeros(); + attrMat->insertOrAssign(inputVoxIndexXYZ); + + SizeTArrayType::Pointer inputVoxIndex = SizeTArrayType::CreateArray(outputData->getNumberOfTuples(), {1}, "Input Voxel Index", true); + inputVoxIndex->initializeWithZeros(); + attrMat->insertOrAssign(inputVoxIndex); + + FloatArrayType::Pointer inputVoxCoord = FloatArrayType::CreateArray(outputData->getNumberOfTuples(), {3}, "Input Voxel Coord", true); + inputVoxCoord->initializeWithZeros(); + attrMat->insertOrAssign(inputVoxCoord); + +#endif + // Generate the Rotation Matrix + OrientationMatrixType om = ax2om(m_RotationAxis); +#if GTS_GENERATE_DEBUG_ARRAYS + FloatArrayType::Pointer copyOfGrid = std::dynamic_pointer_cast(m_Coords->deepCopy()); + IDataArray::Pointer vertexOutputData = outputData->createNewArray(copyOfGrid->getNumberOfTuples(), outputData->getComponentDimensions(), outputData->getName(), true); + vertexOutputData->initializeWithZeros(); +#endif + ImageGeom::ErrorType err; + size_t numTuples = m_Coords->getNumberOfTuples(); + // int32_t numComp = m_Coords->getNumberOfComponents(); + for(size_t tupleIndex = 0; tupleIndex < numTuples; tupleIndex++) + { + size_t outputVoxelIndex = 0; + size_t inputVoxelIndex = 0; + + // Get the original point as a copy + FloatVec3Type inCoord(m_Coords->getComponent(tupleIndex, 0), m_Coords->getComponent(tupleIndex, 1), m_Coords->getComponent(tupleIndex, 2)); +#if GTS_GENERATE_DEBUG_ARRAYS + inputVoxCoord->setTuple(tupleIndex, inCoord.data()); +#endif + // Find the voxel that data will be copied into + err = outputImageGeom->computeCellIndex(inCoord.data(), outputVoxelIndex); + if(err != ImageGeom::ErrorType::NoError) + { + continue; + } + // std::cout << tupleIndex << "\tCoord:" << inCoord[0] << ", " << inCoord[1] << ", " << inCoord[2]; + + // Transform the Point via translation to move it to a relative position to (0,0,0) + inCoord[0] = inCoord[0] - center[0]; + inCoord[1] = inCoord[1] - center[1]; + inCoord[2] = inCoord[2] - center[2]; + + // Transform the point using the Orientation Matrix + CoordinateType outCoord = transformCoordinate(om, inCoord); + + // Translate back to the actual grid + outCoord[0] = outCoord[0] + center[0]; + outCoord[1] = outCoord[1] + center[1]; + outCoord[2] = outCoord[2] + center[2]; + +// Set the transformed coordinate into the copy of the grid Vertex List +#if GTS_GENERATE_DEBUG_ARRAYS + copyOfGrid->setTuple(tupleIndex, outCoord.data()); +#endif + + // std::cout << "\t InputVoxelIndex: " << inputVoxelIndices[0] << ", " << inputVoxelIndices[1] << ", " << inputVoxelIndices[2] << std::endl; +#if GTS_GENERATE_DEBUG_ARRAYS + SizeVec3Type inputVoxelIndices; + err = inputImageGeom->computeCellIndex(outCoord.data(), inputVoxelIndices.data()); + inputVoxIndexXYZ->setTuple(tupleIndex, inputVoxelIndices.data()); +#endif + err = inputImageGeom->computeCellIndex(outCoord.data(), inputVoxelIndex); + +#if GTS_GENERATE_DEBUG_ARRAYS + // This line is OK to have before the error condition is checked because we are writing the value not + // using it to step into an array. This also allows us to debug the data coming out of this + // algorithm + inputVoxIndex->setTuple(tupleIndex, &inputVoxelIndex); +#endif + if(err != ImageGeom::ErrorType::NoError) + { + continue; + } + outputData->copyFromArray(outputVoxelIndex, inputData, inputVoxelIndex, 1); +#if GTS_GENERATE_DEBUG_ARRAYS + // Write the selected cell value array from the input data onto the Vertex Cell Array + // This allows us to visualize the data more easily in ParaView + vertexOutputData->copyFromArray(tupleIndex, inputData, inputVoxelIndex, 1); +#endif + } + +#if GTS_GENERATE_DEBUG_ARRAYS + // Write out the sampling grid + QString dcName = QString("%1 Vertex Grid %2").arg(m_Filter->getOutputPrefix()).arg(m_GridIndex); + DataContainer::Pointer gridGeomDC = DataContainer::New(dcName); + VertexGeom::Pointer gridVertGeom = VertexGeom::CreateGeometry(copyOfGrid->getNumberOfTuples(), "Grid Geometry", true); + gridVertGeom->setVertices(copyOfGrid); + gridGeomDC->setGeometry(gridVertGeom); + dca->insertOrAssign(gridGeomDC); + AttributeMatrix::Pointer cellAttrMat = AttributeMatrix::New({copyOfGrid->getNumberOfTuples()}, Detail::k_AttributeMatrixName, AttributeMatrix::Type::Vertex); + gridGeomDC->insertOrAssign(cellAttrMat); + cellAttrMat->insertOrAssign(vertexOutputData); +#endif + } + + template + K transformCoordinate(const T& orientationMatrix, const K& coord) const + { + K outCoord = {0, 0, 0}; + + outCoord[0] = orientationMatrix[0] * coord[0] + orientationMatrix[1] * coord[1] + orientationMatrix[2] * coord[2]; + outCoord[1] = orientationMatrix[3] * coord[0] + orientationMatrix[4] * coord[1] + orientationMatrix[5] * coord[2]; + outCoord[2] = orientationMatrix[6] * coord[0] + orientationMatrix[7] * coord[1] + orientationMatrix[8] * coord[2]; + + return outCoord; + } + + template + OutputType ax2om(const InputType& a) const + { + OutputType res(9); + typename OutputType::value_type q = 0.0L; + typename OutputType::value_type c = 0.0L; + typename OutputType::value_type s = 0.0L; + typename OutputType::value_type omc = 0.0L; + + c = cos(a[3]); + s = sin(a[3]); + + omc = 1.0f - c; + + res[0] = a[0] * a[0] * omc + c; + res[4] = a[1] * a[1] * omc + c; + res[8] = a[2] * a[2] * omc + c; + size_t _01 = 1; + size_t _10 = 3; + size_t _12 = 5; + size_t _21 = 7; + size_t _02 = 2; + size_t _20 = 6; + // Check to see if we need to transpose + if(Rotations::Constants::epsijk == 1.0f) + { + _01 = 3; + _10 = 1; + _12 = 7; + _21 = 5; + _02 = 6; + _20 = 2; + } + + q = omc * a[0] * a[1]; + res[_01] = q + s * a[2]; + res[_10] = q - s * a[2]; + q = omc * a[1] * a[2]; + res[_12] = q + s * a[0]; + res[_21] = q - s * a[0]; + q = omc * a[2] * a[0]; + res[_02] = q - s * a[1]; + res[_20] = q + s * a[1]; + + return res; + } + +private: + GenerateTiltSeries* m_Filter = nullptr; + FloatArrayType::Pointer m_Coords; + DataContainer::Pointer m_OutputDC; + std::array m_RotationAxis; +#if GTS_GENERATE_DEBUG_ARRAYS + size_t m_GridIndex = 0; +#endif +}; + +} // namespace Detail + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenerateTiltSeries::GenerateTiltSeries() +{ + initialize(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenerateTiltSeries::~GenerateTiltSeries() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void GenerateTiltSeries::initialize() +{ + clearErrorCode(); + clearWarningCode(); + setCancel(false); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void GenerateTiltSeries::setupFilterParameters() +{ + FilterParameterVectorType parameters; + { + ChoiceFilterParameter::Pointer parameter = ChoiceFilterParameter::New(); + parameter->setHumanLabel("Rotation Axis"); + parameter->setPropertyName("RotationAxis"); + + std::vector choices; // Please add choices to the choices QVector to finish this widget + choices.push_back("X Axis"); + choices.push_back("Y Axis"); + choices.push_back("Z Axis"); + parameter->setChoices(choices); + parameter->setCategory(FilterParameter::Category::Parameter); + parameter->setSetterCallback(SIMPL_BIND_SETTER(GenerateTiltSeries, this, RotationAxis)); + parameter->setGetterCallback(SIMPL_BIND_GETTER(GenerateTiltSeries, this, RotationAxis)); + parameters.push_back(parameter); + } + parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Rotation Limits (Start, Stop, Increment) Degrees", RotationLimits, FilterParameter::Category::Parameter, GenerateTiltSeries)); + parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Resample Spacing", Spacing, FilterParameter::Category::Parameter, GenerateTiltSeries)); + // DataArrayCreationFilterParameter::RequirementType dacReq; + // parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Created Array Path", CreatedArrayPath, FilterParameter::Category::Parameter, GenerateTiltSeries, dacReq)); + DataArraySelectionFilterParameter::RequirementType dasReq; + dasReq.dcGeometryTypes = {IGeometry::Type::Image}; + dasReq.amTypes = {AttributeMatrix::Type::Cell}; + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Input Data Array Path", InputDataArrayPath, FilterParameter::Category::Parameter, GenerateTiltSeries, dasReq)); + parameters.push_back(SIMPL_NEW_STRING_FP("DataContainer Prefix", OutputPrefix, FilterParameter::Category::Parameter, GenerateTiltSeries)); + setFilterParameters(parameters); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void GenerateTiltSeries::dataCheck() +{ + clearErrorCode(); + clearWarningCode(); + + // Validate ImageGeometry and Cell Type for attribute matrix + + // Validate correct range of Rotation Axis (0|1|2) + DataContainerArray::Pointer dca = getDataContainerArray(); + IDataArray::Pointer inputData = dca->getPrereqIDataArrayFromPath(this, getInputDataArrayPath()); + if(getErrorCode() < 0) + { + return; + } + + // Generate Data Structure + std::pair gridPair; + if(getRotationAxis() == k_XAxis) + { + gridPair = generateXAxisGrid(); + } + else if(getRotationAxis() == k_YAxis) + { + gridPair = generateYAxisGrid(); + } + else if(getRotationAxis() == k_ZAxis) + { + gridPair = generateZAxisGrid(); + } + if(nullptr == gridPair.first) + { + return; + } + FloatArrayType::Pointer gridCoords = gridPair.first; + ImageGeom::Pointer gridGeometry = gridPair.second; + SizeVec3Type gridDims = gridGeometry->getDimensions(); + + size_t gridIndex = 0; + + for(float currentDeg = m_RotationLimits[0]; currentDeg < m_RotationLimits[1]; currentDeg += m_RotationLimits[2]) + { + QString gridDCName = m_OutputPrefix + QString::number(gridIndex); + DataContainer::Pointer gridDC = DataContainer::New(gridDCName); + ImageGeom::Pointer gridImageGeom = std::dynamic_pointer_cast(gridGeometry->deepCopy()); + gridDC->setGeometry(gridImageGeom); + + AttributeMatrix::Pointer cellAttr = AttributeMatrix::New({gridDims[0], gridDims[1], gridDims[2]}, Detail::k_AttributeMatrixName, AttributeMatrix::Type::Cell); + gridDC->insertOrAssign(cellAttr); + + IDataArray::Pointer outputData = + inputData->createNewArray(gridDims[0] * gridDims[1] * gridDims[2], inputData->getComponentDimensions(), getInputDataArrayPath().getDataArrayName(), !getInPreflight()); + cellAttr->insertOrAssign(outputData); + getDataContainerArray()->insertOrAssign(gridDC); + + gridIndex++; + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void GenerateTiltSeries::execute() +{ + initialize(); + dataCheck(); + if(getErrorCode() < 0) + { + return; + } + + if(getCancel()) + { + return; + } + + // Compute a grid that forms a plane parallel to the rotation axis and centered halfway back in the volume + std::pair gridPair; + if(getRotationAxis() == k_XAxis) + { + gridPair = generateXAxisGrid(); + } + else if(getRotationAxis() == k_YAxis) + { + gridPair = generateYAxisGrid(); + } + else if(getRotationAxis() == k_ZAxis) + { + gridPair = generateZAxisGrid(); + } + FloatArrayType::Pointer gridCoords = gridPair.first; + ImageGeom::Pointer gridGeometry = gridPair.second; + DataContainerArray::Pointer dca = getDataContainerArray(); + +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS + std::shared_ptr g(new tbb::task_group); + // C++11 RIGHT HERE.... + int32_t nthreads = static_cast(std::thread::hardware_concurrency()); // Returns ZERO if not defined on this platform + int32_t threadCount = 0; +#endif + int32_t rotAxisSelection = getRotationAxis(); + + // Now Start Rotating the grid around the axis + size_t gridIndex = 0; + for(float currentDeg = m_RotationLimits[0]; currentDeg < m_RotationLimits[1]; currentDeg += m_RotationLimits[2]) + { + QString msg; + QTextStream out(&msg); + out << "Generating Tilt " << currentDeg << " (Deg)"; + notifyStatusMessage(msg); + QString gridDCName = m_OutputPrefix + QString::number(gridIndex); + DataContainer::Pointer gridDC = dca->getDataContainer(gridDCName); + + std::array rotationAxis = {0.0f, 0.0f, 0.0f, 0.0f}; + float radians = currentDeg * SIMPLib::Constants::k_PiOver180D; + if(k_XAxis == rotAxisSelection) + { + rotationAxis = {1.0f, 0.0f, 0.0f, radians}; + } + else if(k_YAxis == rotAxisSelection) + { + rotationAxis = {0.0f, 1.0f, 0.0f, radians}; + } + else if(k_ZAxis == rotAxisSelection) + { + rotationAxis = {0.0f, 0.0f, 1.0f, radians}; + } + +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS + g->run(Detail::ResampleGrid(this, gridCoords, gridDC, rotationAxis +#if GTS_GENERATE_DEBUG_ARRAYS + , + gridIndex +#endif + )); + threadCount++; + if(threadCount == nthreads) + { + g->wait(); + threadCount = 0; + } +#else + // std::cout << "Resample Deg = " << currentDeg << std::endl; + Detail::ResampleGrid impl(this, gridCoords, gridDC, rotationAxis +#if GTS_GENERATE_DEBUG_ARRAYS + , + gridIndex +#endif + ); + impl(); +#endif + + gridIndex++; + } + +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS + // This will spill over if the number of files to process does not divide evenly by the number of threads. + g->wait(); +#endif + +#if GTS_GENERATE_DEBUG_ARRAYS + // Write out the sampling grid + { + QString dcName = QString("%1 Grid Geom (Vertex)").arg(getOutputPrefix()); + DataContainer::Pointer gridGeomDC = DataContainer::New(dcName); + VertexGeom::Pointer gridVertGeom = VertexGeom::CreateGeometry(gridCoords->getNumberOfTuples(), "Grid Geometry", true); + gridVertGeom->setVertices(gridCoords); + gridGeomDC->setGeometry(gridVertGeom); + getDataContainerArray()->insertOrAssign(gridGeomDC); + } + { + QString dcName = QString("%1 Grid Geom (Image)").arg(getOutputPrefix()); + DataContainer::Pointer gridGeomDC = DataContainer::New(dcName); + gridGeomDC->setGeometry(gridGeometry); + getDataContainerArray()->insertOrAssign(gridGeomDC); + } +#endif +} + +// ----------------------------------------------------------------------------- +std::pair GenerateTiltSeries::generateZAxisGrid() +{ + DataContainer::Pointer inputDC = getDataContainerArray()->getDataContainer(getInputDataArrayPath().getDataContainerName()); + if(nullptr == inputDC.get()) + { + return {FloatArrayType::NullPointer(), ImageGeom::NullPointer()}; + } + ImageGeom::Pointer inputImageGeom = inputDC->getGeometryAs(); + FloatVec3Type origin = inputImageGeom->getOrigin(); + FloatVec3Type spacing = inputImageGeom->getSpacing(); + FloatVec6Type bounds = inputImageGeom->getBoundingBox(); + FloatVec3Type center((bounds[1] - bounds[0]) / 2.0f + bounds[0], (bounds[3] - bounds[2]) / 2.0f + bounds[2], (bounds[5] - bounds[4]) / 2.0f + bounds[4]); + + size_t xAxis = 0; + size_t yAxis = 1; + size_t zAxis = 2; + float diagonalDistance = 0.0; + + // Compute the total number of points along each axis + FloatVec3Type resampleSpacing = getSpacing(); + + std::array axisLength = {0.0f, 0.0f, 0.0f}; + std::array newOrigin = {0.0f, 0.0f, 0.0f}; + + float iStart = bounds[zAxis * 2]; + float iEnd = bounds[zAxis * 2 + 1]; + float iIncr = spacing[zAxis]; + + float jStart = newOrigin[xAxis]; + float jEnd = newOrigin[xAxis] + diagonalDistance; + float jIncr = resampleSpacing[xAxis]; + + axisLength = {bounds[2 * xAxis + 1] - bounds[2 * xAxis], bounds[2 * yAxis + 1] - bounds[2 * yAxis], bounds[2 * zAxis + 1] - bounds[2 * zAxis]}; + diagonalDistance = std::sqrt(axisLength[0] * axisLength[0] + axisLength[1] * axisLength[1]); + + newOrigin[xAxis] = center[xAxis] - diagonalDistance / 2.0f; + newOrigin[yAxis] = center[yAxis]; + newOrigin[zAxis] = bounds[zAxis * 2]; // Use the original origin for the 3rd Axis + + iStart = bounds[zAxis * 2]; + iEnd = bounds[zAxis * 2 + 1]; + iIncr = resampleSpacing[zAxis]; + + jStart = newOrigin[xAxis]; + jEnd = newOrigin[xAxis] + diagonalDistance; + jIncr = resampleSpacing[xAxis]; + + size_t gridPrimAxisDim = static_cast(std::ceil((iEnd - iStart) / iIncr)); + size_t gridSecondAxisDim = static_cast(std::ceil((jEnd - jStart) / jIncr)); + size_t totalElements = gridPrimAxisDim * gridSecondAxisDim; + if(totalElements == 0) + { + return {FloatArrayType::NullPointer(), ImageGeom::NullPointer()}; + } + + std::array halfSpacing = {resampleSpacing[xAxis] / 2.0f, resampleSpacing[yAxis] / 2.0f}; + + ImageGeom::Pointer newGridGeom = ImageGeom::CreateGeometry("Grid Geometry"); + + SizeVec3Type newGridGeomDims; + newGridGeomDims[xAxis] = gridSecondAxisDim; + newGridGeomDims[yAxis] = 1; + newGridGeomDims[zAxis] = gridPrimAxisDim; + + FloatVec3Type newGridGeomSpacing; + newGridGeomSpacing[xAxis] = jIncr; + newGridGeomSpacing[yAxis] = spacing[yAxis]; + newGridGeomSpacing[zAxis] = iIncr; + + FloatVec3Type newGridGeomOrigin; + newGridGeomOrigin[xAxis] = center[xAxis] - diagonalDistance / 2.0f; + newGridGeomOrigin[yAxis] = center[yAxis]; + newGridGeomOrigin[zAxis] = bounds[zAxis * 2]; + + newGridGeom->setDimensions(newGridGeomDims); + newGridGeom->setSpacing(newGridGeomSpacing); + newGridGeom->setOrigin(newGridGeomOrigin); + + FloatArrayType::Pointer gridCoords = FloatArrayType::CreateArray(totalElements, {3}, "Grid Coords", !getInPreflight()); + if(!getInPreflight()) + { + size_t tupleIndex = 0; + for(float i = iStart; i < iEnd; i += iIncr) + { + for(float j = jStart; j < jEnd; j += jIncr) + { + std::array coords; + + coords[xAxis] = j + halfSpacing[0]; + coords[zAxis] = i + halfSpacing[1]; + coords[yAxis] = origin[yAxis] + axisLength[yAxis] / 2.0f + spacing[yAxis] / 2.0f; + + gridCoords->setTuple(tupleIndex, coords.data()); + + tupleIndex++; + } + } + } + return {gridCoords, newGridGeom}; +} + +// ----------------------------------------------------------------------------- +std::pair GenerateTiltSeries::generateYAxisGrid() +{ + DataContainer::Pointer inputDC = getDataContainerArray()->getDataContainer(getInputDataArrayPath().getDataContainerName()); + if(nullptr == inputDC.get()) + { + return {FloatArrayType::NullPointer(), ImageGeom::NullPointer()}; + } + ImageGeom::Pointer inputImageGeom = inputDC->getGeometryAs(); + FloatVec3Type origin = inputImageGeom->getOrigin(); + FloatVec3Type spacing = inputImageGeom->getSpacing(); + FloatVec6Type bounds = inputImageGeom->getBoundingBox(); + FloatVec3Type center((bounds[1] - bounds[0]) / 2.0f + bounds[0], (bounds[3] - bounds[2]) / 2.0f + bounds[2], (bounds[5] - bounds[4]) / 2.0f + bounds[4]); + + size_t xAxis = 0; + size_t yAxis = 1; + size_t zAxis = 2; + float diagonalDistance = 0.0; + + // Compute the total number of points along each axis + FloatVec3Type resampleSpacing = getSpacing(); + + std::array axisLength = {0.0f, 0.0f, 0.0f}; + std::array newOrigin = {0.0f, 0.0f, 0.0f}; + + axisLength = {bounds[2 * yAxis + 1] - bounds[2 * yAxis], bounds[2 * zAxis + 1] - bounds[2 * zAxis], bounds[2 * xAxis + 1] - bounds[2 * xAxis]}; + diagonalDistance = std::sqrt(axisLength[0] * axisLength[0] + axisLength[1] * axisLength[1]); + + newOrigin[xAxis] = center[xAxis]; + newOrigin[yAxis] = bounds[yAxis * 2]; + newOrigin[zAxis] = center[zAxis] - diagonalDistance / 2.0f; + + float iStart = newOrigin[yAxis]; + float iEnd = bounds[yAxis * 2 + 1]; + float iIncr = resampleSpacing[yAxis]; + + float jStart = newOrigin[zAxis]; + float jEnd = newOrigin[zAxis] + diagonalDistance; + float jIncr = resampleSpacing[zAxis]; + + size_t gridPrimAxisDim = static_cast(std::ceil((iEnd - iStart) / iIncr)); + size_t gridSecondAxisDim = static_cast(std::ceil((jEnd - jStart) / jIncr)); + size_t totalElements = gridPrimAxisDim * gridSecondAxisDim; + if(totalElements == 0) + { + return {FloatArrayType::NullPointer(), ImageGeom::NullPointer()}; + } + + std::array halfSpacing = {resampleSpacing[yAxis] / 2.0f, resampleSpacing[zAxis] / 2.0f}; + + ImageGeom::Pointer newGridGeom = ImageGeom::CreateGeometry("Grid Geometry"); + + SizeVec3Type newGridGeomDims; + newGridGeomDims[xAxis] = 1; + ; + newGridGeomDims[yAxis] = gridPrimAxisDim; + newGridGeomDims[zAxis] = gridSecondAxisDim; + + FloatVec3Type newGridGeomSpacing; + newGridGeomSpacing[xAxis] = spacing[xAxis]; + newGridGeomSpacing[yAxis] = iIncr; + newGridGeomSpacing[zAxis] = jIncr; + + FloatVec3Type newGridGeomOrigin; + newGridGeomOrigin[xAxis] = newOrigin[xAxis]; + newGridGeomOrigin[yAxis] = newOrigin[yAxis]; + newGridGeomOrigin[zAxis] = newOrigin[zAxis]; + + newGridGeom->setDimensions(newGridGeomDims); + newGridGeom->setSpacing(newGridGeomSpacing); + newGridGeom->setOrigin(newGridGeomOrigin); + + FloatArrayType::Pointer gridCoords = FloatArrayType::CreateArray(totalElements, {3}, "Grid Coords", !getInPreflight()); + if(!getInPreflight()) + { + size_t tupleIndex = 0; + for(float i = iStart; i < iEnd; i += iIncr) + { + for(float j = jStart; j < jEnd; j += jIncr) + { + std::array coords; + + coords[xAxis] = origin[xAxis] + axisLength[2] / 2.0f + spacing[xAxis] / 2.0f; + coords[yAxis] = i + halfSpacing[0]; + coords[zAxis] = j + halfSpacing[1]; + + gridCoords->setTuple(tupleIndex, coords.data()); + + tupleIndex++; + } + } + } + return {gridCoords, newGridGeom}; +} + +// ----------------------------------------------------------------------------- +std::pair GenerateTiltSeries::generateXAxisGrid() +{ + DataContainer::Pointer inputDC = getDataContainerArray()->getDataContainer(getInputDataArrayPath().getDataContainerName()); + if(nullptr == inputDC.get()) + { + return {FloatArrayType::NullPointer(), ImageGeom::NullPointer()}; + } + ImageGeom::Pointer inputImageGeom = inputDC->getGeometryAs(); + FloatVec3Type origin = inputImageGeom->getOrigin(); + FloatVec3Type spacing = inputImageGeom->getSpacing(); + FloatVec6Type bounds = inputImageGeom->getBoundingBox(); + FloatVec3Type center((bounds[1] - bounds[0]) / 2.0f + bounds[0], (bounds[3] - bounds[2]) / 2.0f + bounds[2], (bounds[5] - bounds[4]) / 2.0f + bounds[4]); + + size_t xAxis = 0; + size_t yAxis = 1; + size_t zAxis = 2; + float diagonalDistance = 0.0; + + // Compute the total number of points along each axis + FloatVec3Type resampleSpacing = getSpacing(); + + std::array axisLength = {0.0f, 0.0f, 0.0f}; + std::array newOrigin = {0.0f, 0.0f, 0.0f}; + + axisLength = {bounds[2 * xAxis + 1] - bounds[2 * xAxis], bounds[2 * yAxis + 1] - bounds[2 * yAxis], bounds[2 * zAxis + 1] - bounds[2 * zAxis]}; + diagonalDistance = std::sqrt(axisLength[xAxis] * axisLength[xAxis] + axisLength[yAxis] * axisLength[yAxis]); + + newOrigin[xAxis] = bounds[xAxis]; // xMin + newOrigin[yAxis] = center[yAxis] - diagonalDistance / 2.0f; + newOrigin[zAxis] = center[zAxis]; + + float iStart = newOrigin[xAxis]; + float iEnd = bounds[xAxis * 2 + 1]; + float iIncr = resampleSpacing[xAxis]; + + float jStart = newOrigin[yAxis]; + float jEnd = newOrigin[yAxis] + diagonalDistance; + float jIncr = resampleSpacing[yAxis]; + + size_t gridPrimAxisDim = static_cast(std::ceil((iEnd - iStart) / iIncr)); + size_t gridSecondAxisDim = static_cast(std::ceil((jEnd - jStart) / jIncr)); + size_t totalElements = gridPrimAxisDim * gridSecondAxisDim; + if(totalElements == 0) + { + return {FloatArrayType::NullPointer(), ImageGeom::NullPointer()}; + } + + std::array halfSpacing = {resampleSpacing[xAxis] / 2.0f, resampleSpacing[yAxis] / 2.0f}; + + ImageGeom::Pointer newGridGeom = ImageGeom::CreateGeometry("Grid Geometry"); + + SizeVec3Type newGridGeomDims; + newGridGeomDims[xAxis] = gridPrimAxisDim; + ; + newGridGeomDims[yAxis] = gridSecondAxisDim; + newGridGeomDims[zAxis] = 1; + + FloatVec3Type newGridGeomSpacing; + newGridGeomSpacing[xAxis] = iIncr; + newGridGeomSpacing[yAxis] = jIncr; + newGridGeomSpacing[zAxis] = spacing[zAxis]; + + FloatVec3Type newGridGeomOrigin; + newGridGeomOrigin[xAxis] = newOrigin[xAxis]; + newGridGeomOrigin[yAxis] = newOrigin[yAxis]; + newGridGeomOrigin[zAxis] = newOrigin[zAxis]; + + newGridGeom->setDimensions(newGridGeomDims); + newGridGeom->setSpacing(newGridGeomSpacing); + newGridGeom->setOrigin(newGridGeomOrigin); + + FloatArrayType::Pointer gridCoords = FloatArrayType::CreateArray(totalElements, {3}, "Grid Coords", !getInPreflight()); + if(!getInPreflight()) + { + size_t tupleIndex = 0; + for(float i = iStart; i < iEnd; i += iIncr) + { + for(float j = jStart; j < jEnd; j += jIncr) + { + std::array coords; + + coords[xAxis] = i + halfSpacing[0]; + coords[yAxis] = j + halfSpacing[1]; + coords[zAxis] = origin[zAxis] + axisLength[zAxis] / 2.0f + spacing[zAxis] / 2.0f; + + gridCoords->setTuple(tupleIndex, coords.data()); + + tupleIndex++; + } + } + } + return {gridCoords, newGridGeom}; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AbstractFilter::Pointer GenerateTiltSeries::newFilterInstance(bool copyFilterParameters) const +{ + GenerateTiltSeries::Pointer filter = GenerateTiltSeries::New(); + if(copyFilterParameters) + { + copyFilterParameterInstanceVariables(filter.get()); + } + return filter; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenerateTiltSeries::getCompiledLibraryName() const +{ + return Core::CoreBaseName; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenerateTiltSeries::getBrandingString() const +{ + return "SIMPLib Core Filter"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenerateTiltSeries::getFilterVersion() const +{ + QString version; + QTextStream vStream(&version); + vStream << SIMPLib::Version::Major() << "." << SIMPLib::Version::Minor() << "." << SIMPLib::Version::Patch(); + return version; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenerateTiltSeries::getGroupName() const +{ + return SIMPL::FilterGroups::CoreFilters; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenerateTiltSeries::getSubGroupName() const +{ + return SIMPL::FilterSubGroups::CropCutFilters; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenerateTiltSeries::getHumanLabel() const +{ + return "Generate Tilt Series"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QUuid GenerateTiltSeries::getUuid() const +{ + return QUuid("{829da805-6d7c-5106-8209-aae1c207de15}"); +} + +// ----------------------------------------------------------------------------- +GenerateTiltSeries::Pointer GenerateTiltSeries::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr GenerateTiltSeries::New() +{ + struct make_shared_enabler : public GenerateTiltSeries + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString GenerateTiltSeries::getNameOfClass() const +{ + return QString("GenerateTiltSeries"); +} + +// ----------------------------------------------------------------------------- +QString GenerateTiltSeries::ClassName() +{ + return QString("GenerateTiltSeries"); +} + +// ----------------------------------------------------------------------------- +void GenerateTiltSeries::setRotationAxis(int value) +{ + m_RotationAxis = value; +} + +// ----------------------------------------------------------------------------- +int GenerateTiltSeries::getRotationAxis() const +{ + return m_RotationAxis; +} + +// ----------------------------------------------------------------------------- +void GenerateTiltSeries::setRotationLimits(const FloatVec3Type& value) +{ + m_RotationLimits = value; +} + +// ----------------------------------------------------------------------------- +FloatVec3Type GenerateTiltSeries::getRotationLimits() const +{ + return m_RotationLimits; +} + +// ----------------------------------------------------------------------------- +void GenerateTiltSeries::setSpacing(const FloatVec3Type& value) +{ + m_Spacing = value; +} + +// ----------------------------------------------------------------------------- +FloatVec3Type GenerateTiltSeries::getSpacing() const +{ + return m_Spacing; +} + +// ----------------------------------------------------------------------------- +void GenerateTiltSeries::setInputDataArrayPath(const DataArrayPath& value) +{ + m_InputDataArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath GenerateTiltSeries::getInputDataArrayPath() const +{ + return m_InputDataArrayPath; +} + +// ----------------------------------------------------------------------------- +void GenerateTiltSeries::setOutputPrefix(const QString& value) +{ + m_OutputPrefix = value; +} + +// ----------------------------------------------------------------------------- +QString GenerateTiltSeries::getOutputPrefix() const +{ + return m_OutputPrefix; +} diff --git a/Source/SIMPLib/CoreFilters/GenerateTiltSeries.h b/Source/SIMPLib/CoreFilters/GenerateTiltSeries.h new file mode 100644 index 0000000000..541485d236 --- /dev/null +++ b/Source/SIMPLib/CoreFilters/GenerateTiltSeries.h @@ -0,0 +1,237 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * United States Air Force Prime Contract FA8650-10-D-5210 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLArray.hpp" +#include "SIMPLib/Filtering/AbstractFilter.h" +#include "SIMPLib/Geometry/ImageGeom.h" + +/** + * @brief The GenerateTiltSeries class. See [Filter documentation](@ref GenerateTiltSeries) for details. + */ +class SIMPLib_EXPORT GenerateTiltSeries : public AbstractFilter +{ + Q_OBJECT + + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(GenerateTiltSeries SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(GenerateTiltSeries) + PYB11_STATIC_NEW_MACRO(GenerateTiltSeries) + PYB11_PROPERTY(int RotationAxis READ getRotationAxis WRITE setRotationAxis) + PYB11_PROPERTY(float RotationLimits READ getRotationLimits WRITE setRotationLimits) + PYB11_PROPERTY(float Spacing READ getSpacing WRITE setSpacing) + PYB11_PROPERTY(DataArrayPath InputDataArrayPath READ getInputDataArrayPath WRITE setInputDataArrayPath) + PYB11_PROPERTY(QString OutputPrefix READ getOutputPrefix WRITE setOutputPrefix) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations + +public: + using Self = GenerateTiltSeries; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for GenerateTiltSeries + */ + QString getNameOfClass() const override; + + /** + * @brief Returns the name of the class for GenerateTiltSeries + */ + static QString ClassName(); + + ~GenerateTiltSeries() override; + + static constexpr int32_t k_XAxis = 0; + static constexpr int32_t k_YAxis = 1; + static constexpr int32_t k_ZAxis = 2; + + /** + * @brief Setter property for RotationAxis + */ + void setRotationAxis(int value); + /** + * @brief Getter property for RotationAxis + * @return Value of RotationAxis + */ + int getRotationAxis() const; + + Q_PROPERTY(int RotationAxis READ getRotationAxis WRITE setRotationAxis) + + /** + * @brief Setter property for RotationLimits + */ + void setRotationLimits(const FloatVec3Type& value); + /** + * @brief Getter property for RotationLimits + * @return Value of RotationLimits + */ + FloatVec3Type getRotationLimits() const; + + Q_PROPERTY(FloatVec3Type RotationLimits READ getRotationLimits WRITE setRotationLimits) + + /** + * @brief Setter property for Spacing + */ + void setSpacing(const FloatVec3Type& value); + /** + * @brief Getter property for Spacing + * @return Value of Spacing + */ + FloatVec3Type getSpacing() const; + + Q_PROPERTY(FloatVec3Type Spacing READ getSpacing WRITE setSpacing) + + /** + * @brief Setter property for InputDataArrayPath + */ + void setInputDataArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for InputDataArrayPath + * @return Value of InputDataArrayPath + */ + DataArrayPath getInputDataArrayPath() const; + + Q_PROPERTY(DataArrayPath InputDataArrayPath READ getInputDataArrayPath WRITE setInputDataArrayPath) + + /** + * @brief Setter property for OutputPrefix + */ + void setOutputPrefix(const QString& value); + /** + * @brief Getter property for OutputPrefix + * @return Value of OutputPrefix + */ + QString getOutputPrefix() const; + + Q_PROPERTY(QString OutputPrefix READ getOutputPrefix WRITE setOutputPrefix) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + GenerateTiltSeries(); + + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + + std::pair generateXAxisGrid(); + std::pair generateYAxisGrid(); + std::pair generateZAxisGrid(); + +private: + int m_RotationAxis = 0; + FloatVec3Type m_RotationLimits = FloatVec3Type{0.0f, 180.f, 10.0f}; + FloatVec3Type m_Spacing = FloatVec3Type(1.0, 1.0, 1.0); + DataArrayPath m_InputDataArrayPath = DataArrayPath("DataContainer", "AttributeMatrix", "FeatureIds"); + QString m_OutputPrefix = {"Rotation_"}; + + static constexpr unsigned Dimension = 3; + +public: + GenerateTiltSeries(const GenerateTiltSeries&) = delete; // Copy Constructor Not Implemented + GenerateTiltSeries& operator=(const GenerateTiltSeries&) = delete; // Copy Assignment Not Implemented + GenerateTiltSeries(GenerateTiltSeries&&) = delete; // Move Constructor Not Implemented + GenerateTiltSeries& operator=(GenerateTiltSeries&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/CoreFilters/GenerateVertexCoordinates.cpp b/Source/SIMPLib/CoreFilters/GenerateVertexCoordinates.cpp new file mode 100644 index 0000000000..2504007a57 --- /dev/null +++ b/Source/SIMPLib/CoreFilters/GenerateVertexCoordinates.cpp @@ -0,0 +1,288 @@ +/* ============================================================================ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "GenerateVertexCoordinates.h" + +#include +#include + +#include + +#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" +#include "SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h" +#include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + DataArrayID31 = 31 +}; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenerateVertexCoordinates::GenerateVertexCoordinates() +{ + initialize(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GenerateVertexCoordinates::~GenerateVertexCoordinates() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void GenerateVertexCoordinates::initialize() +{ + clearErrorCode(); + clearWarningCode(); + setCancel(false); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void GenerateVertexCoordinates::setupFilterParameters() +{ + FilterParameterVectorType parameters; + { + DataContainerSelectionFilterParameter::RequirementType req; + req.dcGeometryTypes = {IGeometry::Type::Image, IGeometry::Type::RectGrid}; + parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container with Input Geometry", SelectedDataContainerName, FilterParameter::Category::RequiredArray, GenerateVertexCoordinates, req)); + } + + DataArrayCreationFilterParameter::RequirementType req; + req.amTypes = {AttributeMatrix::Type::Cell}; + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Created Vertex Coordinates", CoordinateArrayPath, FilterParameter::Category::CreatedArray, GenerateVertexCoordinates, req, 0)); + + setFilterParameters(parameters); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void GenerateVertexCoordinates::dataCheck() +{ + clearErrorCode(); + clearWarningCode(); + + if(m_SelectedDataContainerName.isEmpty()) + { + QString ss = QObject::tr("The name of the input DataContainer is empty. Please specify a value."); + setErrorCondition(-2004, ss); + return; + } + + DataContainer::Pointer dc = getDataContainerArray()->getPrereqDataContainer(this, getSelectedDataContainerName()); + if(getErrorCode() < 0) + { + return; + } + + IGeometry::Pointer fromGeometry = dc->getGeometry(); + if(nullptr == fromGeometry) + { + QString ss = QObject::tr("Selected input DataContainer must contain either an Image Geometry or RectLinearGrid Geometry. The DataContainer did not contain a Geometry object."); + setErrorCondition(-2008, ss); + return; + } + IGeometry::Type geomType = fromGeometry->getGeometryType(); + if(IGeometry::Type::Image == geomType || IGeometry::Type::RectGrid == geomType) + { + m_CoordinatesPtr = getDataContainerArray()->createNonPrereqArrayFromPath(this, getCoordinateArrayPath(), 0, {3}, "", DataArrayID31); + } + else + { + QString ss = QObject::tr("Data Container's Geometry type must be either an Image Geometry or RectLinearGrid Geometry. The Geomerty is of type %1").arg(fromGeometry->getGeometryTypeAsString()); + setErrorCondition(-2010, ss); + return; + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void GenerateVertexCoordinates::execute() +{ + initialize(); + dataCheck(); + if(getErrorCode() < 0) + { + return; + } + + IGeometryGrid::Pointer sourceGeometry = getDataContainerArray()->getDataContainer(getSelectedDataContainerName())->getGeometryAs(); + + std::array coords = {0.0f, 0.0f, 0.0f}; + + SizeVec3Type dims = sourceGeometry->getDimensions(); + size_t cellCount = std::accumulate(dims.begin(), dims.end(), static_cast(1), std::multiplies()); + + // Use the APIs from the IGeometryGrid to get the XYZ coord for the center of each cell and then set that into the + // the new VertexGeometry + for(size_t idx = 0; idx < cellCount; idx++) + { + sourceGeometry->getCoords(idx, coords.data()); + m_CoordinatesPtr->setTuple(idx, coords.data()); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AbstractFilter::Pointer GenerateVertexCoordinates::newFilterInstance(bool copyFilterParameters) const +{ + GenerateVertexCoordinates::Pointer filter = GenerateVertexCoordinates::New(); + if(copyFilterParameters) + { + copyFilterParameterInstanceVariables(filter.get()); + } + return filter; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenerateVertexCoordinates::getCompiledLibraryName() const +{ + return Core::CoreBaseName; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenerateVertexCoordinates::getBrandingString() const +{ + return "SIMPLib Core Filter"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenerateVertexCoordinates::getFilterVersion() const +{ + QString version; + QTextStream vStream(&version); + vStream << SIMPLib::Version::Major() << "." << SIMPLib::Version::Minor() << "." << SIMPLib::Version::Patch(); + return version; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenerateVertexCoordinates::getGroupName() const +{ + return SIMPL::FilterGroups::CoreFilters; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenerateVertexCoordinates::getSubGroupName() const +{ + return SIMPL::FilterSubGroups::ConversionFilters; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString GenerateVertexCoordinates::getHumanLabel() const +{ + return "Generate Cell Center Coords"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QUuid GenerateVertexCoordinates::getUuid() const +{ + return QUuid("{657a79de-7d60-5d9d-9f41-80abb62a3158}"); +} + +// ----------------------------------------------------------------------------- +GenerateVertexCoordinates::Pointer GenerateVertexCoordinates::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr GenerateVertexCoordinates::New() +{ + struct make_shared_enabler : public GenerateVertexCoordinates + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString GenerateVertexCoordinates::getNameOfClass() const +{ + return QString("GenerateVertexCoordinates"); +} + +// ----------------------------------------------------------------------------- +QString GenerateVertexCoordinates::ClassName() +{ + return QString("GenerateVertexCoordinates"); +} + +// ----------------------------------------------------------------------------- +void GenerateVertexCoordinates::setSelectedDataContainerName(const DataArrayPath& value) +{ + m_SelectedDataContainerName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath GenerateVertexCoordinates::getSelectedDataContainerName() const +{ + return m_SelectedDataContainerName; +} + +// ----------------------------------------------------------------------------- +void GenerateVertexCoordinates::setCoordinateArrayPath(const DataArrayPath& value) +{ + m_CoordinateArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath GenerateVertexCoordinates::getCoordinateArrayPath() const +{ + return m_CoordinateArrayPath; +} diff --git a/Source/SIMPLib/CoreFilters/GenerateVertexCoordinates.h b/Source/SIMPLib/CoreFilters/GenerateVertexCoordinates.h new file mode 100644 index 0000000000..a5019e4ad6 --- /dev/null +++ b/Source/SIMPLib/CoreFilters/GenerateVertexCoordinates.h @@ -0,0 +1,195 @@ +/* ============================================================================ + * Copyright (c) 2009-2018 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" +#include "SIMPLib/Geometry/ImageGeom.h" +#include "SIMPLib/Geometry/RectGridGeom.h" +#include "SIMPLib/Geometry/VertexGeom.h" + +/** + * @brief The GenerateVertexCoordinates class. See [Filter documentation](@ref convertdatacontainergeometry) for details. + */ +class SIMPLib_EXPORT GenerateVertexCoordinates : public AbstractFilter +{ + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(GenerateVertexCoordinates SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(GenerateVertexCoordinates) + PYB11_FILTER_NEW_MACRO(GenerateVertexCoordinates) + PYB11_PROPERTY(DataArrayPath SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) + PYB11_PROPERTY(DataArrayPath CoordinateArrayPath READ getCoordinateArrayPath WRITE setCoordinateArrayPath) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = GenerateVertexCoordinates; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + ~GenerateVertexCoordinates() override; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for GenerateVertexCoordinates + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for GenerateVertexCoordinates + */ + static QString ClassName(); + + /** + * @brief Setter property for SelectedDataContainerName + */ + void setSelectedDataContainerName(const DataArrayPath& value); + /** + * @brief Getter property for SelectedDataContainerName + * @return Value of SelectedDataContainerName + */ + DataArrayPath getSelectedDataContainerName() const; + + Q_PROPERTY(DataArrayPath SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) + + /** + * @brief Setter property for VertexDataContainerName + */ + void setCoordinateArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for VertexDataContainerName + * @return Value of VertexDataContainerName + */ + DataArrayPath getCoordinateArrayPath() const; + + Q_PROPERTY(DataArrayPath CoordinateArrayPath READ getCoordinateArrayPath WRITE setCoordinateArrayPath) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + GenerateVertexCoordinates(); + + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + DataArrayPath m_SelectedDataContainerName = {}; + DataArrayPath m_CoordinateArrayPath = {"", "", ""}; + FloatArrayType::Pointer m_CoordinatesPtr; + +public: + GenerateVertexCoordinates(const GenerateVertexCoordinates&) = delete; // Copy Constructor Not Implemented + GenerateVertexCoordinates& operator=(const GenerateVertexCoordinates&) = delete; // Copy Assignment Not Implemented + GenerateVertexCoordinates(GenerateVertexCoordinates&&) = delete; // Move Constructor Not Implemented + GenerateVertexCoordinates& operator=(GenerateVertexCoordinates&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/CoreFilters/ImportAsciDataArray.cpp b/Source/SIMPLib/CoreFilters/ImportAsciDataArray.cpp index 3ed72e14dc..f8b0618053 100644 --- a/Source/SIMPLib/CoreFilters/ImportAsciDataArray.cpp +++ b/Source/SIMPLib/CoreFilters/ImportAsciDataArray.cpp @@ -1,60 +1,63 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ImportAsciDataArray.h" -#include #include +#include -#include #include +#include +#include +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/ScopedFileMonitor.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" -#include "SIMPLib/SIMPLibVersion.h" - #include "SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h" #include "SIMPLib/FilterParameters/InputFileFilterParameter.h" #include "SIMPLib/FilterParameters/IntFilterParameter.h" -#include "SIMPLib/FilterParameters/LinkedBooleanFilterParameter.h" #include "SIMPLib/FilterParameters/LinkedChoicesFilterParameter.h" #include "SIMPLib/FilterParameters/NumericTypeFilterParameter.h" -#include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/FilterParameters/PreflightUpdatedValueFilterParameter.h" +enum createdPathID : RenameDataPath::DataID_t +{ + AsciiArrayID = 1 +}; #define RBR_FILE_NOT_OPEN -1000 #define RBR_FILE_TOO_SMALL -1010 @@ -79,7 +82,7 @@ int32_t readLine(std::istream& in, char* result, size_t length) { return 0; } - if(in.gcount() == static_cast(length) ) + if(in.gcount() == static_cast(length)) { // Read kBufferSize chars; ignoring the rest of the line. in.clear(); @@ -89,21 +92,20 @@ int32_t readLine(std::istream& in, char* result, size_t length) return 1; } - class DelimiterType : public std::ctype { - mask my_table[table_size]; - public: - DelimiterType(char delimiter, size_t refs = 0) - : std::ctype(&my_table[0], false, refs) - { - std::copy_n(classic_table(), table_size, my_table); - my_table[static_cast(delimiter)] = (mask)space; - } -}; + mask my_table[table_size]; +public: + DelimiterType(char delimiter, size_t refs = 0) + : std::ctype(&my_table[0], false, refs) + { + std::copy_n(classic_table(), table_size, my_table); + my_table[static_cast(delimiter)] = (mask)space; + } +}; -} +} // namespace Detail // ----------------------------------------------------------------------------- // @@ -113,17 +115,17 @@ int check_error_bits(std::ifstream* f) int stop = RBR_NO_ERROR; if(f->eof()) { - //std::perror("stream eofbit. error state"); + // std::perror("stream eofbit. error state"); stop = RBR_READ_EOF; } else if(f->fail()) { - //std::perror("stream failbit (or badbit). error state"); + // std::perror("stream failbit (or badbit). error state"); stop = RBR_READ_ERROR; } else if(f->bad()) { - //std::perror("stream badbit. error state"); + // std::perror("stream badbit. error state"); stop = RBR_READ_ERROR; } return stop; @@ -132,7 +134,8 @@ int check_error_bits(std::ifstream* f) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template int32_t readAsciFile(typename DataArray::Pointer data, const QString& filename, int32_t skipHeaderLines, char delimiter, bool inputIsBool = false) +template +int32_t readAsciFile(typename DataArray::Pointer data, const QString& filename, int32_t skipHeaderLines, char delimiter, bool inputIsBool = false) { int32_t err = 0; QFileInfo fi(filename); @@ -156,7 +159,7 @@ template int32_t readAsciFile(typename DataArray::Po // thing we are going to do it over write those bytes with the real data that we are after. for(int i = 0; i < skipHeaderLines; i++) { - buf.fill(0x00); // Splat Null Chars across the line + buf.fill(0x00); // Splat Null Chars across the line err = Detail::readLine(in, buffer, kBufferSize); // Read Line 1 - VTK Version Info if(err < 0) { @@ -190,7 +193,7 @@ template int32_t readAsciFile(typename DataArray::Po { return err; } - if(err == RBR_READ_ERROR || err == RBR_READ_ERROR) + if(err == RBR_READ_ERROR) { return err; } @@ -202,13 +205,13 @@ template int32_t readAsciFile(typename DataArray::Po for(size_t i = 0; i < totalSize; ++i) { in >> value; - data->setValue(i, static_cast(value) ); + data->setValue(i, static_cast(value)); err = check_error_bits(&in); if(err == RBR_READ_EOF && i < totalSize - 1) { return err; } - if(err == RBR_READ_ERROR || err == RBR_READ_ERROR) + if(err == RBR_READ_ERROR) { return err; } @@ -217,8 +220,6 @@ template int32_t readAsciFile(typename DataArray::Po return RBR_NO_ERROR; } - - /* ############## Start Private Implementation ############################### */ // ----------------------------------------------------------------------------- // @@ -247,19 +248,11 @@ ImportAsciDataArrayPrivate::ImportAsciDataArrayPrivate(ImportAsciDataArray* ptr) } /* ############## End Private Implementation ############################### */ - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- ImportAsciDataArray::ImportAsciDataArray() -: m_CreatedAttributeArrayPath("") -, m_ScalarType(SIMPL::NumericTypes::Type::Int8) -, m_NumberOfComponents(0) -, m_SkipHeaderLines(0) -, m_InputFile("") -, m_Delimiter(0) -, d_ptr(new ImportAsciDataArrayPrivate(this)) - +: d_ptr(new ImportAsciDataArrayPrivate(this)) { } @@ -271,10 +264,61 @@ ImportAsciDataArray::~ImportAsciDataArray() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -SIMPL_PIMPL_PROPERTY_DEF(ImportAsciDataArray, QString, FirstLine) -SIMPL_PIMPL_PROPERTY_DEF(ImportAsciDataArray, QString, InputFile_Cache) -SIMPL_PIMPL_PROPERTY_DEF(ImportAsciDataArray, QDateTime, LastRead) -SIMPL_PIMPL_PROPERTY_DEF(ImportAsciDataArray, int, HeaderLines) +// ----------------------------------------------------------------------------- +void ImportAsciDataArray::setFirstLine(const QString& value) +{ + Q_D(ImportAsciDataArray); + d->m_FirstLine = value; +} + +// ----------------------------------------------------------------------------- +QString ImportAsciDataArray::getFirstLine() const +{ + Q_D(const ImportAsciDataArray); + return d->m_FirstLine; +} + +// ----------------------------------------------------------------------------- +void ImportAsciDataArray::setInputFile_Cache(const QString& value) +{ + Q_D(ImportAsciDataArray); + d->m_InputFile_Cache = value; +} + +// ----------------------------------------------------------------------------- +QString ImportAsciDataArray::getInputFile_Cache() const +{ + Q_D(const ImportAsciDataArray); + return d->m_InputFile_Cache; +} + +// ----------------------------------------------------------------------------- +void ImportAsciDataArray::setLastRead(const QDateTime& value) +{ + Q_D(ImportAsciDataArray); + d->m_LastRead = value; +} + +// ----------------------------------------------------------------------------- +QDateTime ImportAsciDataArray::getLastRead() const +{ + Q_D(const ImportAsciDataArray); + return d->m_LastRead; +} + +// ----------------------------------------------------------------------------- +void ImportAsciDataArray::setHeaderLines(int value) +{ + Q_D(ImportAsciDataArray); + d->m_HeaderLines = value; +} + +// ----------------------------------------------------------------------------- +int ImportAsciDataArray::getHeaderLines() const +{ + Q_D(const ImportAsciDataArray); + return d->m_HeaderLines; +} // ----------------------------------------------------------------------------- // @@ -283,79 +327,70 @@ void ImportAsciDataArray::readHeaderPortion() { int32_t err = 0; QString filename = getInputFile(); - + QFileInfo fi(getInputFile()); - + QDateTime lastModified(fi.lastModified()); - if(getInputFile() == getInputFile_Cache() - && getLastRead().isValid() - && lastModified.msecsTo(getLastRead()) >= 0 - && getSkipHeaderLines() == getHeaderLines() ) + if(getInputFile() == getInputFile_Cache() && getLastRead().isValid() && lastModified.msecsTo(getLastRead()) >= 0 && getSkipHeaderLines() == getHeaderLines()) { // We are reading from the cache, so set the FileWasRead flag to false } else { // We are reading from the file - + std::ifstream in(filename.toLatin1().constData(), std::ios_base::in | std::ios_base::binary); if(!in.is_open()) { - setErrorCondition(RBR_FILE_NOT_OPEN); QString errorMessage = QString("Error opening input file '%1'").arg(filename); - notifyErrorMessage(getHumanLabel(), errorMessage, getErrorCondition()); + setErrorCondition(RBR_FILE_NOT_OPEN, errorMessage); return; } - + in.imbue(std::locale(std::locale(), new Detail::DelimiterType(getDelimiter()))); - + QByteArray buf(kBufferSize, '\0'); char* buffer = buf.data(); - + int skipHeaderLines = getSkipHeaderLines(); for(int i = 0; i < skipHeaderLines; i++) { buf.fill(0x00); // Splat Null Chars across the line - err = Detail::readLine(in, buffer, kBufferSize); + err = Detail::readLine(in, buffer, kBufferSize); if(err < 0) { QString errorMessage = QString("Error reading the input file at line %1 of the file").arg(i); - notifyErrorMessage(getHumanLabel(), errorMessage, getErrorCondition()); - setErrorCondition(RBR_READ_ERROR); + setErrorCondition(RBR_READ_ERROR, errorMessage); return; } } - + err = Detail::readLine(in, buffer, kBufferSize); if(err < 0) { - setErrorCondition(err); - notifyErrorMessage(getHumanLabel(), "Error reading the first line of data from the input file", getErrorCondition()); + setErrorCondition(err, "Error reading the first line of data from the input file"); } - + setFirstLine(buf); - - + // Set the file path and time stamp into the cache setLastRead(QDateTime::currentDateTime()); setInputFile_Cache(getInputFile()); } - } - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ImportAsciDataArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(SIMPL_NEW_INPUT_FILE_FP("Input File", InputFile, FilterParameter::Parameter, ImportAsciDataArray, "*.*")); - parameters.push_back(SIMPL_NEW_NUMERICTYPE_FP("Scalar Type", ScalarType, FilterParameter::Parameter, ImportAsciDataArray)); - parameters.push_back(SIMPL_NEW_INTEGER_FP("Number of Components", NumberOfComponents, FilterParameter::Parameter, ImportAsciDataArray)); + parameters.push_back(SIMPL_NEW_INPUT_FILE_FP("Input File", InputFile, FilterParameter::Category::Parameter, ImportAsciDataArray, "*.*")); + parameters.push_back(SIMPL_NEW_NUMERICTYPE_FP("Scalar Type", ScalarType, FilterParameter::Category::Parameter, ImportAsciDataArray)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Number of Components", NumberOfComponents, FilterParameter::Category::Parameter, ImportAsciDataArray)); - parameters.push_back(SIMPL_NEW_INTEGER_FP("Skip Header Lines", SkipHeaderLines, FilterParameter::Parameter, ImportAsciDataArray)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Skip Header Lines", SkipHeaderLines, FilterParameter::Category::Parameter, ImportAsciDataArray)); { ChoiceFilterParameter::Pointer parameter = ChoiceFilterParameter::New(); parameter->setHumanLabel("Delimiter"); @@ -363,29 +398,26 @@ void ImportAsciDataArray::setupFilterParameters() parameter->setSetterCallback(SIMPL_BIND_SETTER(ImportAsciDataArray, this, Delimiter)); parameter->setGetterCallback(SIMPL_BIND_GETTER(ImportAsciDataArray, this, Delimiter)); - QVector choices; + std::vector choices; choices.push_back(", (comma)"); choices.push_back("; (semicolon)"); choices.push_back(" (space)"); choices.push_back(": (colon)"); choices.push_back("\\t (Tab)"); parameter->setChoices(choices); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameters.push_back(parameter); } - { DataArrayCreationFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Output Attribute Array", CreatedAttributeArrayPath, FilterParameter::CreatedArray, ImportAsciDataArray, req)); + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Output Attribute Array", CreatedAttributeArrayPath, FilterParameter::Category::CreatedArray, ImportAsciDataArray, req)); } - - PreflightUpdatedValueFilterParameter::Pointer param = - SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP("First Line of Data:", FirstLine, FilterParameter::Parameter, ImportAsciDataArray); + + PreflightUpdatedValueFilterParameter::Pointer param = SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP("First Line of Data:", FirstLine, FilterParameter::Category::Parameter, ImportAsciDataArray); param->setReadOnly(true); parameters.push_back(param); - setFilterParameters(parameters); } @@ -401,106 +433,90 @@ void ImportAsciDataArray::initialize() // ----------------------------------------------------------------------------- void ImportAsciDataArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QFileInfo fi(getInputFile()); if(getInputFile().isEmpty()) { QString ss = QObject::tr("The input file must be set"); - setErrorCondition(-387); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-387, ss); } else if(!fi.exists()) { QString ss = QObject::tr("The input file does not exist"); - setErrorCondition(-388); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-388, ss); } if(m_NumberOfComponents < 1) { QString ss = QObject::tr("The number of components must be positive"); - setErrorCondition(-391); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-391, ss); } - AttributeMatrix::Pointer attrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getCreatedAttributeArrayPath(), -30003); - if(getErrorCondition() < 0) + AttributeMatrix::Pointer attrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getCreatedAttributeArrayPath(), -30003); + if(getErrorCode() < 0) { return; } - QVector tDims = attrMat->getTupleDimensions(); + std::vector tDims = attrMat->getTupleDimensions(); size_t totalDim = 1; - for(int i = 0; i < tDims.size(); i++) + for(size_t i = 0; i < tDims.size(); i++) { totalDim = totalDim * tDims[i]; } - QVector cDims(1, m_NumberOfComponents); + std::vector cDims(1, m_NumberOfComponents); if(m_ScalarType == SIMPL::NumericTypes::Type::Int8) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt8) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::Int16) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt16) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::Int32) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt32) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::Int64) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt64) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::Float) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::Double) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } else if(m_ScalarType == SIMPL::NumericTypes::Type::Bool) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), false, cDims, "CreatedAttributeArrayPath"); + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), false, cDims, "CreatedAttributeArrayPath", AsciiArrayID); + } + else if(m_ScalarType == SIMPL::NumericTypes::Type::SizeT) + { + getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), false, cDims, "CreatedAttributeArrayPath", AsciiArrayID); } - - readHeaderPortion(); - - -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void ImportAsciDataArray::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); } // ----------------------------------------------------------------------------- @@ -508,10 +524,11 @@ void ImportAsciDataArray::preflight() // ----------------------------------------------------------------------------- void ImportAsciDataArray::execute() { - int32_t err = 0; - setErrorCondition(err); + clearErrorCode(); + clearWarningCode(); + dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -520,10 +537,11 @@ void ImportAsciDataArray::execute() char delimiter = converSelectedDelimiter(); - QVector cDims(1, m_NumberOfComponents); + std::vector cDims(1, m_NumberOfComponents); + int32_t err = 0; if(m_ScalarType == SIMPL::NumericTypes::Type::Int8) { - Int8ArrayType::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getCreatedAttributeArrayPath()); + Int8ArrayType::Pointer p = getDataContainerArray()->getPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), cDims); err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); if(err >= 0) { @@ -532,7 +550,7 @@ void ImportAsciDataArray::execute() } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt8) { - UInt8ArrayType::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getCreatedAttributeArrayPath()); + UInt8ArrayType::Pointer p = getDataContainerArray()->getPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), cDims); err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); if(err >= 0) { @@ -541,8 +559,8 @@ void ImportAsciDataArray::execute() } else if(m_ScalarType == SIMPL::NumericTypes::Type::Int16) { - Int16ArrayType::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getCreatedAttributeArrayPath()); - err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); + Int16ArrayType::Pointer p = getDataContainerArray()->getPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), cDims); + err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); if(err >= 0) { m_Array = p; @@ -550,8 +568,8 @@ void ImportAsciDataArray::execute() } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt16) { - UInt16ArrayType::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getCreatedAttributeArrayPath()); - err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); + UInt16ArrayType::Pointer p = getDataContainerArray()->getPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), cDims); + err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); if(err >= 0) { m_Array = p; @@ -559,8 +577,8 @@ void ImportAsciDataArray::execute() } else if(m_ScalarType == SIMPL::NumericTypes::Type::Int32) { - Int32ArrayType::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getCreatedAttributeArrayPath()); - err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); + Int32ArrayType::Pointer p = getDataContainerArray()->getPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), cDims); + err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); if(err >= 0) { m_Array = p; @@ -568,8 +586,8 @@ void ImportAsciDataArray::execute() } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt32) { - UInt32ArrayType::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getCreatedAttributeArrayPath()); - err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); + UInt32ArrayType::Pointer p = getDataContainerArray()->getPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), cDims); + err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); if(err >= 0) { m_Array = p; @@ -577,8 +595,8 @@ void ImportAsciDataArray::execute() } else if(m_ScalarType == SIMPL::NumericTypes::Type::Int64) { - Int64ArrayType::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getCreatedAttributeArrayPath()); - err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); + Int64ArrayType::Pointer p = getDataContainerArray()->getPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), cDims); + err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); if(err >= 0) { m_Array = p; @@ -586,8 +604,8 @@ void ImportAsciDataArray::execute() } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt64) { - UInt64ArrayType::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getCreatedAttributeArrayPath()); - err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); + UInt64ArrayType::Pointer p = getDataContainerArray()->getPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), cDims); + err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); if(err >= 0) { m_Array = p; @@ -595,8 +613,8 @@ void ImportAsciDataArray::execute() } else if(m_ScalarType == SIMPL::NumericTypes::Type::Float) { - FloatArrayType::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getCreatedAttributeArrayPath()); - err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); + FloatArrayType::Pointer p = getDataContainerArray()->getPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), cDims); + err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); if(err >= 0) { m_Array = p; @@ -604,8 +622,8 @@ void ImportAsciDataArray::execute() } else if(m_ScalarType == SIMPL::NumericTypes::Type::Double) { - DoubleArrayType::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getCreatedAttributeArrayPath()); - err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); + DoubleArrayType::Pointer p = getDataContainerArray()->getPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), cDims); + err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); if(err >= 0) { m_Array = p; @@ -613,38 +631,42 @@ void ImportAsciDataArray::execute() } else if(m_ScalarType == SIMPL::NumericTypes::Type::Bool) { - BoolArrayType::Pointer p = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getCreatedAttributeArrayPath()); + BoolArrayType::Pointer p = getDataContainerArray()->getPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), cDims); err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter, true); if(err >= 0) { m_Array = p; } } + else if(m_ScalarType == SIMPL::NumericTypes::Type::SizeT) + { + SizeTArrayType::Pointer p = getDataContainerArray()->getPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), cDims); + err = readAsciFile(p, m_InputFile, m_SkipHeaderLines, delimiter); + if(err >= 0) + { + m_Array = p; + } + } if(err == RBR_FILE_NOT_OPEN) { - setErrorCondition(RBR_FILE_NOT_OPEN); - notifyErrorMessage(getHumanLabel(), "Unable to open the specified file", getErrorCondition()); + setErrorCondition(RBR_FILE_NOT_OPEN, "Unable to open the specified file"); } else if(err == RBR_FILE_TOO_SMALL) { - setErrorCondition(RBR_FILE_TOO_SMALL); - notifyErrorMessage(getHumanLabel(), "The file size is smaller than the allocated size", getErrorCondition()); + setErrorCondition(RBR_FILE_TOO_SMALL, "The file size is smaller than the allocated size"); } else if(err == RBR_FILE_TOO_BIG) { - setWarningCondition(RBR_FILE_TOO_BIG); - notifyWarningMessage(getHumanLabel(), "The file size is larger than the allocated size", getWarningCondition()); + setWarningCondition(RBR_FILE_TOO_BIG, "The file size is larger than the allocated size"); } else if(err == RBR_READ_ERROR) { - setErrorCondition(RBR_READ_ERROR); - notifyErrorMessage(getHumanLabel(), "General read error while importing ASCI file.", getErrorCondition()); + setErrorCondition(RBR_READ_ERROR, "General read error while importing ASCI file."); } else if(err == RBR_READ_EOF) { - setErrorCondition(RBR_READ_EOF); - notifyErrorMessage(getHumanLabel(), "ImportAsciDataArray read past the end of the specified file", getErrorCondition()); + setErrorCondition(RBR_READ_EOF, "ImportAsciDataArray read past the end of the specified file"); } } @@ -692,7 +714,7 @@ AbstractFilter::Pointer ImportAsciDataArray::newFilterInstance(bool copyFilterPa // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ImportAsciDataArray::getCompiledLibraryName() const +QString ImportAsciDataArray::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -700,7 +722,7 @@ const QString ImportAsciDataArray::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ImportAsciDataArray::getBrandingString() const +QString ImportAsciDataArray::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -708,7 +730,7 @@ const QString ImportAsciDataArray::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ImportAsciDataArray::getFilterVersion() const +QString ImportAsciDataArray::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -719,7 +741,7 @@ const QString ImportAsciDataArray::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ImportAsciDataArray::getGroupName() const +QString ImportAsciDataArray::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -727,7 +749,7 @@ const QString ImportAsciDataArray::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid ImportAsciDataArray::getUuid() +QUuid ImportAsciDataArray::getUuid() const { return QUuid("{a7007472-29e5-5d0a-89a6-1aed11b603f8}"); } @@ -735,7 +757,7 @@ const QUuid ImportAsciDataArray::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ImportAsciDataArray::getSubGroupName() const +QString ImportAsciDataArray::getSubGroupName() const { return SIMPL::FilterSubGroups::InputFilters; } @@ -743,7 +765,108 @@ const QString ImportAsciDataArray::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ImportAsciDataArray::getHumanLabel() const +QString ImportAsciDataArray::getHumanLabel() const { return "Import ASCII Attribute Array"; } + +// ----------------------------------------------------------------------------- +ImportAsciDataArray::Pointer ImportAsciDataArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr ImportAsciDataArray::New() +{ + struct make_shared_enabler : public ImportAsciDataArray + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString ImportAsciDataArray::getNameOfClass() const +{ + return QString("ImportAsciDataArray"); +} + +// ----------------------------------------------------------------------------- +QString ImportAsciDataArray::ClassName() +{ + return QString("ImportAsciDataArray"); +} + +// ----------------------------------------------------------------------------- +void ImportAsciDataArray::setCreatedAttributeArrayPath(const DataArrayPath& value) +{ + m_CreatedAttributeArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ImportAsciDataArray::getCreatedAttributeArrayPath() const +{ + return m_CreatedAttributeArrayPath; +} + +// ----------------------------------------------------------------------------- +void ImportAsciDataArray::setScalarType(SIMPL::NumericTypes::Type value) +{ + m_ScalarType = value; +} + +// ----------------------------------------------------------------------------- +SIMPL::NumericTypes::Type ImportAsciDataArray::getScalarType() const +{ + return m_ScalarType; +} + +// ----------------------------------------------------------------------------- +void ImportAsciDataArray::setNumberOfComponents(int value) +{ + m_NumberOfComponents = value; +} + +// ----------------------------------------------------------------------------- +int ImportAsciDataArray::getNumberOfComponents() const +{ + return m_NumberOfComponents; +} + +// ----------------------------------------------------------------------------- +void ImportAsciDataArray::setSkipHeaderLines(int value) +{ + m_SkipHeaderLines = value; +} + +// ----------------------------------------------------------------------------- +int ImportAsciDataArray::getSkipHeaderLines() const +{ + return m_SkipHeaderLines; +} + +// ----------------------------------------------------------------------------- +void ImportAsciDataArray::setInputFile(const QString& value) +{ + m_InputFile = value; +} + +// ----------------------------------------------------------------------------- +QString ImportAsciDataArray::getInputFile() const +{ + return m_InputFile; +} + +// ----------------------------------------------------------------------------- +void ImportAsciDataArray::setDelimiter(int value) +{ + m_Delimiter = value; +} + +// ----------------------------------------------------------------------------- +int ImportAsciDataArray::getDelimiter() const +{ + return m_Delimiter; +} diff --git a/Source/SIMPLib/CoreFilters/ImportAsciDataArray.h b/Source/SIMPLib/CoreFilters/ImportAsciDataArray.h index 976846c3b8..53c83fe3d1 100644 --- a/Source/SIMPLib/CoreFilters/ImportAsciDataArray.h +++ b/Source/SIMPLib/CoreFilters/ImportAsciDataArray.h @@ -1,45 +1,50 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +class IDataArray; +using IDataArrayShPtrType = std::shared_ptr; // our PIMPL private class for caching class ImportAsciDataArrayPrivate; @@ -49,175 +54,262 @@ class ImportAsciDataArrayPrivate; */ class SIMPLib_EXPORT ImportAsciDataArray : public AbstractFilter { - Q_OBJECT - Q_DECLARE_PRIVATE(ImportAsciDataArray) - PYB11_CREATE_BINDINGS(ImportAsciDataArray SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath CreatedAttributeArrayPath READ getCreatedAttributeArrayPath WRITE setCreatedAttributeArrayPath) - PYB11_PROPERTY(SIMPL::NumericTypes::Type ScalarType READ getScalarType WRITE setScalarType) - PYB11_PROPERTY(int NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) - PYB11_PROPERTY(int SkipHeaderLines READ getSkipHeaderLines WRITE setSkipHeaderLines) - PYB11_PROPERTY(QString InputFile READ getInputFile WRITE setInputFile) - PYB11_PROPERTY(int Delimiter READ getDelimiter WRITE setDelimiter) - - public: - SIMPL_SHARED_POINTERS(ImportAsciDataArray) - SIMPL_FILTER_NEW_MACRO(ImportAsciDataArray) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ImportAsciDataArray, AbstractFilter) - - ~ImportAsciDataArray() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, CreatedAttributeArrayPath) - Q_PROPERTY(DataArrayPath CreatedAttributeArrayPath READ getCreatedAttributeArrayPath WRITE setCreatedAttributeArrayPath) - - SIMPL_FILTER_PARAMETER(SIMPL::NumericTypes::Type, ScalarType) - Q_PROPERTY(SIMPL::NumericTypes::Type ScalarType READ getScalarType WRITE setScalarType) - - SIMPL_FILTER_PARAMETER(int, NumberOfComponents) - Q_PROPERTY(int NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) - - SIMPL_FILTER_PARAMETER(int, SkipHeaderLines) - Q_PROPERTY(int SkipHeaderLines READ getSkipHeaderLines WRITE setSkipHeaderLines) - - SIMPL_FILTER_PARAMETER(QString, InputFile) - Q_PROPERTY(QString InputFile READ getInputFile WRITE setInputFile) - - SIMPL_FILTER_PARAMETER(int, Delimiter) - Q_PROPERTY(int Delimiter READ getDelimiter WRITE setDelimiter) - - - Q_PROPERTY(QString FirstLine READ getFirstLine) - - SIMPL_PIMPL_PROPERTY_DECL(QString, FirstLine) - SIMPL_PIMPL_PROPERTY_DECL(QString, InputFile_Cache) - SIMPL_PIMPL_PROPERTY_DECL(QDateTime, LastRead) - SIMPL_PIMPL_PROPERTY_DECL(int, HeaderLines) - - enum DelimeterType - { - Comma = 0, - Semicolon = 1, - Space = 2, - Colon = 3, - Tab = 4 - }; - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - ImportAsciDataArray(); - - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - /** - * @brief Converts from the enumeration to a char - * @return - */ - char converSelectedDelimiter(); - - /** - * @brief readHeaderPortion - * @return - */ - void readHeaderPortion(); - - private: - QScopedPointer const d_ptr; - - IDataArray::Pointer m_Array; - - public: - ImportAsciDataArray(const ImportAsciDataArray&) = delete; // Copy Constructor Not Implemented - ImportAsciDataArray(ImportAsciDataArray&&) = delete; // Move Constructor Not Implemented - ImportAsciDataArray& operator=(const ImportAsciDataArray&) = delete; // Copy Assignment Not Implemented - ImportAsciDataArray& operator=(ImportAsciDataArray&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + Q_DECLARE_PRIVATE(ImportAsciDataArray) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ImportAsciDataArray SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(ImportAsciDataArray) + PYB11_FILTER_NEW_MACRO(ImportAsciDataArray) + PYB11_PROPERTY(DataArrayPath CreatedAttributeArrayPath READ getCreatedAttributeArrayPath WRITE setCreatedAttributeArrayPath) + PYB11_PROPERTY(SIMPL::NumericTypes::Type ScalarType READ getScalarType WRITE setScalarType) + PYB11_PROPERTY(int NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) + PYB11_PROPERTY(int SkipHeaderLines READ getSkipHeaderLines WRITE setSkipHeaderLines) + PYB11_PROPERTY(QString InputFile READ getInputFile WRITE setInputFile) + PYB11_PROPERTY(int Delimiter READ getDelimiter WRITE setDelimiter) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = ImportAsciDataArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for ImportAsciDataArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ImportAsciDataArray + */ + static QString ClassName(); + + ~ImportAsciDataArray() override; + + /** + * @brief Setter property for CreatedAttributeArrayPath + */ + void setCreatedAttributeArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for CreatedAttributeArrayPath + * @return Value of CreatedAttributeArrayPath + */ + DataArrayPath getCreatedAttributeArrayPath() const; + + Q_PROPERTY(DataArrayPath CreatedAttributeArrayPath READ getCreatedAttributeArrayPath WRITE setCreatedAttributeArrayPath) + + /** + * @brief Setter property for ScalarType + */ + void setScalarType(SIMPL::NumericTypes::Type value); + /** + * @brief Getter property for ScalarType + * @return Value of ScalarType + */ + SIMPL::NumericTypes::Type getScalarType() const; + + Q_PROPERTY(SIMPL::NumericTypes::Type ScalarType READ getScalarType WRITE setScalarType) + + /** + * @brief Setter property for NumberOfComponents + */ + void setNumberOfComponents(int value); + /** + * @brief Getter property for NumberOfComponents + * @return Value of NumberOfComponents + */ + int getNumberOfComponents() const; + + Q_PROPERTY(int NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) + + /** + * @brief Setter property for SkipHeaderLines + */ + void setSkipHeaderLines(int value); + /** + * @brief Getter property for SkipHeaderLines + * @return Value of SkipHeaderLines + */ + int getSkipHeaderLines() const; + + Q_PROPERTY(int SkipHeaderLines READ getSkipHeaderLines WRITE setSkipHeaderLines) + + /** + * @brief Setter property for InputFile + */ + void setInputFile(const QString& value); + /** + * @brief Getter property for InputFile + * @return Value of InputFile + */ + QString getInputFile() const; + + Q_PROPERTY(QString InputFile READ getInputFile WRITE setInputFile) + + /** + * @brief Setter property for Delimiter + */ + void setDelimiter(int value); + /** + * @brief Getter property for Delimiter + * @return Value of Delimiter + */ + int getDelimiter() const; + + Q_PROPERTY(int Delimiter READ getDelimiter WRITE setDelimiter) + + Q_PROPERTY(QString FirstLine READ getFirstLine) + + /** + * @brief Setter property for FirstLine + */ + void setFirstLine(const QString& value); + /** + * @brief Getter property for FirstLine + * @return Value of FirstLine + */ + QString getFirstLine() const; + + /** + * @brief Setter property for InputFile_Cache + */ + void setInputFile_Cache(const QString& value); + /** + * @brief Getter property for InputFile_Cache + * @return Value of InputFile_Cache + */ + QString getInputFile_Cache() const; + + /** + * @brief Setter property for LastRead + */ + void setLastRead(const QDateTime& value); + /** + * @brief Getter property for LastRead + * @return Value of LastRead + */ + QDateTime getLastRead() const; + + /** + * @brief Setter property for HeaderLines + */ + void setHeaderLines(int value); + /** + * @brief Getter property for HeaderLines + * @return Value of HeaderLines + */ + int getHeaderLines() const; + + enum DelimeterType + { + Comma = 0, + Semicolon = 1, + Space = 2, + Colon = 3, + Tab = 4 + }; + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + ImportAsciDataArray(); + + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + + /** + * @brief Converts from the enumeration to a char + * @return + */ + char converSelectedDelimiter(); + + /** + * @brief readHeaderPortion + * @return + */ + void readHeaderPortion(); + +private: + DataArrayPath m_CreatedAttributeArrayPath = {"", "", ""}; + SIMPL::NumericTypes::Type m_ScalarType = {SIMPL::NumericTypes::Type::Int8}; + int m_NumberOfComponents = {}; + int m_SkipHeaderLines = {}; + QString m_InputFile = {""}; + int m_Delimiter = {}; + + QScopedPointer const d_ptr; + + IDataArrayShPtrType m_Array; + +public: + ImportAsciDataArray(const ImportAsciDataArray&) = delete; // Copy Constructor Not Implemented + ImportAsciDataArray(ImportAsciDataArray&&) = delete; // Move Constructor Not Implemented + ImportAsciDataArray& operator=(const ImportAsciDataArray&) = delete; // Copy Assignment Not Implemented + ImportAsciDataArray& operator=(ImportAsciDataArray&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/ImportHDF5Dataset.cpp b/Source/SIMPLib/CoreFilters/ImportHDF5Dataset.cpp index fb747dd363..78a12f2895 100644 --- a/Source/SIMPLib/CoreFilters/ImportHDF5Dataset.cpp +++ b/Source/SIMPLib/CoreFilters/ImportHDF5Dataset.cpp @@ -29,32 +29,38 @@ * * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - #include "ImportHDF5Dataset.h" +#include #include +#include + +#include "H5Support/H5ScopedSentinel.h" +#include "H5Support/H5Utilities.h" +#include "H5Support/QH5Lite.h" +#include "H5Support/QH5Utilities.h" +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Common/QtBackwardCompatibilityMacro.h" +#include "SIMPLib/DataArrays/IDataArray.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/ImportHDF5DatasetFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" - -#include "H5Support/H5ScopedSentinel.h" -#include "H5Support/H5Utilities.h" -#include "H5Support/QH5Utilities.h" namespace Detail { // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template IDataArray::Pointer readH5Dataset(hid_t locId, const QString& datasetPath, const size_t& numOfTuples, const QVector& cDims) +template +IDataArray::Pointer readH5Dataset(hid_t locId, const QString& datasetPath, const size_t& numOfTuples, const std::vector& cDims) { herr_t err = -1; IDataArray::Pointer ptr; - ptr = DataArray::CreateArray(numOfTuples, cDims, datasetPath); + ptr = DataArray::CreateArray(numOfTuples, cDims, datasetPath, true); T* data = (T*)(ptr->getVoidPointer(0)); err = QH5Lite::readPointerDataset(locId, datasetPath, data); @@ -85,7 +91,7 @@ ImportHDF5Dataset::~ImportHDF5Dataset() = default; // ----------------------------------------------------------------------------- void ImportHDF5Dataset::initialize() { - setErrorCondition(0); + clearErrorCode(); setCancel(false); } @@ -94,19 +100,19 @@ void ImportHDF5Dataset::initialize() // ----------------------------------------------------------------------------- void ImportHDF5Dataset::setupFilterParameters() { - FilterParameterVector parameters; - - ImportHDF5DatasetFilterParameter::Pointer parameter = ImportHDF5DatasetFilterParameter::New(QString("Select HDF5 File"), // Human Label - QString("ImportHDF5File"), // Property Name - QString(""), // File Path Default Value - QString(""), // Dataset Default value - FilterParameter::Parameter, // Category - this, -1); + FilterParameterVectorType parameters; + + ImportHDF5DatasetFilterParameter::Pointer parameter = ImportHDF5DatasetFilterParameter::Create(QString("Select HDF5 File"), // Human Label + QString("ImportHDF5File"), // Property Name + QString(""), // File Path Default Value + QString(""), // Dataset Default value + FilterParameter::Category::Parameter, // Category + this, -1); parameters.push_back(parameter); { AttributeMatrixSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Attribute Matrix", SelectedAttributeMatrix, FilterParameter::RequiredArray, ImportHDF5Dataset, req)); + parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Attribute Matrix", SelectedAttributeMatrix, FilterParameter::Category::RequiredArray, ImportHDF5Dataset, req)); } setFilterParameters(parameters); @@ -117,14 +123,14 @@ void ImportHDF5Dataset::setupFilterParameters() // ----------------------------------------------------------------------------- void ImportHDF5Dataset::dataCheck() { - setErrorCondition(0); + clearErrorCode(); + clearWarningCode(); m_DatasetPathsWithErrors.clear(); if(m_HDF5FilePath.isEmpty()) { QString ss = "The HDF5 file path is empty. Please select an HDF5 file."; - setErrorCondition(-20001); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20001, ss); return; } @@ -133,30 +139,27 @@ void ImportHDF5Dataset::dataCheck() if(ext != "h5" && ext != "hdf5" && ext != "dream3d") { QString ss = tr("The selected file '%1' is not an HDF5 file.").arg(hdf5FileInfo.fileName()); - setErrorCondition(-20002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20002, ss); return; } if(!hdf5FileInfo.exists()) { QString ss = tr("The selected file '%1' does not exist.").arg(hdf5FileInfo.fileName()); - setErrorCondition(-20003); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20003, ss); return; } if(m_DatasetImportInfoList.isEmpty()) { QString ss = tr("No dataset has been checked. Please check a dataset."); - setErrorCondition(-20004); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20004, ss); return; } int err = 0; - AttributeMatrix::Pointer am = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedAttributeMatrix, err); - if(getErrorCondition() < 0) + AttributeMatrix::Pointer am = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, m_SelectedAttributeMatrix, err); + if(getErrorCode() < 0) { return; } @@ -167,7 +170,7 @@ void ImportHDF5Dataset::dataCheck() std::cout << "Error Reading HDF5 file: " << m_HDF5FilePath.toStdString() << std::endl; return; } - H5ScopedFileSentinel sentinel(&fileId, true); + H5ScopedFileSentinel sentinel(fileId, true); QMap openedParentPathsMap; for(int i = 0; i < m_DatasetImportInfoList.size(); i++) @@ -185,7 +188,7 @@ void ImportHDF5Dataset::dataCheck() if(!openedParentPathsMap.contains(parentPath)) { parentId = QH5Utilities::openHDF5Object(fileId, parentPath); - sentinel.addGroupId(&parentId); + sentinel.addGroupId(parentId); openedParentPathsMap.insert(parentPath, parentId); } else @@ -204,8 +207,7 @@ void ImportHDF5Dataset::dataCheck() if(err < 0) { QString ss = tr("Error reading type info from dataset with path '%1'").arg(datasetPath); - setErrorCondition(-20005); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20005, ss); m_DatasetPathsWithErrors.push_back(datasetPath); return; } @@ -215,18 +217,16 @@ void ImportHDF5Dataset::dataCheck() { QString ss = tr("The component dimensions are empty for dataset with path '%1'. Please enter the component dimensions, using comma-separated values (ex: 4x2 would be '4, 2').").arg(datasetPath); - setErrorCondition(-20006); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20006, ss); m_DatasetPathsWithErrors.push_back(datasetPath); return; } - QVector cDims = createComponentDimensions(cDimsStr); - if(cDims.isEmpty()) + std::vector cDims = createComponentDimensions(cDimsStr); + if(cDims.empty()) { QString ss = tr("Component Dimensions are not in the right format for dataset with path '%1'. Use comma-separated values (ex: 4x2 would be '4, 2').").arg(datasetPath); - setErrorCondition(-20007); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20007, ss); m_DatasetPathsWithErrors.push_back(datasetPath); return; } @@ -243,7 +243,7 @@ void ImportHDF5Dataset::dataCheck() stream << tr("HDF5 File Path: %1\n").arg(m_HDF5FilePath); stream << tr("HDF5 Dataset Path: %1\n").arg(datasetPath); - int hdf5TotalElements = 1; + size_t hdf5TotalElements = 1; stream << tr(" No. of Dimension(s): ") << locale.toString(dims.size()) << "\n"; stream << tr(" Dimension Size(s): "); for(int i = 0; i < dims.size(); i++) @@ -256,15 +256,15 @@ void ImportHDF5Dataset::dataCheck() } } stream << "\n"; - stream << tr(" Total HDF5 Dataset Element Count: %1\n").arg(locale.toString(hdf5TotalElements)); + stream << tr(" Total HDF5 Dataset Element Count: ") << hdf5TotalElements << "\n"; stream << "-------------------------------------------\n"; stream << "Current Data Structure Information: \n"; stream << tr("Attribute Matrix Path: %1\n").arg(m_SelectedAttributeMatrix.serialize("/")); size_t userEnteredTotalElements = 1; - QVector amTupleDims = am->getTupleDimensions(); - stream << tr("No. of Attribute Matrix Dimension(s): ") << locale.toString(amTupleDims.size()) << "\n"; + std::vector amTupleDims = am->getTupleDimensions(); + stream << tr("No. of Attribute Matrix Dimension(s): ") << locale.toString(static_cast(amTupleDims.size())) << "\n"; stream << "Attribute Matrix Dimension(s): "; for(int i = 0; i < amTupleDims.size(); i++) { @@ -281,7 +281,7 @@ void ImportHDF5Dataset::dataCheck() int numOfAMTuples = am->getNumberOfTuples(); stream << tr("Total Attribute Matrix Tuple Count: %1\n").arg(locale.toString(numOfAMTuples)); - stream << tr("No. of Component Dimension(s): ") << locale.toString(cDims.size()) << "\n"; + stream << tr("No. of Component Dimension(s): ") << locale.toString(static_cast(cDims.size())) << "\n"; stream << "Component Dimension(s): "; int totalComponents = 1; @@ -313,40 +313,37 @@ void ImportHDF5Dataset::dataCheck() .arg(locale.toString(numOfAMTuples)) .arg(locale.toString(totalComponents)) .arg(locale.toString(numOfAMTuples * totalComponents)) - .arg(locale.toString(hdf5TotalElements)) + .arg(locale.toString(static_cast(hdf5TotalElements))) .arg(locale.toString(numOfAMTuples * totalComponents)) - .arg(locale.toString(hdf5TotalElements)); + .arg(locale.toString(static_cast(hdf5TotalElements))); - setErrorCondition(-20008); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20008, ss); m_DatasetPathsWithErrors.push_back(datasetPath); return; } if(am->doesAttributeArrayExist(objectName)) { - setErrorCondition(-20010); ss.clear(); DataArrayPath dap = getSelectedAttributeMatrix(); dap.setDataArrayName(objectName); stream << tr("The selected dataset '") << dap.serialize("/") << tr("' already exists."); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20010, ss); } else { IDataArray::Pointer dPtr = readIDataArray(parentId, objectName, am->getNumberOfTuples(), cDims, getInPreflight()); if(nullptr != dPtr) { - am->addAttributeArray(dPtr->getName(), dPtr); + am->insertOrAssign(dPtr); } else { - setErrorCondition(-20009); ss.clear(); stream << tr("The selected datatset is not a supported type for importing. Please select a different data set"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-20009, ss); } } } // End For Loop over dataset imoprt info list @@ -354,20 +351,6 @@ void ImportHDF5Dataset::dataCheck() // The sentinel will close the HDF5 File and any groups that were open. } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void ImportHDF5Dataset::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -375,20 +358,19 @@ void ImportHDF5Dataset::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector ImportHDF5Dataset::createComponentDimensions(const QString& cDimsStr) +std::vector ImportHDF5Dataset::createComponentDimensions(const QString& cDimsStr) { - QVector cDims; - QStringList dimsStrVec = cDimsStr.split(',', QString::SkipEmptyParts); + std::vector cDims; + QStringList dimsStrVec = cDimsStr.split(',', QSTRING_SKIP_EMPTY_PARTS); for(int i = 0; i < dimsStrVec.size(); i++) { QString dimsStr = dimsStrVec[i]; @@ -398,7 +380,7 @@ QVector ImportHDF5Dataset::createComponentDimensions(const QString& cDim int val = dimsStr.toInt(&ok); if(!ok) { - return QVector(); + return std::vector(); } cDims.push_back(val); @@ -410,7 +392,7 @@ QVector ImportHDF5Dataset::createComponentDimensions(const QString& cDim // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IDataArray::Pointer ImportHDF5Dataset::readIDataArray(hid_t gid, const QString& name, size_t numOfTuples, QVector cDims, bool metaDataOnly) +IDataArrayShPtrType ImportHDF5Dataset::readIDataArray(hid_t gid, const QString& name, size_t numOfTuples, const std::vector& cDims, bool metaDataOnly) { herr_t err = -1; // herr_t retErr = 1; @@ -439,12 +421,6 @@ IDataArray::Pointer ImportHDF5Dataset::readIDataArray(hid_t gid, const QString& case H5T_STRING: res.clear(); // Clear the string out first err = QH5Lite::readStringDataset(gid, name, res); - // if(err >= 0) - // { - // IDataArray::Pointer attr = MXAAsciiStringData::Create(res); - // attr->setName(name); - // attributes[*iter] = attr; - // } break; case H5T_INTEGER: // qDebug() << "User Meta Data Type is Integer" ; @@ -581,14 +557,6 @@ IDataArray::Pointer ImportHDF5Dataset::readIDataArray(hid_t gid, const QString& return ptr; } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString ImportHDF5Dataset::getHDF5Dimensions() -{ - return m_HDF5Dimensions; -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -608,7 +576,7 @@ AbstractFilter::Pointer ImportHDF5Dataset::newFilterInstance(bool copyFilterPara // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ImportHDF5Dataset::getCompiledLibraryName() const +QString ImportHDF5Dataset::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -616,7 +584,7 @@ const QString ImportHDF5Dataset::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ImportHDF5Dataset::getBrandingString() const +QString ImportHDF5Dataset::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -624,7 +592,7 @@ const QString ImportHDF5Dataset::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ImportHDF5Dataset::getFilterVersion() const +QString ImportHDF5Dataset::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -635,7 +603,7 @@ const QString ImportHDF5Dataset::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ImportHDF5Dataset::getGroupName() const +QString ImportHDF5Dataset::getGroupName() const { return SIMPL::FilterGroups::IOFilters; } @@ -643,7 +611,7 @@ const QString ImportHDF5Dataset::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid ImportHDF5Dataset::getUuid() +QUuid ImportHDF5Dataset::getUuid() const { return QUuid("{9e98c3b0-5707-5a3b-b8b5-23ef83b02896}"); } @@ -651,7 +619,7 @@ const QUuid ImportHDF5Dataset::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ImportHDF5Dataset::getSubGroupName() const +QString ImportHDF5Dataset::getSubGroupName() const { return SIMPL::FilterSubGroups::InputFilters; } @@ -659,7 +627,84 @@ const QString ImportHDF5Dataset::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ImportHDF5Dataset::getHumanLabel() const +QString ImportHDF5Dataset::getHumanLabel() const { return "Import HDF5 Dataset"; } + +// ----------------------------------------------------------------------------- +ImportHDF5Dataset::Pointer ImportHDF5Dataset::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr ImportHDF5Dataset::New() +{ + struct make_shared_enabler : public ImportHDF5Dataset + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString ImportHDF5Dataset::getNameOfClass() const +{ + return QString("ImportHDF5Dataset"); +} + +// ----------------------------------------------------------------------------- +QString ImportHDF5Dataset::ClassName() +{ + return QString("ImportHDF5Dataset"); +} + +// ----------------------------------------------------------------------------- +void ImportHDF5Dataset::setHDF5FilePath(const QString& value) +{ + m_HDF5FilePath = value; +} + +// ----------------------------------------------------------------------------- +QString ImportHDF5Dataset::getHDF5FilePath() const +{ + return m_HDF5FilePath; +} + +// ----------------------------------------------------------------------------- +void ImportHDF5Dataset::setDatasetImportInfoList(const QList& value) +{ + m_DatasetImportInfoList = value; +} + +// ----------------------------------------------------------------------------- +QList ImportHDF5Dataset::getDatasetImportInfoList() const +{ + return m_DatasetImportInfoList; +} + +// ----------------------------------------------------------------------------- +void ImportHDF5Dataset::setSelectedAttributeMatrix(const DataArrayPath& value) +{ + m_SelectedAttributeMatrix = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ImportHDF5Dataset::getSelectedAttributeMatrix() const +{ + return m_SelectedAttributeMatrix; +} + +// ----------------------------------------------------------------------------- +void ImportHDF5Dataset::setDatasetPathsWithErrors(const QStringList& value) +{ + m_DatasetPathsWithErrors = value; +} + +// ----------------------------------------------------------------------------- +QStringList ImportHDF5Dataset::getDatasetPathsWithErrors() const +{ + return m_DatasetPathsWithErrors; +} diff --git a/Source/SIMPLib/CoreFilters/ImportHDF5Dataset.h b/Source/SIMPLib/CoreFilters/ImportHDF5Dataset.h index 32d917c9ba..89c9dc8bce 100644 --- a/Source/SIMPLib/CoreFilters/ImportHDF5Dataset.h +++ b/Source/SIMPLib/CoreFilters/ImportHDF5Dataset.h @@ -32,11 +32,17 @@ #pragma once +#include + +#include + #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +class IDataArray; +using IDataArrayShPtrType = std::shared_ptr; /** * @brief The ImportHDF5Dataset class. See [Filter documentation](@ref readhdf5file) for details. @@ -44,16 +50,45 @@ class SIMPLib_EXPORT ImportHDF5Dataset : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(ImportHDF5Dataset SUPERCLASS AbstractFilter) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ImportHDF5Dataset SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(ImportHDF5Dataset) + PYB11_FILTER_NEW_MACRO(ImportHDF5Dataset) PYB11_PROPERTY(QString HDF5FilePath READ getHDF5FilePath WRITE setHDF5FilePath) - PYB11_PROPERTY(QString HDF5Dimensions READ getHDF5Dimensions) - PYB11_PROPERTY(QList DatasetImportInfoList READ getDatasetImportInfoList WRITE setDatasetImportInfoList) + PYB11_PROPERTY(QList DatasetImportInfoList READ getDatasetImportInfoList WRITE setDatasetImportInfoList) PYB11_PROPERTY(DataArrayPath SelectedAttributeMatrix READ getSelectedAttributeMatrix WRITE setSelectedAttributeMatrix) + PYB11_END_BINDINGS() + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(ImportHDF5Dataset) - SIMPL_FILTER_NEW_MACRO(ImportHDF5Dataset) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ImportHDF5Dataset, AbstractFilter) + using Self = ImportHDF5Dataset; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for ImportHDF5Dataset + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ImportHDF5Dataset + */ + static QString ClassName(); ~ImportHDF5Dataset() override; @@ -75,38 +110,70 @@ class SIMPLib_EXPORT ImportHDF5Dataset : public AbstractFilter } }; - SIMPL_FILTER_PARAMETER(QString, HDF5FilePath) + /** + * @brief Setter property for HDF5FilePath + */ + void setHDF5FilePath(const QString& value); + /** + * @brief Getter property for HDF5FilePath + * @return Value of HDF5FilePath + */ + QString getHDF5FilePath() const; + Q_PROPERTY(QString HDF5FilePath READ getHDF5FilePath WRITE setHDF5FilePath) - SIMPL_FILTER_PARAMETER(QList, DatasetImportInfoList) + /** + * @brief Setter property for DatasetImportInfoList + */ + void setDatasetImportInfoList(const QList& value); + /** + * @brief Getter property for DatasetImportInfoList + * @return Value of DatasetImportInfoList + */ + QList getDatasetImportInfoList() const; + Q_PROPERTY(QList DatasetImportInfoList READ getDatasetImportInfoList WRITE setDatasetImportInfoList) - QString getHDF5Dimensions(); - Q_PROPERTY(QString HDF5Dimensions READ getHDF5Dimensions) + /** + * @brief Setter property for SelectedAttributeMatrix + */ + void setSelectedAttributeMatrix(const DataArrayPath& value); + /** + * @brief Getter property for SelectedAttributeMatrix + * @return Value of SelectedAttributeMatrix + */ + DataArrayPath getSelectedAttributeMatrix() const; - SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedAttributeMatrix) Q_PROPERTY(DataArrayPath SelectedAttributeMatrix READ getSelectedAttributeMatrix WRITE setSelectedAttributeMatrix) - SIMPL_FILTER_PARAMETER(QStringList, DatasetPathsWithErrors) + /** + * @brief Setter property for DatasetPathsWithErrors + */ + void setDatasetPathsWithErrors(const QStringList& value); + /** + * @brief Getter property for DatasetPathsWithErrors + * @return Value of DatasetPathsWithErrors + */ + QStringList getDatasetPathsWithErrors() const; /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class */ - const QString getCompiledLibraryName() const override; + QString getCompiledLibraryName() const override; /** * @brief getBrandingString Returns the branding string for the filter, which is a tag * used to denote the filter's association with specific plugins * @return Branding string */ - const QString getBrandingString() const override; + QString getBrandingString() const override; /** * @brief getFilterVersion Returns a version string for this filter. Default * value is an empty string. * @return */ - const QString getFilterVersion() const override; + QString getFilterVersion() const override; /** * @brief newFilterInstance Reimplemented from @see AbstractFilter class @@ -116,23 +183,23 @@ class SIMPLib_EXPORT ImportHDF5Dataset : public AbstractFilter /** * @brief getGroupName Reimplemented from @see AbstractFilter class */ - const QString getGroupName() const override; + QString getGroupName() const override; /** * @brief getSubGroupName Reimplemented from @see AbstractFilter class */ - const QString getSubGroupName() const override; + QString getSubGroupName() const override; /** * @brief getUuid Return the unique identifier for this filter. * @return A QUuid object. */ - const QUuid getUuid() override; + QUuid getUuid() const override; /** * @brief getHumanLabel Reimplemented from @see AbstractFilter class */ - const QString getHumanLabel() const override; + QString getHumanLabel() const override; /** * @brief setupFilterParameters Reimplemented from @see AbstractFilter class @@ -144,41 +211,13 @@ class SIMPLib_EXPORT ImportHDF5Dataset : public AbstractFilter */ void execute() override; - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - -signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - protected: ImportHDF5Dataset(); /** * @brief dataCheck Checks for the appropriate parameter values and availability of arrays */ - void dataCheck(); + void dataCheck() override; /** * @brief Initializes all the private instance variables. @@ -186,15 +225,18 @@ class SIMPLib_EXPORT ImportHDF5Dataset : public AbstractFilter void initialize(); private: - QString m_HDF5Dimensions = ""; + QString m_HDF5FilePath = {}; + QList m_DatasetImportInfoList = {}; + DataArrayPath m_SelectedAttributeMatrix = {}; + QStringList m_DatasetPathsWithErrors = {}; - IDataArray::Pointer readIDataArray(hid_t gid, const QString& name, size_t numOfTuples, QVector cDims, bool metaDataOnly); + IDataArrayShPtrType readIDataArray(hid_t gid, const QString& name, size_t numOfTuples, const std::vector& cDims, bool metaDataOnly); /** * @brief createComponentDimensions * @return */ - QVector createComponentDimensions(const QString& cDimsStr); + std::vector createComponentDimensions(const QString& cDimsStr); public: ImportHDF5Dataset(const ImportHDF5Dataset&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SIMPLib/CoreFilters/InitializeData.cpp b/Source/SIMPLib/CoreFilters/InitializeData.cpp index 98afd4c3c9..4883077d47 100644 --- a/Source/SIMPLib/CoreFilters/InitializeData.cpp +++ b/Source/SIMPLib/CoreFilters/InitializeData.cpp @@ -1,47 +1,50 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "InitializeData.h" -#include #include +#include #include -#include +#include +#include +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DoubleFilterParameter.h" #include "SIMPLib/FilterParameters/IntFilterParameter.h" @@ -49,8 +52,6 @@ #include "SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/Geometry/ImageGeom.h" -#include "SIMPLib/SIMPLibVersion.h" - // ----------------------------------------------------------------------------- // @@ -67,17 +68,7 @@ void delay(int seconds) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -InitializeData::InitializeData() -: m_XMin(0) -, m_YMin(0) -, m_ZMin(0) -, m_XMax(0) -, m_YMax(0) -, m_ZMax(0) -, m_InitType(Manual) -, m_InitValue(0) -{ -} +InitializeData::InitializeData() = default; // ----------------------------------------------------------------------------- // @@ -89,20 +80,20 @@ InitializeData::~InitializeData() = default; // ----------------------------------------------------------------------------- void InitializeData::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(SeparatorFilterParameter::New("Cell Data", FilterParameter::RequiredArray)); + parameters.push_back(SeparatorFilterParameter::Create("Cell Data", FilterParameter::Category::RequiredArray)); { MultiDataArraySelectionFilterParameter::RequirementType req = MultiDataArraySelectionFilterParameter::CreateRequirement(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, AttributeMatrix::Type::Cell, IGeometry::Type::Image); - parameters.push_back(SIMPL_NEW_MDA_SELECTION_FP("Cell Arrays", CellAttributeMatrixPaths, FilterParameter::RequiredArray, InitializeData, req)); + parameters.push_back(SIMPL_NEW_MDA_SELECTION_FP("Cell Arrays", CellAttributeMatrixPaths, FilterParameter::Category::RequiredArray, InitializeData, req)); } - parameters.push_back(SIMPL_NEW_INTEGER_FP("X Min (Column)", XMin, FilterParameter::Parameter, InitializeData)); - parameters.push_back(SIMPL_NEW_INTEGER_FP("Y Min (Row)", YMin, FilterParameter::Parameter, InitializeData)); - parameters.push_back(SIMPL_NEW_INTEGER_FP("Z Min (Plane)", ZMin, FilterParameter::Parameter, InitializeData)); - parameters.push_back(SIMPL_NEW_INTEGER_FP("X Max (Column)", XMax, FilterParameter::Parameter, InitializeData)); - parameters.push_back(SIMPL_NEW_INTEGER_FP("Y Max (Row)", YMax, FilterParameter::Parameter, InitializeData)); - parameters.push_back(SIMPL_NEW_INTEGER_FP("Z Max (Plane)", ZMax, FilterParameter::Parameter, InitializeData)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("X Min (Column)", XMin, FilterParameter::Category::Parameter, InitializeData)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Y Min (Row)", YMin, FilterParameter::Category::Parameter, InitializeData)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Z Min (Plane)", ZMin, FilterParameter::Category::Parameter, InitializeData)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("X Max (Column)", XMax, FilterParameter::Category::Parameter, InitializeData)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Y Max (Row)", YMax, FilterParameter::Category::Parameter, InitializeData)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Z Max (Plane)", ZMax, FilterParameter::Category::Parameter, InitializeData)); { LinkedChoicesFilterParameter::Pointer parameter = LinkedChoicesFilterParameter::New(); @@ -113,43 +104,24 @@ void InitializeData::setupFilterParameters() parameter->setDefaultValue(Manual); - QVector choices; + std::vector choices; choices.push_back("Manual"); choices.push_back("Random"); choices.push_back("Random With Range"); parameter->setChoices(choices); - QStringList linkedProps; - linkedProps << "InitValue" - << "InitRange"; + std::vector linkedProps; + linkedProps.push_back("InitValue"); + linkedProps.push_back("InitRange"); parameter->setLinkedProperties(linkedProps); parameter->setEditable(false); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameters.push_back(parameter); } - parameters.push_back(SIMPL_NEW_DOUBLE_FP("Initialization Value", InitValue, FilterParameter::Parameter, InitializeData, Manual)); - parameters.push_back(SIMPL_NEW_RANGE_FP("Initialization Range", InitRange, FilterParameter::Parameter, InitializeData, RandomWithRange)); + parameters.push_back(SIMPL_NEW_DOUBLE_FP("Initialization Value", InitValue, FilterParameter::Category::Parameter, InitializeData, Manual)); + parameters.push_back(SIMPL_NEW_RANGE_FP("Initialization Range", InitRange, FilterParameter::Category::Parameter, InitializeData, RandomWithRange)); setFilterParameters(parameters); } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void InitializeData::readFilterParameters(AbstractFilterParametersReader* reader, int index) -{ - reader->openFilterGroup(this, index); - setCellAttributeMatrixPaths(reader->readDataArrayPathVector("CellAttributeMatrixPaths", getCellAttributeMatrixPaths())); - setXMin(reader->readValue("XMin", getXMin())); - setYMin(reader->readValue("YMin", getYMin())); - setZMin(reader->readValue("ZMin", getZMin())); - setXMax(reader->readValue("XMax", getXMax())); - setYMax(reader->readValue("YMax", getYMax())); - setZMax(reader->readValue("ZMax", getZMax())); - setInitType(reader->readValue("InitType", getInitType())); - setInitValue(reader->readValue("InitValue", getInitValue())); - setInitRange(reader->readPairOfDoubles("InitRange", getInitRange())); - reader->closeFilterGroup(); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -162,21 +134,24 @@ void InitializeData::initialize() // ----------------------------------------------------------------------------- void InitializeData::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(m_CellAttributeMatrixPaths.empty()) { QString ss = "At least one data array must be selected."; - setErrorCondition(-5550); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5550, ss); return; } DataArrayPath attributeMatrixPath(m_CellAttributeMatrixPaths[0].getDataContainerName(), m_CellAttributeMatrixPaths[0].getAttributeMatrixName(), ""); - getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, attributeMatrixPath, -301); + AttributeMatrix::Pointer am = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, attributeMatrixPath, -301); + if(getErrorCode() < 0) + { + return; + } - ImageGeom::Pointer image = getDataContainerArray()->getPrereqGeometryFromDataContainer(this, attributeMatrixPath.getDataContainerName()); + ImageGeom::Pointer image = getDataContainerArray()->getPrereqGeometryFromDataContainer(this, attributeMatrixPath.getDataContainerName()); if(nullptr == image.get()) { return; @@ -185,69 +160,59 @@ void InitializeData::dataCheck() if(getXMax() < getXMin()) { QString ss = QObject::tr("X Max (%1) less than X Min (%2)").arg(getXMax()).arg(getXMin()); - setErrorCondition(-5551); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5551, ss); } if(getYMax() < getYMin()) { QString ss = QObject::tr("Y Max (%1) less than Y Min (%2)").arg(getYMax()).arg(getYMin()); - setErrorCondition(-5552); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5552, ss); } if(getZMax() < getZMin()) { QString ss = QObject::tr("Z Max (%1) less than Z Min (%2)").arg(getZMax()).arg(getZMin()); - setErrorCondition(-5553); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5553, ss); } if(getXMin() < 0) { QString ss = QObject::tr("X Min (%1) less than 0").arg(getXMin()); - setErrorCondition(-5554); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5554, ss); } if(getYMin() < 0) { QString ss = QObject::tr("Y Min (%1) less than 0").arg(getYMin()); - setErrorCondition(-5555); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5555, ss); } if(getZMin() < 0) { QString ss = QObject::tr("Z Min (%1) less than 0").arg(getZMin()); - setErrorCondition(-5556); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5556, ss); } if(getXMax() > (static_cast(image->getXPoints()) - 1)) { QString ss = QObject::tr("The X Max you entered of %1 is greater than your Max X Point of %2").arg(getXMax()).arg(static_cast(image->getXPoints()) - 1); - setErrorCondition(-5557); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5557, ss); } if(getYMax() > (static_cast(image->getYPoints()) - 1)) { QString ss = QObject::tr("The Y Max you entered of %1 is greater than your Max Y Point of %2").arg(getYMax()).arg(static_cast(image->getYPoints()) - 1); - setErrorCondition(-5558); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5558, ss); } if(getZMax() > (static_cast(image->getZPoints()) - 1)) { QString ss = QObject::tr("The Z Max you entered of %1) greater than your Max Z Point of %2").arg(getZMax()).arg(static_cast(image->getZPoints()) - 1); - setErrorCondition(-5559); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5559, ss); } - DataContainer::Pointer m = getDataContainerArray()->getDataContainer(attributeMatrixPath.getDataContainerName()); + std::vector voxelArrayNames = DataArrayPath::GetDataArrayNames(m_CellAttributeMatrixPaths); - size_t udims[3] = {0, 0, 0}; - std::tie(udims[0], udims[1], udims[2]) = m->getGeometryAs()->getDimensions(); - - QString attrMatName = attributeMatrixPath.getAttributeMatrixName(); - QList voxelArrayNames = DataArrayPath::GetDataArrayNames(m_CellAttributeMatrixPaths); - - for(QList::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter) + for(const QString& name : voxelArrayNames) { - IDataArray::Pointer p = m->getAttributeMatrix(attrMatName)->getAttributeArray(*iter); + IDataArray::Pointer p = am->getAttributeArray(name); + if(p == nullptr) + { + setErrorCondition(-5560, QString("DataArray \"%1\" doesn't exist").arg(name)); + return; + } QString type = p->getTypeAsString(); if(type == "int8_t") @@ -291,7 +256,7 @@ void InitializeData::dataCheck() checkInitialization(p); } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -301,7 +266,8 @@ void InitializeData::dataCheck() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void InitializeData::checkInitialization(IDataArray::Pointer p) +template +void InitializeData::checkInitialization(IDataArray::Pointer p) { QString arrayName = p->getName(); @@ -310,9 +276,8 @@ template void InitializeData::checkInitialization(IDataArray::Point double input = m_InitValue; if(input < static_cast(std::numeric_limits().lowest()) || input > static_cast(std::numeric_limits().max())) { - setErrorCondition(-4000); QString ss = QObject::tr("%1: The initialization value could not be converted. The valid range is %2 to %3").arg(arrayName).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4000, ss); return; } } @@ -323,49 +288,31 @@ template void InitializeData::checkInitialization(IDataArray::Point if(min > max) { QString ss = arrayName + ": Invalid initialization range. Minimum value is larger than maximum value."; - setErrorCondition(-5550); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-5550, ss); return; } if(min < static_cast(std::numeric_limits().lowest()) || max > static_cast(std::numeric_limits().max())) { - setErrorCondition(-4001); QString ss = QObject::tr("%1: The initialization range can only be from %2 to %3").arg(arrayName).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4001, ss); return; } if(min == max) { - setErrorCondition(-4002); QString ss = arrayName + ": The initialization range must have differing values"; - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4002, ss); return; } } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void InitializeData::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InitializeData::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -373,19 +320,20 @@ void InitializeData::execute() DataArrayPath attributeMatrixPath(m_CellAttributeMatrixPaths[0].getDataContainerName(), m_CellAttributeMatrixPaths[0].getAttributeMatrixName(), ""); DataContainer::Pointer m = getDataContainerArray()->getDataContainer(attributeMatrixPath.getDataContainerName()); - size_t udims[3] = {0, 0, 0}; - std::tie(udims[0], udims[1], udims[2]) = m->getGeometryAs()->getDimensions(); + SizeVec3Type udims = m->getGeometryAs()->getDimensions(); int64_t dims[3] = { - static_cast(udims[0]), static_cast(udims[1]), static_cast(udims[2]), + static_cast(udims[0]), + static_cast(udims[1]), + static_cast(udims[2]), }; QString attrMatName = attributeMatrixPath.getAttributeMatrixName(); - QList voxelArrayNames = DataArrayPath::GetDataArrayNames(m_CellAttributeMatrixPaths); + std::vector voxelArrayNames = DataArrayPath::GetDataArrayNames(m_CellAttributeMatrixPaths); - for(QList::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter) + for(const QString& name : voxelArrayNames) { - IDataArray::Pointer p = m->getAttributeMatrix(attrMatName)->getAttributeArray(*iter); + IDataArray::Pointer p = m->getAttributeMatrix(attrMatName)->getAttributeArray(name); QString type = p->getTypeAsString(); if(type == "int8_t") @@ -431,13 +379,13 @@ void InitializeData::execute() delay(1); // Delay the execution by 1 second to avoid the exact same seedings for each array } - } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void InitializeData::initializeArrayWithInts(IDataArray::Pointer p, int64_t dims[3]) +template +void InitializeData::initializeArrayWithInts(IDataArray::Pointer p, int64_t dims[3]) { T rangeMin; T rangeMax; @@ -484,7 +432,8 @@ template void InitializeData::initializeArrayWithInts(IDataArray::P // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void InitializeData::initializeArrayWithReals(IDataArray::Pointer p, int64_t dims[3]) +template +void InitializeData::initializeArrayWithReals(IDataArray::Pointer p, int64_t dims[3]) { T rangeMin; T rangeMax; @@ -544,7 +493,7 @@ AbstractFilter::Pointer InitializeData::newFilterInstance(bool copyFilterParamet // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString InitializeData::getCompiledLibraryName() const +QString InitializeData::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -552,7 +501,7 @@ const QString InitializeData::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString InitializeData::getBrandingString() const +QString InitializeData::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -560,7 +509,7 @@ const QString InitializeData::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString InitializeData::getFilterVersion() const +QString InitializeData::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -570,7 +519,7 @@ const QString InitializeData::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString InitializeData::getGroupName() const +QString InitializeData::getGroupName() const { return SIMPL::FilterGroups::ProcessingFilters; } @@ -578,7 +527,7 @@ const QString InitializeData::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid InitializeData::getUuid() +QUuid InitializeData::getUuid() const { return QUuid("{dfab9921-fea3-521c-99ba-48db98e43ff8}"); } @@ -586,7 +535,7 @@ const QUuid InitializeData::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString InitializeData::getSubGroupName() const +QString InitializeData::getSubGroupName() const { return SIMPL::FilterSubGroups::ConversionFilters; } @@ -594,7 +543,168 @@ const QString InitializeData::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString InitializeData::getHumanLabel() const +QString InitializeData::getHumanLabel() const { return "Initialize Data"; } + +// ----------------------------------------------------------------------------- +InitializeData::Pointer InitializeData::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr InitializeData::New() +{ + struct make_shared_enabler : public InitializeData + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString InitializeData::getNameOfClass() const +{ + return QString("InitializeData"); +} + +// ----------------------------------------------------------------------------- +QString InitializeData::ClassName() +{ + return QString("InitializeData"); +} + +// ----------------------------------------------------------------------------- +void InitializeData::setCellAttributeMatrixPaths(const std::vector& value) +{ + m_CellAttributeMatrixPaths = value; +} + +// ----------------------------------------------------------------------------- +std::vector InitializeData::getCellAttributeMatrixPaths() const +{ + return m_CellAttributeMatrixPaths; +} + +// ----------------------------------------------------------------------------- +void InitializeData::setXMin(int value) +{ + m_XMin = value; +} + +// ----------------------------------------------------------------------------- +int InitializeData::getXMin() const +{ + return m_XMin; +} + +// ----------------------------------------------------------------------------- +void InitializeData::setYMin(int value) +{ + m_YMin = value; +} + +// ----------------------------------------------------------------------------- +int InitializeData::getYMin() const +{ + return m_YMin; +} + +// ----------------------------------------------------------------------------- +void InitializeData::setZMin(int value) +{ + m_ZMin = value; +} + +// ----------------------------------------------------------------------------- +int InitializeData::getZMin() const +{ + return m_ZMin; +} + +// ----------------------------------------------------------------------------- +void InitializeData::setXMax(int value) +{ + m_XMax = value; +} + +// ----------------------------------------------------------------------------- +int InitializeData::getXMax() const +{ + return m_XMax; +} + +// ----------------------------------------------------------------------------- +void InitializeData::setYMax(int value) +{ + m_YMax = value; +} + +// ----------------------------------------------------------------------------- +int InitializeData::getYMax() const +{ + return m_YMax; +} + +// ----------------------------------------------------------------------------- +void InitializeData::setZMax(int value) +{ + m_ZMax = value; +} + +// ----------------------------------------------------------------------------- +int InitializeData::getZMax() const +{ + return m_ZMax; +} + +// ----------------------------------------------------------------------------- +void InitializeData::setInitType(int value) +{ + m_InitType = value; +} + +// ----------------------------------------------------------------------------- +int InitializeData::getInitType() const +{ + return m_InitType; +} + +// ----------------------------------------------------------------------------- +void InitializeData::setRandom(bool value) +{ + m_Random = value; +} + +// ----------------------------------------------------------------------------- +bool InitializeData::getRandom() const +{ + return m_Random; +} + +// ----------------------------------------------------------------------------- +void InitializeData::setInitValue(double value) +{ + m_InitValue = value; +} + +// ----------------------------------------------------------------------------- +double InitializeData::getInitValue() const +{ + return m_InitValue; +} + +// ----------------------------------------------------------------------------- +void InitializeData::setInitRange(const FPRangePair& value) +{ + m_InitRange = value; +} + +// ----------------------------------------------------------------------------- +FPRangePair InitializeData::getInitRange() const +{ + return m_InitRange; +} diff --git a/Source/SIMPLib/CoreFilters/InitializeData.h b/Source/SIMPLib/CoreFilters/InitializeData.h index 04f7d6bbfa..8fbde84e94 100644 --- a/Source/SIMPLib/CoreFilters/InitializeData.h +++ b/Source/SIMPLib/CoreFilters/InitializeData.h @@ -1,46 +1,50 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/FilterParameters/RangeFilterParameter.h" #include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/SIMPLib.h" + +class IDataArray; +using IDataArrayShPtrType = std::shared_ptr; /** * @brief The InitializeData class. See [Filter documentation](@ref initializedata) for details. @@ -48,76 +52,206 @@ class SIMPLib_EXPORT InitializeData : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(InitializeData SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QVector CellAttributeMatrixPaths READ getCellAttributeMatrixPaths WRITE setCellAttributeMatrixPaths) - PYB11_PROPERTY(int XMin READ getXMin WRITE setXMin) - PYB11_PROPERTY(int YMin READ getYMin WRITE setYMin) - PYB11_PROPERTY(int ZMin READ getZMin WRITE setZMin) - PYB11_PROPERTY(int XMax READ getXMax WRITE setXMax) - PYB11_PROPERTY(int YMax READ getYMax WRITE setYMax) - PYB11_PROPERTY(int ZMax READ getZMax WRITE setZMax) - PYB11_PROPERTY(int InitType READ getInitType WRITE setInitType) - PYB11_PROPERTY(bool Random READ getRandom WRITE setRandom) - PYB11_PROPERTY(double InitValue READ getInitValue WRITE setInitValue) - PYB11_PROPERTY(FPRangePair InitRange READ getInitRange WRITE setInitRange) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(InitializeData SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(InitializeData) + PYB11_FILTER_NEW_MACRO(InitializeData) + PYB11_PROPERTY(std::vector CellAttributeMatrixPaths READ getCellAttributeMatrixPaths WRITE setCellAttributeMatrixPaths) + PYB11_PROPERTY(int XMin READ getXMin WRITE setXMin) + PYB11_PROPERTY(int YMin READ getYMin WRITE setYMin) + PYB11_PROPERTY(int ZMin READ getZMin WRITE setZMin) + PYB11_PROPERTY(int XMax READ getXMax WRITE setXMax) + PYB11_PROPERTY(int YMax READ getYMax WRITE setYMax) + PYB11_PROPERTY(int ZMax READ getZMax WRITE setZMax) + PYB11_PROPERTY(int InitType READ getInitType WRITE setInitType) + PYB11_PROPERTY(bool Random READ getRandom WRITE setRandom) + PYB11_PROPERTY(double InitValue READ getInitValue WRITE setInitValue) + PYB11_PROPERTY(FPRangePair InitRange READ getInitRange WRITE setInitRange) + PYB11_END_BINDINGS() + // End Python bindings declarations + public: - SIMPL_SHARED_POINTERS(InitializeData) - SIMPL_FILTER_NEW_MACRO(InitializeData) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(InitializeData, AbstractFilter) + using Self = InitializeData; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for InitializeData + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for InitializeData + */ + static QString ClassName(); ~InitializeData() override; - SIMPL_FILTER_PARAMETER(QVector, CellAttributeMatrixPaths) - Q_PROPERTY(QVector CellAttributeMatrixPaths READ getCellAttributeMatrixPaths WRITE setCellAttributeMatrixPaths) + /** + * @brief Setter property for CellAttributeMatrixPaths + */ + void setCellAttributeMatrixPaths(const std::vector& value); + /** + * @brief Getter property for CellAttributeMatrixPaths + * @return Value of CellAttributeMatrixPaths + */ + std::vector getCellAttributeMatrixPaths() const; + + Q_PROPERTY(DataArrayPathVec CellAttributeMatrixPaths READ getCellAttributeMatrixPaths WRITE setCellAttributeMatrixPaths) + + /** + * @brief Setter property for XMin + */ + void setXMin(int value); + /** + * @brief Getter property for XMin + * @return Value of XMin + */ + int getXMin() const; - SIMPL_FILTER_PARAMETER(int, XMin) Q_PROPERTY(int XMin READ getXMin WRITE setXMin) - SIMPL_FILTER_PARAMETER(int, YMin) + /** + * @brief Setter property for YMin + */ + void setYMin(int value); + /** + * @brief Getter property for YMin + * @return Value of YMin + */ + int getYMin() const; + Q_PROPERTY(int YMin READ getYMin WRITE setYMin) - SIMPL_FILTER_PARAMETER(int, ZMin) + /** + * @brief Setter property for ZMin + */ + void setZMin(int value); + /** + * @brief Getter property for ZMin + * @return Value of ZMin + */ + int getZMin() const; + Q_PROPERTY(int ZMin READ getZMin WRITE setZMin) - SIMPL_FILTER_PARAMETER(int, XMax) + /** + * @brief Setter property for XMax + */ + void setXMax(int value); + /** + * @brief Getter property for XMax + * @return Value of XMax + */ + int getXMax() const; + Q_PROPERTY(int XMax READ getXMax WRITE setXMax) - SIMPL_FILTER_PARAMETER(int, YMax) + /** + * @brief Setter property for YMax + */ + void setYMax(int value); + /** + * @brief Getter property for YMax + * @return Value of YMax + */ + int getYMax() const; + Q_PROPERTY(int YMax READ getYMax WRITE setYMax) - SIMPL_FILTER_PARAMETER(int, ZMax) + /** + * @brief Setter property for ZMax + */ + void setZMax(int value); + /** + * @brief Getter property for ZMax + * @return Value of ZMax + */ + int getZMax() const; + Q_PROPERTY(int ZMax READ getZMax WRITE setZMax) - SIMPL_FILTER_PARAMETER(int, InitType) + /** + * @brief Setter property for InitType + */ + void setInitType(int value); + /** + * @brief Getter property for InitType + * @return Value of InitType + */ + int getInitType() const; + Q_PROPERTY(int InitType READ getInitType WRITE setInitType) - SIMPL_FILTER_PARAMETER(bool, Random) + /** + * @brief Setter property for Random + */ + void setRandom(bool value); + /** + * @brief Getter property for Random + * @return Value of Random + */ + bool getRandom() const; + Q_PROPERTY(bool Random READ getRandom WRITE setRandom) - SIMPL_FILTER_PARAMETER(double, InitValue) + /** + * @brief Setter property for InitValue + */ + void setInitValue(double value); + /** + * @brief Getter property for InitValue + * @return Value of InitValue + */ + double getInitValue() const; + Q_PROPERTY(double InitValue READ getInitValue WRITE setInitValue) - SIMPL_FILTER_PARAMETER(FPRangePair, InitRange) + /** + * @brief Setter property for InitRange + */ + void setInitRange(const FPRangePair& value); + /** + * @brief Getter property for InitRange + * @return Value of InitRange + */ + FPRangePair getInitRange() const; + Q_PROPERTY(FPRangePair InitRange READ getInitRange WRITE setInitRange) /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class */ - const QString getCompiledLibraryName() const override; + QString getCompiledLibraryName() const override; /** * @brief getBrandingString Returns the branding string for the filter, which is a tag * used to denote the filter's association with specific plugins * @return Branding string - */ - const QString getBrandingString() const override; + */ + QString getBrandingString() const override; /** * @brief getFilterVersion Returns a version string for this filter. Default * value is an empty string. * @return */ - const QString getFilterVersion() const override; + QString getFilterVersion() const override; /** * @brief newFilterInstance Reimplemented from @see AbstractFilter class @@ -127,73 +261,40 @@ class SIMPLib_EXPORT InitializeData : public AbstractFilter /** * @brief getGroupName Reimplemented from @see AbstractFilter class */ - const QString getGroupName() const override; + QString getGroupName() const override; /** * @brief getSubGroupName Reimplemented from @see AbstractFilter class */ - const QString getSubGroupName() const override; + QString getSubGroupName() const override; /** * @brief getUuid Return the unique identifier for this filter. * @return A QUuid object. */ - const QUuid getUuid() override; + QUuid getUuid() const override; /** * @brief getHumanLabel Reimplemented from @see AbstractFilter class */ - const QString getHumanLabel() const override; + QString getHumanLabel() const override; /** * @brief setupFilterParameters Reimplemented from @see AbstractFilter class */ void setupFilterParameters() override; - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - /** * @brief execute Reimplemented from @see AbstractFilter class */ void execute() override; - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - -signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - protected: InitializeData(); /** * @brief dataCheck Checks for the appropriate parameter values and availability of arrays */ - void dataCheck(); + void dataCheck() override; /** * @brief Initializes all the private instance variables. @@ -201,6 +302,18 @@ class SIMPLib_EXPORT InitializeData : public AbstractFilter void initialize(); private: + std::vector m_CellAttributeMatrixPaths = {}; + int m_XMin = {0}; + int m_YMin = {0}; + int m_ZMin = {0}; + int m_XMax = {0}; + int m_YMax = {0}; + int m_ZMax = {0}; + int m_InitType = {Manual}; + bool m_Random = {}; + double m_InitValue = {0}; + FPRangePair m_InitRange = {}; + enum InitChoices { Manual, @@ -209,36 +322,38 @@ class SIMPLib_EXPORT InitializeData : public AbstractFilter }; /** - * @brief initializeArrayWithInts Initializes the array p with integers, either from the - * manual value entered in the filter, or with a random number. This function does not - * check that the template type actually is an integer, so it will most likely cause - * unexpected results when passing anything other than an integer as a template parameter. - * @param p The array that will be initialized - * @param dims The dimensions of the array p - */ - template void initializeArrayWithInts(IDataArray::Pointer p, int64_t dims[3]); + * @brief initializeArrayWithInts Initializes the array p with integers, either from the + * manual value entered in the filter, or with a random number. This function does not + * check that the template type actually is an integer, so it will most likely cause + * unexpected results when passing anything other than an integer as a template parameter. + * @param p The array that will be initialized + * @param dims The dimensions of the array p + */ + template + void initializeArrayWithInts(IDataArrayShPtrType p, int64_t dims[3]); /** - * @brief initializeArrayWithReals Initializes the array p with real numbers, either from the - * manual value entered in the filter, or with a random number. This function does not - * check that the template type actually is a non-integer, so it will most likely cause - * unexpected results when passing anything other than a float or double as a template - * parameter. - * @param p The array that will be initialized - * @param dims The dimensions of the array p - */ - template void initializeArrayWithReals(IDataArray::Pointer p, int64_t dims[3]); + * @brief initializeArrayWithReals Initializes the array p with real numbers, either from the + * manual value entered in the filter, or with a random number. This function does not + * check that the template type actually is a non-integer, so it will most likely cause + * unexpected results when passing anything other than a float or double as a template + * parameter. + * @param p The array that will be initialized + * @param dims The dimensions of the array p + */ + template + void initializeArrayWithReals(IDataArrayShPtrType p, int64_t dims[3]); /** - * @brief checkInitialization Checks that the chosen initialization value/range is inside - * the bounds of the array type - */ - template void checkInitialization(IDataArray::Pointer p); + * @brief checkInitialization Checks that the chosen initialization value/range is inside + * the bounds of the array type + */ + template + void checkInitialization(IDataArrayShPtrType p); public: - InitializeData(const InitializeData&) = delete; // Copy Constructor Not Implemented - InitializeData(InitializeData&&) = delete; // Move Constructor Not Implemented + InitializeData(const InitializeData&) = delete; // Copy Constructor Not Implemented + InitializeData(InitializeData&&) = delete; // Move Constructor Not Implemented InitializeData& operator=(const InitializeData&) = delete; // Copy Assignment Not Implemented InitializeData& operator=(InitializeData&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/LinkFeatureMapToElementArray.cpp b/Source/SIMPLib/CoreFilters/LinkFeatureMapToElementArray.cpp index ebe7fb4486..d4548176bf 100644 --- a/Source/SIMPLib/CoreFilters/LinkFeatureMapToElementArray.cpp +++ b/Source/SIMPLib/CoreFilters/LinkFeatureMapToElementArray.cpp @@ -1,57 +1,61 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "LinkFeatureMapToElementArray.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" -#include "SIMPLib/SIMPLibVersion.h" - #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" +#include "SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.h" #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" +enum createdPathID : RenameDataPath::DataID_t +{ + AttributeMatrixID = 1, + DataArrayID +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -LinkFeatureMapToElementArray::LinkFeatureMapToElementArray() -: m_CellFeatureAttributeMatrixName("") -, m_SelectedCellArrayPath("", "", "") -, m_ActiveArrayName("") -{ -} +LinkFeatureMapToElementArray::LinkFeatureMapToElementArray() = default; // ----------------------------------------------------------------------------- // @@ -63,15 +67,17 @@ LinkFeatureMapToElementArray::~LinkFeatureMapToElementArray() = default; // ----------------------------------------------------------------------------- void LinkFeatureMapToElementArray::setupFilterParameters() { - FilterParameterVector parameters; - parameters.push_back(SeparatorFilterParameter::New("Element Data", FilterParameter::RequiredArray)); + FilterParameterVectorType parameters; + parameters.push_back(SeparatorFilterParameter::Create("Element Data", FilterParameter::Category::RequiredArray)); { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::TypeNames::Int32, 1, AttributeMatrix::Category::Element); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Element Attribute Array to Link", SelectedCellArrayPath, FilterParameter::RequiredArray, LinkFeatureMapToElementArray, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Element Attribute Array to Link", SelectedCellArrayPath, FilterParameter::Category::RequiredArray, LinkFeatureMapToElementArray, req)); } - parameters.push_back(SeparatorFilterParameter::New("Feature Data", FilterParameter::CreatedArray)); - parameters.push_back(SIMPL_NEW_STRING_FP("Feature Attribute Matrix", CellFeatureAttributeMatrixName, FilterParameter::CreatedArray, LinkFeatureMapToElementArray)); - parameters.push_back(SIMPL_NEW_STRING_FP("Active", ActiveArrayName, FilterParameter::CreatedArray, LinkFeatureMapToElementArray)); + parameters.push_back(SeparatorFilterParameter::Create("Feature Data", FilterParameter::Category::CreatedArray)); + parameters.push_back( + SIMPL_NEW_AM_WITH_LINKED_DC_FP("Feature Attribute Matrix", CellFeatureAttributeMatrixName, SelectedCellArrayPath, FilterParameter::Category::CreatedArray, LinkFeatureMapToElementArray)); + parameters.push_back( + SIMPL_NEW_DA_WITH_LINKED_AM_FP("Active", ActiveArrayName, SelectedCellArrayPath, CellFeatureAttributeMatrixName, FilterParameter::Category::CreatedArray, LinkFeatureMapToElementArray)); setFilterParameters(parameters); } @@ -93,10 +99,10 @@ void LinkFeatureMapToElementArray::readFilterParameters(AbstractFilterParameters // ----------------------------------------------------------------------------- void LinkFeatureMapToElementArray::updateFeatureInstancePointers() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - if(nullptr != m_ActivePtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ + if(nullptr != m_ActivePtr.lock()) { m_Active = m_ActivePtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ @@ -114,63 +120,46 @@ void LinkFeatureMapToElementArray::initialize() // ----------------------------------------------------------------------------- void LinkFeatureMapToElementArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); DataArrayPath tempPath; DataContainer::Pointer m = getDataContainerArray()->getPrereqDataContainer(this, getSelectedCellArrayPath().getDataContainerName(), false); - if(getErrorCondition() < 0 || nullptr == m.get()) + if(getErrorCode() < 0 || nullptr == m.get()) { return; } - QVector tDims(1, 0); - m->createNonPrereqAttributeMatrix(this, getCellFeatureAttributeMatrixName(), tDims, AttributeMatrix::Type::CellFeature); + std::vector tDims(1, 0); + m->createNonPrereqAttributeMatrix(this, getCellFeatureAttributeMatrixName(), tDims, AttributeMatrix::Type::CellFeature, AttributeMatrixID); - QVector cDims(1, 1); - m_SelectedCellDataPtr = getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getSelectedCellArrayPath(), - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ - if(nullptr != m_SelectedCellDataPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ + std::vector cDims(1, 1); + m_SelectedCellDataPtr = getDataContainerArray()->getPrereqArrayFromPath>(this, getSelectedCellArrayPath(), cDims); + if(nullptr != m_SelectedCellDataPtr.lock()) { m_SelectedCellData = m_SelectedCellDataPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } tempPath.update(getSelectedCellArrayPath().getDataContainerName(), getCellFeatureAttributeMatrixName(), getActiveArrayName()); - m_ActivePtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, bool>(this, tempPath, false, - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ - if(nullptr != m_ActivePtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ + m_ActivePtr = getDataContainerArray()->createNonPrereqArrayFromPath>(this, tempPath, false, cDims, "", DataArrayID); + if(nullptr != m_ActivePtr.lock()) { m_Active = m_ActivePtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void LinkFeatureMapToElementArray::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void LinkFeatureMapToElementArray::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -191,7 +180,7 @@ void LinkFeatureMapToElementArray::execute() } } - QVector tDims(1, maxIndex); + std::vector tDims(1, maxIndex); m->getAttributeMatrix(getCellFeatureAttributeMatrixName())->resizeAttributeArrays(tDims); updateFeatureInstancePointers(); @@ -199,7 +188,6 @@ void LinkFeatureMapToElementArray::execute() { m_Active[i] = active[i]; } - } // ----------------------------------------------------------------------------- @@ -218,7 +206,7 @@ AbstractFilter::Pointer LinkFeatureMapToElementArray::newFilterInstance(bool cop // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString LinkFeatureMapToElementArray::getCompiledLibraryName() const +QString LinkFeatureMapToElementArray::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -226,7 +214,7 @@ const QString LinkFeatureMapToElementArray::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString LinkFeatureMapToElementArray::getBrandingString() const +QString LinkFeatureMapToElementArray::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -234,7 +222,7 @@ const QString LinkFeatureMapToElementArray::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString LinkFeatureMapToElementArray::getFilterVersion() const +QString LinkFeatureMapToElementArray::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -245,7 +233,7 @@ const QString LinkFeatureMapToElementArray::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString LinkFeatureMapToElementArray::getGroupName() const +QString LinkFeatureMapToElementArray::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -253,7 +241,7 @@ const QString LinkFeatureMapToElementArray::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid LinkFeatureMapToElementArray::getUuid() +QUuid LinkFeatureMapToElementArray::getUuid() const { return QUuid("{0e1c45f6-ed7a-5279-8a5c-a2d5cc6bfead}"); } @@ -261,7 +249,7 @@ const QUuid LinkFeatureMapToElementArray::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString LinkFeatureMapToElementArray::getSubGroupName() const +QString LinkFeatureMapToElementArray::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -269,7 +257,72 @@ const QString LinkFeatureMapToElementArray::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString LinkFeatureMapToElementArray::getHumanLabel() const +QString LinkFeatureMapToElementArray::getHumanLabel() const { return "Link Feature Attribute Matrix to Element Attribute Array"; } + +// ----------------------------------------------------------------------------- +LinkFeatureMapToElementArray::Pointer LinkFeatureMapToElementArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr LinkFeatureMapToElementArray::New() +{ + struct make_shared_enabler : public LinkFeatureMapToElementArray + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString LinkFeatureMapToElementArray::getNameOfClass() const +{ + return QString("LinkFeatureMapToElementArray"); +} + +// ----------------------------------------------------------------------------- +QString LinkFeatureMapToElementArray::ClassName() +{ + return QString("LinkFeatureMapToElementArray"); +} + +// ----------------------------------------------------------------------------- +void LinkFeatureMapToElementArray::setCellFeatureAttributeMatrixName(const QString& value) +{ + m_CellFeatureAttributeMatrixName = value; +} + +// ----------------------------------------------------------------------------- +QString LinkFeatureMapToElementArray::getCellFeatureAttributeMatrixName() const +{ + return m_CellFeatureAttributeMatrixName; +} + +// ----------------------------------------------------------------------------- +void LinkFeatureMapToElementArray::setSelectedCellArrayPath(const DataArrayPath& value) +{ + m_SelectedCellArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath LinkFeatureMapToElementArray::getSelectedCellArrayPath() const +{ + return m_SelectedCellArrayPath; +} + +// ----------------------------------------------------------------------------- +void LinkFeatureMapToElementArray::setActiveArrayName(const QString& value) +{ + m_ActiveArrayName = value; +} + +// ----------------------------------------------------------------------------- +QString LinkFeatureMapToElementArray::getActiveArrayName() const +{ + return m_ActiveArrayName; +} diff --git a/Source/SIMPLib/CoreFilters/LinkFeatureMapToElementArray.h b/Source/SIMPLib/CoreFilters/LinkFeatureMapToElementArray.h old mode 100755 new mode 100644 index ceb91bb861..f6286bc352 --- a/Source/SIMPLib/CoreFilters/LinkFeatureMapToElementArray.h +++ b/Source/SIMPLib/CoreFilters/LinkFeatureMapToElementArray.h @@ -1,186 +1,211 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The LinkFeatureMapToElementArray class. See [Filter documentation](@ref linkfeaturemaptoelementarray) for details. */ class SIMPLib_EXPORT LinkFeatureMapToElementArray : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(LinkFeatureMapToElementArray SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString CellFeatureAttributeMatrixName READ getCellFeatureAttributeMatrixName WRITE setCellFeatureAttributeMatrixName) - PYB11_PROPERTY(DataArrayPath SelectedCellArrayPath READ getSelectedCellArrayPath WRITE setSelectedCellArrayPath) - PYB11_PROPERTY(QString ActiveArrayName READ getActiveArrayName WRITE setActiveArrayName) - - public: - SIMPL_SHARED_POINTERS(LinkFeatureMapToElementArray) - SIMPL_FILTER_NEW_MACRO(LinkFeatureMapToElementArray) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(LinkFeatureMapToElementArray, AbstractFilter) - - ~LinkFeatureMapToElementArray() override; - - SIMPL_FILTER_PARAMETER(QString, CellFeatureAttributeMatrixName) - Q_PROPERTY(QString CellFeatureAttributeMatrixName READ getCellFeatureAttributeMatrixName WRITE setCellFeatureAttributeMatrixName) - - SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedCellArrayPath) - Q_PROPERTY(DataArrayPath SelectedCellArrayPath READ getSelectedCellArrayPath WRITE setSelectedCellArrayPath) - - SIMPL_FILTER_PARAMETER(QString, ActiveArrayName) - Q_PROPERTY(QString ActiveArrayName READ getActiveArrayName WRITE setActiveArrayName) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - LinkFeatureMapToElementArray(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - /** - * @brief updateFeatureInstancePointers Updates raw feature pointers - */ - void updateFeatureInstancePointers(); - - private: - DEFINE_DATAARRAY_VARIABLE(int32_t, SelectedCellData) - DEFINE_DATAARRAY_VARIABLE(bool, Active) - - public: - LinkFeatureMapToElementArray(const LinkFeatureMapToElementArray&) = delete; // Copy Constructor Not Implemented - LinkFeatureMapToElementArray(LinkFeatureMapToElementArray&&) = delete; // Move Constructor Not Implemented - LinkFeatureMapToElementArray& operator=(const LinkFeatureMapToElementArray&) = delete; // Copy Assignment Not Implemented - LinkFeatureMapToElementArray& operator=(LinkFeatureMapToElementArray&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(LinkFeatureMapToElementArray SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(LinkFeatureMapToElementArray) + PYB11_FILTER_NEW_MACRO(LinkFeatureMapToElementArray) + PYB11_PROPERTY(QString CellFeatureAttributeMatrixName READ getCellFeatureAttributeMatrixName WRITE setCellFeatureAttributeMatrixName) + PYB11_PROPERTY(DataArrayPath SelectedCellArrayPath READ getSelectedCellArrayPath WRITE setSelectedCellArrayPath) + PYB11_PROPERTY(QString ActiveArrayName READ getActiveArrayName WRITE setActiveArrayName) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = LinkFeatureMapToElementArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for LinkFeatureMapToElementArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for LinkFeatureMapToElementArray + */ + static QString ClassName(); + + ~LinkFeatureMapToElementArray() override; + + /** + * @brief Setter property for CellFeatureAttributeMatrixName + */ + void setCellFeatureAttributeMatrixName(const QString& value); + /** + * @brief Getter property for CellFeatureAttributeMatrixName + * @return Value of CellFeatureAttributeMatrixName + */ + QString getCellFeatureAttributeMatrixName() const; + + Q_PROPERTY(QString CellFeatureAttributeMatrixName READ getCellFeatureAttributeMatrixName WRITE setCellFeatureAttributeMatrixName) + + /** + * @brief Setter property for SelectedCellArrayPath + */ + void setSelectedCellArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SelectedCellArrayPath + * @return Value of SelectedCellArrayPath + */ + DataArrayPath getSelectedCellArrayPath() const; + + Q_PROPERTY(DataArrayPath SelectedCellArrayPath READ getSelectedCellArrayPath WRITE setSelectedCellArrayPath) + + /** + * @brief Setter property for ActiveArrayName + */ + void setActiveArrayName(const QString& value); + /** + * @brief Getter property for ActiveArrayName + * @return Value of ActiveArrayName + */ + QString getActiveArrayName() const; + + Q_PROPERTY(QString ActiveArrayName READ getActiveArrayName WRITE setActiveArrayName) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + LinkFeatureMapToElementArray(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + + /** + * @brief updateFeatureInstancePointers Updates raw feature pointers + */ + void updateFeatureInstancePointers(); + +private: + std::weak_ptr> m_SelectedCellDataPtr; + int32_t* m_SelectedCellData = nullptr; + std::weak_ptr> m_ActivePtr; + bool* m_Active = nullptr; + + QString m_CellFeatureAttributeMatrixName = {""}; + DataArrayPath m_SelectedCellArrayPath = {"", "", ""}; + QString m_ActiveArrayName = {""}; + +public: + LinkFeatureMapToElementArray(const LinkFeatureMapToElementArray&) = delete; // Copy Constructor Not Implemented + LinkFeatureMapToElementArray(LinkFeatureMapToElementArray&&) = delete; // Move Constructor Not Implemented + LinkFeatureMapToElementArray& operator=(const LinkFeatureMapToElementArray&) = delete; // Copy Assignment Not Implemented + LinkFeatureMapToElementArray& operator=(LinkFeatureMapToElementArray&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/MaskCountDecision.cpp b/Source/SIMPLib/CoreFilters/MaskCountDecision.cpp index 0425888587..128ac4e84a 100644 --- a/Source/SIMPLib/CoreFilters/MaskCountDecision.cpp +++ b/Source/SIMPLib/CoreFilters/MaskCountDecision.cpp @@ -1,43 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "MaskCountDecision.h" +#include #include #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/IntFilterParameter.h" @@ -45,11 +47,7 @@ // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -MaskCountDecision::MaskCountDecision() -: m_MaskArrayPath("", "", "") -, m_NumberOfTrues(0) -{ -} +MaskCountDecision::MaskCountDecision() = default; // ----------------------------------------------------------------------------- // @@ -61,11 +59,10 @@ MaskCountDecision::~MaskCountDecision() = default; // ----------------------------------------------------------------------------- void MaskCountDecision::setupFilterParameters() { - FilterParameterVector parameters = getFilterParameters(); - DataArraySelectionFilterParameter::RequirementType req = - DataArraySelectionFilterParameter::CreateRequirement(SIMPL::TypeNames::Bool, 1, AttributeMatrix::Type::Any, IGeometry::Type::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Mask", MaskArrayPath, FilterParameter::RequiredArray, MaskCountDecision, req)); - parameters.push_back(SIMPL_NEW_INTEGER_FP("Number of True Instances", NumberOfTrues, FilterParameter::Parameter, MaskCountDecision, 0)); + FilterParameterVectorType parameters = getFilterParameters(); + DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateRequirement(SIMPL::TypeNames::Bool, 1, AttributeMatrix::Type::Any, IGeometry::Type::Any); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Mask", MaskArrayPath, FilterParameter::Category::RequiredArray, MaskCountDecision, req)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Number of True Instances", NumberOfTrues, FilterParameter::Category::Parameter, MaskCountDecision, 0)); setFilterParameters(parameters); } @@ -93,41 +90,25 @@ void MaskCountDecision::initialize() // ----------------------------------------------------------------------------- void MaskCountDecision::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - QVector cDims(1, 1); + std::vector cDims(1, 1); - m_MaskPtr = - getDataContainerArray()->getPrereqArrayFromPath, AbstractFilter>(this, getMaskArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ - if(nullptr != m_MaskPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ + m_MaskPtr = getDataContainerArray()->getPrereqArrayFromPath>(this, getMaskArrayPath(), cDims); + if(nullptr != m_MaskPtr.lock()) { m_Mask = m_MaskPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void MaskCountDecision::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void MaskCountDecision::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -144,7 +125,7 @@ void MaskCountDecision::execute() if(m_NumberOfTrues < 0 && !m_Mask[i]) { qDebug() << "First if check: " << dm; - emit decisionMade(dm); + Q_EMIT decisionMade(dm); return; } if(m_Mask[i]) @@ -156,16 +137,15 @@ void MaskCountDecision::execute() dm = false; qDebug() << "Second if check: " << dm; - emit decisionMade(dm); - emit targetValue(trueCount); + Q_EMIT decisionMade(dm); + Q_EMIT targetValue(trueCount); return; } } qDebug() << "Fell through: " << dm; - emit decisionMade(dm); - + Q_EMIT decisionMade(dm); } // ----------------------------------------------------------------------------- @@ -215,7 +195,7 @@ AbstractFilter::Pointer MaskCountDecision::newFilterInstance(bool copyFilterPara // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MaskCountDecision::getCompiledLibraryName() const +QString MaskCountDecision::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -223,7 +203,7 @@ const QString MaskCountDecision::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MaskCountDecision::getGroupName() const +QString MaskCountDecision::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -231,7 +211,7 @@ const QString MaskCountDecision::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid MaskCountDecision::getUuid() +QUuid MaskCountDecision::getUuid() const { return QUuid("{34a19028-c50b-5dea-af0e-e06c798d3686}"); } @@ -239,7 +219,7 @@ const QUuid MaskCountDecision::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MaskCountDecision::getSubGroupName() const +QString MaskCountDecision::getSubGroupName() const { return SIMPL::FilterSubGroups::MiscFilters; } @@ -247,7 +227,56 @@ const QString MaskCountDecision::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MaskCountDecision::getHumanLabel() const +QString MaskCountDecision::getHumanLabel() const { return "Mask Count Decision"; } + +// ----------------------------------------------------------------------------- +MaskCountDecision::Pointer MaskCountDecision::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +MaskCountDecision::Pointer MaskCountDecision::New() +{ + Pointer sharedPtr(new(MaskCountDecision)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString MaskCountDecision::getNameOfClass() const +{ + return QString("MaskCountDecision"); +} + +// ----------------------------------------------------------------------------- +QString MaskCountDecision::ClassName() +{ + return QString("MaskCountDecision"); +} + +// ----------------------------------------------------------------------------- +void MaskCountDecision::setMaskArrayPath(const DataArrayPath& value) +{ + m_MaskArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath MaskCountDecision::getMaskArrayPath() const +{ + return m_MaskArrayPath; +} + +// ----------------------------------------------------------------------------- +void MaskCountDecision::setNumberOfTrues(int value) +{ + m_NumberOfTrues = value; +} + +// ----------------------------------------------------------------------------- +int MaskCountDecision::getNumberOfTrues() const +{ + return m_NumberOfTrues; +} diff --git a/Source/SIMPLib/CoreFilters/MaskCountDecision.h b/Source/SIMPLib/CoreFilters/MaskCountDecision.h old mode 100755 new mode 100644 index 4be2d1cd70..086802afad --- a/Source/SIMPLib/CoreFilters/MaskCountDecision.h +++ b/Source/SIMPLib/CoreFilters/MaskCountDecision.h @@ -1,147 +1,183 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/SIMPLib.h" +#include +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/AbstractDecisionFilter.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The MaskCountDecision class. See [Filter documentation](@ref MaskCountDecision) for details. */ class SIMPLib_EXPORT MaskCountDecision : public AbstractDecisionFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(MaskCountDecision SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath MaskArrayPath READ getMaskArrayPath WRITE setMaskArrayPath) - PYB11_PROPERTY(int NumberOfTrues READ getNumberOfTrues WRITE setNumberOfTrues) - - public: - SIMPL_SHARED_POINTERS(MaskCountDecision) - SIMPL_STATIC_NEW_MACRO(MaskCountDecision) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(MaskCountDecision, AbstractDecisionFilter) - - ~MaskCountDecision() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, MaskArrayPath) - Q_PROPERTY(DataArrayPath MaskArrayPath READ getMaskArrayPath WRITE setMaskArrayPath) - - SIMPL_FILTER_PARAMETER(int, NumberOfTrues) - Q_PROPERTY(int NumberOfTrues READ getNumberOfTrues WRITE setNumberOfTrues) - - /** - * @brief - * @param jsonDoc - */ - void extractProperties(const QJsonDocument &jsonDoc) override; - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - protected: - MaskCountDecision(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - DEFINE_DATAARRAY_VARIABLE(bool, Mask) - - public: - MaskCountDecision(const MaskCountDecision&) = delete; // Copy Constructor Not Implemented - MaskCountDecision(MaskCountDecision&&) = delete; // Move Constructor Not Implemented - MaskCountDecision& operator=(const MaskCountDecision&) = delete; // Copy Assignment Not Implemented - MaskCountDecision& operator=(MaskCountDecision&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(MaskCountDecision SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(MaskCountDecision) + PYB11_STATIC_NEW_MACRO(MaskCountDecision) + PYB11_PROPERTY(DataArrayPath MaskArrayPath READ getMaskArrayPath WRITE setMaskArrayPath) + PYB11_PROPERTY(int NumberOfTrues READ getNumberOfTrues WRITE setNumberOfTrues) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = MaskCountDecision; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for MaskCountDecision + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for MaskCountDecision + */ + static QString ClassName(); + + ~MaskCountDecision() override; + + /** + * @brief Setter property for MaskArrayPath + */ + void setMaskArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for MaskArrayPath + * @return Value of MaskArrayPath + */ + DataArrayPath getMaskArrayPath() const; + + Q_PROPERTY(DataArrayPath MaskArrayPath READ getMaskArrayPath WRITE setMaskArrayPath) + + /** + * @brief Setter property for NumberOfTrues + */ + void setNumberOfTrues(int value); + /** + * @brief Getter property for NumberOfTrues + * @return Value of NumberOfTrues + */ + int getNumberOfTrues() const; + + Q_PROPERTY(int NumberOfTrues READ getNumberOfTrues WRITE setNumberOfTrues) + + /** + * @brief + * @param jsonDoc + */ + void extractProperties(const QJsonDocument& jsonDoc) override; + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + MaskCountDecision(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + std::weak_ptr> m_MaskPtr; + bool* m_Mask = nullptr; + + DataArrayPath m_MaskArrayPath = {"", "", ""}; + int m_NumberOfTrues = {0}; + +public: + MaskCountDecision(const MaskCountDecision&) = delete; // Copy Constructor Not Implemented + MaskCountDecision(MaskCountDecision&&) = delete; // Move Constructor Not Implemented + MaskCountDecision& operator=(const MaskCountDecision&) = delete; // Copy Assignment Not Implemented + MaskCountDecision& operator=(MaskCountDecision&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/MassCreateData.cpp b/Source/SIMPLib/CoreFilters/MassCreateData.cpp new file mode 100644 index 0000000000..8235ddbaaa --- /dev/null +++ b/Source/SIMPLib/CoreFilters/MassCreateData.cpp @@ -0,0 +1,235 @@ +/* ============================================================================ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "MassCreateData.h" + +#include + +#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" +#include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" +#include "SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + DataContainerBaseID = 1 +}; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MassCreateData::MassCreateData() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MassCreateData::~MassCreateData() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MassCreateData::setupFilterParameters() +{ + FilterParameterVectorType parameters; + parameters.push_back(SIMPL_NEW_DC_CREATION_FP("Data Container Name", DataContainerName, FilterParameter::Category::CreatedArray, MassCreateData)); + setFilterParameters(parameters); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MassCreateData::readFilterParameters(AbstractFilterParametersReader* reader, int index) +{ + reader->openFilterGroup(this, index); + setDataContainerName(reader->readDataArrayPath("DataContainerName", getDataContainerName())); + reader->closeFilterGroup(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MassCreateData::initialize() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MassCreateData::dataCheck() +{ + clearErrorCode(); + clearWarningCode(); + + const int iterations = 4000; + for(int i = 0; i < iterations; i++) + { + DataContainerShPtr dc = getDataContainerArray()->createNonPrereqDataContainer(this, getDataContainerName().getDataContainerName() + QString::number(i), DataContainerBaseID + i); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MassCreateData::execute() +{ + clearErrorCode(); + clearWarningCode(); + + dataCheck(); + if(getErrorCode() < 0) + { + return; + } + + if(getCancel()) + { + return; + } + + notifyStatusMessage("Complete"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AbstractFilter::Pointer MassCreateData::newFilterInstance(bool copyFilterParameters) const +{ + MassCreateData::Pointer filter = MassCreateData::New(); + if(copyFilterParameters) + { + copyFilterParameterInstanceVariables(filter.get()); + } + return filter; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString MassCreateData::getCompiledLibraryName() const +{ + return Core::CoreBaseName; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString MassCreateData::getBrandingString() const +{ + return "SIMPLib Core Filter"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString MassCreateData::getFilterVersion() const +{ + QString version; + QTextStream vStream(&version); + vStream << SIMPLib::Version::Major() << "." << SIMPLib::Version::Minor() << "." << SIMPLib::Version::Patch(); + return version; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString MassCreateData::getGroupName() const +{ + return SIMPL::FilterGroups::CoreFilters; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString MassCreateData::getHumanLabel() const +{ + return "Mass Create Data Containers"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QUuid MassCreateData::getUuid() const +{ + return QUuid("{816fbe6b-7c38-581b-b149-3f839fb65b95}"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString MassCreateData::getSubGroupName() const +{ + return SIMPL::FilterSubGroups::GenerationFilters; +} + +// ----------------------------------------------------------------------------- +MassCreateData::Pointer MassCreateData::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr MassCreateData::New() +{ + struct make_shared_enabler : public MassCreateData + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString MassCreateData::getNameOfClass() const +{ + return QString("MassCreateData"); +} + +// ----------------------------------------------------------------------------- +QString MassCreateData::ClassName() +{ + return QString("MassCreateData"); +} + +// ----------------------------------------------------------------------------- +void MassCreateData::setDataContainerName(const DataArrayPath& value) +{ + m_DataContainerName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath MassCreateData::getDataContainerName() const +{ + return m_DataContainerName; +} diff --git a/Source/SIMPLib/CoreFilters/MassCreateData.h b/Source/SIMPLib/CoreFilters/MassCreateData.h new file mode 100644 index 0000000000..4b8788142e --- /dev/null +++ b/Source/SIMPLib/CoreFilters/MassCreateData.h @@ -0,0 +1,181 @@ +/* ============================================================================ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +/** + * @brief The MassCreateData class. See [Filter documentation](@ref MassCreateData) for details. + */ +class SIMPLib_EXPORT MassCreateData : public AbstractFilter +{ + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(MassCreateData SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(MassCreateData) + PYB11_FILTER_NEW_MACRO(MassCreateData) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = MassCreateData; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for MassCreateData + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for MassCreateData + */ + static QString ClassName(); + + ~MassCreateData() override; + + /** + * @brief Setter property for DataContainerName + */ + void setDataContainerName(const DataArrayPath& value); + /** + * @brief Getter property for DataContainerName + * @return Value of DataContainerName + */ + DataArrayPath getDataContainerName() const; + + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + MassCreateData(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +public: + MassCreateData(const MassCreateData&) = delete; // Copy Constructor Not Implemented + MassCreateData(MassCreateData&&) = delete; // Move Constructor Not Implemented + MassCreateData& operator=(const MassCreateData&) = delete; // Copy Assignment Not Implemented + MassCreateData& operator=(MassCreateData&&) = delete; // Move Assignment Not Implemented + +private: + DataArrayPath m_DataContainerName = {"DataContainer", "", ""}; +}; diff --git a/Source/SIMPLib/CoreFilters/MoveData.cpp b/Source/SIMPLib/CoreFilters/MoveData.cpp index cb7f0fb0ab..078f5ae788 100644 --- a/Source/SIMPLib/CoreFilters/MoveData.cpp +++ b/Source/SIMPLib/CoreFilters/MoveData.cpp @@ -1,44 +1,46 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "MoveData.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" -#include "SIMPLib/SIMPLibVersion.h" - #include "SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" @@ -48,15 +50,14 @@ namespace { const int32_t k_MoveAttributeMatrix = 0; const int32_t k_MoveDataArray = 1; -} +} // namespace // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- MoveData::MoveData() -: m_WhatToMove(k_MoveAttributeMatrix) -, m_DataContainerDestination("") { + m_WhatToMove = k_MoveAttributeMatrix; } // ----------------------------------------------------------------------------- @@ -69,13 +70,13 @@ MoveData::~MoveData() = default; // ----------------------------------------------------------------------------- void MoveData::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - QStringList linkedProps; - linkedProps << "DataContainerDestination" - << "AttributeMatrixSource" - << "AttributeMatrixDestination" - << "DataArraySource"; + std::vector linkedProps; + linkedProps.push_back("DataContainerDestination"); + linkedProps.push_back("AttributeMatrixSource"); + linkedProps.push_back("AttributeMatrixDestination"); + linkedProps.push_back("DataArraySource"); { LinkedChoicesFilterParameter::Pointer parameter = LinkedChoicesFilterParameter::New(); parameter->setHumanLabel("Object to Move"); @@ -84,31 +85,31 @@ void MoveData::setupFilterParameters() parameter->setGetterCallback(SIMPL_BIND_GETTER(MoveData, this, WhatToMove)); parameter->setDefaultValue(getWhatToMove()); // Just set the first index - QVector choices; + std::vector choices; choices.push_back("Attribute Matrix"); choices.push_back("Attribute Array"); parameter->setChoices(choices); parameter->setLinkedProperties(linkedProps); parameter->setEditable(false); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameters.push_back(parameter); } { AttributeMatrixSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Attribute Matrix Source", AttributeMatrixSource, FilterParameter::RequiredArray, MoveData, req, 0)); + parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Attribute Matrix Source", AttributeMatrixSource, FilterParameter::Category::RequiredArray, MoveData, req, 0)); } { DataContainerSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container Destination", DataContainerDestination, FilterParameter::RequiredArray, MoveData, req, 0)); + parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container Destination", DataContainerDestination, FilterParameter::Category::RequiredArray, MoveData, req, 0)); } { DataArraySelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Attribute Array Source", DataArraySource, FilterParameter::RequiredArray, MoveData, req, 1)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Attribute Array Source", DataArraySource, FilterParameter::Category::RequiredArray, MoveData, req, 1)); } { AttributeMatrixSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Attribute Matrix Destination", AttributeMatrixDestination, FilterParameter::RequiredArray, MoveData, req, 1)); + parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Attribute Matrix Destination", AttributeMatrixDestination, FilterParameter::Category::RequiredArray, MoveData, req, 1)); } setFilterParameters(parameters); @@ -121,7 +122,7 @@ void MoveData::readFilterParameters(AbstractFilterParametersReader* reader, int { reader->openFilterGroup(this, index); setWhatToMove(reader->readValue("WhatToMove", getWhatToMove())); - setDataContainerDestination(reader->readString("DataContainerDestination", getDataContainerDestination())); + setDataContainerDestination(reader->readDataArrayPath("DataContainerDestination", getDataContainerDestination())); setAttributeMatrixSource(reader->readDataArrayPath("AttributeMatrixSource", getAttributeMatrixSource())); setAttributeMatrixDestination(reader->readDataArrayPath("AttributeMatrixDestination", getAttributeMatrixDestination())); setDataArraySource(reader->readDataArrayPath("DataArraySource", getDataArraySource())); @@ -140,8 +141,8 @@ void MoveData::initialize() // ----------------------------------------------------------------------------- void MoveData::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); DataArrayPath amSrcPath = getAttributeMatrixSource(); DataArrayPath amDestPath = getAttributeMatrixDestination(); DataArrayPath daSrcPath = getDataArraySource(); @@ -150,91 +151,75 @@ void MoveData::dataCheck() { DataContainer::Pointer amDestDataContainer = getDataContainerArray()->getPrereqDataContainer(this, getDataContainerDestination()); DataContainer::Pointer amSrcDataContainer = getDataContainerArray()->getPrereqDataContainer(this, amSrcPath.getDataContainerName()); - AttributeMatrix::Pointer amSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, amSrcPath, -301); + AttributeMatrix::Pointer amSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, amSrcPath, -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } if(amSrcDataContainer->getName() == amDestDataContainer->getName()) { - setWarningCondition(-11018); QString ss = QObject::tr("The source and destination Data Container are the same. Is this what you meant to do?"); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-11018, ss); return; } - amDestDataContainer->addAttributeMatrix(amSrcAttributeMatrix->getName(), amSrcAttributeMatrix); - amSrcDataContainer->removeAttributeMatrix(amSrcAttributeMatrix->getName()); + amDestDataContainer->addOrReplaceAttributeMatrix(amSrcAttributeMatrix); + // amSrcDataContainer->removeAttributeMatrix(amSrcAttributeMatrix->getName()); + addPathRename(amSrcPath, amSrcAttributeMatrix->getDataArrayPath()); } else if(getWhatToMove() == k_MoveDataArray) { - AttributeMatrix::Pointer daSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, daSrcPath, -301); - AttributeMatrix::Pointer daDestAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, amDestPath, -301); - IDataArray::Pointer daSrcDataArray = getDataContainerArray()->getPrereqIDataArrayFromPath(this, daSrcPath); + AttributeMatrix::Pointer daSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, daSrcPath, -301); + AttributeMatrix::Pointer daDestAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, amDestPath, -301); + IDataArray::Pointer daSrcDataArray = getDataContainerArray()->getPrereqIDataArrayFromPath(this, daSrcPath); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } if(daDestAttributeMatrix->getNumberOfTuples() != 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->getNumberOfTuples()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11019, ss); return; } if(amSrcPath == amDestPath) { - setWarningCondition(-11020); QString ss = QObject::tr("The source and destination Attribute Matrix are the same. Is this what you meant to do?"); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-11020, ss); return; } - daDestAttributeMatrix->addAttributeArray(daSrcPath.getDataArrayName(), daSrcDataArray); - daSrcAttributeMatrix->removeAttributeArray(daSrcPath.getDataArrayName()); + daDestAttributeMatrix->insertOrAssign(daSrcDataArray); + // daSrcAttributeMatrix->removeAttributeArray(daSrcPath.getDataArrayName()); + addPathRename(daSrcPath, daSrcDataArray->getDataArrayPath()); } else { - setErrorCondition(-11021); QString ss = QObject::tr("Neither an Attribute Matrix nor an Attribute Array was selected to be moved"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11021, ss); return; } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void MoveData::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void MoveData::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); // Simply running the preflight will do what we need it to. dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - } // ----------------------------------------------------------------------------- @@ -253,7 +238,7 @@ AbstractFilter::Pointer MoveData::newFilterInstance(bool copyFilterParameters) c // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MoveData::getCompiledLibraryName() const +QString MoveData::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -261,7 +246,7 @@ const QString MoveData::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MoveData::getBrandingString() const +QString MoveData::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -269,7 +254,7 @@ const QString MoveData::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MoveData::getFilterVersion() const +QString MoveData::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -280,7 +265,7 @@ const QString MoveData::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MoveData::getGroupName() const +QString MoveData::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -288,7 +273,7 @@ const QString MoveData::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid MoveData::getUuid() +QUuid MoveData::getUuid() const { return QUuid("{fe2cbe09-8ae1-5bea-9397-fd5741091fdb}"); } @@ -296,7 +281,7 @@ const QUuid MoveData::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MoveData::getSubGroupName() const +QString MoveData::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -304,7 +289,96 @@ const QString MoveData::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MoveData::getHumanLabel() const +QString MoveData::getHumanLabel() const { return "Move Data"; } + +// ----------------------------------------------------------------------------- +MoveData::Pointer MoveData::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr MoveData::New() +{ + struct make_shared_enabler : public MoveData + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString MoveData::getNameOfClass() const +{ + return QString("MoveData"); +} + +// ----------------------------------------------------------------------------- +QString MoveData::ClassName() +{ + return QString("MoveData"); +} + +// ----------------------------------------------------------------------------- +void MoveData::setWhatToMove(int value) +{ + m_WhatToMove = value; +} + +// ----------------------------------------------------------------------------- +int MoveData::getWhatToMove() const +{ + return m_WhatToMove; +} + +// ----------------------------------------------------------------------------- +void MoveData::setDataContainerDestination(const DataArrayPath& value) +{ + m_DataContainerDestination = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath MoveData::getDataContainerDestination() const +{ + return m_DataContainerDestination; +} + +// ----------------------------------------------------------------------------- +void MoveData::setAttributeMatrixSource(const DataArrayPath& value) +{ + m_AttributeMatrixSource = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath MoveData::getAttributeMatrixSource() const +{ + return m_AttributeMatrixSource; +} + +// ----------------------------------------------------------------------------- +void MoveData::setAttributeMatrixDestination(const DataArrayPath& value) +{ + m_AttributeMatrixDestination = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath MoveData::getAttributeMatrixDestination() const +{ + return m_AttributeMatrixDestination; +} + +// ----------------------------------------------------------------------------- +void MoveData::setDataArraySource(const DataArrayPath& value) +{ + m_DataArraySource = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath MoveData::getDataArraySource() const +{ + return m_DataArraySource; +} diff --git a/Source/SIMPLib/CoreFilters/MoveData.h b/Source/SIMPLib/CoreFilters/MoveData.h old mode 100755 new mode 100644 index ec11182197..525bffba94 --- a/Source/SIMPLib/CoreFilters/MoveData.h +++ b/Source/SIMPLib/CoreFilters/MoveData.h @@ -1,185 +1,229 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The MoveData class. See [Filter documentation](@ref movedata) for details. */ class SIMPLib_EXPORT MoveData : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(MoveData SUPERCLASS AbstractFilter) - PYB11_PROPERTY(int WhatToMove READ getWhatToMove WRITE setWhatToMove) - PYB11_PROPERTY(QString DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) - PYB11_PROPERTY(DataArrayPath AttributeMatrixSource READ getAttributeMatrixSource WRITE setAttributeMatrixSource) - PYB11_PROPERTY(DataArrayPath AttributeMatrixDestination READ getAttributeMatrixDestination WRITE setAttributeMatrixDestination) - PYB11_PROPERTY(DataArrayPath DataArraySource READ getDataArraySource WRITE setDataArraySource) - - public: - SIMPL_SHARED_POINTERS(MoveData) - SIMPL_FILTER_NEW_MACRO(MoveData) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(MoveData, AbstractFilter) - - ~MoveData() override; - - SIMPL_FILTER_PARAMETER(int, WhatToMove) - Q_PROPERTY(int WhatToMove READ getWhatToMove WRITE setWhatToMove) - - SIMPL_FILTER_PARAMETER(QString, DataContainerDestination) - Q_PROPERTY(QString DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) - - SIMPL_FILTER_PARAMETER(DataArrayPath, AttributeMatrixSource) - Q_PROPERTY(DataArrayPath AttributeMatrixSource READ getAttributeMatrixSource WRITE setAttributeMatrixSource) - - SIMPL_FILTER_PARAMETER(DataArrayPath, AttributeMatrixDestination) - Q_PROPERTY(DataArrayPath AttributeMatrixDestination READ getAttributeMatrixDestination WRITE setAttributeMatrixDestination) - - SIMPL_FILTER_PARAMETER(DataArrayPath, DataArraySource) - Q_PROPERTY(DataArrayPath DataArraySource READ getDataArraySource WRITE setDataArraySource) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - MoveData(); - - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - public: - MoveData(const MoveData&) = delete; // Copy Constructor Not Implemented - MoveData(MoveData&&) = delete; // Move Constructor Not Implemented - MoveData& operator=(const MoveData&) = delete; // Copy Assignment Not Implemented - MoveData& operator=(MoveData&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(MoveData SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(MoveData) + PYB11_FILTER_NEW_MACRO(MoveData) + PYB11_PROPERTY(int WhatToMove READ getWhatToMove WRITE setWhatToMove) + PYB11_PROPERTY(DataArrayPath DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) + PYB11_PROPERTY(DataArrayPath AttributeMatrixSource READ getAttributeMatrixSource WRITE setAttributeMatrixSource) + PYB11_PROPERTY(DataArrayPath AttributeMatrixDestination READ getAttributeMatrixDestination WRITE setAttributeMatrixDestination) + PYB11_PROPERTY(DataArrayPath DataArraySource READ getDataArraySource WRITE setDataArraySource) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = MoveData; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for MoveData + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for MoveData + */ + static QString ClassName(); + + ~MoveData() override; + + /** + * @brief Setter property for WhatToMove + */ + void setWhatToMove(int value); + /** + * @brief Getter property for WhatToMove + * @return Value of WhatToMove + */ + int getWhatToMove() const; + + Q_PROPERTY(int WhatToMove READ getWhatToMove WRITE setWhatToMove) + + /** + * @brief Setter property for DataContainerDestination + */ + void setDataContainerDestination(const DataArrayPath& value); + /** + * @brief Getter property for DataContainerDestination + * @return Value of DataContainerDestination + */ + DataArrayPath getDataContainerDestination() const; + + Q_PROPERTY(DataArrayPath DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) + + /** + * @brief Setter property for AttributeMatrixSource + */ + void setAttributeMatrixSource(const DataArrayPath& value); + /** + * @brief Getter property for AttributeMatrixSource + * @return Value of AttributeMatrixSource + */ + DataArrayPath getAttributeMatrixSource() const; + + Q_PROPERTY(DataArrayPath AttributeMatrixSource READ getAttributeMatrixSource WRITE setAttributeMatrixSource) + + /** + * @brief Setter property for AttributeMatrixDestination + */ + void setAttributeMatrixDestination(const DataArrayPath& value); + /** + * @brief Getter property for AttributeMatrixDestination + * @return Value of AttributeMatrixDestination + */ + DataArrayPath getAttributeMatrixDestination() const; + + Q_PROPERTY(DataArrayPath AttributeMatrixDestination READ getAttributeMatrixDestination WRITE setAttributeMatrixDestination) + + /** + * @brief Setter property for DataArraySource + */ + void setDataArraySource(const DataArrayPath& value); + /** + * @brief Getter property for DataArraySource + * @return Value of DataArraySource + */ + DataArrayPath getDataArraySource() const; + + Q_PROPERTY(DataArrayPath DataArraySource READ getDataArraySource WRITE setDataArraySource) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + MoveData(); + + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +public: + MoveData(const MoveData&) = delete; // Copy Constructor Not Implemented + MoveData(MoveData&&) = delete; // Move Constructor Not Implemented + MoveData& operator=(const MoveData&) = delete; // Copy Assignment Not Implemented + MoveData& operator=(MoveData&&) = delete; // Move Assignment Not Implemented + +private: + int m_WhatToMove = {}; + DataArrayPath m_DataContainerDestination = {}; + DataArrayPath m_AttributeMatrixSource = {}; + DataArrayPath m_AttributeMatrixDestination = {}; + DataArrayPath m_DataArraySource = {}; }; - diff --git a/Source/SIMPLib/CoreFilters/MoveMultiData.cpp b/Source/SIMPLib/CoreFilters/MoveMultiData.cpp index 120eb31ac9..bf88905dd1 100644 --- a/Source/SIMPLib/CoreFilters/MoveMultiData.cpp +++ b/Source/SIMPLib/CoreFilters/MoveMultiData.cpp @@ -1,44 +1,46 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "MoveMultiData.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" -#include "SIMPLib/SIMPLibVersion.h" - #include "SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" @@ -50,16 +52,12 @@ namespace { const int32_t k_MoveAttributeMatrix = 0; const int32_t k_MoveMultiDataArray = 1; -} +} // namespace // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -MoveMultiData::MoveMultiData() -: m_WhatToMove(k_MoveAttributeMatrix) -, m_DataContainerDestination("") -{ -} +MoveMultiData::MoveMultiData() = default; // ----------------------------------------------------------------------------- // @@ -71,13 +69,13 @@ MoveMultiData::~MoveMultiData() = default; // ----------------------------------------------------------------------------- void MoveMultiData::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - QStringList linkedProps; - linkedProps << "DataContainerDestination" - << "AttributeMatrixSources" - << "AttributeMatrixDestination" - << "DataArraySources"; + std::vector linkedProps; + linkedProps.push_back("DataContainerDestination"); + linkedProps.push_back("AttributeMatrixSources"); + linkedProps.push_back("AttributeMatrixDestination"); + linkedProps.push_back("DataArraySources"); { LinkedChoicesFilterParameter::Pointer parameter = LinkedChoicesFilterParameter::New(); parameter->setHumanLabel("Object to Move"); @@ -86,50 +84,36 @@ void MoveMultiData::setupFilterParameters() parameter->setGetterCallback(SIMPL_BIND_GETTER(MoveMultiData, this, WhatToMove)); parameter->setDefaultValue(getWhatToMove()); // Just set the first index - QVector choices; + std::vector choices; choices.push_back("Attribute Matrix"); choices.push_back("Attribute Array"); parameter->setChoices(choices); parameter->setLinkedProperties(linkedProps); parameter->setEditable(false); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameters.push_back(parameter); } { MultiAttributeMatrixSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_MAM_SELECTION_FP("Attribute Matrix Sources", AttributeMatrixSources, FilterParameter::RequiredArray, MoveMultiData, req, 0)); + parameters.push_back(SIMPL_NEW_MAM_SELECTION_FP("Attribute Matrix Sources", AttributeMatrixSources, FilterParameter::Category::RequiredArray, MoveMultiData, req, 0)); } { DataContainerSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container Destination", DataContainerDestination, FilterParameter::RequiredArray, MoveMultiData, req, 0)); + parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container Destination", DataContainerDestination, FilterParameter::Category::RequiredArray, MoveMultiData, req, 0)); } { MultiDataArraySelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_MDA_SELECTION_FP("Attribute Array Sources", DataArraySources, FilterParameter::RequiredArray, MoveMultiData, req, 1)); + parameters.push_back(SIMPL_NEW_MDA_SELECTION_FP("Attribute Array Sources", DataArraySources, FilterParameter::Category::RequiredArray, MoveMultiData, req, 1)); } { AttributeMatrixSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Attribute Matrix Destination", AttributeMatrixDestination, FilterParameter::RequiredArray, MoveMultiData, req, 1)); + parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Attribute Matrix Destination", AttributeMatrixDestination, FilterParameter::Category::RequiredArray, MoveMultiData, req, 1)); } setFilterParameters(parameters); } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void MoveMultiData::readFilterParameters(AbstractFilterParametersReader* reader, int index) -{ - reader->openFilterGroup(this, index); - setWhatToMove(reader->readValue("WhatToMove", getWhatToMove())); - setDataContainerDestination(reader->readString("DataContainerDestination", getDataContainerDestination())); - setAttributeMatrixSources(reader->readDataArrayPathVector("AttributeMatrixSource", getAttributeMatrixSources())); - setAttributeMatrixDestination(reader->readDataArrayPath("AttributeMatrixDestination", getAttributeMatrixDestination())); - setDataArraySources(reader->readDataArrayPathVector("DataArraySources", getDataArraySources())); - reader->closeFilterGroup(); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -142,23 +126,23 @@ void MoveMultiData::initialize() // ----------------------------------------------------------------------------- void MoveMultiData::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); - QVector amSrcPaths = getAttributeMatrixSources(); + clearErrorCode(); + clearWarningCode(); + std::vector amSrcPaths = getAttributeMatrixSources(); DataArrayPath amDestPath = getAttributeMatrixDestination(); - QVector daSrcPaths = getDataArraySources(); + std::vector daSrcPaths = getDataArraySources(); if(getWhatToMove() == k_MoveAttributeMatrix) { DataContainer::Pointer amDestDataContainer = getDataContainerArray()->getPrereqDataContainer(this, getDataContainerDestination()); // Repeat for each AttributeMatrix - for(int i = 0; i < amSrcPaths.size(); i++) + for(size_t i = 0; i < amSrcPaths.size(); i++) { DataContainer::Pointer amSrcDataContainer = getDataContainerArray()->getPrereqDataContainer(this, amSrcPaths[i].getDataContainerName()); - AttributeMatrix::Pointer amSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, amSrcPaths[i], -301); + AttributeMatrix::Pointer amSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, amSrcPaths[i], -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -166,28 +150,28 @@ void MoveMultiData::dataCheck() // Source and Destination match if(amSrcDataContainer->getName() == amDestDataContainer->getName()) { - setWarningCondition(-11018); QString ss = QObject::tr("The source and destination Data Container are the same. Is this what you meant to do?"); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-11018, ss); return; } // Move Attribute Matrix - amDestDataContainer->addAttributeMatrix(amSrcAttributeMatrix->getName(), amSrcAttributeMatrix); - amSrcDataContainer->removeAttributeMatrix(amSrcAttributeMatrix->getName()); + amDestDataContainer->addOrReplaceAttributeMatrix(amSrcAttributeMatrix); + // amSrcDataContainer->removeAttributeMatrix(amSrcAttributeMatrix->getName()); + addPathRename(amSrcPaths[i], amSrcAttributeMatrix->getDataArrayPath()); } } else if(getWhatToMove() == k_MoveMultiDataArray) { - AttributeMatrix::Pointer daDestAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, amDestPath, -301); - + AttributeMatrix::Pointer daDestAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, amDestPath, -301); + // Repeat for each DataArray for(int i = 0; i < daSrcPaths.size(); i++) { - AttributeMatrix::Pointer daSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, daSrcPaths[i], -301); - IDataArray::Pointer daSrcDataArray = getDataContainerArray()->getPrereqIDataArrayFromPath(this, daSrcPaths[i]); + AttributeMatrix::Pointer daSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, daSrcPaths[i], -301); + IDataArray::Pointer daSrcDataArray = getDataContainerArray()->getPrereqIDataArrayFromPath(this, daSrcPaths[i]); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -195,63 +179,47 @@ void MoveMultiData::dataCheck() // Number of tuples does not match if(daDestAttributeMatrix->getNumberOfTuples() != 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->getNumberOfTuples()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + .arg(daSrcDataArray->getNumberOfTuples()) + .arg(daDestAttributeMatrix->getNumberOfTuples()); + setErrorCondition(-11019, ss); return; } // Source and Destination match if(daSrcPaths[i].hasSameAttributeMatrix(amDestPath)) { - setWarningCondition(-11020); QString ss = QObject::tr("The source and destination Attribute Matrix are the same. Is this what you meant to do?"); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-11020, ss); return; } // Move Array - daDestAttributeMatrix->addAttributeArray(daSrcPaths[i].getDataArrayName(), daSrcDataArray); - daSrcAttributeMatrix->removeAttributeArray(daSrcPaths[i].getDataArrayName()); + daDestAttributeMatrix->insertOrAssign(daSrcDataArray); + // daSrcAttributeMatrix->removeAttributeArray(daSrcPaths[i].getDataArrayName()); + addPathRename(daSrcPaths[i], daSrcDataArray->getDataArrayPath()); } } else { - setErrorCondition(-11021); QString ss = QObject::tr("Neither an Attribute Matrix nor an Attribute Array was selected to be moved"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11021, ss); return; } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void MoveMultiData::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void MoveMultiData::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); // Simply running the preflight will do what we need it to. dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - } // ----------------------------------------------------------------------------- @@ -270,7 +238,7 @@ AbstractFilter::Pointer MoveMultiData::newFilterInstance(bool copyFilterParamete // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MoveMultiData::getCompiledLibraryName() const +QString MoveMultiData::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -278,7 +246,7 @@ const QString MoveMultiData::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MoveMultiData::getBrandingString() const +QString MoveMultiData::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -286,7 +254,7 @@ const QString MoveMultiData::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MoveMultiData::getFilterVersion() const +QString MoveMultiData::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -297,7 +265,7 @@ const QString MoveMultiData::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MoveMultiData::getGroupName() const +QString MoveMultiData::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -305,7 +273,7 @@ const QString MoveMultiData::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid MoveMultiData::getUuid() +QUuid MoveMultiData::getUuid() const { return QUuid("{e3702900-a6c1-59e1-9180-b57557a7b193}"); } @@ -313,7 +281,7 @@ const QUuid MoveMultiData::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MoveMultiData::getSubGroupName() const +QString MoveMultiData::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -321,7 +289,96 @@ const QString MoveMultiData::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MoveMultiData::getHumanLabel() const +QString MoveMultiData::getHumanLabel() const { return "Move Multi Data"; } + +// ----------------------------------------------------------------------------- +MoveMultiData::Pointer MoveMultiData::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr MoveMultiData::New() +{ + struct make_shared_enabler : public MoveMultiData + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString MoveMultiData::getNameOfClass() const +{ + return QString("MoveMultiData"); +} + +// ----------------------------------------------------------------------------- +QString MoveMultiData::ClassName() +{ + return QString("MoveMultiData"); +} + +// ----------------------------------------------------------------------------- +void MoveMultiData::setWhatToMove(int value) +{ + m_WhatToMove = value; +} + +// ----------------------------------------------------------------------------- +int MoveMultiData::getWhatToMove() const +{ + return m_WhatToMove; +} + +// ----------------------------------------------------------------------------- +void MoveMultiData::setDataContainerDestination(const DataArrayPath& value) +{ + m_DataContainerDestination = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath MoveMultiData::getDataContainerDestination() const +{ + return m_DataContainerDestination; +} + +// ----------------------------------------------------------------------------- +void MoveMultiData::setAttributeMatrixSources(const std::vector& value) +{ + m_AttributeMatrixSources = value; +} + +// ----------------------------------------------------------------------------- +std::vector MoveMultiData::getAttributeMatrixSources() const +{ + return m_AttributeMatrixSources; +} + +// ----------------------------------------------------------------------------- +void MoveMultiData::setAttributeMatrixDestination(const DataArrayPath& value) +{ + m_AttributeMatrixDestination = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath MoveMultiData::getAttributeMatrixDestination() const +{ + return m_AttributeMatrixDestination; +} + +// ----------------------------------------------------------------------------- +void MoveMultiData::setDataArraySources(const std::vector& value) +{ + m_DataArraySources = value; +} + +// ----------------------------------------------------------------------------- +std::vector MoveMultiData::getDataArraySources() const +{ + return m_DataArraySources; +} diff --git a/Source/SIMPLib/CoreFilters/MoveMultiData.h b/Source/SIMPLib/CoreFilters/MoveMultiData.h index 9ab0fb3200..ce25f0edb1 100644 --- a/Source/SIMPLib/CoreFilters/MoveMultiData.h +++ b/Source/SIMPLib/CoreFilters/MoveMultiData.h @@ -1,185 +1,224 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The MoveMultiData class. See [Filter documentation](@ref MoveMultiData) for details. */ class SIMPLib_EXPORT MoveMultiData : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(MoveMultiData SUPERCLASS AbstractFilter) - PYB11_PROPERTY(int WhatToMove READ getWhatToMove WRITE setWhatToMove) - PYB11_PROPERTY(QString DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) - PYB11_PROPERTY(QVector AttributeMatrixSources READ getAttributeMatrixSources WRITE setAttributeMatrixSources) - PYB11_PROPERTY(DataArrayPath AttributeMatrixDestination READ getAttributeMatrixDestination WRITE setAttributeMatrixDestination) - PYB11_PROPERTY(QVector DataArraySources READ getDataArraySources WRITE setDataArraySources) - - public: - SIMPL_SHARED_POINTERS(MoveMultiData) - SIMPL_FILTER_NEW_MACRO(MoveMultiData) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(MoveMultiData, AbstractFilter) - - ~MoveMultiData() override; - - SIMPL_FILTER_PARAMETER(int, WhatToMove) - Q_PROPERTY(int WhatToMove READ getWhatToMove WRITE setWhatToMove) - - SIMPL_FILTER_PARAMETER(QString, DataContainerDestination) - Q_PROPERTY(QString DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) - - SIMPL_FILTER_PARAMETER(QVector, AttributeMatrixSources) - Q_PROPERTY(QVector AttributeMatrixSources READ getAttributeMatrixSources WRITE setAttributeMatrixSources) - - SIMPL_FILTER_PARAMETER(DataArrayPath, AttributeMatrixDestination) - Q_PROPERTY(DataArrayPath AttributeMatrixDestination READ getAttributeMatrixDestination WRITE setAttributeMatrixDestination) - - SIMPL_FILTER_PARAMETER(QVector, DataArraySources) - Q_PROPERTY(QVector DataArraySources READ getDataArraySources WRITE setDataArraySources) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - MoveMultiData(); - - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - public: - MoveMultiData(const MoveMultiData&) = delete; // Copy Constructor Not Implemented - MoveMultiData(MoveMultiData&&) = delete; // Move Constructor Not Implemented - MoveMultiData& operator=(const MoveMultiData&) = delete; // Copy Assignment Not Implemented - MoveMultiData& operator=(MoveMultiData&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(MoveMultiData SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(MoveMultiData) + PYB11_FILTER_NEW_MACRO(MoveMultiData) + PYB11_PROPERTY(int WhatToMove READ getWhatToMove WRITE setWhatToMove) + PYB11_PROPERTY(DataArrayPath DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) + PYB11_PROPERTY(std::vector AttributeMatrixSources READ getAttributeMatrixSources WRITE setAttributeMatrixSources) + PYB11_PROPERTY(DataArrayPath AttributeMatrixDestination READ getAttributeMatrixDestination WRITE setAttributeMatrixDestination) + PYB11_PROPERTY(std::vector DataArraySources READ getDataArraySources WRITE setDataArraySources) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = MoveMultiData; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for MoveMultiData + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for MoveMultiData + */ + static QString ClassName(); + + ~MoveMultiData() override; + + /** + * @brief Setter property for WhatToMove + */ + void setWhatToMove(int value); + /** + * @brief Getter property for WhatToMove + * @return Value of WhatToMove + */ + int getWhatToMove() const; + + Q_PROPERTY(int WhatToMove READ getWhatToMove WRITE setWhatToMove) + + /** + * @brief Setter property for DataContainerDestination + */ + void setDataContainerDestination(const DataArrayPath& value); + /** + * @brief Getter property for DataContainerDestination + * @return Value of DataContainerDestination + */ + DataArrayPath getDataContainerDestination() const; + + Q_PROPERTY(DataArrayPath DataContainerDestination READ getDataContainerDestination WRITE setDataContainerDestination) + + /** + * @brief Setter property for AttributeMatrixSources + */ + void setAttributeMatrixSources(const std::vector& value); + /** + * @brief Getter property for AttributeMatrixSources + * @return Value of AttributeMatrixSources + */ + std::vector getAttributeMatrixSources() const; + + Q_PROPERTY(DataArrayPathVec AttributeMatrixSources READ getAttributeMatrixSources WRITE setAttributeMatrixSources) + + /** + * @brief Setter property for AttributeMatrixDestination + */ + void setAttributeMatrixDestination(const DataArrayPath& value); + /** + * @brief Getter property for AttributeMatrixDestination + * @return Value of AttributeMatrixDestination + */ + DataArrayPath getAttributeMatrixDestination() const; + + Q_PROPERTY(DataArrayPath AttributeMatrixDestination READ getAttributeMatrixDestination WRITE setAttributeMatrixDestination) + + /** + * @brief Setter property for DataArraySources + */ + void setDataArraySources(const std::vector& value); + /** + * @brief Getter property for DataArraySources + * @return Value of DataArraySources + */ + std::vector getDataArraySources() const; + + Q_PROPERTY(DataArrayPathVec DataArraySources READ getDataArraySources WRITE setDataArraySources) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + MoveMultiData(); + + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +public: + MoveMultiData(const MoveMultiData&) = delete; // Copy Constructor Not Implemented + MoveMultiData(MoveMultiData&&) = delete; // Move Constructor Not Implemented + MoveMultiData& operator=(const MoveMultiData&) = delete; // Copy Assignment Not Implemented + MoveMultiData& operator=(MoveMultiData&&) = delete; // Move Assignment Not Implemented + +private: + int m_WhatToMove = {}; + DataArrayPath m_DataContainerDestination = {"", "", ""}; + std::vector m_AttributeMatrixSources = {}; + DataArrayPath m_AttributeMatrixDestination = {}; + std::vector m_DataArraySources = {}; }; - diff --git a/Source/SIMPLib/CoreFilters/MultiThresholdObjects.cpp b/Source/SIMPLib/CoreFilters/MultiThresholdObjects.cpp index ffc226d7eb..4bb3ed7c2a 100644 --- a/Source/SIMPLib/CoreFilters/MultiThresholdObjects.cpp +++ b/Source/SIMPLib/CoreFilters/MultiThresholdObjects.cpp @@ -1,55 +1,60 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "MultiThresholdObjects.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/Filtering/ThresholdFilterHelper.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + ThresholdArrayID = 1 +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -MultiThresholdObjects::MultiThresholdObjects() -: m_DestinationArrayName(SIMPL::GeneralData::Mask) -{ -} +MultiThresholdObjects::MultiThresholdObjects() = default; // ----------------------------------------------------------------------------- // @@ -61,19 +66,19 @@ MultiThresholdObjects::~MultiThresholdObjects() = default; // ----------------------------------------------------------------------------- void MultiThresholdObjects::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { ComparisonSelectionFilterParameter::Pointer parameter = ComparisonSelectionFilterParameter::New(); parameter->setHumanLabel("Select Arrays to Threshold"); parameter->setPropertyName("SelectedThresholds"); parameter->setShowOperators(true); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameter->setSetterCallback(SIMPL_BIND_SETTER(MultiThresholdObjects, this, SelectedThresholds)); parameter->setGetterCallback(SIMPL_BIND_GETTER(MultiThresholdObjects, this, SelectedThresholds)); parameters.push_back(parameter); } - parameters.push_back(SIMPL_NEW_STRING_FP("Output Attribute Array", DestinationArrayName, FilterParameter::CreatedArray, MultiThresholdObjects)); + parameters.push_back(SIMPL_NEW_STRING_FP("Output Attribute Array", DestinationArrayName, FilterParameter::Category::CreatedArray, MultiThresholdObjects)); setFilterParameters(parameters); } @@ -100,13 +105,12 @@ void MultiThresholdObjects::initialize() // ----------------------------------------------------------------------------- void MultiThresholdObjects::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(m_SelectedThresholds.size() == 0) { - setErrorCondition(-12000); - notifyErrorMessage(getHumanLabel(), "You must add at least 1 threshold value.", getErrorCondition()); + setErrorCondition(-12000, "You must add at least 1 threshold value."); } else { @@ -125,23 +129,20 @@ void MultiThresholdObjects::dataCheck() // Enforce that right now all the arrays MUST come from the same data container and attribute matrix if(dcSet.size() != 1) { - setErrorCondition(-13090); QString ss = QObject::tr("Threshold selections must come from the same DataContainer. %1 were selected").arg(dcSet.size()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13090, ss); } if(amSet.size() != 1) { - setErrorCondition(-13091); QString ss = QObject::tr("Threshold selections must come from the same AttributeMatrix. %1 were selected").arg(amSet.size()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13091, ss); } ComparisonInput_t comp = m_SelectedThresholds[0]; - QVector cDims(1, 1); + std::vector cDims(1, 1); DataArrayPath tempPath(comp.dataContainerName, comp.attributeMatrixName, getDestinationArrayName()); - m_DestinationPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, bool>(this, tempPath, true, - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ - if(nullptr != m_DestinationPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ + m_DestinationPtr = getDataContainerArray()->createNonPrereqArrayFromPath>(this, tempPath, true, cDims, "", ThresholdArrayID); + if(nullptr != m_DestinationPtr.lock()) { m_Destination = m_DestinationPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ @@ -151,8 +152,8 @@ void MultiThresholdObjects::dataCheck() { ComparisonInput_t comp = m_SelectedThresholds[i]; tempPath.update(comp.dataContainerName, comp.attributeMatrixName, comp.attributeArrayName); - IDataArray::Pointer inputData = getDataContainerArray()->getPrereqIDataArrayFromPath(this, tempPath); - if(getErrorCondition() >= 0) + IDataArray::Pointer inputData = getDataContainerArray()->getPrereqIDataArrayFromPath(this, tempPath); + if(getErrorCode() >= 0) { cDims = inputData->getComponentDimensions(); int32_t numComp = static_cast(cDims[0]); @@ -163,36 +164,20 @@ void MultiThresholdObjects::dataCheck() if(numComp > 1) { QString ss = QObject::tr("Selected array '%1' is not a scalar array").arg(m_SelectedThresholds[i].attributeArrayName); - setErrorCondition(-11003); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11003, ss); } } } } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void MultiThresholdObjects::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void MultiThresholdObjects::execute() { - int32_t err = 0; - setErrorCondition(err); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -210,13 +195,12 @@ void MultiThresholdObjects::execute() { ThresholdFilterHelper filter(static_cast(comp_0.compOperator), comp_0.compValue, m_DestinationPtr.lock().get()); // Run the first threshold and store the results in our output array - err = filter.execute(m->getAttributeMatrix(amName)->getAttributeArray(comp_0.attributeArrayName).get(), m_DestinationPtr.lock().get()); + int32_t err = filter.execute(m->getAttributeMatrix(amName)->getAttributeArray(comp_0.attributeArrayName), m_DestinationPtr.lock().get()); if(err < 0) { DataArrayPath tempPath(comp_0.dataContainerName, comp_0.attributeMatrixName, comp_0.attributeArrayName); QString ss = QObject::tr("Error Executing threshold filter on first array. The path is %1").arg(tempPath.serialize()); - setErrorCondition(-13001); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13001, ss); return; } } @@ -225,7 +209,7 @@ void MultiThresholdObjects::execute() { // Get the total number of tuples, create and initialize an array to use for these results int64_t totalTuples = static_cast(m->getAttributeMatrix(amName)->getNumberOfTuples()); - BoolArrayType::Pointer currentArrayPtr = BoolArrayType::CreateArray(totalTuples, "_INTERNAL_USE_ONLY_TEMP"); + BoolArrayType::Pointer currentArrayPtr = BoolArrayType::CreateArray(totalTuples, std::string("_INTERNAL_USE_ONLY_TEMP"), true); // Loop on the remaining Comparison objects updating our final result array as we go for(int32_t i = 1; i < m_SelectedThresholds.size(); ++i) @@ -239,13 +223,12 @@ void MultiThresholdObjects::execute() ThresholdFilterHelper filter(static_cast(compRef.compOperator), compRef.compValue, currentArrayPtr.get()); - err = filter.execute(m->getAttributeMatrix(amName)->getAttributeArray(compRef.attributeArrayName).get(), currentArrayPtr.get()); + int32_t err = filter.execute(m->getAttributeMatrix(amName)->getAttributeArray(compRef.attributeArrayName), currentArrayPtr.get()); if(err < 0) { DataArrayPath tempPath(compRef.dataContainerName, compRef.attributeMatrixName, compRef.attributeArrayName); QString ss = QObject::tr("Error Executing threshold filter on array. The path is %1").arg(tempPath.serialize()); - setErrorCondition(-13002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13002, ss); return; } for(int64_t p = 0; p < totalTuples; ++p) @@ -275,7 +258,7 @@ AbstractFilter::Pointer MultiThresholdObjects::newFilterInstance(bool copyFilter // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MultiThresholdObjects::getCompiledLibraryName() const +QString MultiThresholdObjects::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -283,7 +266,7 @@ const QString MultiThresholdObjects::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MultiThresholdObjects::getBrandingString() const +QString MultiThresholdObjects::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -291,7 +274,7 @@ const QString MultiThresholdObjects::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MultiThresholdObjects::getFilterVersion() const +QString MultiThresholdObjects::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -301,7 +284,7 @@ const QString MultiThresholdObjects::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MultiThresholdObjects::getGroupName() const +QString MultiThresholdObjects::getGroupName() const { return SIMPL::FilterGroups::ProcessingFilters; } @@ -309,7 +292,7 @@ const QString MultiThresholdObjects::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid MultiThresholdObjects::getUuid() +QUuid MultiThresholdObjects::getUuid() const { return QUuid("{014b7300-cf36-5ede-a751-5faf9b119dae}"); } @@ -317,7 +300,7 @@ const QUuid MultiThresholdObjects::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MultiThresholdObjects::getSubGroupName() const +QString MultiThresholdObjects::getSubGroupName() const { return SIMPL::FilterSubGroups::ThresholdFilters; } @@ -325,7 +308,60 @@ const QString MultiThresholdObjects::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MultiThresholdObjects::getHumanLabel() const +QString MultiThresholdObjects::getHumanLabel() const { return "Threshold Objects"; } + +// ----------------------------------------------------------------------------- +MultiThresholdObjects::Pointer MultiThresholdObjects::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr MultiThresholdObjects::New() +{ + struct make_shared_enabler : public MultiThresholdObjects + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString MultiThresholdObjects::getNameOfClass() const +{ + return QString("MultiThresholdObjects"); +} + +// ----------------------------------------------------------------------------- +QString MultiThresholdObjects::ClassName() +{ + return QString("MultiThresholdObjects"); +} + +// ----------------------------------------------------------------------------- +void MultiThresholdObjects::setDestinationArrayName(const QString& value) +{ + m_DestinationArrayName = value; +} + +// ----------------------------------------------------------------------------- +QString MultiThresholdObjects::getDestinationArrayName() const +{ + return m_DestinationArrayName; +} + +// ----------------------------------------------------------------------------- +void MultiThresholdObjects::setSelectedThresholds(const ComparisonInputs& value) +{ + m_SelectedThresholds = value; +} + +// ----------------------------------------------------------------------------- +ComparisonInputs MultiThresholdObjects::getSelectedThresholds() const +{ + return m_SelectedThresholds; +} diff --git a/Source/SIMPLib/CoreFilters/MultiThresholdObjects.h b/Source/SIMPLib/CoreFilters/MultiThresholdObjects.h index 6cc0dc3113..bf4dede8c2 100644 --- a/Source/SIMPLib/CoreFilters/MultiThresholdObjects.h +++ b/Source/SIMPLib/CoreFilters/MultiThresholdObjects.h @@ -1,177 +1,191 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/Filtering/ComparisonInputs.h" -#include "SIMPLib/SIMPLib.h" /** * @brief The MultiThresholdObjects class. See [Filter documentation](@ref multithresholdobjects) for details. */ class SIMPLib_EXPORT MultiThresholdObjects : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(MultiThresholdObjects SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DestinationArrayName READ getDestinationArrayName WRITE setDestinationArrayName) - PYB11_PROPERTY(ComparisonInputs SelectedThresholds READ getSelectedThresholds WRITE setSelectedThresholds) - - public: - SIMPL_SHARED_POINTERS(MultiThresholdObjects) - SIMPL_FILTER_NEW_MACRO(MultiThresholdObjects) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(MultiThresholdObjects, AbstractFilter) - - ~MultiThresholdObjects() override; - - SIMPL_FILTER_PARAMETER(QString, DestinationArrayName) - Q_PROPERTY(QString DestinationArrayName READ getDestinationArrayName WRITE setDestinationArrayName) - - SIMPL_FILTER_PARAMETER(ComparisonInputs, SelectedThresholds) - Q_PROPERTY(ComparisonInputs SelectedThresholds READ getSelectedThresholds WRITE setSelectedThresholds) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - MultiThresholdObjects(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - DEFINE_DATAARRAY_VARIABLE(bool, Destination) - - public: - MultiThresholdObjects(const MultiThresholdObjects&) = delete; // Copy Constructor Not Implemented - MultiThresholdObjects(MultiThresholdObjects&&) = delete; // Move Constructor Not Implemented - MultiThresholdObjects& operator=(const MultiThresholdObjects&) = delete; // Copy Assignment Not Implemented - MultiThresholdObjects& operator=(MultiThresholdObjects&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(MultiThresholdObjects SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(MultiThresholdObjects) + PYB11_FILTER_NEW_MACRO(MultiThresholdObjects) + PYB11_PROPERTY(QString DestinationArrayName READ getDestinationArrayName WRITE setDestinationArrayName) + PYB11_PROPERTY(ComparisonInputs SelectedThresholds READ getSelectedThresholds WRITE setSelectedThresholds) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = MultiThresholdObjects; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for MultiThresholdObjects + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for MultiThresholdObjects + */ + static QString ClassName(); + + ~MultiThresholdObjects() override; + + /** + * @brief Setter property for DestinationArrayName + */ + void setDestinationArrayName(const QString& value); + /** + * @brief Getter property for DestinationArrayName + * @return Value of DestinationArrayName + */ + QString getDestinationArrayName() const; + + Q_PROPERTY(QString DestinationArrayName READ getDestinationArrayName WRITE setDestinationArrayName) + + /** + * @brief Setter property for SelectedThresholds + */ + void setSelectedThresholds(const ComparisonInputs& value); + /** + * @brief Getter property for SelectedThresholds + * @return Value of SelectedThresholds + */ + ComparisonInputs getSelectedThresholds() const; + + Q_PROPERTY(ComparisonInputs SelectedThresholds READ getSelectedThresholds WRITE setSelectedThresholds) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + MultiThresholdObjects(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + std::weak_ptr> m_DestinationPtr; + bool* m_Destination = nullptr; + + QString m_DestinationArrayName = {SIMPL::GeneralData::Mask}; + ComparisonInputs m_SelectedThresholds = {}; + +public: + MultiThresholdObjects(const MultiThresholdObjects&) = delete; // Copy Constructor Not Implemented + MultiThresholdObjects(MultiThresholdObjects&&) = delete; // Move Constructor Not Implemented + MultiThresholdObjects& operator=(const MultiThresholdObjects&) = delete; // Copy Assignment Not Implemented + MultiThresholdObjects& operator=(MultiThresholdObjects&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/MultiThresholdObjects2.cpp b/Source/SIMPLib/CoreFilters/MultiThresholdObjects2.cpp index 4c4613ace8..276af37e9f 100644 --- a/Source/SIMPLib/CoreFilters/MultiThresholdObjects2.cpp +++ b/Source/SIMPLib/CoreFilters/MultiThresholdObjects2.cpp @@ -1,55 +1,61 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "MultiThresholdObjects2.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.h" +#include "SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.h" #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/Filtering/ThresholdFilterHelper.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + ThresholdArrayID = 1 +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -MultiThresholdObjects2::MultiThresholdObjects2() -: m_DestinationArrayName(SIMPL::GeneralData::Mask) -{ -} +MultiThresholdObjects2::MultiThresholdObjects2() = default; // ----------------------------------------------------------------------------- // @@ -61,19 +67,19 @@ MultiThresholdObjects2::~MultiThresholdObjects2() = default; // ----------------------------------------------------------------------------- void MultiThresholdObjects2::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { ComparisonSelectionAdvancedFilterParameter::Pointer parameter = ComparisonSelectionAdvancedFilterParameter::New(); parameter->setHumanLabel("Select Arrays to Threshold"); parameter->setPropertyName("SelectedThresholds"); parameter->setShowOperators(true); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameter->setSetterCallback(SIMPL_BIND_SETTER(MultiThresholdObjects2, this, SelectedThresholds)); parameter->setGetterCallback(SIMPL_BIND_GETTER(MultiThresholdObjects2, this, SelectedThresholds)); parameters.push_back(parameter); } - parameters.push_back(SIMPL_NEW_STRING_FP("Output Attribute Array", DestinationArrayName, FilterParameter::CreatedArray, MultiThresholdObjects2)); + parameters.push_back(SIMPL_NEW_DA_FROM_ADV_COMPARISON_FP("Output Attribute Array", DestinationArrayName, SelectedThresholds, FilterParameter::Category::CreatedArray, MultiThresholdObjects2)); setFilterParameters(parameters); } @@ -100,42 +106,38 @@ void MultiThresholdObjects2::initialize() // ----------------------------------------------------------------------------- void MultiThresholdObjects2::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); QVector comparisonValues = m_SelectedThresholds.getComparisonValues(); if(comparisonValues.empty()) { - setErrorCondition(-12000); - notifyErrorMessage(getHumanLabel(), "You must add at least 1 threshold value.", getErrorCondition()); + setErrorCondition(-12000, "You must add at least 1 threshold value."); } else { - //int32_t count = comparisonValues.size(); + // int32_t count = comparisonValues.size(); QString dcName = m_SelectedThresholds.getDataContainerName(); QString amName = m_SelectedThresholds.getAttributeMatrixName(); // Enforce that right now all the arrays MUST come from the same data container and attribute matrix if(dcName.isEmpty()) { - setErrorCondition(-13090); QString ss = QObject::tr("Threshold must have a DataContainer. None were selected"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13090, ss); } if(amName.isEmpty()) { - setErrorCondition(-13091); QString ss = QObject::tr("Threshold must have an AttributeMatrix. None were selected"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13091, ss); } - //AbstractComparison::Pointer comp = m_SelectedThresholds[0]; - QVector cDims(1, 1); + // AbstractComparison::Pointer comp = m_SelectedThresholds[0]; + std::vector cDims(1, 1); DataArrayPath tempPath(dcName, amName, getDestinationArrayName()); - m_DestinationPtr = getDataContainerArray()->createNonPrereqArrayFromPath, AbstractFilter, bool>(this, tempPath, true, - cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ - if(nullptr != m_DestinationPtr.lock()) /* Validate the Weak Pointer wraps a non-nullptr pointer to a DataArray object */ + m_DestinationPtr = getDataContainerArray()->createNonPrereqArrayFromPath>(this, tempPath, true, cDims, "", ThresholdArrayID); + if(nullptr != m_DestinationPtr.lock()) { m_Destination = m_DestinationPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray object */ @@ -145,23 +147,22 @@ void MultiThresholdObjects2::dataCheck() { ComparisonValue::Pointer comp = std::dynamic_pointer_cast(comparisonValues[i]); - if (nullptr != comp) + if(nullptr != comp) { tempPath.update(dcName, amName, comp->getAttributeArrayName()); - IDataArray::Pointer inputData = getDataContainerArray()->getPrereqIDataArrayFromPath(this, tempPath); - if (getErrorCondition() >= 0) + IDataArray::Pointer inputData = getDataContainerArray()->getPrereqIDataArrayFromPath(this, tempPath); + if(getErrorCode() >= 0) { cDims = inputData->getComponentDimensions(); int32_t numComp = static_cast(cDims[0]); - for (int32_t d = 1; d < cDims.size(); d++) + for(int32_t d = 1; d < cDims.size(); d++) { numComp *= cDims[d]; } - if (numComp > 1) + if(numComp > 1) { QString ss = QObject::tr("Selected array '%1' is not a scalar array").arg(comp->getAttributeArrayName()); - setErrorCondition(-11003); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11003, ss); } } } @@ -169,28 +170,13 @@ void MultiThresholdObjects2::dataCheck() } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void MultiThresholdObjects2::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void MultiThresholdObjects2::execute() { - int32_t err = 0; - setErrorCondition(err); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -205,49 +191,50 @@ void MultiThresholdObjects2::execute() DataContainer::Pointer m = dca->getDataContainer(dcName); // At least one threshold value is required - if (!m_SelectedThresholds.hasComparisonValue()) + if(!m_SelectedThresholds.hasComparisonValue()) { QString ss = QObject::tr("Error Executing threshold filter. There are no specified values to threshold against"); - setErrorCondition(-13001); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13001, ss); return; } - bool invert = m_SelectedThresholds.shouldInvert(); + bool invert = m_SelectedThresholds.shouldInvert(); - int64_t thresholdSize; - BoolArrayType::Pointer thresholdArray; + int64_t thresholdSize; + BoolArrayType::Pointer thresholdArray; - createBoolArray(thresholdSize, thresholdArray); - bool firstValueFound = false; + createBoolArray(thresholdSize, thresholdArray); + bool firstValueFound = false; - // Loop on the remaining Comparison objects updating our final result array as we go - for(int32_t i = 0; i < m_SelectedThresholds.size() && err >= 0; ++i) - { - if (std::dynamic_pointer_cast(m_SelectedThresholds[i])) - { - ComparisonSet::Pointer comparisonSet = std::dynamic_pointer_cast(m_SelectedThresholds[i]); - thresholdSet(comparisonSet, thresholdArray, err, !firstValueFound, false); - firstValueFound = true; - } - else if(std::dynamic_pointer_cast(m_SelectedThresholds[i])) - { - ComparisonValue::Pointer comparisonValue = std::dynamic_pointer_cast(m_SelectedThresholds[i]); - thresholdValue(comparisonValue, thresholdArray, err, !firstValueFound, false); - firstValueFound = true; - } - } + int32_t err = 0; - if (invert) + // Loop on the remaining Comparison objects updating our final result array as we go + for(int32_t i = 0; i < m_SelectedThresholds.size() && err >= 0; ++i) + { + if(std::dynamic_pointer_cast(m_SelectedThresholds[i])) { - invertThreshold(thresholdSize, thresholdArray); + ComparisonSet::Pointer comparisonSet = std::dynamic_pointer_cast(m_SelectedThresholds[i]); + thresholdSet(comparisonSet, thresholdArray, err, !firstValueFound, false); + firstValueFound = true; } - - bool* threshold = thresholdArray->getPointer(0); - for (int64_t p = 0; p < thresholdSize; p++) + else if(std::dynamic_pointer_cast(m_SelectedThresholds[i])) { - m_Destination[p] = threshold[p]; + ComparisonValue::Pointer comparisonValue = std::dynamic_pointer_cast(m_SelectedThresholds[i]); + thresholdValue(comparisonValue, thresholdArray, err, !firstValueFound, false); + firstValueFound = true; } + } + + if(invert) + { + invertThreshold(thresholdSize, thresholdArray); + } + + bool* threshold = thresholdArray->getPointer(0); + for(int64_t p = 0; p < thresholdSize; p++) + { + m_Destination[p] = threshold[p]; + } } // ----------------------------------------------------------------------------- @@ -264,7 +251,7 @@ void MultiThresholdObjects2::createBoolArray(int64_t& totalTuples, BoolArrayType // Get the total number of tuples, create and initialize an array to use for these results totalTuples = static_cast(m->getAttributeMatrix(amName)->getNumberOfTuples()); - thresholdArrayPtr = BoolArrayType::CreateArray(totalTuples, "_INTERNAL_USE_ONLY_TEMP"); + thresholdArrayPtr = BoolArrayType::CreateArray(totalTuples, std::string("_INTERNAL_USE_ONLY_TEMP"), true); // Initialize the array to false thresholdArrayPtr->initializeWithZeros(); @@ -278,15 +265,15 @@ void MultiThresholdObjects2::insertThreshold(int64_t numItems, BoolArrayType::Po bool* newArray = newArrayPtr->getPointer(0); bool* currentArray = currentArrayPtr->getPointer(0); - for (int64_t i = 0; i < numItems; i++) + for(int64_t i = 0; i < numItems; i++) { // invert the current comparison if necessary - if (inverse) + if(inverse) { newArray[i] = !newArray[i]; } - if (SIMPL::Union::Operator_Or == unionOperator) + if(SIMPL::Union::Operator_Or == unionOperator) { currentArray[i] = currentArray[i] || newArray[i]; } @@ -304,7 +291,7 @@ void MultiThresholdObjects2::invertThreshold(int64_t numItems, BoolArrayType::Po { bool* threshold = thresholdArray->getPointer(0); - for (int64_t i = 0; i < numItems; i++) + for(int64_t i = 0; i < numItems; i++) { threshold[i] = !threshold[i]; } @@ -313,14 +300,14 @@ void MultiThresholdObjects2::invertThreshold(int64_t numItems, BoolArrayType::Po // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void MultiThresholdObjects2::thresholdSet(ComparisonSet::Pointer comparisonSet, BoolArrayType::Pointer& currentThreshold, int32_t &err, bool replaceInput, bool inverse) +void MultiThresholdObjects2::thresholdSet(ComparisonSet::Pointer comparisonSet, BoolArrayType::Pointer& currentThreshold, int32_t& err, bool replaceInput, bool inverse) { - if (nullptr == comparisonSet) + if(nullptr == comparisonSet) { return; } - if (inverse) + if(inverse) { inverse = !comparisonSet->getInvertComparison(); } @@ -336,32 +323,32 @@ void MultiThresholdObjects2::thresholdSet(ComparisonSet::Pointer comparisonSet, bool firstValueFound = false; QVector comparisons = comparisonSet->getComparisons(); - for (int i = 0; i < comparisons.size(); i++) + for(int i = 0; i < comparisons.size(); i++) { // Check all contents of child Comparison Sets - if (std::dynamic_pointer_cast(comparisons.at(i))) - { + if(std::dynamic_pointer_cast(comparisons.at(i))) + { ComparisonSet::Pointer childSet = std::dynamic_pointer_cast(comparisons.at(i)); thresholdSet(childSet, setThresholdArray, err, !firstValueFound, false); firstValueFound = true; } // Check Comparison Values - if (std::dynamic_pointer_cast(comparisons.at(i))) + if(std::dynamic_pointer_cast(comparisons.at(i))) { ComparisonValue::Pointer childValue = std::dynamic_pointer_cast(comparisons.at(i)); thresholdValue(childValue, setThresholdArray, err, !firstValueFound, false); firstValueFound = true; } - if (err < 0) + if(err < 0) { return; } } - if (replaceInput) + if(replaceInput) { - if (inverse) + if(inverse) { invertThreshold(setArraySize, setThresholdArray); } @@ -377,9 +364,9 @@ void MultiThresholdObjects2::thresholdSet(ComparisonSet::Pointer comparisonSet, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void MultiThresholdObjects2::thresholdValue(ComparisonValue::Pointer comparisonValue, BoolArrayType::Pointer& inputThreshold, int32_t &err, bool replaceInput, bool inverse) +void MultiThresholdObjects2::thresholdValue(ComparisonValue::Pointer comparisonValue, BoolArrayType::Pointer& inputThreshold, int32_t& err, bool replaceInput, bool inverse) { - if (nullptr == comparisonValue) + if(nullptr == comparisonValue) { return; } @@ -393,36 +380,35 @@ void MultiThresholdObjects2::thresholdValue(ComparisonValue::Pointer comparisonV // Get the total number of tuples, create and initialize an array to use for these results int64_t totalTuples = static_cast(m->getAttributeMatrix(amName)->getNumberOfTuples()); - BoolArrayType::Pointer currentArrayPtr = BoolArrayType::CreateArray(totalTuples, "_INTERNAL_USE_ONLY_TEMP"); + BoolArrayType::Pointer currentArrayPtr = BoolArrayType::CreateArray(totalTuples, std::string("_INTERNAL_USE_ONLY_TEMP"), true); // Initialize the array to false currentArrayPtr->initializeWithZeros(); - //bool* currentArray = currentArrayPtr->getPointer(0); + // bool* currentArray = currentArrayPtr->getPointer(0); int compOperator = comparisonValue->getCompOperator(); double compValue = comparisonValue->getCompValue(); ThresholdFilterHelper filter(static_cast(compOperator), compValue, currentArrayPtr.get()); - err = filter.execute(m->getAttributeMatrix(amName)->getAttributeArray(comparisonValue->getAttributeArrayName()).get(), currentArrayPtr.get()); - if (err < 0) + err = filter.execute(m->getAttributeMatrix(amName)->getAttributeArray(comparisonValue->getAttributeArrayName()), currentArrayPtr.get()); + if(err < 0) { DataArrayPath tempPath(m_SelectedThresholds.getDataContainerName(), m_SelectedThresholds.getAttributeMatrixName(), comparisonValue->getAttributeArrayName()); QString ss = QObject::tr("Error Executing threshold filter on array. The path is %1").arg(tempPath.serialize()); - setErrorCondition(-13002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-13002, ss); return; } - - if (replaceInput) + + if(replaceInput) { - if (inverse) + if(inverse) { invertThreshold(totalTuples, currentArrayPtr); } inputThreshold.swap(currentArrayPtr); } - else + else { // insert into current threshold insertThreshold(totalTuples, inputThreshold, comparisonValue->getUnionOperator(), currentArrayPtr, inverse); @@ -445,7 +431,7 @@ AbstractFilter::Pointer MultiThresholdObjects2::newFilterInstance(bool copyFilte // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MultiThresholdObjects2::getCompiledLibraryName() const +QString MultiThresholdObjects2::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -453,7 +439,7 @@ const QString MultiThresholdObjects2::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MultiThresholdObjects2::getBrandingString() const +QString MultiThresholdObjects2::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -461,7 +447,7 @@ const QString MultiThresholdObjects2::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MultiThresholdObjects2::getFilterVersion() const +QString MultiThresholdObjects2::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -471,7 +457,7 @@ const QString MultiThresholdObjects2::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MultiThresholdObjects2::getGroupName() const +QString MultiThresholdObjects2::getGroupName() const { return SIMPL::FilterGroups::ProcessingFilters; } @@ -479,7 +465,7 @@ const QString MultiThresholdObjects2::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid MultiThresholdObjects2::getUuid() +QUuid MultiThresholdObjects2::getUuid() const { return QUuid("{686d5393-2b02-5c86-b887-dd81a8ae80f2}"); } @@ -487,7 +473,7 @@ const QUuid MultiThresholdObjects2::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MultiThresholdObjects2::getSubGroupName() const +QString MultiThresholdObjects2::getSubGroupName() const { return SIMPL::FilterSubGroups::ThresholdFilters; } @@ -495,7 +481,60 @@ const QString MultiThresholdObjects2::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString MultiThresholdObjects2::getHumanLabel() const +QString MultiThresholdObjects2::getHumanLabel() const { return "Threshold Objects (Advanced)"; } + +// ----------------------------------------------------------------------------- +MultiThresholdObjects2::Pointer MultiThresholdObjects2::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr MultiThresholdObjects2::New() +{ + struct make_shared_enabler : public MultiThresholdObjects2 + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString MultiThresholdObjects2::getNameOfClass() const +{ + return QString("MultiThresholdObjects2"); +} + +// ----------------------------------------------------------------------------- +QString MultiThresholdObjects2::ClassName() +{ + return QString("MultiThresholdObjects2"); +} + +// ----------------------------------------------------------------------------- +void MultiThresholdObjects2::setDestinationArrayName(const QString& value) +{ + m_DestinationArrayName = value; +} + +// ----------------------------------------------------------------------------- +QString MultiThresholdObjects2::getDestinationArrayName() const +{ + return m_DestinationArrayName; +} + +// ----------------------------------------------------------------------------- +void MultiThresholdObjects2::setSelectedThresholds(const ComparisonInputsAdvanced& value) +{ + m_SelectedThresholds = value; +} + +// ----------------------------------------------------------------------------- +ComparisonInputsAdvanced MultiThresholdObjects2::getSelectedThresholds() const +{ + return m_SelectedThresholds; +} diff --git a/Source/SIMPLib/CoreFilters/MultiThresholdObjects2.h b/Source/SIMPLib/CoreFilters/MultiThresholdObjects2.h index f0199ee439..a72e760af9 100644 --- a/Source/SIMPLib/CoreFilters/MultiThresholdObjects2.h +++ b/Source/SIMPLib/CoreFilters/MultiThresholdObjects2.h @@ -1,221 +1,235 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/Filtering/ComparisonInputsAdvanced.h" #include "SIMPLib/Filtering/ComparisonSet.h" #include "SIMPLib/Filtering/ComparisonValue.h" -#include "SIMPLib/SIMPLib.h" /** * @brief The MultiThresholdObjects2 class. See [Filter documentation](@ref multithresholdobjects2) for details. */ -class SIMPLib_EXPORT MultiThresholdObjects2 : public AbstractFilter +class SIMPLib_EXPORT MultiThresholdObjects2 : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(MultiThresholdObjects2 SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DestinationArrayName READ getDestinationArrayName WRITE setDestinationArrayName) - PYB11_PROPERTY(ComparisonInputsAdvanced SelectedThresholds READ getSelectedThresholds WRITE setSelectedThresholds) - - public: - SIMPL_SHARED_POINTERS(MultiThresholdObjects2) - SIMPL_FILTER_NEW_MACRO(MultiThresholdObjects2) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(MultiThresholdObjects2, AbstractFilter) - - ~MultiThresholdObjects2() override; - - SIMPL_FILTER_PARAMETER(QString, DestinationArrayName) - Q_PROPERTY(QString DestinationArrayName READ getDestinationArrayName WRITE setDestinationArrayName) - - SIMPL_FILTER_PARAMETER(ComparisonInputsAdvanced, SelectedThresholds) - Q_PROPERTY(ComparisonInputsAdvanced SelectedThresholds READ getSelectedThresholds WRITE setSelectedThresholds) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - MultiThresholdObjects2(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - /** - * @brief Creates and returns a DataArray for the given AttributeMatrix and the number of tuples - */ - void createBoolArray(int64_t& numItems, BoolArrayType::Pointer& thresholdArrayPtr); - - /** - * @brief Merges two DataArrays of a given size using a union operator AND / OR and inverts the second DataArray if requested - * @param numItems Number of values in both DataArrays - * @param currentArray DataArray to merge values into - * @param unionOperator Union operator used to merge into currentArray - * @param newArray DataArray of values to merge into the currentArray - * @param inverse Should newArray have its boolean values flipped before being merged in - */ - void insertThreshold(int64_t numItems, BoolArrayType::Pointer currentArray, int unionOperator, const BoolArrayType::Pointer newArray, bool inverse); - - /** - * @brief Flips the boolean values for a DataArray - * @param numItems Number of tuples in the DataArray - * @param thresholdArray DataArray to invert - */ - void invertThreshold(int64_t numItems, BoolArrayType::Pointer thresholdArray); - - /** - * @brief Performs a check on a ComparisonSet and either merges the result into the DataArray passed in or replaces the DataArray - * @param comparisonSet The set of comparisons used for setting the threshold - * @param inputThreshold DataArray merged into or replaced after finding the ComparisonSet's threshould output - * @param err Return any error code given - * @param replaceInput Specifies whether or not the result gets merged into inputThreshold or replaces it - * @param inverse Specifies whether or not the results need to be flipped before merging or replacing inputThreshold - */ - void thresholdSet(ComparisonSet::Pointer comparisonSet, BoolArrayType::Pointer& inputThreshold, int32_t& err, bool replaceInput = false, bool inverse = false); - - /** - * @brief Performs a check on a single ComparisonValue and either merges the result into the DataArray passed in or replaces the DataArray - * @param comparisonValue The comparison operator and value used for caluculating the threshold - * @param inputThreshold DataArray merged into or replaced after finding the ComparisonSet's threshould output - * @param err Return any error code given - * @param replaceInput Specifies whether or not the result gets merged into inputThreshold or replaces it - * @param inverse Specifies whether or not the results need to be flipped before merging or replacing inputThreshold - */ - void thresholdValue(ComparisonValue::Pointer comparisonValue, BoolArrayType::Pointer& inputThreshold, int32_t& err, bool replaceInput = false, bool inverse = false); - - - private: - DEFINE_DATAARRAY_VARIABLE(bool, Destination) - - public: - MultiThresholdObjects2(const MultiThresholdObjects2&) = delete; // Copy Constructor Not Implemented - MultiThresholdObjects2(MultiThresholdObjects2&&) = delete; // Move Constructor Not Implemented - MultiThresholdObjects2& operator=(const MultiThresholdObjects2&) = delete; // Copy Assignment Not Implemented - MultiThresholdObjects2& operator=(MultiThresholdObjects2&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(MultiThresholdObjects2 SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(MultiThresholdObjects2) + PYB11_FILTER_NEW_MACRO(MultiThresholdObjects2) + PYB11_PROPERTY(QString DestinationArrayName READ getDestinationArrayName WRITE setDestinationArrayName) + PYB11_PROPERTY(ComparisonInputsAdvanced SelectedThresholds READ getSelectedThresholds WRITE setSelectedThresholds) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = MultiThresholdObjects2; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for MultiThresholdObjects2 + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for MultiThresholdObjects2 + */ + static QString ClassName(); + + ~MultiThresholdObjects2() override; + + /** + * @brief Setter property for DestinationArrayName + */ + void setDestinationArrayName(const QString& value); + /** + * @brief Getter property for DestinationArrayName + * @return Value of DestinationArrayName + */ + QString getDestinationArrayName() const; + + Q_PROPERTY(QString DestinationArrayName READ getDestinationArrayName WRITE setDestinationArrayName) + + /** + * @brief Setter property for SelectedThresholds + */ + void setSelectedThresholds(const ComparisonInputsAdvanced& value); + /** + * @brief Getter property for SelectedThresholds + * @return Value of SelectedThresholds + */ + ComparisonInputsAdvanced getSelectedThresholds() const; + + Q_PROPERTY(ComparisonInputsAdvanced SelectedThresholds READ getSelectedThresholds WRITE setSelectedThresholds) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + MultiThresholdObjects2(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + + /** + * @brief Creates and returns a DataArray for the given AttributeMatrix and the number of tuples + */ + void createBoolArray(int64_t& numItems, BoolArrayType::Pointer& thresholdArrayPtr); + + /** + * @brief Merges two DataArrays of a given size using a union operator AND / OR and inverts the second DataArray if requested + * @param numItems Number of values in both DataArrays + * @param currentArray DataArray to merge values into + * @param unionOperator Union operator used to merge into currentArray + * @param newArray DataArray of values to merge into the currentArray + * @param inverse Should newArray have its boolean values flipped before being merged in + */ + void insertThreshold(int64_t numItems, BoolArrayType::Pointer currentArray, int unionOperator, const BoolArrayType::Pointer newArray, bool inverse); + + /** + * @brief Flips the boolean values for a DataArray + * @param numItems Number of tuples in the DataArray + * @param thresholdArray DataArray to invert + */ + void invertThreshold(int64_t numItems, BoolArrayType::Pointer thresholdArray); + + /** + * @brief Performs a check on a ComparisonSet and either merges the result into the DataArray passed in or replaces the DataArray + * @param comparisonSet The set of comparisons used for setting the threshold + * @param inputThreshold DataArray merged into or replaced after finding the ComparisonSet's threshould output + * @param err Return any error code given + * @param replaceInput Specifies whether or not the result gets merged into inputThreshold or replaces it + * @param inverse Specifies whether or not the results need to be flipped before merging or replacing inputThreshold + */ + void thresholdSet(ComparisonSet::Pointer comparisonSet, BoolArrayType::Pointer& inputThreshold, int32_t& err, bool replaceInput = false, bool inverse = false); + + /** + * @brief Performs a check on a single ComparisonValue and either merges the result into the DataArray passed in or replaces the DataArray + * @param comparisonValue The comparison operator and value used for caluculating the threshold + * @param inputThreshold DataArray merged into or replaced after finding the ComparisonSet's threshould output + * @param err Return any error code given + * @param replaceInput Specifies whether or not the result gets merged into inputThreshold or replaces it + * @param inverse Specifies whether or not the results need to be flipped before merging or replacing inputThreshold + */ + void thresholdValue(ComparisonValue::Pointer comparisonValue, BoolArrayType::Pointer& inputThreshold, int32_t& err, bool replaceInput = false, bool inverse = false); + +private: + std::weak_ptr> m_DestinationPtr; + bool* m_Destination = nullptr; + + QString m_DestinationArrayName = {SIMPL::GeneralData::Mask}; + ComparisonInputsAdvanced m_SelectedThresholds = {}; + +public: + MultiThresholdObjects2(const MultiThresholdObjects2&) = delete; // Copy Constructor Not Implemented + MultiThresholdObjects2(MultiThresholdObjects2&&) = delete; // Move Constructor Not Implemented + MultiThresholdObjects2& operator=(const MultiThresholdObjects2&) = delete; // Copy Assignment Not Implemented + MultiThresholdObjects2& operator=(MultiThresholdObjects2&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/PipelineAnnotation.cpp b/Source/SIMPLib/CoreFilters/PipelineAnnotation.cpp index 94f1aa1ceb..ec34837b2a 100644 --- a/Source/SIMPLib/CoreFilters/PipelineAnnotation.cpp +++ b/Source/SIMPLib/CoreFilters/PipelineAnnotation.cpp @@ -1,42 +1,43 @@ /* ============================================================================ -* Copyright (c) 2017 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the following contracts: -* United States Air Force Prime Contract FA8650-15-D-5231 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2017 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "PipelineAnnotation.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/ParagraphFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- // @@ -53,9 +54,9 @@ PipelineAnnotation::~PipelineAnnotation() = default; // ----------------------------------------------------------------------------- void PipelineAnnotation::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(SIMPL_NEW_PARAGRAPH_FP("", Summary, FilterParameter::Parameter, PipelineAnnotation, false)); + parameters.push_back(SIMPL_NEW_PARAGRAPH_FP("", Summary, FilterParameter::Category::Parameter, PipelineAnnotation, false)); setFilterParameters(parameters); } @@ -72,22 +73,8 @@ void PipelineAnnotation::initialize() // ----------------------------------------------------------------------------- void PipelineAnnotation::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void PipelineAnnotation::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -95,10 +82,8 @@ void PipelineAnnotation::preflight() // ----------------------------------------------------------------------------- void PipelineAnnotation::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -120,7 +105,7 @@ AbstractFilter::Pointer PipelineAnnotation::newFilterInstance(bool copyFilterPar // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString PipelineAnnotation::getCompiledLibraryName() const +QString PipelineAnnotation::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -128,7 +113,7 @@ const QString PipelineAnnotation::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString PipelineAnnotation::getBrandingString() const +QString PipelineAnnotation::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -136,7 +121,7 @@ const QString PipelineAnnotation::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString PipelineAnnotation::getFilterVersion() const +QString PipelineAnnotation::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -147,7 +132,7 @@ const QString PipelineAnnotation::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString PipelineAnnotation::getGroupName() const +QString PipelineAnnotation::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -155,7 +140,7 @@ const QString PipelineAnnotation::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid PipelineAnnotation::getUuid() +QUuid PipelineAnnotation::getUuid() const { return QUuid("{8cc2198b-6a9d-5bf4-b8c0-b0878bb57f10}"); } @@ -163,7 +148,7 @@ const QUuid PipelineAnnotation::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString PipelineAnnotation::getSubGroupName() const +QString PipelineAnnotation::getSubGroupName() const { return SIMPL::FilterSubGroups::MiscFilters; } @@ -171,7 +156,48 @@ const QString PipelineAnnotation::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString PipelineAnnotation::getHumanLabel() const +QString PipelineAnnotation::getHumanLabel() const { return "Pipeline Annotation"; } + +// ----------------------------------------------------------------------------- +PipelineAnnotation::Pointer PipelineAnnotation::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr PipelineAnnotation::New() +{ + struct make_shared_enabler : public PipelineAnnotation + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString PipelineAnnotation::getNameOfClass() const +{ + return QString("PipelineAnnotation"); +} + +// ----------------------------------------------------------------------------- +QString PipelineAnnotation::ClassName() +{ + return QString("PipelineAnnotation"); +} + +// ----------------------------------------------------------------------------- +void PipelineAnnotation::setSummary(const QString& value) +{ + m_Summary = value; +} + +// ----------------------------------------------------------------------------- +QString PipelineAnnotation::getSummary() const +{ + return m_Summary; +} diff --git a/Source/SIMPLib/CoreFilters/PipelineAnnotation.h b/Source/SIMPLib/CoreFilters/PipelineAnnotation.h index 7b2c0d2871..b369c3c309 100644 --- a/Source/SIMPLib/CoreFilters/PipelineAnnotation.h +++ b/Source/SIMPLib/CoreFilters/PipelineAnnotation.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2017 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the following contracts: -* United States Air Force Prime Contract FA8650-15-D-5231 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2017 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The PipelineAnnotation class. See [Filter documentation](@ref PipelineAnnotation) for details. @@ -43,15 +44,54 @@ class SIMPLib_EXPORT PipelineAnnotation : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(PipelineAnnotation SUPERCLASS AbstractFilter) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(PipelineAnnotation SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(PipelineAnnotation) + PYB11_FILTER_NEW_MACRO(PipelineAnnotation) PYB11_PROPERTY(QString Summary READ getSummary WRITE setSummary) + PYB11_END_BINDINGS() + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(PipelineAnnotation) - SIMPL_FILTER_NEW_MACRO(PipelineAnnotation) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(PipelineAnnotation, AbstractFilter) + using Self = PipelineAnnotation; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for PipelineAnnotation + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for PipelineAnnotation + */ + static QString ClassName(); + + /** + * @brief Setter property for Summary + */ + void setSummary(const QString& value); + /** + * @brief Getter property for Summary + * @return Value of Summary + */ + QString getSummary() const; - SIMPL_FILTER_PARAMETER(QString, Summary) Q_PROPERTY(QString Summary READ getSummary WRITE setSummary) ~PipelineAnnotation() override; @@ -59,21 +99,21 @@ class SIMPLib_EXPORT PipelineAnnotation : public AbstractFilter /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class */ - const QString getCompiledLibraryName() const override; + QString getCompiledLibraryName() const override; /** * @brief getBrandingString Returns the branding string for the filter, which is a tag * used to denote the filter's association with specific plugins * @return Branding string - */ - const QString getBrandingString() const override; + */ + QString getBrandingString() const override; /** * @brief getFilterVersion Returns a version string for this filter. Default * value is an empty string. * @return */ - const QString getFilterVersion() const override; + QString getFilterVersion() const override; /** * @brief newFilterInstance Reimplemented from @see AbstractFilter class @@ -83,23 +123,23 @@ class SIMPLib_EXPORT PipelineAnnotation : public AbstractFilter /** * @brief getGroupName Reimplemented from @see AbstractFilter class */ - const QString getGroupName() const override; + QString getGroupName() const override; /** * @brief getSubGroupName Reimplemented from @see AbstractFilter class */ - const QString getSubGroupName() const override; + QString getSubGroupName() const override; /** * @brief getUuid Return the unique identifier for this filter. * @return A QUuid object. */ - const QUuid getUuid() override; + QUuid getUuid() const override; /** * @brief getHumanLabel Reimplemented from @see AbstractFilter class */ - const QString getHumanLabel() const override; + QString getHumanLabel() const override; /** * @brief setupFilterParameters Reimplemented from @see AbstractFilter class @@ -111,40 +151,12 @@ class SIMPLib_EXPORT PipelineAnnotation : public AbstractFilter */ void execute() override; - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - -signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - protected: PipelineAnnotation(); /** * @brief dataCheck Checks for the appropriate parameter values and availability of arrays */ - void dataCheck(); + void dataCheck() override; /** * @brief Initializes all the private instance variables. @@ -152,9 +164,11 @@ class SIMPLib_EXPORT PipelineAnnotation : public AbstractFilter void initialize(); public: - PipelineAnnotation(const PipelineAnnotation&) = delete; // Copy Constructor Not Implemented - PipelineAnnotation(PipelineAnnotation&&) = delete; // Move Constructor Not Implemented + PipelineAnnotation(const PipelineAnnotation&) = delete; // Copy Constructor Not Implemented + PipelineAnnotation(PipelineAnnotation&&) = delete; // Move Constructor Not Implemented PipelineAnnotation& operator=(const PipelineAnnotation&) = delete; // Copy Assignment Not Implemented PipelineAnnotation& operator=(PipelineAnnotation&&) = delete; // Move Assignment Not Implemented -}; +private: + QString m_Summary = {}; +}; diff --git a/Source/SIMPLib/CoreFilters/PostSlackMessage.cpp b/Source/SIMPLib/CoreFilters/PostSlackMessage.cpp index 573951c819..ed5d88e41a 100644 --- a/Source/SIMPLib/CoreFilters/PostSlackMessage.cpp +++ b/Source/SIMPLib/CoreFilters/PostSlackMessage.cpp @@ -29,11 +29,9 @@ * * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - #include "PostSlackMessage.h" #include -#include #include #include @@ -41,40 +39,34 @@ #include #include +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" -#include "SIMPLib/FilterParameters/StringFilterParameter.h" #include "SIMPLib/FilterParameters/BooleanFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/FilterParameters/StringFilterParameter.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- PostSlackMessage::PostSlackMessage() -: m_SlackUser("") -, m_SlackUrl("") -, m_SlackMessage("") -, m_WarningsAsError(false) { m_SlackUser = "[DREAM.3D@" + QSysInfo::machineHostName() + "]"; initialize(); - m_NetworkManager = new QNetworkAccessManager(this); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PostSlackMessage::~PostSlackMessage() -{ - delete m_NetworkManager; -} +PostSlackMessage::~PostSlackMessage() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void PostSlackMessage::initialize() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); setCancel(false); } @@ -83,12 +75,12 @@ void PostSlackMessage::initialize() // ----------------------------------------------------------------------------- void PostSlackMessage::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(SIMPL_NEW_STRING_FP("Slack User", SlackUser, FilterParameter::Parameter, PostSlackMessage)); - parameters.push_back(SIMPL_NEW_STRING_FP("Slack Url", SlackUrl, FilterParameter::Parameter, PostSlackMessage)); - parameters.push_back(SIMPL_NEW_STRING_FP("Slack Message", SlackMessage, FilterParameter::Parameter, PostSlackMessage)); - parameters.push_back(SIMPL_NEW_BOOL_FP("Treat a Warning as an Error", WarningsAsError, FilterParameter::Parameter, PostSlackMessage)); + parameters.push_back(SIMPL_NEW_STRING_FP("Slack User", SlackUser, FilterParameter::Category::Parameter, PostSlackMessage)); + parameters.push_back(SIMPL_NEW_STRING_FP("Slack Url", SlackUrl, FilterParameter::Category::Parameter, PostSlackMessage)); + parameters.push_back(SIMPL_NEW_STRING_FP("Slack Message", SlackMessage, FilterParameter::Category::Parameter, PostSlackMessage)); + parameters.push_back(SIMPL_NEW_BOOL_FP("Treat a Warning as an Error", WarningsAsError, FilterParameter::Category::Parameter, PostSlackMessage)); setFilterParameters(parameters); } @@ -98,22 +90,8 @@ void PostSlackMessage::setupFilterParameters() // ----------------------------------------------------------------------------- void PostSlackMessage::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void PostSlackMessage::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -123,7 +101,7 @@ void PostSlackMessage::execute() { initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -162,21 +140,18 @@ void PostSlackMessage::execute() { if(getWarningsAsError()) { - setErrorCondition(-76000); - QString ss = QObject::tr("Slack returned the following error code: %1").arg(getErrorCondition()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + QString ss = QObject::tr("Slack returned the following error code: %1").arg(getErrorCode()); + setErrorCondition(-76000, ss); } else { - setWarningCondition(-76001); - QString ss = QObject::tr("Slack returned the following error code: %1").arg(getErrorCondition()); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + QString ss = QObject::tr("Slack returned the following error code: %1").arg(getErrorCode()); + setWarningCondition(-76001, ss); } } delete reply; delete connection; - } // ----------------------------------------------------------------------------- @@ -195,7 +170,7 @@ AbstractFilter::Pointer PostSlackMessage::newFilterInstance(bool copyFilterParam // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString PostSlackMessage::getCompiledLibraryName() const +QString PostSlackMessage::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -203,7 +178,7 @@ const QString PostSlackMessage::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString PostSlackMessage::getBrandingString() const +QString PostSlackMessage::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -211,7 +186,7 @@ const QString PostSlackMessage::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString PostSlackMessage::getFilterVersion() const +QString PostSlackMessage::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -222,7 +197,7 @@ const QString PostSlackMessage::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString PostSlackMessage::getGroupName() const +QString PostSlackMessage::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -230,7 +205,7 @@ const QString PostSlackMessage::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid PostSlackMessage::getUuid() +QUuid PostSlackMessage::getUuid() const { return QUuid("{0ca83462-8564-54ea-9f4e-e5141974f30b}"); } @@ -238,7 +213,7 @@ const QUuid PostSlackMessage::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString PostSlackMessage::getSubGroupName() const +QString PostSlackMessage::getSubGroupName() const { return SIMPL::FilterSubGroups::MiscFilters; } @@ -246,7 +221,84 @@ const QString PostSlackMessage::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString PostSlackMessage::getHumanLabel() const +QString PostSlackMessage::getHumanLabel() const { return "Post Slack Message"; } + +// ----------------------------------------------------------------------------- +PostSlackMessage::Pointer PostSlackMessage::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr PostSlackMessage::New() +{ + struct make_shared_enabler : public PostSlackMessage + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString PostSlackMessage::getNameOfClass() const +{ + return QString("PostSlackMessage"); +} + +// ----------------------------------------------------------------------------- +QString PostSlackMessage::ClassName() +{ + return QString("PostSlackMessage"); +} + +// ----------------------------------------------------------------------------- +void PostSlackMessage::setSlackUser(const QString& value) +{ + m_SlackUser = value; +} + +// ----------------------------------------------------------------------------- +QString PostSlackMessage::getSlackUser() const +{ + return m_SlackUser; +} + +// ----------------------------------------------------------------------------- +void PostSlackMessage::setSlackUrl(const QString& value) +{ + m_SlackUrl = value; +} + +// ----------------------------------------------------------------------------- +QString PostSlackMessage::getSlackUrl() const +{ + return m_SlackUrl; +} + +// ----------------------------------------------------------------------------- +void PostSlackMessage::setSlackMessage(const QString& value) +{ + m_SlackMessage = value; +} + +// ----------------------------------------------------------------------------- +QString PostSlackMessage::getSlackMessage() const +{ + return m_SlackMessage; +} + +// ----------------------------------------------------------------------------- +void PostSlackMessage::setWarningsAsError(bool value) +{ + m_WarningsAsError = value; +} + +// ----------------------------------------------------------------------------- +bool PostSlackMessage::getWarningsAsError() const +{ + return m_WarningsAsError; +} diff --git a/Source/SIMPLib/CoreFilters/PostSlackMessage.h b/Source/SIMPLib/CoreFilters/PostSlackMessage.h index 7147ae61d0..bccf641347 100644 --- a/Source/SIMPLib/CoreFilters/PostSlackMessage.h +++ b/Source/SIMPLib/CoreFilters/PostSlackMessage.h @@ -32,14 +32,10 @@ #pragma once -#include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/SIMPLib.h" - -class QNetworkAccessManager; -class QNetworkReply; +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The PostSlackMessage class. See [Filter documentation](@ref postslackmessage) for details. @@ -47,136 +43,174 @@ class QNetworkReply; class SIMPLib_EXPORT PostSlackMessage : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(PostSlackMessage SUPERCLASS AbstractFilter) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(PostSlackMessage SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(PostSlackMessage) + PYB11_FILTER_NEW_MACRO(PostSlackMessage) PYB11_PROPERTY(QString SlackUser READ getSlackUser WRITE setSlackUser) PYB11_PROPERTY(QString SlackUrl READ getSlackUrl WRITE setSlackUrl) PYB11_PROPERTY(QString SlackMessage READ getSlackMessage WRITE setSlackMessage) PYB11_PROPERTY(bool WarningsAsError READ getWarningsAsError WRITE setWarningsAsError) + PYB11_END_BINDINGS() + // End Python bindings declarations - public: - SIMPL_SHARED_POINTERS(PostSlackMessage) - SIMPL_FILTER_NEW_MACRO(PostSlackMessage) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(PostSlackMessage, AbstractFilter) +public: + using Self = PostSlackMessage; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; - ~PostSlackMessage() override; + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); - SIMPL_FILTER_PARAMETER(QString, SlackUser) - Q_PROPERTY(QString SlackUser READ getSlackUser WRITE setSlackUser) + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); - SIMPL_FILTER_PARAMETER(QString, SlackUrl) - Q_PROPERTY(QString SlackUrl READ getSlackUrl WRITE setSlackUrl) + /** + * @brief Returns the name of the class for PostSlackMessage + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for PostSlackMessage + */ + static QString ClassName(); - SIMPL_FILTER_PARAMETER(QString, SlackMessage) - Q_PROPERTY(QString SlackMessage READ getSlackMessage WRITE setSlackMessage) + ~PostSlackMessage() override; - SIMPL_FILTER_PARAMETER(bool, WarningsAsError) - Q_PROPERTY(bool WarningsAsError READ getWarningsAsError WRITE setWarningsAsError) + /** + * @brief Setter property for SlackUser + */ + void setSlackUser(const QString& value); + /** + * @brief Getter property for SlackUser + * @return Value of SlackUser + */ + QString getSlackUser() const; - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; + Q_PROPERTY(QString SlackUser READ getSlackUser WRITE setSlackUser) - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; + /** + * @brief Setter property for SlackUrl + */ + void setSlackUrl(const QString& value); + /** + * @brief Getter property for SlackUrl + * @return Value of SlackUrl + */ + QString getSlackUrl() const; - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; + Q_PROPERTY(QString SlackUrl READ getSlackUrl WRITE setSlackUrl) - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + /** + * @brief Setter property for SlackMessage + */ + void setSlackMessage(const QString& value); + /** + * @brief Getter property for SlackMessage + * @return Value of SlackMessage + */ + QString getSlackMessage() const; - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; + Q_PROPERTY(QString SlackMessage READ getSlackMessage WRITE setSlackMessage) - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; + /** + * @brief Setter property for WarningsAsError + */ + void setWarningsAsError(bool value); + /** + * @brief Getter property for WarningsAsError + * @return Value of WarningsAsError + */ + bool getWarningsAsError() const; + + Q_PROPERTY(bool WarningsAsError READ getWarningsAsError WRITE setWarningsAsError) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; -signals: /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. */ - void updateFilterParameters(AbstractFilter* filter); + QUuid getUuid() const override; /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally + * @brief getHumanLabel Reimplemented from @see AbstractFilter class */ - void parametersChanged(); + QString getHumanLabel() const override; /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class */ - void preflightAboutToExecute(); + void setupFilterParameters() override; /** - * @brief preflightExecuted Emitted just after calling dataCheck() + * @brief execute Reimplemented from @see AbstractFilter class */ - void preflightExecuted(); + void execute() override; protected: PostSlackMessage(); /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; /** - * @brief Initializes all the private instance variables. - */ + * @brief Initializes all the private instance variables. + */ void initialize(); private: - QWaitCondition m_WaitCondition; - QMutex m_Mutex; - QNetworkAccessManager* m_NetworkManager; - - public: - PostSlackMessage(const PostSlackMessage&) = delete; // Copy Constructor Not Implemented - PostSlackMessage(PostSlackMessage&&) = delete; // Move Constructor Not Implemented - PostSlackMessage& operator=(const PostSlackMessage&) = delete; // Copy Assignment Not Implemented - PostSlackMessage& operator=(PostSlackMessage&&) = delete; // Move Assignment Not Implemented + QString m_SlackUser = {""}; + QString m_SlackUrl = {""}; + QString m_SlackMessage = {""}; + bool m_WarningsAsError = {false}; + +public: + PostSlackMessage(const PostSlackMessage&) = delete; // Copy Constructor Not Implemented + PostSlackMessage(PostSlackMessage&&) = delete; // Move Constructor Not Implemented + PostSlackMessage& operator=(const PostSlackMessage&) = delete; // Copy Assignment Not Implemented + PostSlackMessage& operator=(PostSlackMessage&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/RawBinaryReader.cpp b/Source/SIMPLib/CoreFilters/RawBinaryReader.cpp index 2b4cfeefc5..e206cbbbd8 100644 --- a/Source/SIMPLib/CoreFilters/RawBinaryReader.cpp +++ b/Source/SIMPLib/CoreFilters/RawBinaryReader.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -36,13 +36,17 @@ #include "RawBinaryReader.h" -#include +#include +#include +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/ScopedFileMonitor.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" -#include "SIMPLib/SIMPLibVersion.h" - #include "SIMPLib/FilterParameters/ChoiceFilterParameter.h" #include "SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h" #include "SIMPLib/FilterParameters/InputFileFilterParameter.h" @@ -53,30 +57,33 @@ #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/FilterParameters/UInt64FilterParameter.h" -#define RBR_FILE_NOT_OPEN -1000 -#define RBR_FILE_TOO_SMALL -1010 -#define RBR_FILE_TOO_BIG -1020 -#define RBR_READ_EOF -1030 -#define RBR_NO_ERROR 0 +#if defined(_MSC_VER) +#define FSEEK _fseeki64 +#else +#define FSEEK std::fseek +#endif +namespace +{ #ifdef CMP_WORDS_BIGENDIAN -#define SWAP_ARRAY(array) \ - if(filter->getEndian() == 0) \ - { \ - array->byteSwapElements(); \ - } - +constexpr int32_t k_EndianCheck = 0; #else -#define SWAP_ARRAY(array) \ - if(filter->getEndian() == 1) \ - { \ - array->byteSwapElements(); \ - } - +constexpr int32_t k_EndianCheck = 1; #endif -// ----------------------------------------------------------------------------- -// +constexpr int32_t RBR_NO_ERROR = 0; +constexpr int32_t RBR_FILENAME_EMPTY = -387; +constexpr int32_t RBR_FILE_NOT_EXIST = -388; +constexpr int32_t RBR_NUM_COMPONENTS_ERROR = -391; +constexpr int32_t RBR_FILE_NOT_OPEN = -1000; +constexpr int32_t RBR_FILE_TOO_SMALL = -1010; +constexpr int32_t RBR_FILE_TOO_BIG = -1020; +constexpr int32_t RBR_READ_EOF = -1030; +constexpr int32_t RBR_DCA_ERROR = -1040; +constexpr int32_t RBR_DA_ERROR = -1050; +constexpr int32_t RBR_COMPONENT_ERROR = -1060; +constexpr int32_t RBR_DA_NULL = -1070; + // ----------------------------------------------------------------------------- int32_t SanityCheckFileSizeVersusAllocatedSize(size_t allocatedBytes, size_t fileSize, size_t skipHeaderBytes) { @@ -88,113 +95,87 @@ int32_t SanityCheckFileSizeVersusAllocatedSize(size_t allocatedBytes, size_t fil { return 1; } - // File Size and Allocated Size are equal so we are good to go + // File Size and Allocated Size are equal so we are good to go return 0; } // ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -template int32_t readBinaryFile(RawBinaryReader* filter) +template +int32_t readBinaryFile(IDataArray* dataArrayPtr, const std::string& filename, uint64_t skipHeaderBytes, int32_t endian) { + auto dataArray = dynamic_cast*>(dataArrayPtr); - typename DataArray::Pointer p = filter->getDataContainerArray()->getPrereqIDataArrayFromPath, AbstractFilter>(filter, filter->getCreatedAttributeArrayPath()); - QString filename = filter->getInputFile(); - int64_t skipHeaderBytes = filter->getSkipHeaderBytes(); + if(dataArray == nullptr) + { + return RBR_DA_NULL; + } - int32_t err = 0; - QFileInfo fi(filename); - uint64_t fileSize = static_cast(fi.size()); - size_t allocatedBytes = p->getSize() * sizeof(T); - err = SanityCheckFileSizeVersusAllocatedSize(allocatedBytes, fileSize, skipHeaderBytes); + const size_t fileSize = fs::file_size(filename); + const size_t numBytesToRead = dataArray->getSize() * sizeof(T); + int32_t err = SanityCheckFileSizeVersusAllocatedSize(numBytesToRead, fileSize, skipHeaderBytes); if(err < 0) { return RBR_FILE_TOO_SMALL; } - FILE* f = fopen(filename.toLatin1().data(), "rb"); - if(nullptr == f) + FILE* f = std::fopen(filename.c_str(), "rb"); + if(f == nullptr) { return RBR_FILE_NOT_OPEN; } ScopedFileMonitor monitor(f); - size_t numBytesToRead = p->getNumberOfTuples() * static_cast(p->getNumberOfComponents()) * sizeof(T); - size_t numRead = 0; - - uint8_t* chunkptr = reinterpret_cast(p->getPointer(0)); // Skip some header bytes if the user asked for it. if(skipHeaderBytes > 0) { - #if defined (_MSC_VER) - _fseeki64(f, skipHeaderBytes, SEEK_SET); - #else - fseek(f, skipHeaderBytes, SEEK_SET); - #endif + FSEEK(f, skipHeaderBytes, SEEK_SET); } - numRead = 0; - // Now start reading the data in chunks if needed. - size_t chunkSize = DEFAULT_BLOCKSIZE; - if(numBytesToRead < DEFAULT_BLOCKSIZE) - { - chunkSize = numBytesToRead; - } + std::byte* chunkptr = reinterpret_cast(dataArray->data()); + + // Now start reading the data in chunks if needed. + size_t chunkSize = std::min(numBytesToRead, SIMPL::DEFAULT_BLOCKSIZE); size_t master_counter = 0; - size_t bytes_read = 0; - while(true) + while(master_counter < numBytesToRead) { - bytes_read = fread(chunkptr, sizeof(uint8_t), chunkSize, f); - chunkptr = chunkptr + bytes_read; + size_t bytes_read = std::fread(chunkptr, sizeof(std::byte), chunkSize, f); + chunkptr += bytes_read; master_counter += bytes_read; - if(numBytesToRead - master_counter < chunkSize) - { - chunkSize = numBytesToRead - master_counter; - } - if(master_counter >= numBytesToRead) + size_t bytesLeft = numBytesToRead - master_counter; + + if(bytesLeft < chunkSize) { - break; + chunkSize = bytesLeft; } } - - SWAP_ARRAY(p) + if(endian == k_EndianCheck) + { + dataArray->byteSwapElements(); + } return RBR_NO_ERROR; } +} // namespace // ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -RawBinaryReader::RawBinaryReader() -: m_CreatedAttributeArrayPath("") -, m_ScalarType(SIMPL::NumericTypes::Type::Int8) -, m_Endian(0) -, m_NumberOfComponents(0) -, m_SkipHeaderBytes(0) -, m_InputFile("") -{ -} +RawBinaryReader::RawBinaryReader() = default; -// ----------------------------------------------------------------------------- -// // ----------------------------------------------------------------------------- RawBinaryReader::~RawBinaryReader() = default; -// ----------------------------------------------------------------------------- -// // ----------------------------------------------------------------------------- void RawBinaryReader::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(SIMPL_NEW_INPUT_FILE_FP("Input File", InputFile, FilterParameter::Parameter, RawBinaryReader, "*.raw *.bin")); - parameters.push_back(SIMPL_NEW_NUMERICTYPE_FP("Scalar Type", ScalarType, FilterParameter::Parameter, RawBinaryReader)); - parameters.push_back(SIMPL_NEW_INTEGER_FP("Number of Components", NumberOfComponents, FilterParameter::Parameter, RawBinaryReader)); + parameters.push_back(SIMPL_NEW_INPUT_FILE_FP("Input File", InputFile, FilterParameter::Category::Parameter, RawBinaryReader, "*.raw *.bin")); + parameters.push_back(SIMPL_NEW_NUMERICTYPE_FP("Scalar Type", ScalarType, FilterParameter::Category::Parameter, RawBinaryReader)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Number of Components", NumberOfComponents, FilterParameter::Category::Parameter, RawBinaryReader)); { ChoiceFilterParameter::Pointer parameter = ChoiceFilterParameter::New(); parameter->setHumanLabel("Endian"); @@ -202,23 +183,21 @@ void RawBinaryReader::setupFilterParameters() parameter->setSetterCallback(SIMPL_BIND_SETTER(RawBinaryReader, this, Endian)); parameter->setGetterCallback(SIMPL_BIND_GETTER(RawBinaryReader, this, Endian)); - QVector choices; + std::vector choices; choices.push_back("Little"); choices.push_back("Big"); parameter->setChoices(choices); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameters.push_back(parameter); } - parameters.push_back(SIMPL_NEW_UINT64_FP("Skip Header Bytes", SkipHeaderBytes, FilterParameter::Parameter, RawBinaryReader)); + parameters.push_back(SIMPL_NEW_UINT64_FP("Skip Header Bytes", SkipHeaderBytes, FilterParameter::Category::Parameter, RawBinaryReader)); { DataArrayCreationFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Output Attribute Array", CreatedAttributeArrayPath, FilterParameter::CreatedArray, RawBinaryReader, req)); + parameters.push_back(SIMPL_NEW_DA_CREATION_FP("Output Attribute Array", CreatedAttributeArrayPath, FilterParameter::Category::CreatedArray, RawBinaryReader, req)); } setFilterParameters(parameters); } -// ----------------------------------------------------------------------------- -// // ----------------------------------------------------------------------------- void RawBinaryReader::readFilterParameters(AbstractFilterParametersReader* reader, int index) { @@ -233,107 +212,99 @@ void RawBinaryReader::readFilterParameters(AbstractFilterParametersReader* reade reader->closeFilterGroup(); } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void RawBinaryReader::initialize() -{ -} - -// ----------------------------------------------------------------------------- -// // ----------------------------------------------------------------------------- void RawBinaryReader::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - QFileInfo fi(getInputFile()); - if(getInputFile().isEmpty()) + auto dca = getDataContainerArray(); + + const std::string inputFile = m_InputFile.toStdString(); + + if(inputFile.empty()) { QString ss = QObject::tr("The input file must be set"); - setErrorCondition(-387); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(RBR_FILENAME_EMPTY, ss); } - else if(!fi.exists()) + else if(!fs::exists(inputFile)) { - QString ss = QObject::tr("The input file does not exist"); - setErrorCondition(-388); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + QString ss = QObject::tr("The input file does not exist: %1").arg(getInputFile()); + setErrorCondition(RBR_FILE_NOT_EXIST, ss); } if(m_NumberOfComponents < 1) { QString ss = QObject::tr("The number of components must be positive"); - setErrorCondition(-391); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(RBR_NUM_COMPONENTS_ERROR, ss); } - AttributeMatrix::Pointer attrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getCreatedAttributeArrayPath(), -30003); - if(getErrorCondition() < 0) + AttributeMatrix::Pointer attrMat = dca->getPrereqAttributeMatrixFromPath(this, getCreatedAttributeArrayPath(), -30003); + if(getErrorCode() < 0) { return; } - QVector tDims = attrMat->getTupleDimensions(); - size_t totalDim = std::accumulate(tDims.begin(), tDims.end(), 1, std::multiplies()); + const std::vector tDims = attrMat->getTupleDimensions(); + const size_t totalDim = std::accumulate(tDims.cbegin(), tDims.cend(), static_cast(1), std::multiplies()); + const size_t totalSize = m_NumberOfComponents * totalDim; size_t allocatedBytes = 0; - QVector cDims(1, m_NumberOfComponents); + std::vector cDims = {static_cast(m_NumberOfComponents)}; if(m_ScalarType == SIMPL::NumericTypes::Type::Int8) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); - allocatedBytes = sizeof(int8_t) * m_NumberOfComponents * totalDim; + dca->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + allocatedBytes = sizeof(int8_t) * totalSize; } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt8) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); - allocatedBytes = sizeof(uint8_t) * m_NumberOfComponents * totalDim; + dca->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + allocatedBytes = sizeof(uint8_t) * totalSize; } else if(m_ScalarType == SIMPL::NumericTypes::Type::Int16) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); - allocatedBytes = sizeof(int16_t) * m_NumberOfComponents * totalDim; + dca->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + allocatedBytes = sizeof(int16_t) * totalSize; } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt16) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); - allocatedBytes = sizeof(uint16_t) * m_NumberOfComponents * totalDim; + dca->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + allocatedBytes = sizeof(uint16_t) * totalSize; } else if(m_ScalarType == SIMPL::NumericTypes::Type::Int32) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); - allocatedBytes = sizeof(int32_t) * m_NumberOfComponents * totalDim; + dca->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + allocatedBytes = sizeof(int32_t) * totalSize; } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt32) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); - allocatedBytes = sizeof(uint32_t) * m_NumberOfComponents * totalDim; + dca->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + allocatedBytes = sizeof(uint32_t) * totalSize; } else if(m_ScalarType == SIMPL::NumericTypes::Type::Int64) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); - allocatedBytes = sizeof(int64_t) * m_NumberOfComponents * totalDim; + dca->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + allocatedBytes = sizeof(int64_t) * totalSize; } else if(m_ScalarType == SIMPL::NumericTypes::Type::UInt64) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); - allocatedBytes = sizeof(uint64_t) * m_NumberOfComponents * totalDim; + dca->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + allocatedBytes = sizeof(uint64_t) * totalSize; } else if(m_ScalarType == SIMPL::NumericTypes::Type::Float) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); - allocatedBytes = sizeof(float) * m_NumberOfComponents * totalDim; + dca->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + allocatedBytes = sizeof(float) * totalSize; } else if(m_ScalarType == SIMPL::NumericTypes::Type::Double) { - getDataContainerArray()->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); - allocatedBytes = sizeof(double) * m_NumberOfComponents * totalDim; + dca->createNonPrereqArrayFromPath(this, getCreatedAttributeArrayPath(), 0, cDims, "CreatedAttributeArrayPath"); + allocatedBytes = sizeof(double) * totalSize; } // Sanity Check Allocated Bytes versus size of file - uint64_t fileSize = fi.size(); - int32_t check = SanityCheckFileSizeVersusAllocatedSize(allocatedBytes, fileSize, m_SkipHeaderBytes); + const uint64_t fileSize = fs::file_size(inputFile); + const int32_t check = SanityCheckFileSizeVersusAllocatedSize(allocatedBytes, fileSize, m_SkipHeaderBytes); if(check == -1) { @@ -341,8 +312,7 @@ void RawBinaryReader::dataCheck() " Please adjust the input parameters to match the size of the file or select a different data file") .arg(fileSize) .arg(allocatedBytes); - setErrorCondition(RBR_FILE_TOO_SMALL); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(RBR_FILE_TOO_SMALL, ss); } else if(check == 1) { @@ -351,76 +321,83 @@ void RawBinaryReader::dataCheck() " SIMPLView will read only the first part of the file into the array") .arg(fileSize) .arg(allocatedBytes); - setWarningCondition(RBR_FILE_TOO_BIG); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(RBR_FILE_TOO_BIG, ss); } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void RawBinaryReader::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - -// ----------------------------------------------------------------------------- -// // ----------------------------------------------------------------------------- void RawBinaryReader::execute() { - int32_t err = 0; - setErrorCondition(err); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getCreatedAttributeArrayPath().getDataContainerName()); + auto dca = getDataContainerArray(); + if(dca == nullptr) + { + setErrorCondition(RBR_DCA_ERROR, "Failed to acquire DataContainerArray"); + return; + } + + const std::vector cDims = {static_cast(m_NumberOfComponents)}; + + auto dataArray = dca->getPrereqIDataArrayFromPath(this, getCreatedAttributeArrayPath()); + + if(dataArray == nullptr) + { + setErrorCondition(RBR_DA_ERROR, "Failed to acquire DataArray"); + return; + } + + if(dataArray->getComponentDimensions() != cDims) + { + setErrorCondition(RBR_COMPONENT_ERROR, "Failed to acquire DataArray with the correct dimensions"); + return; + } + + const std::string inputFile = m_InputFile.toStdString(); + + int32_t err = 0; switch(m_ScalarType) { case SIMPL::NumericTypes::Type::Int8: - err = readBinaryFile(this); + err = readBinaryFile(dataArray.get(), inputFile, m_SkipHeaderBytes, m_Endian); break; case SIMPL::NumericTypes::Type::UInt8: - err = readBinaryFile(this); + err = readBinaryFile(dataArray.get(), inputFile, m_SkipHeaderBytes, m_Endian); break; case SIMPL::NumericTypes::Type::Int16: - err = readBinaryFile(this); + err = readBinaryFile(dataArray.get(), inputFile, m_SkipHeaderBytes, m_Endian); break; case SIMPL::NumericTypes::Type::UInt16: - err = readBinaryFile(this); + err = readBinaryFile(dataArray.get(), inputFile, m_SkipHeaderBytes, m_Endian); break; case SIMPL::NumericTypes::Type::Int32: - err = readBinaryFile(this); + err = readBinaryFile(dataArray.get(), inputFile, m_SkipHeaderBytes, m_Endian); break; case SIMPL::NumericTypes::Type::UInt32: - err = readBinaryFile(this); + err = readBinaryFile(dataArray.get(), inputFile, m_SkipHeaderBytes, m_Endian); break; case SIMPL::NumericTypes::Type::Int64: - err = readBinaryFile(this); + err = readBinaryFile(dataArray.get(), inputFile, m_SkipHeaderBytes, m_Endian); break; case SIMPL::NumericTypes::Type::UInt64: - err = readBinaryFile(this); + err = readBinaryFile(dataArray.get(), inputFile, m_SkipHeaderBytes, m_Endian); break; case SIMPL::NumericTypes::Type::Float: - err = readBinaryFile(this); + err = readBinaryFile(dataArray.get(), inputFile, m_SkipHeaderBytes, m_Endian); break; case SIMPL::NumericTypes::Type::Double: - err = readBinaryFile(this); + err = readBinaryFile(dataArray.get(), inputFile, m_SkipHeaderBytes, m_Endian); break; case SIMPL::NumericTypes::Type::Bool: - err = readBinaryFile(this); + err = readBinaryFile(dataArray.get(), inputFile, m_SkipHeaderBytes, m_Endian); break; case SIMPL::NumericTypes::Type::SizeT: - err = readBinaryFile(this); + err = readBinaryFile(dataArray.get(), inputFile, m_SkipHeaderBytes, m_Endian); break; case SIMPL::NumericTypes::Type::UnknownNumType: break; @@ -428,28 +405,26 @@ void RawBinaryReader::execute() if(err == RBR_FILE_NOT_OPEN) { - setErrorCondition(RBR_FILE_NOT_OPEN); - notifyErrorMessage(getHumanLabel(), "Unable to open the specified file", getErrorCondition()); + setErrorCondition(RBR_FILE_NOT_OPEN, "Unable to open the specified file"); } else if(err == RBR_FILE_TOO_SMALL) { - setErrorCondition(RBR_FILE_TOO_SMALL); - notifyErrorMessage(getHumanLabel(), "The file size is smaller than the allocated size", getErrorCondition()); + setErrorCondition(RBR_FILE_TOO_SMALL, "The file size is smaller than the allocated size"); } else if(err == RBR_FILE_TOO_BIG) { - setWarningCondition(RBR_FILE_TOO_BIG); - notifyWarningMessage(getHumanLabel(), "The file size is larger than the allocated size", getWarningCondition()); + setWarningCondition(RBR_FILE_TOO_BIG, "The file size is larger than the allocated size"); } else if(err == RBR_READ_EOF) { - setErrorCondition(RBR_READ_EOF); - notifyErrorMessage(getHumanLabel(), "RawBinaryReader read past the end of the specified file", getErrorCondition()); + setErrorCondition(RBR_READ_EOF, "RawBinaryReader read past the end of the specified file"); + } + else if(err == RBR_DA_NULL) + { + setErrorCondition(RBR_DA_NULL, "Failed DataArray cast"); } } -// ----------------------------------------------------------------------------- -// // ----------------------------------------------------------------------------- AbstractFilter::Pointer RawBinaryReader::newFilterInstance(bool copyFilterParameters) const { @@ -462,25 +437,19 @@ AbstractFilter::Pointer RawBinaryReader::newFilterInstance(bool copyFilterParame } // ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -const QString RawBinaryReader::getCompiledLibraryName() const +QString RawBinaryReader::getCompiledLibraryName() const { return Core::CoreBaseName; } // ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -const QString RawBinaryReader::getBrandingString() const +QString RawBinaryReader::getBrandingString() const { return "SIMPLib Core Filter"; } // ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -const QString RawBinaryReader::getFilterVersion() const +QString RawBinaryReader::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -489,33 +458,126 @@ const QString RawBinaryReader::getFilterVersion() const } // ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -const QString RawBinaryReader::getGroupName() const +QString RawBinaryReader::getGroupName() const { return SIMPL::FilterGroups::IOFilters; } // ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -const QUuid RawBinaryReader::getUuid() +QUuid RawBinaryReader::getUuid() const { return QUuid("{0791f556-3d73-5b1e-b275-db3f7bb6850d}"); } // ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -const QString RawBinaryReader::getSubGroupName() const +QString RawBinaryReader::getSubGroupName() const { return SIMPL::FilterSubGroups::InputFilters; } // ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -const QString RawBinaryReader::getHumanLabel() const +QString RawBinaryReader::getHumanLabel() const { return "Raw Binary Importer"; } + +// ----------------------------------------------------------------------------- +RawBinaryReader::Pointer RawBinaryReader::NullPointer() +{ + return nullptr; +} + +// ----------------------------------------------------------------------------- +RawBinaryReader::Pointer RawBinaryReader::New() +{ + struct make_shared_enabler : public RawBinaryReader + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString RawBinaryReader::getNameOfClass() const +{ + return ClassName(); +} + +// ----------------------------------------------------------------------------- +QString RawBinaryReader::ClassName() +{ + return "RawBinaryReader"; +} + +// ----------------------------------------------------------------------------- +void RawBinaryReader::setCreatedAttributeArrayPath(const DataArrayPath& value) +{ + m_CreatedAttributeArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath RawBinaryReader::getCreatedAttributeArrayPath() const +{ + return m_CreatedAttributeArrayPath; +} + +// ----------------------------------------------------------------------------- +void RawBinaryReader::setScalarType(SIMPL::NumericTypes::Type value) +{ + m_ScalarType = value; +} + +// ----------------------------------------------------------------------------- +SIMPL::NumericTypes::Type RawBinaryReader::getScalarType() const +{ + return m_ScalarType; +} + +// ----------------------------------------------------------------------------- +void RawBinaryReader::setEndian(int32_t value) +{ + m_Endian = value; +} + +// ----------------------------------------------------------------------------- +int32_t RawBinaryReader::getEndian() const +{ + return m_Endian; +} + +// ----------------------------------------------------------------------------- +void RawBinaryReader::setNumberOfComponents(int32_t value) +{ + m_NumberOfComponents = value; +} + +// ----------------------------------------------------------------------------- +int32_t RawBinaryReader::getNumberOfComponents() const +{ + return m_NumberOfComponents; +} + +// ----------------------------------------------------------------------------- +void RawBinaryReader::setSkipHeaderBytes(uint64_t value) +{ + m_SkipHeaderBytes = value; +} + +// ----------------------------------------------------------------------------- +uint64_t RawBinaryReader::getSkipHeaderBytes() const +{ + return m_SkipHeaderBytes; +} + +// ----------------------------------------------------------------------------- +void RawBinaryReader::setInputFile(const QString& value) +{ + m_InputFile = value; +} + +// ----------------------------------------------------------------------------- +QString RawBinaryReader::getInputFile() const +{ + return m_InputFile; +} diff --git a/Source/SIMPLib/CoreFilters/RawBinaryReader.h b/Source/SIMPLib/CoreFilters/RawBinaryReader.h old mode 100755 new mode 100644 index aa8d58e8e3..6c7f97888a --- a/Source/SIMPLib/CoreFilters/RawBinaryReader.h +++ b/Source/SIMPLib/CoreFilters/RawBinaryReader.h @@ -1,194 +1,251 @@ /* ============================================================================ -* Copyright (c) 2009-2019 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* United States Air Force Prime Contract FA8650-15-D-5231 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +class IDataArray; +using IDataArrayShPtrType = std::shared_ptr; /** * @brief The RawBinaryReader class. See [Filter documentation](@ref rawbinaryreader) for details. */ class SIMPLib_EXPORT RawBinaryReader : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(RawBinaryReader SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath CreatedAttributeArrayPath READ getCreatedAttributeArrayPath WRITE setCreatedAttributeArrayPath) - PYB11_PROPERTY(SIMPL::NumericTypes::Type ScalarType READ getScalarType WRITE setScalarType) - PYB11_PROPERTY(int Endian READ getEndian WRITE setEndian) - PYB11_PROPERTY(int NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) - PYB11_PROPERTY(uint64_t SkipHeaderBytes READ getSkipHeaderBytes WRITE setSkipHeaderBytes) - PYB11_PROPERTY(QString InputFile READ getInputFile WRITE setInputFile) - - public: - SIMPL_SHARED_POINTERS(RawBinaryReader) - SIMPL_FILTER_NEW_MACRO(RawBinaryReader) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(RawBinaryReader, AbstractFilter) - - ~RawBinaryReader() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, CreatedAttributeArrayPath) - Q_PROPERTY(DataArrayPath CreatedAttributeArrayPath READ getCreatedAttributeArrayPath WRITE setCreatedAttributeArrayPath) - - SIMPL_FILTER_PARAMETER(SIMPL::NumericTypes::Type, ScalarType) - Q_PROPERTY(SIMPL::NumericTypes::Type ScalarType READ getScalarType WRITE setScalarType) - - SIMPL_FILTER_PARAMETER(int, Endian) - Q_PROPERTY(int Endian READ getEndian WRITE setEndian) - - SIMPL_FILTER_PARAMETER(int, NumberOfComponents) - Q_PROPERTY(int NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) - - SIMPL_FILTER_PARAMETER(uint64_t, SkipHeaderBytes) - Q_PROPERTY(uint64_t SkipHeaderBytes READ getSkipHeaderBytes WRITE setSkipHeaderBytes) - - SIMPL_FILTER_PARAMETER(QString, InputFile) - Q_PROPERTY(QString InputFile READ getInputFile WRITE setInputFile) - - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - RawBinaryReader(); - - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - IDataArray::Pointer m_Array; - - public: - RawBinaryReader(const RawBinaryReader&) = delete; // Copy Constructor Not Implemented - RawBinaryReader(RawBinaryReader&&) = delete; // Move Constructor Not Implemented - RawBinaryReader& operator=(const RawBinaryReader&) = delete; // Copy Assignment Not Implemented - RawBinaryReader& operator=(RawBinaryReader&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(RawBinaryReader SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(RawBinaryReader) + PYB11_FILTER_NEW_MACRO(RawBinaryReader) + PYB11_PROPERTY(DataArrayPath CreatedAttributeArrayPath READ getCreatedAttributeArrayPath WRITE setCreatedAttributeArrayPath) + PYB11_PROPERTY(SIMPL::NumericTypes::Type ScalarType READ getScalarType WRITE setScalarType) + PYB11_PROPERTY(int32_t Endian READ getEndian WRITE setEndian) + PYB11_PROPERTY(int32_t NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) + PYB11_PROPERTY(uint64_t SkipHeaderBytes READ getSkipHeaderBytes WRITE setSkipHeaderBytes) + PYB11_PROPERTY(QString InputFile READ getInputFile WRITE setInputFile) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = RawBinaryReader; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for RawBinaryReader + */ + QString getNameOfClass() const override; + + /** + * @brief Returns the name of the class for RawBinaryReader + */ + static QString ClassName(); + + ~RawBinaryReader() override; + + /** + * @brief Setter property for CreatedAttributeArrayPath + */ + void setCreatedAttributeArrayPath(const DataArrayPath& value); + + /** + * @brief Getter property for CreatedAttributeArrayPath + * @return Value of CreatedAttributeArrayPath + */ + DataArrayPath getCreatedAttributeArrayPath() const; + + Q_PROPERTY(DataArrayPath CreatedAttributeArrayPath READ getCreatedAttributeArrayPath WRITE setCreatedAttributeArrayPath) + + /** + * @brief Setter property for ScalarType + */ + void setScalarType(SIMPL::NumericTypes::Type value); + + /** + * @brief Getter property for ScalarType + * @return Value of ScalarType + */ + SIMPL::NumericTypes::Type getScalarType() const; + + Q_PROPERTY(SIMPL::NumericTypes::Type ScalarType READ getScalarType WRITE setScalarType) + + /** + * @brief Setter property for Endian + */ + void setEndian(int32_t value); + + /** + * @brief Getter property for Endian + * @return Value of Endian + */ + int32_t getEndian() const; + + Q_PROPERTY(int32_t Endian READ getEndian WRITE setEndian) + + /** + * @brief Setter property for NumberOfComponents + */ + void setNumberOfComponents(int32_t value); + + /** + * @brief Getter property for NumberOfComponents + * @return Value of NumberOfComponents + */ + int32_t getNumberOfComponents() const; + + Q_PROPERTY(int32_t NumberOfComponents READ getNumberOfComponents WRITE setNumberOfComponents) + + /** + * @brief Setter property for SkipHeaderBytes + */ + void setSkipHeaderBytes(uint64_t value); + + /** + * @brief Getter property for SkipHeaderBytes + * @return Value of SkipHeaderBytes + */ + uint64_t getSkipHeaderBytes() const; + + Q_PROPERTY(uint64_t SkipHeaderBytes READ getSkipHeaderBytes WRITE setSkipHeaderBytes) + + /** + * @brief Setter property for InputFile + */ + void setInputFile(const QString& value); + + /** + * @brief Getter property for InputFile + * @return Value of InputFile + */ + QString getInputFile() const; + + Q_PROPERTY(QString InputFile READ getInputFile WRITE setInputFile) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + RawBinaryReader(); + + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + +private: + DataArrayPath m_CreatedAttributeArrayPath = {"", "", ""}; + SIMPL::NumericTypes::Type m_ScalarType = {SIMPL::NumericTypes::Type::Int8}; + int32_t m_Endian = {0}; + int32_t m_NumberOfComponents = {0}; + uint64_t m_SkipHeaderBytes = {0}; + QString m_InputFile = {""}; + +public: + RawBinaryReader(const RawBinaryReader&) = delete; // Copy Constructor Not Implemented + RawBinaryReader(RawBinaryReader&&) = delete; // Move Constructor Not Implemented + RawBinaryReader& operator=(const RawBinaryReader&) = delete; // Copy Assignment Not Implemented + RawBinaryReader& operator=(RawBinaryReader&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/ReadASCIIData.cpp b/Source/SIMPLib/CoreFilters/ReadASCIIData.cpp index 7c96c30d34..984023e135 100644 --- a/Source/SIMPLib/CoreFilters/ReadASCIIData.cpp +++ b/Source/SIMPLib/CoreFilters/ReadASCIIData.cpp @@ -5,21 +5,24 @@ #include "ReadASCIIData.h" #include +#include +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataArrays/StringDataArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.h" -#include "SIMPLib/Utilities/StringOperations.h" #include "SIMPLib/Utilities/SIMPLDataPathValidator.h" - -#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Utilities/StringOperations.h" #include "SIMPLib/CoreFilters/util/AbstractDataParser.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" -namespace { - const QString k_Skip("Skip"); +namespace +{ +const QString k_Skip("Skip"); } // ----------------------------------------------------------------------------- @@ -27,7 +30,6 @@ namespace { // ----------------------------------------------------------------------------- ReadASCIIData::ReadASCIIData() = default; - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -38,9 +40,9 @@ ReadASCIIData::~ReadASCIIData() = default; // ----------------------------------------------------------------------------- void ReadASCIIData::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(ReadASCIIDataFilterParameter::New("ASCII Wizard Data", "WizardData", "WizardData", FilterParameter::Parameter)); + parameters.push_back(ReadASCIIDataFilterParameter::Create("ASCII Wizard Data", "WizardData", "WizardData", FilterParameter::Category::Parameter)); setFilterParameters(parameters); } @@ -58,7 +60,7 @@ void ReadASCIIData::readFilterParameters(AbstractFilterParametersReader* reader, QString delimitersStr = reader->readString(prefix + "Delimiters", ""); QList delimiters; - for(auto && i : delimitersStr) + for(auto&& i : delimitersStr) { delimiters.push_back(i.toLatin1()); } @@ -73,7 +75,7 @@ void ReadASCIIData::readFilterParameters(AbstractFilterParametersReader* reader, data.automaticAM = reader->readValue(prefix + "AutomaticAM", false); QVector tmpVec; - QVector tDims; + std::vector tDims; tmpVec = reader->readArray(prefix + "TupleDims", QVector()); for(uint64_t i : tmpVec) { @@ -142,7 +144,7 @@ void ReadASCIIData::readFilterParameters(QJsonObject& obj) { QJsonArray jsonArray = obj[prefix + "TupleDims"].toArray(); - QVector tupleDims; + std::vector tupleDims; for(int i = 0, total = jsonArray.size(); i < total; ++i) { tupleDims.push_back(static_cast(jsonArray[i].toInt())); @@ -219,7 +221,7 @@ void ReadASCIIData::writeFilterParameters(QJsonObject& obj) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ReadASCIIData::renameDataArrayPath(DataArrayPath::RenameType renamePath) +void ReadASCIIData::renameDataArrayPath(const DataArrayPath::RenameType& renamePath) { getWizardData().updateDataArrayPath(renamePath); @@ -239,16 +241,15 @@ void ReadASCIIData::initialize() // ----------------------------------------------------------------------------- void ReadASCIIData::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); m_ASCIIArrayMap.clear(); ASCIIWizardData wizardData = getWizardData(); if(wizardData.isEmpty()) { QString ss = "A file has not been chosen to import. Please pick a file to import."; - setErrorCondition(EMPTY_FILE); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(EMPTY_FILE, ss); return; } @@ -257,26 +258,22 @@ void ReadASCIIData::dataCheck() QStringList dataTypes = wizardData.dataTypes; bool automaticAM = wizardData.automaticAM; DataArrayPath selectedPath = wizardData.selectedPath; - QVector tDims = wizardData.tupleDims; - QVector cDims(1, 1); + std::vector tDims = wizardData.tupleDims; + std::vector cDims(1, 1); QFileInfo fi(inputFilePath); if(inputFilePath.isEmpty()) { QString ss = QObject::tr("The input file must be set"); - setErrorCondition(-387); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-387, ss); } - SIMPLDataPathValidator* validator = SIMPLDataPathValidator::Instance(); - inputFilePath = validator->convertToAbsolutePath(inputFilePath); fi.setFile(inputFilePath); if(!fi.exists()) { - QString ss = QObject::tr("The input file does not exist"); - setErrorCondition(-388); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + QString ss = QObject::tr("The input file does not exist: '%1'").arg(inputFilePath); + setErrorCondition(-388, ss); } if(!automaticAM) @@ -285,8 +282,7 @@ void ReadASCIIData::dataCheck() if(nullptr == am.get()) { QString ss = "The attribute matrix input is empty. Please select an attribute matrix."; - setErrorCondition(EMPTY_ATTR_MATRIX); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(EMPTY_ATTR_MATRIX, ss); return; } @@ -300,8 +296,13 @@ void ReadASCIIData::dataCheck() if(amArrayName == headerName) { QString ss = "The header name \"" + headerName + "\" matches an array name that already exists in the selected attribute matrix."; - setErrorCondition(DUPLICATE_NAMES); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(DUPLICATE_NAMES, ss); + return; + } + if(headerName.contains("&") || headerName.contains(":") || headerName.contains("/") || headerName.contains("\\") ) + { + QString ss = "The header name \"" + headerName + "\" contains a character that will cause problems. Do Not use '&',':', '/' or '\\' in the header names."; + setErrorCondition(ILLEGAL_NAMES, ss); return; } } @@ -317,8 +318,7 @@ void ReadASCIIData::dataCheck() // QTextStream out(&ss); // out << selectedPath.getAttributeMatrixName() << " tuple dims: " << am->getTupleDimensions().at(0) << "\n"; // out << fi.fileName() << "tuple dims: " << tDims[0] << "\n"; - // setErrorCondition(INCONSISTENT_TUPLES); - // notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + // setErrorCondition(INCONSISTENT_TUPLES, ss); // return; // } @@ -341,7 +341,7 @@ void ReadASCIIData::dataCheck() for(int i = 0; i < dataTypes.size(); i++) { QString dataType = dataTypes[i]; - if(dataType == ::k_Skip) + if(dataType == ::k_Skip) { continue; } @@ -352,93 +352,78 @@ void ReadASCIIData::dataCheck() if(dataType == SIMPL::TypeNames::Double) { - DoubleArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + DoubleArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::Float) { - FloatArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + FloatArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::Int8) { - Int8ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + Int8ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::Int16) { - Int16ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + Int16ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::Int32) { - Int32ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + Int32ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::Int64) { - Int64ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + Int64ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::UInt8) { - UInt8ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + UInt8ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::UInt16) { - UInt16ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + UInt16ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::UInt32) { - UInt32ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + UInt32ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::UInt64) { - UInt64ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims); + UInt64ArrayType::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, 0, cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else if(dataType == SIMPL::TypeNames::String) { - StringDataArray::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, "", cDims); + StringDataArray::Pointer ptr = getDataContainerArray()->createNonPrereqArrayFromPath(this, arrayPath, "", cDims, ""); m_ASCIIArrayMap.insert(i, ptr); } else { QString ss = "The data type that was chosen for column number " + QString::number(i + 1) + " is not a valid data array type."; - setErrorCondition(INVALID_ARRAY_TYPE); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(INVALID_ARRAY_TYPE, ss); return; } } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void ReadASCIIData::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ReadASCIIData::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -528,9 +513,6 @@ void ReadASCIIData::execute() int insertIndex = 0; - SIMPLDataPathValidator* validator = SIMPLDataPathValidator::Instance(); - inputFilePath = validator->convertToAbsolutePath(inputFilePath); - QFile inputFile(inputFilePath); if(inputFile.open(QIODevice::ReadOnly)) { @@ -557,8 +539,7 @@ void ReadASCIIData::execute() out << "Expecting " << dataTypes.size() << " but found " << tokens.size() << "\n"; out << "Input line was:\n"; out << line; - setErrorCondition(INCONSISTENT_COLS); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(INCONSISTENT_COLS, ss); return; } @@ -572,21 +553,21 @@ void ReadASCIIData::execute() { QString errorMessage = obj.errorMessage; QString ss = errorMessage + "(line " + QString::number(lineNum) + ", column " + QString::number(index) + ")."; - setErrorCondition(CONVERSION_FAILURE); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(CONVERSION_FAILURE, ss); return; } } - if((static_cast(lineNum) / numTuples) * 100.0f > threshold) + const float percentCompleted = (static_cast(lineNum) / numTuples) * 100.0f; + if(percentCompleted > threshold) { // Print the status of the import - QString ss = QObject::tr("Importing ASCII Data || %1% Complete").arg((static_cast(lineNum) / numTuples) * 100.0f, 0, 'f', 0); - notifyStatusMessage(getMessagePrefix(), getHumanLabel(), ss); + QString ss = QObject::tr("Importing ASCII Data || %1% Complete").arg(static_cast(percentCompleted), 0, 'f', 0); + notifyStatusMessage(ss); threshold = threshold + 5.0f; - if(threshold < (static_cast(lineNum) / numTuples) * 100.0f) + if(threshold < percentCompleted) { - threshold = (static_cast(lineNum) / numTuples) * 100.0f; + threshold = percentCompleted; } } @@ -599,7 +580,6 @@ void ReadASCIIData::execute() } inputFile.close(); } - } // ----------------------------------------------------------------------------- @@ -618,7 +598,7 @@ AbstractFilter::Pointer ReadASCIIData::newFilterInstance(bool copyFilterParamete // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ReadASCIIData::getCompiledLibraryName() const +QString ReadASCIIData::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -626,7 +606,7 @@ const QString ReadASCIIData::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ReadASCIIData::getBrandingString() const +QString ReadASCIIData::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -634,7 +614,7 @@ const QString ReadASCIIData::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ReadASCIIData::getFilterVersion() const +QString ReadASCIIData::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -645,7 +625,7 @@ const QString ReadASCIIData::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ReadASCIIData::getGroupName() const +QString ReadASCIIData::getGroupName() const { return SIMPL::FilterGroups::IOFilters; } @@ -653,7 +633,7 @@ const QString ReadASCIIData::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid ReadASCIIData::getUuid() +QUuid ReadASCIIData::getUuid() const { return QUuid("{bdb978bc-96bf-5498-972c-b509c38b8d50}"); } @@ -661,7 +641,7 @@ const QUuid ReadASCIIData::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ReadASCIIData::getSubGroupName() const +QString ReadASCIIData::getSubGroupName() const { return SIMPL::FilterSubGroups::InputFilters; } @@ -669,7 +649,48 @@ const QString ReadASCIIData::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ReadASCIIData::getHumanLabel() const +QString ReadASCIIData::getHumanLabel() const { return "Import ASCII Data"; } + +// ----------------------------------------------------------------------------- +ReadASCIIData::Pointer ReadASCIIData::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr ReadASCIIData::New() +{ + struct make_shared_enabler : public ReadASCIIData + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString ReadASCIIData::getNameOfClass() const +{ + return QString("ReadASCIIData"); +} + +// ----------------------------------------------------------------------------- +QString ReadASCIIData::ClassName() +{ + return QString("ReadASCIIData"); +} + +// ----------------------------------------------------------------------------- +void ReadASCIIData::setWizardData(const ASCIIWizardData& value) +{ + m_WizardData = value; +} + +// ----------------------------------------------------------------------------- +ASCIIWizardData ReadASCIIData::getWizardData() const +{ + return m_WizardData; +} diff --git a/Source/SIMPLib/CoreFilters/ReadASCIIData.h b/Source/SIMPLib/CoreFilters/ReadASCIIData.h index 624c0c7480..4b32931544 100644 --- a/Source/SIMPLib/CoreFilters/ReadASCIIData.h +++ b/Source/SIMPLib/CoreFilters/ReadASCIIData.h @@ -1,14 +1,46 @@ -/* - * Your License or Copyright can go here - */ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-10-D-5210 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/SIMPLib.h" +#include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/CoreFilters/util/ASCIIWizardData.hpp" +#include "SIMPLib/Filtering/AbstractFilter.h" + +class IDataArray; +using IDataArrayShPtrType = std::shared_ptr; /** * @brief The ReadASCIIData class. See [Filter documentation](@ref ReadASCIIData) for details. @@ -16,17 +48,56 @@ class SIMPLib_EXPORT ReadASCIIData : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(ReadASCIIData SUPERCLASS AbstractFilter) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ReadASCIIData SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(ReadASCIIData) + PYB11_FILTER_NEW_MACRO(ReadASCIIData) PYB11_PROPERTY(ASCIIWizardData WizardData READ getWizardData WRITE setWizardData) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = ReadASCIIData; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); - public: - SIMPL_SHARED_POINTERS(ReadASCIIData) - SIMPL_FILTER_NEW_MACRO(ReadASCIIData) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ReadASCIIData, AbstractFilter) + /** + * @brief Returns the name of the class for ReadASCIIData + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ReadASCIIData + */ + static QString ClassName(); + + ~ReadASCIIData() override; - ~ReadASCIIData() override; + /** + * @brief Setter property for WizardData + */ + void setWizardData(const ASCIIWizardData& value); + /** + * @brief Getter property for WizardData + * @return Value of WizardData + */ + ASCIIWizardData getWizardData() const; - SIMPL_FILTER_PARAMETER(ASCIIWizardData, WizardData) Q_PROPERTY(ASCIIWizardData WizardData READ getWizardData WRITE setWizardData) enum ErrorCodes @@ -37,136 +108,109 @@ class SIMPLib_EXPORT ReadASCIIData : public AbstractFilter INCONSISTENT_COLS = -103, CONVERSION_FAILURE = -104, DUPLICATE_NAMES = -105, - INVALID_ARRAY_TYPE = -106 + INVALID_ARRAY_TYPE = -106, + ILLEGAL_NAMES = -107 }; - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief readFilterParametersFromJson Reads the filter parameters from a file - * @param reader Reader that is used to read the parameters from a file - */ + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief readFilterParametersFromJson Reads the filter parameters from a file + * @param reader Reader that is used to read the parameters from a file + */ void readFilterParameters(QJsonObject& obj) override; /** - * @brief writeFilterParametersToJson Writes the filter parameters to a file - * @param root The root json object - */ + * @brief writeFilterParametersToJson Writes the filter parameters to a file + * @param root The root json object + */ void writeFilterParameters(QJsonObject& obj) const override; - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - /** - * @brief Updates any DataArrayPath properties from the old path to a new path - * For DataArrayPaths longer than the given path, only the specified values are modified - * @param renamePath - */ - void renameDataArrayPath(DataArrayPath::RenameType renamePath) override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - ReadASCIIData(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - QMap m_ASCIIArrayMap; - - public: - ReadASCIIData(const ReadASCIIData&) = delete; // Copy Constructor Not Implemented - ReadASCIIData(ReadASCIIData&&) = delete; // Move Constructor Not Implemented - ReadASCIIData& operator=(const ReadASCIIData&) = delete; // Copy Assignment Not Implemented - ReadASCIIData& operator=(ReadASCIIData&&) = delete; // Move Assignment Not Implemented -}; + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + + /** + * @brief Updates any DataArrayPath properties from the old path to a new path + * For DataArrayPaths longer than the given path, only the specified values are modified + * @param renamePath + */ + void renameDataArrayPath(const DataArrayPath::RenameType& renamePath) override; + +protected: + ReadASCIIData(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); +private: + ASCIIWizardData m_WizardData = {}; + + QMap m_ASCIIArrayMap; + +public: + ReadASCIIData(const ReadASCIIData&) = delete; // Copy Constructor Not Implemented + ReadASCIIData(ReadASCIIData&&) = delete; // Move Constructor Not Implemented + ReadASCIIData& operator=(const ReadASCIIData&) = delete; // Copy Assignment Not Implemented + ReadASCIIData& operator=(ReadASCIIData&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/CoreFilters/RemoveArrays.cpp b/Source/SIMPLib/CoreFilters/RemoveArrays.cpp index dceccb2d0c..dd1335de87 100644 --- a/Source/SIMPLib/CoreFilters/RemoveArrays.cpp +++ b/Source/SIMPLib/CoreFilters/RemoveArrays.cpp @@ -1,44 +1,47 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "RemoveArrays.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- // @@ -55,7 +58,7 @@ RemoveArrays::~RemoveArrays() = default; // ----------------------------------------------------------------------------- void RemoveArrays::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { DataContainerArrayProxyFilterParameter::Pointer parameter = DataContainerArrayProxyFilterParameter::New(); @@ -65,7 +68,7 @@ void RemoveArrays::setupFilterParameters() parameter->setGetterCallback(SIMPL_BIND_GETTER(RemoveArrays, this, DataArraysToRemove)); parameter->setDefaultFlagValue(Qt::Unchecked); - parameter->setCategory(FilterParameter::RequiredArray); + parameter->setCategory(FilterParameter::Category::RequiredArray); parameters.push_back(parameter); } @@ -95,8 +98,8 @@ void RemoveArrays::initialize() // ----------------------------------------------------------------------------- void RemoveArrays::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); markSelectionsForDeletion(getDataContainerArray().get(), Qt::Checked); @@ -104,19 +107,6 @@ void RemoveArrays::dataCheck() removeSelectionsFromDataContainerArray(getDataContainerArray().get(), Qt::Checked); } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void RemoveArrays::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -129,6 +119,8 @@ void RemoveArrays::markSelectionsForDeletion(DataContainerArray* dca, Qt::CheckS // ----------------------------------------------------------------------------- void RemoveArrays::removeSelectionsFromDataContainerArray(DataContainerArray* dca, Qt::CheckState state) { + m_RemovedPaths.clear(); + // Loop over the data containers until we find the proper data container QList containers = m_DataArraysToRemove.getDataContainers().values(); QMutableListIterator containerIter(containers); @@ -138,7 +130,7 @@ void RemoveArrays::removeSelectionsFromDataContainerArray(DataContainerArray* dc DataContainerProxy dcProxy = containerIter.next(); dcList.push_back(dcProxy.getName()); DataContainer::Pointer dcItem = dca->getPrereqDataContainer(this, dcProxy.getName()); - if(getErrorCondition() < 0 || dcItem.get() == nullptr) + if(getErrorCode() < 0 || dcItem.get() == nullptr) { continue; } @@ -147,8 +139,9 @@ void RemoveArrays::removeSelectionsFromDataContainerArray(DataContainerArray* dc // the DataContainerArray if(dcProxy.getFlag() == state) { - dca->removeDataContainer(dcProxy.getName()); // Remove it out - continue; // Continue to the next DataContainer + auto dc = dca->removeDataContainer(dcProxy.getName()); // Remove it out + m_RemovedPaths.merge(dc->getDescendantPaths()); + continue; // Continue to the next DataContainer } QMap attrMats = dcProxy.getAttributeMatricies(); QMutableMapIterator attrMatsIter(attrMats); @@ -160,16 +153,16 @@ void RemoveArrays::removeSelectionsFromDataContainerArray(DataContainerArray* dc // assert(amItem.get() != nullptr); if(amItem.get() == nullptr) { - setErrorCondition(-11008); QString ss = QObject::tr("The AttributeMatrix '%1' could not be removed because it was not found in DataContainer '%2'").arg(amName).arg(dcProxy.getName()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11008, ss); continue; } AttributeMatrixProxy attrProxy = attrMatsIter.value(); // Check to see if this AttributeMatrix is checked, if not then remove it from the DataContainer and go to the next loop if(attrProxy.getFlag() == state) { - dcItem->removeAttributeMatrix(amName); + auto am = dcItem->removeAttributeMatrix(amName); + m_RemovedPaths.merge(am->getDescendantPaths()); continue; } // We found the selected AttributeMatrix, so loop over this attribute matrix arrays and populate the list widget @@ -182,16 +175,16 @@ void RemoveArrays::removeSelectionsFromDataContainerArray(DataContainerArray* dc IDataArray::Pointer daItem = amItem->getAttributeArray(daName); if(daItem.get() == nullptr) { - setWarningCondition(-11009); QString ss = QObject::tr("%1/%2/%3 was not found. This could be due to another filter removing the array.").arg(dcProxy.getName()).arg(amName).arg(daName); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-11009, ss); continue; } DataArrayProxy daProxy = dataArraysIter.value(); // Check to see if the user selected this item if(daProxy.getFlag() == state) { - amItem->removeAttributeArray(daName); + auto da = amItem->removeAttributeArray(daName); + m_RemovedPaths.push_back(da->getDataArrayPath()); continue; } } @@ -199,20 +192,27 @@ void RemoveArrays::removeSelectionsFromDataContainerArray(DataContainerArray* dc } } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::list RemoveArrays::getDeletedPaths() +{ + return m_RemovedPaths; +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void RemoveArrays::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); // Simply running the preflight will do what we need it to. dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - } // ----------------------------------------------------------------------------- @@ -231,7 +231,7 @@ AbstractFilter::Pointer RemoveArrays::newFilterInstance(bool copyFilterParameter // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RemoveArrays::getCompiledLibraryName() const +QString RemoveArrays::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -239,7 +239,7 @@ const QString RemoveArrays::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RemoveArrays::getBrandingString() const +QString RemoveArrays::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -247,7 +247,7 @@ const QString RemoveArrays::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RemoveArrays::getFilterVersion() const +QString RemoveArrays::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -258,7 +258,7 @@ const QString RemoveArrays::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RemoveArrays::getGroupName() const +QString RemoveArrays::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -266,7 +266,7 @@ const QString RemoveArrays::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid RemoveArrays::getUuid() +QUuid RemoveArrays::getUuid() const { return QUuid("{7b1c8f46-90dd-584a-b3ba-34e16958a7d0}"); } @@ -274,7 +274,7 @@ const QUuid RemoveArrays::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RemoveArrays::getSubGroupName() const +QString RemoveArrays::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -282,7 +282,48 @@ const QString RemoveArrays::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RemoveArrays::getHumanLabel() const +QString RemoveArrays::getHumanLabel() const { return "Delete Data"; } + +// ----------------------------------------------------------------------------- +RemoveArrays::Pointer RemoveArrays::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr RemoveArrays::New() +{ + struct make_shared_enabler : public RemoveArrays + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString RemoveArrays::getNameOfClass() const +{ + return QString("RemoveArrays"); +} + +// ----------------------------------------------------------------------------- +QString RemoveArrays::ClassName() +{ + return QString("RemoveArrays"); +} + +// ----------------------------------------------------------------------------- +void RemoveArrays::setDataArraysToRemove(const DataContainerArrayProxy& value) +{ + m_DataArraysToRemove = value; +} + +// ----------------------------------------------------------------------------- +DataContainerArrayProxy RemoveArrays::getDataArraysToRemove() const +{ + return m_DataArraysToRemove; +} diff --git a/Source/SIMPLib/CoreFilters/RemoveArrays.h b/Source/SIMPLib/CoreFilters/RemoveArrays.h index 4cbf883955..c746751a37 100644 --- a/Source/SIMPLib/CoreFilters/RemoveArrays.h +++ b/Source/SIMPLib/CoreFilters/RemoveArrays.h @@ -1,183 +1,194 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" #include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/SIMPLib.h" /** * @brief The RemoveArrays class. See [Filter documentation](@ref removearrays) for details. */ class SIMPLib_EXPORT RemoveArrays : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(RemoveArrays SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataContainerArrayProxy DataArraysToRemove READ getDataArraysToRemove WRITE setDataArraysToRemove) - - public: - SIMPL_SHARED_POINTERS(RemoveArrays) - SIMPL_FILTER_NEW_MACRO(RemoveArrays) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(RemoveArrays, AbstractFilter) - - ~RemoveArrays() override; - - SIMPL_FILTER_PARAMETER(DataContainerArrayProxy, DataArraysToRemove) - Q_PROPERTY(DataContainerArrayProxy DataArraysToRemove READ getDataArraysToRemove WRITE setDataArraysToRemove) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - /** - * @brief removeSelectionsFromDataContainerArray Attempts to remove those DataContainers, AttributeMatrices, and DataArrays selected by the user. - * DataArray items that are flagged as selected by the user/programmer. - * @param dca DataContainerArray instance pointer - * @param state Flagged state of items in the DataContainerArray - */ - void removeSelectionsFromDataContainerArray(DataContainerArray* dca, Qt::CheckState state); - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - RemoveArrays(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - /** - * @brief markSelectionsForDeletion Marks the items in the data container array with checkstate 'state' for deletion - */ - void markSelectionsForDeletion(DataContainerArray* dca, Qt::CheckState state); - - public: - RemoveArrays(const RemoveArrays&) = delete; // Copy Constructor Not Implemented - RemoveArrays(RemoveArrays&&) = delete; // Move Constructor Not Implemented - RemoveArrays& operator=(const RemoveArrays&) = delete; // Copy Assignment Not Implemented - RemoveArrays& operator=(RemoveArrays&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(RemoveArrays SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(RemoveArrays) + PYB11_FILTER_NEW_MACRO(RemoveArrays) + PYB11_PROPERTY(DataContainerArrayProxy DataArraysToRemove READ getDataArraysToRemove WRITE setDataArraysToRemove) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = RemoveArrays; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for RemoveArrays + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for RemoveArrays + */ + static QString ClassName(); + + ~RemoveArrays() override; + + /** + * @brief Setter property for DataArraysToRemove + */ + void setDataArraysToRemove(const DataContainerArrayProxy& value); + /** + * @brief Getter property for DataArraysToRemove + * @return Value of DataArraysToRemove + */ + DataContainerArrayProxy getDataArraysToRemove() const; + + Q_PROPERTY(DataContainerArrayProxy DataArraysToRemove READ getDataArraysToRemove WRITE setDataArraysToRemove) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + + /** + * @brief removeSelectionsFromDataContainerArray Attempts to remove those DataContainers, AttributeMatrices, and DataArrays selected by the user. + * DataArray items that are flagged as selected by the user/programmer. + * @param dca DataContainerArray instance pointer + * @param state Flagged state of items in the DataContainerArray + */ + void removeSelectionsFromDataContainerArray(DataContainerArray* dca, Qt::CheckState state); + + /** + * @brief Returns the list of deleted data paths. + * @return + */ + std::list getDeletedPaths() override; + +protected: + RemoveArrays(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + + /** + * @brief markSelectionsForDeletion Marks the items in the data container array with checkstate 'state' for deletion + */ + void markSelectionsForDeletion(DataContainerArray* dca, Qt::CheckState state); + +public: + RemoveArrays(const RemoveArrays&) = delete; // Copy Constructor Not Implemented + RemoveArrays(RemoveArrays&&) = delete; // Move Constructor Not Implemented + RemoveArrays& operator=(const RemoveArrays&) = delete; // Copy Assignment Not Implemented + RemoveArrays& operator=(RemoveArrays&&) = delete; // Move Assignment Not Implemented + +private: + DataContainerArrayProxy m_DataArraysToRemove = {}; + + std::list m_RemovedPaths; }; - diff --git a/Source/SIMPLib/CoreFilters/RemoveComponentFromArray.cpp b/Source/SIMPLib/CoreFilters/RemoveComponentFromArray.cpp index ead5f4d1a9..81f0a4d283 100644 --- a/Source/SIMPLib/CoreFilters/RemoveComponentFromArray.cpp +++ b/Source/SIMPLib/CoreFilters/RemoveComponentFromArray.cpp @@ -1,60 +1,63 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "RemoveComponentFromArray.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/IntFilterParameter.h" #include "SIMPLib/FilterParameters/LinkedBooleanFilterParameter.h" +#include "SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.h" #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + NewDataArrayID = 1, + ReducedDataArrayID +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -RemoveComponentFromArray::RemoveComponentFromArray() -: m_SelectedArrayPath("", "", "") -, m_CompNumber(0) -, m_SaveRemovedComponent(false) -, m_NewArrayArrayName("") -{ -} +RemoveComponentFromArray::RemoveComponentFromArray() = default; // ----------------------------------------------------------------------------- // @@ -66,22 +69,24 @@ RemoveComponentFromArray::~RemoveComponentFromArray() = default; // ----------------------------------------------------------------------------- void RemoveComponentFromArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(SIMPL_NEW_INTEGER_FP("Component Number to Remove", CompNumber, FilterParameter::Parameter, RemoveComponentFromArray)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Component Number to Remove", CompNumber, FilterParameter::Category::Parameter, RemoveComponentFromArray)); DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Multicomponent Attribute Array", SelectedArrayPath, FilterParameter::RequiredArray, RemoveComponentFromArray, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Multicomponent Attribute Array", SelectedArrayPath, FilterParameter::Category::RequiredArray, RemoveComponentFromArray, req)); - parameters.push_back(SIMPL_NEW_STRING_FP("Removed Component Attribute Array", NewArrayArrayName, FilterParameter::CreatedArray, RemoveComponentFromArray)); + parameters.push_back( + SIMPL_NEW_DA_WITH_LINKED_AM_FP("Removed Component Attribute Array", NewArrayArrayName, SelectedArrayPath, SelectedArrayPath, FilterParameter::Category::CreatedArray, RemoveComponentFromArray)); - parameters.push_back(SIMPL_NEW_STRING_FP("Reduced Attribute Array", ReducedArrayArrayName, FilterParameter::CreatedArray, RemoveComponentFromArray)); + parameters.push_back( + SIMPL_NEW_DA_WITH_LINKED_AM_FP("Reduced Attribute Array", ReducedArrayArrayName, SelectedArrayPath, SelectedArrayPath, FilterParameter::Category::CreatedArray, RemoveComponentFromArray)); - QStringList linkedProps; + std::vector linkedProps; linkedProps.clear(); - linkedProps << "NewArrayArrayName"; - parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Save Removed Component in New Array", SaveRemovedComponent, FilterParameter::Parameter, RemoveComponentFromArray, linkedProps)); + linkedProps.push_back("NewArrayArrayName"); + parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Save Removed Component in New Array", SaveRemovedComponent, FilterParameter::Category::Parameter, RemoveComponentFromArray, linkedProps)); setFilterParameters(parameters); } @@ -112,83 +117,67 @@ void RemoveComponentFromArray::initialize() // ----------------------------------------------------------------------------- void RemoveComponentFromArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - m_InArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArrayPath()); + m_InArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArrayPath()); if(m_SaveRemovedComponent) { if(m_NewArrayArrayName.isEmpty()) { - setErrorCondition(-11001); - notifyErrorMessage(getHumanLabel(), "Removed Component array name must be set.", getErrorCondition()); + setErrorCondition(-11001, "Removed Component array name must be set."); return; } } if(m_ReducedArrayArrayName.isEmpty()) { - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), "Reduced array name must be set.", getErrorCondition()); + setErrorCondition(-11002, "Reduced array name must be set."); return; } - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } if(m_InArrayPtr.lock()->getNumberOfComponents() < 2) { - setErrorCondition(-11003); QString ss = QObject::tr("Selected array '%1' must have more than 1 component. The number of components is %2") .arg(getSelectedArrayPath().getDataArrayName()) .arg(m_InArrayPtr.lock()->getNumberOfComponents()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11003, ss); return; } if(m_CompNumber >= m_InArrayPtr.lock()->getNumberOfComponents()) { - setErrorCondition(-11004); QString ss = QObject::tr("Error removing component from DataArray '%3', Component to remove (%1) is greater than or equal to the number of components (%2) for array selected.") .arg(m_CompNumber) .arg(m_InArrayPtr.lock()->getNumberOfComponents()) .arg(getSelectedArrayPath().getDataArrayName()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11004, ss); return; } - QVector cDims(1, 1); + std::vector cDims(1, 1); if(m_SaveRemovedComponent) { DataArrayPath tempPath(getSelectedArrayPath().getDataContainerName(), getSelectedArrayPath().getAttributeMatrixName(), getNewArrayArrayName()); - m_NewArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, m_InArrayPtr.lock()); + m_NewArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath, cDims, m_InArrayPtr.lock(), NewDataArrayID); } - cDims[0] = m_InArrayPtr.lock()->getNumberOfComponents() - 1; + cDims[0] = static_cast(m_InArrayPtr.lock()->getNumberOfComponents()) - 1; DataArrayPath tempPath2(getSelectedArrayPath().getDataContainerName(), getSelectedArrayPath().getAttributeMatrixName(), getReducedArrayArrayName()); - m_ReducedArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath2, cDims, m_InArrayPtr.lock()); + m_ReducedArrayPtr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, tempPath2, cDims, m_InArrayPtr.lock(), ReducedDataArrayID); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void RemoveComponentFromArray::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -template void extractComponent(IDataArray::Pointer inputData, IDataArray::Pointer newData, IDataArray::Pointer reducedData, int compNumber) +template +void extractComponent(IDataArray::Pointer inputData, IDataArray::Pointer newData, IDataArray::Pointer reducedData, int compNumber) { typename DataArray::Pointer inputArrayPtr = std::dynamic_pointer_cast>(inputData); typename DataArray::Pointer newArrayPtr = std::dynamic_pointer_cast>(newData); @@ -229,7 +218,8 @@ template void extractComponent(IDataArray::Pointer inputData, IData // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void reduceArrayOnly(IDataArray::Pointer inputData, IDataArray::Pointer reducedData, int compNumber) +template +void reduceArrayOnly(IDataArray::Pointer inputData, IDataArray::Pointer reducedData, int compNumber) { typename DataArray::Pointer inputArrayPtr = std::dynamic_pointer_cast>(inputData); typename DataArray::Pointer reducedArrayPtr = std::dynamic_pointer_cast>(reducedData); @@ -267,10 +257,8 @@ template void reduceArrayOnly(IDataArray::Pointer inputData, IDataA // ----------------------------------------------------------------------------- void RemoveComponentFromArray::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -283,7 +271,6 @@ void RemoveComponentFromArray::execute() { EXECUTE_FUNCTION_TEMPLATE(this, reduceArrayOnly, m_InArrayPtr.lock(), m_InArrayPtr.lock(), m_ReducedArrayPtr.lock(), m_CompNumber) } - } // ----------------------------------------------------------------------------- @@ -302,7 +289,7 @@ AbstractFilter::Pointer RemoveComponentFromArray::newFilterInstance(bool copyFil // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RemoveComponentFromArray::getCompiledLibraryName() const +QString RemoveComponentFromArray::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -310,7 +297,7 @@ const QString RemoveComponentFromArray::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RemoveComponentFromArray::getBrandingString() const +QString RemoveComponentFromArray::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -318,7 +305,7 @@ const QString RemoveComponentFromArray::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RemoveComponentFromArray::getFilterVersion() const +QString RemoveComponentFromArray::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -329,7 +316,7 @@ const QString RemoveComponentFromArray::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RemoveComponentFromArray::getGroupName() const +QString RemoveComponentFromArray::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -337,7 +324,7 @@ const QString RemoveComponentFromArray::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid RemoveComponentFromArray::getUuid() +QUuid RemoveComponentFromArray::getUuid() const { return QUuid("{1b4b9941-62e4-52f2-9918-15d48147ab88}"); } @@ -345,7 +332,7 @@ const QUuid RemoveComponentFromArray::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RemoveComponentFromArray::getSubGroupName() const +QString RemoveComponentFromArray::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -353,7 +340,96 @@ const QString RemoveComponentFromArray::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RemoveComponentFromArray::getHumanLabel() const +QString RemoveComponentFromArray::getHumanLabel() const { return "Remove Component From Array"; } + +// ----------------------------------------------------------------------------- +RemoveComponentFromArray::Pointer RemoveComponentFromArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr RemoveComponentFromArray::New() +{ + struct make_shared_enabler : public RemoveComponentFromArray + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString RemoveComponentFromArray::getNameOfClass() const +{ + return QString("RemoveComponentFromArray"); +} + +// ----------------------------------------------------------------------------- +QString RemoveComponentFromArray::ClassName() +{ + return QString("RemoveComponentFromArray"); +} + +// ----------------------------------------------------------------------------- +void RemoveComponentFromArray::setSelectedArrayPath(const DataArrayPath& value) +{ + m_SelectedArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath RemoveComponentFromArray::getSelectedArrayPath() const +{ + return m_SelectedArrayPath; +} + +// ----------------------------------------------------------------------------- +void RemoveComponentFromArray::setCompNumber(int value) +{ + m_CompNumber = value; +} + +// ----------------------------------------------------------------------------- +int RemoveComponentFromArray::getCompNumber() const +{ + return m_CompNumber; +} + +// ----------------------------------------------------------------------------- +void RemoveComponentFromArray::setSaveRemovedComponent(bool value) +{ + m_SaveRemovedComponent = value; +} + +// ----------------------------------------------------------------------------- +bool RemoveComponentFromArray::getSaveRemovedComponent() const +{ + return m_SaveRemovedComponent; +} + +// ----------------------------------------------------------------------------- +void RemoveComponentFromArray::setNewArrayArrayName(const QString& value) +{ + m_NewArrayArrayName = value; +} + +// ----------------------------------------------------------------------------- +QString RemoveComponentFromArray::getNewArrayArrayName() const +{ + return m_NewArrayArrayName; +} + +// ----------------------------------------------------------------------------- +void RemoveComponentFromArray::setReducedArrayArrayName(const QString& value) +{ + m_ReducedArrayArrayName = value; +} + +// ----------------------------------------------------------------------------- +QString RemoveComponentFromArray::getReducedArrayArrayName() const +{ + return m_ReducedArrayArrayName; +} diff --git a/Source/SIMPLib/CoreFilters/RemoveComponentFromArray.h b/Source/SIMPLib/CoreFilters/RemoveComponentFromArray.h old mode 100755 new mode 100644 index 950732d4de..b7dddb48f9 --- a/Source/SIMPLib/CoreFilters/RemoveComponentFromArray.h +++ b/Source/SIMPLib/CoreFilters/RemoveComponentFromArray.h @@ -1,190 +1,235 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +class IDataArray; +using IDataArrayWkPtrType = std::weak_ptr; /** * @brief The RemoveComponentFromArray class. See [Filter documentation](@ref RemoveComponentFromArray) for details. */ class SIMPLib_EXPORT RemoveComponentFromArray : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(RemoveComponentFromArray SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) - PYB11_PROPERTY(int CompNumber READ getCompNumber WRITE setCompNumber) - PYB11_PROPERTY(bool SaveRemovedComponent READ getSaveRemovedComponent WRITE setSaveRemovedComponent) - PYB11_PROPERTY(QString NewArrayArrayName READ getNewArrayArrayName WRITE setNewArrayArrayName) - PYB11_PROPERTY(QString ReducedArrayArrayName READ getReducedArrayArrayName WRITE setReducedArrayArrayName) - - public: - SIMPL_SHARED_POINTERS(RemoveComponentFromArray) - SIMPL_FILTER_NEW_MACRO(RemoveComponentFromArray) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(RemoveComponentFromArray, AbstractFilter) - - ~RemoveComponentFromArray() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedArrayPath) - Q_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) - - SIMPL_FILTER_PARAMETER(int, CompNumber) - Q_PROPERTY(int CompNumber READ getCompNumber WRITE setCompNumber) - - SIMPL_FILTER_PARAMETER(bool, SaveRemovedComponent) - Q_PROPERTY(bool SaveRemovedComponent READ getSaveRemovedComponent WRITE setSaveRemovedComponent) - - SIMPL_FILTER_PARAMETER(QString, NewArrayArrayName) - Q_PROPERTY(QString NewArrayArrayName READ getNewArrayArrayName WRITE setNewArrayArrayName) - - SIMPL_FILTER_PARAMETER(QString, ReducedArrayArrayName) - Q_PROPERTY(QString ReducedArrayArrayName READ getReducedArrayArrayName WRITE setReducedArrayArrayName) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - RemoveComponentFromArray(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - DEFINE_IDATAARRAY_WEAKPTR(InArray) - DEFINE_IDATAARRAY_WEAKPTR(NewArray) - DEFINE_IDATAARRAY_WEAKPTR(ReducedArray) - - public: - RemoveComponentFromArray(const RemoveComponentFromArray&) = delete; // Copy Constructor Not Implemented - RemoveComponentFromArray(RemoveComponentFromArray&&) = delete; // Move Constructor Not Implemented - RemoveComponentFromArray& operator=(const RemoveComponentFromArray&) = delete; // Copy Assignment Not Implemented - RemoveComponentFromArray& operator=(RemoveComponentFromArray&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(RemoveComponentFromArray SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(RemoveComponentFromArray) + PYB11_FILTER_NEW_MACRO(RemoveComponentFromArray) + PYB11_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) + PYB11_PROPERTY(int CompNumber READ getCompNumber WRITE setCompNumber) + PYB11_PROPERTY(bool SaveRemovedComponent READ getSaveRemovedComponent WRITE setSaveRemovedComponent) + PYB11_PROPERTY(QString NewArrayArrayName READ getNewArrayArrayName WRITE setNewArrayArrayName) + PYB11_PROPERTY(QString ReducedArrayArrayName READ getReducedArrayArrayName WRITE setReducedArrayArrayName) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = RemoveComponentFromArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for RemoveComponentFromArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for RemoveComponentFromArray + */ + static QString ClassName(); + + ~RemoveComponentFromArray() override; + + /** + * @brief Setter property for SelectedArrayPath + */ + void setSelectedArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SelectedArrayPath + * @return Value of SelectedArrayPath + */ + DataArrayPath getSelectedArrayPath() const; + + Q_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) + + /** + * @brief Setter property for CompNumber + */ + void setCompNumber(int value); + /** + * @brief Getter property for CompNumber + * @return Value of CompNumber + */ + int getCompNumber() const; + + Q_PROPERTY(int CompNumber READ getCompNumber WRITE setCompNumber) + + /** + * @brief Setter property for SaveRemovedComponent + */ + void setSaveRemovedComponent(bool value); + /** + * @brief Getter property for SaveRemovedComponent + * @return Value of SaveRemovedComponent + */ + bool getSaveRemovedComponent() const; + + Q_PROPERTY(bool SaveRemovedComponent READ getSaveRemovedComponent WRITE setSaveRemovedComponent) + + /** + * @brief Setter property for NewArrayArrayName + */ + void setNewArrayArrayName(const QString& value); + /** + * @brief Getter property for NewArrayArrayName + * @return Value of NewArrayArrayName + */ + QString getNewArrayArrayName() const; + + Q_PROPERTY(QString NewArrayArrayName READ getNewArrayArrayName WRITE setNewArrayArrayName) + + /** + * @brief Setter property for ReducedArrayArrayName + */ + void setReducedArrayArrayName(const QString& value); + /** + * @brief Getter property for ReducedArrayArrayName + * @return Value of ReducedArrayArrayName + */ + QString getReducedArrayArrayName() const; + + Q_PROPERTY(QString ReducedArrayArrayName READ getReducedArrayArrayName WRITE setReducedArrayArrayName) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + RemoveComponentFromArray(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + IDataArrayWkPtrType m_InArrayPtr; + IDataArrayWkPtrType m_NewArrayPtr; + IDataArrayWkPtrType m_ReducedArrayPtr; + + DataArrayPath m_SelectedArrayPath = {"", "", ""}; + int m_CompNumber = {0}; + bool m_SaveRemovedComponent = {false}; + QString m_NewArrayArrayName = {""}; + QString m_ReducedArrayArrayName = {}; + +public: + RemoveComponentFromArray(const RemoveComponentFromArray&) = delete; // Copy Constructor Not Implemented + RemoveComponentFromArray(RemoveComponentFromArray&&) = delete; // Move Constructor Not Implemented + RemoveComponentFromArray& operator=(const RemoveComponentFromArray&) = delete; // Copy Assignment Not Implemented + RemoveComponentFromArray& operator=(RemoveComponentFromArray&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/RenameAttributeArray.cpp b/Source/SIMPLib/CoreFilters/RenameAttributeArray.cpp index eb5b727d14..fa5d85bbfb 100644 --- a/Source/SIMPLib/CoreFilters/RenameAttributeArray.cpp +++ b/Source/SIMPLib/CoreFilters/RenameAttributeArray.cpp @@ -1,54 +1,52 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "RenameAttributeArray.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -RenameAttributeArray::RenameAttributeArray() -: m_SelectedArrayPath("", "", "") -, m_NewArrayName("") -{ -} +RenameAttributeArray::RenameAttributeArray() = default; // ----------------------------------------------------------------------------- // @@ -60,12 +58,12 @@ RenameAttributeArray::~RenameAttributeArray() = default; // ----------------------------------------------------------------------------- void RenameAttributeArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; DataArraySelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Attribute Array to Rename", SelectedArrayPath, FilterParameter::RequiredArray, RenameAttributeArray, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Attribute Array to Rename", SelectedArrayPath, FilterParameter::Category::RequiredArray, RenameAttributeArray, req)); - parameters.push_back(SIMPL_NEW_STRING_FP("New Attribute Array Name", NewArrayName, FilterParameter::Parameter, RenameAttributeArray)); + parameters.push_back(SIMPL_NEW_STRING_FP("New Attribute Array Name", NewArrayName, FilterParameter::Category::Parameter, RenameAttributeArray)); setFilterParameters(parameters); } @@ -93,21 +91,31 @@ void RenameAttributeArray::initialize() // ----------------------------------------------------------------------------- void RenameAttributeArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(m_NewArrayName.isEmpty()) { - setErrorCondition(-11009); QString ss = QObject::tr("The new Attribute Array name must be set"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11009, ss); return; } QString daName = getSelectedArrayPath().getDataArrayName(); - AttributeMatrix::Pointer attrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getSelectedArrayPath(), -301); - if(getErrorCondition() < 0) + // Update the last array name. This is important for creating rename paths. + if(m_LastArrayName != getNewArrayName()) + { + DataArrayPath newArrayPath = getSelectedArrayPath(); + newArrayPath.setAttributeMatrixName(m_NewArrayName); + DataArrayPath oldArrayPath = getSelectedArrayPath(); + oldArrayPath.setAttributeMatrixName(m_LastArrayName); + addPathRename(oldArrayPath, newArrayPath); + m_LastArrayName = getNewArrayName(); + } + + AttributeMatrix::Pointer attrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getSelectedArrayPath(), -301); + if(getErrorCode() < 0) { return; } @@ -115,40 +123,30 @@ void RenameAttributeArray::dataCheck() RenameErrorCodes code = attrMat->renameAttributeArray(daName, m_NewArrayName, false); switch(code) { - case OLD_DOES_NOT_EXIST: - { - setErrorCondition(-11016); + case OLD_DOES_NOT_EXIST: { QString ss = QObject::tr("A DataArray with the name '%1' was not found in the AttributeMatrix").arg(daName); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11016, ss); return; } - case NEW_EXISTS: - { - setErrorCondition(-11017); + case NEW_EXISTS: { QString ss = QObject::tr("A DataArray with the name '%1' already exists in the AttributeMatrix").arg(m_NewArrayName); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11017, ss); return; } - case SUCCESS: - { - setErrorCondition(0); - setWarningCondition(0); + case RenameErrorCodes::SAME_PATH: { + QString ss = QObject::tr("The new and original DataArray names cannot be identical"); + setErrorCondition(-11018, ss); + return; + } + case SUCCESS: { + clearErrorCode(); + clearWarningCode(); + DataArrayPath newPath = getSelectedArrayPath(); + newPath.setDataArrayName(m_NewArrayName); + addPathRename(getSelectedArrayPath(), newPath); return; } } -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void RenameAttributeArray::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); } // ----------------------------------------------------------------------------- @@ -156,14 +154,11 @@ void RenameAttributeArray::preflight() // ----------------------------------------------------------------------------- void RenameAttributeArray::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); // calling the dataCheck will rename the array, so nothing is required here - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - } // ----------------------------------------------------------------------------- // @@ -181,7 +176,7 @@ AbstractFilter::Pointer RenameAttributeArray::newFilterInstance(bool copyFilterP // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameAttributeArray::getCompiledLibraryName() const +QString RenameAttributeArray::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -189,7 +184,7 @@ const QString RenameAttributeArray::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameAttributeArray::getBrandingString() const +QString RenameAttributeArray::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -197,7 +192,7 @@ const QString RenameAttributeArray::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameAttributeArray::getFilterVersion() const +QString RenameAttributeArray::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -208,7 +203,7 @@ const QString RenameAttributeArray::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameAttributeArray::getGroupName() const +QString RenameAttributeArray::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -216,7 +211,7 @@ const QString RenameAttributeArray::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid RenameAttributeArray::getUuid() +QUuid RenameAttributeArray::getUuid() const { return QUuid("{53a5f731-2858-5e3e-bd43-8f2cf45d90ec}"); } @@ -224,7 +219,7 @@ const QUuid RenameAttributeArray::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameAttributeArray::getSubGroupName() const +QString RenameAttributeArray::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -232,7 +227,7 @@ const QString RenameAttributeArray::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameAttributeArray::getHumanLabel() const +QString RenameAttributeArray::getHumanLabel() const { return "Rename Attribute Array"; } @@ -247,7 +242,61 @@ DataArrayPath::RenameContainer RenameAttributeArray::getRenamedPaths() newPath.setDataArrayName(getNewArrayName()); DataArrayPath::RenameContainer container; - container.push_back(DataArrayPath::RenameType(oldPath, newPath)); + DataArrayPath::RenameType rename = {oldPath, newPath}; + container.push_back(rename); return container; } + +// ----------------------------------------------------------------------------- +RenameAttributeArray::Pointer RenameAttributeArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr RenameAttributeArray::New() +{ + struct make_shared_enabler : public RenameAttributeArray + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString RenameAttributeArray::getNameOfClass() const +{ + return QString("RenameAttributeArray"); +} + +// ----------------------------------------------------------------------------- +QString RenameAttributeArray::ClassName() +{ + return QString("RenameAttributeArray"); +} + +// ----------------------------------------------------------------------------- +void RenameAttributeArray::setSelectedArrayPath(const DataArrayPath& value) +{ + m_SelectedArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath RenameAttributeArray::getSelectedArrayPath() const +{ + return m_SelectedArrayPath; +} + +// ----------------------------------------------------------------------------- +void RenameAttributeArray::setNewArrayName(const QString& value) +{ + m_NewArrayName = value; +} + +// ----------------------------------------------------------------------------- +QString RenameAttributeArray::getNewArrayName() const +{ + return m_NewArrayName; +} diff --git a/Source/SIMPLib/CoreFilters/RenameAttributeArray.h b/Source/SIMPLib/CoreFilters/RenameAttributeArray.h old mode 100755 new mode 100644 index 9803cbf987..da565260c0 --- a/Source/SIMPLib/CoreFilters/RenameAttributeArray.h +++ b/Source/SIMPLib/CoreFilters/RenameAttributeArray.h @@ -1,179 +1,194 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The RenameAttributeArray class. See [Filter documentation](@ref renameattributearray) for details. */ class SIMPLib_EXPORT RenameAttributeArray : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(RenameAttributeArray SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) - PYB11_PROPERTY(QString NewArrayName READ getNewArrayName WRITE setNewArrayName) - - public: - SIMPL_SHARED_POINTERS(RenameAttributeArray) - SIMPL_FILTER_NEW_MACRO(RenameAttributeArray) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(RenameAttributeArray, AbstractFilter) - - ~RenameAttributeArray() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedArrayPath) - Q_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) - - SIMPL_FILTER_PARAMETER(QString, NewArrayName) - Q_PROPERTY(QString NewArrayName READ getNewArrayName WRITE setNewArrayName) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - /** - * @brief Returns a list of DataArrayPaths that have been renamed along with their corresponding renamed value - * @return - */ - DataArrayPath::RenameContainer getRenamedPaths() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - RenameAttributeArray(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - public: - RenameAttributeArray(const RenameAttributeArray&) = delete; // Copy Constructor Not Implemented - RenameAttributeArray(RenameAttributeArray&&) = delete; // Move Constructor Not Implemented - RenameAttributeArray& operator=(const RenameAttributeArray&) = delete; // Copy Assignment Not Implemented - RenameAttributeArray& operator=(RenameAttributeArray&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(RenameAttributeArray SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(RenameAttributeArray) + PYB11_FILTER_NEW_MACRO(RenameAttributeArray) + PYB11_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) + PYB11_PROPERTY(QString NewArrayName READ getNewArrayName WRITE setNewArrayName) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = RenameAttributeArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for RenameAttributeArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for RenameAttributeArray + */ + static QString ClassName(); + + ~RenameAttributeArray() override; + + /** + * @brief Setter property for SelectedArrayPath + */ + void setSelectedArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for SelectedArrayPath + * @return Value of SelectedArrayPath + */ + DataArrayPath getSelectedArrayPath() const; + + Q_PROPERTY(DataArrayPath SelectedArrayPath READ getSelectedArrayPath WRITE setSelectedArrayPath) + + /** + * @brief Setter property for NewArrayName + */ + void setNewArrayName(const QString& value); + /** + * @brief Getter property for NewArrayName + * @return Value of NewArrayName + */ + QString getNewArrayName() const; + + Q_PROPERTY(QString NewArrayName READ getNewArrayName WRITE setNewArrayName) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + + /** + * @brief Returns a list of DataArrayPaths that have been renamed along with their corresponding renamed value + * @return + */ + DataArrayPath::RenameContainer getRenamedPaths() override; + +protected: + RenameAttributeArray(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + DataArrayPath m_SelectedArrayPath = {"", "", ""}; + QString m_NewArrayName = {""}; + + QString m_LastArrayName = ""; + +public: + RenameAttributeArray(const RenameAttributeArray&) = delete; // Copy Constructor Not Implemented + RenameAttributeArray(RenameAttributeArray&&) = delete; // Move Constructor Not Implemented + RenameAttributeArray& operator=(const RenameAttributeArray&) = delete; // Copy Assignment Not Implemented + RenameAttributeArray& operator=(RenameAttributeArray&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.cpp b/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.cpp index 253d60ca15..0c7316ce63 100644 --- a/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.cpp +++ b/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.cpp @@ -1,54 +1,53 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "RenameAttributeMatrix.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -RenameAttributeMatrix::RenameAttributeMatrix() -: m_SelectedAttributeMatrixPath("", "", "") -, m_NewAttributeMatrix("") -{ -} +RenameAttributeMatrix::RenameAttributeMatrix() = default; // ----------------------------------------------------------------------------- // @@ -60,14 +59,14 @@ RenameAttributeMatrix::~RenameAttributeMatrix() = default; // ----------------------------------------------------------------------------- void RenameAttributeMatrix::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { AttributeMatrixSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Attribute Matrix to Rename", SelectedAttributeMatrixPath, FilterParameter::RequiredArray, RenameAttributeMatrix, req)); + parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Attribute Matrix to Rename", SelectedAttributeMatrixPath, FilterParameter::Category::RequiredArray, RenameAttributeMatrix, req)); } - parameters.push_back(SIMPL_NEW_STRING_FP("New Attribute Matrix Name", NewAttributeMatrix, FilterParameter::Parameter, RenameAttributeMatrix)); + parameters.push_back(SIMPL_NEW_STRING_FP("New Attribute Matrix Name", NewAttributeMatrix, FilterParameter::Category::Parameter, RenameAttributeMatrix)); setFilterParameters(parameters); } @@ -95,23 +94,32 @@ void RenameAttributeMatrix::initialize() // ----------------------------------------------------------------------------- void RenameAttributeMatrix::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(m_NewAttributeMatrix.isEmpty()) { - setErrorCondition(-11004); QString ss = QObject::tr("The new Attribute Matrix name must be set"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11004, ss); return; } QString amName = getSelectedAttributeMatrixPath().getAttributeMatrixName(); + if(m_LastMatrixName != getNewAttributeMatrix()) + { + DataArrayPath newMatrixPath = getSelectedAttributeMatrixPath(); + newMatrixPath.setAttributeMatrixName(getNewAttributeMatrix()); + DataArrayPath oldMatrixPath = getSelectedAttributeMatrixPath(); + oldMatrixPath.setAttributeMatrixName(m_LastMatrixName); + addPathRename(oldMatrixPath, getSelectedAttributeMatrixPath()); + m_LastMatrixName = getNewAttributeMatrix(); + } + DataContainer::Pointer dc = getDataContainerArray()->getPrereqDataContainer(this, getSelectedAttributeMatrixPath().getDataContainerName()); - getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getSelectedAttributeMatrixPath(), -301); + getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getSelectedAttributeMatrixPath(), -301); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -119,23 +127,15 @@ void RenameAttributeMatrix::dataCheck() bool check = dc->renameAttributeMatrix(amName, getNewAttributeMatrix()); if(!check) { - setErrorCondition(-11006); QString ss = QObject::tr("Attempt to rename Attribute Matrix '%1' to '%2' failed").arg(amName).arg(getNewAttributeMatrix()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11006, ss); + } + else + { + DataArrayPath newPath = getSelectedAttributeMatrixPath(); + newPath.setAttributeMatrixName(getNewAttributeMatrix()); + addPathRename(getSelectedAttributeMatrixPath(), newPath); } -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void RenameAttributeMatrix::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); } // ----------------------------------------------------------------------------- @@ -143,14 +143,11 @@ void RenameAttributeMatrix::preflight() // ----------------------------------------------------------------------------- void RenameAttributeMatrix::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); // calling the dataCheck will rename the array, so nothing is required here - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - } // ----------------------------------------------------------------------------- // @@ -168,7 +165,7 @@ AbstractFilter::Pointer RenameAttributeMatrix::newFilterInstance(bool copyFilter // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameAttributeMatrix::getCompiledLibraryName() const +QString RenameAttributeMatrix::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -176,7 +173,7 @@ const QString RenameAttributeMatrix::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameAttributeMatrix::getBrandingString() const +QString RenameAttributeMatrix::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -184,7 +181,7 @@ const QString RenameAttributeMatrix::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameAttributeMatrix::getFilterVersion() const +QString RenameAttributeMatrix::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -195,7 +192,7 @@ const QString RenameAttributeMatrix::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameAttributeMatrix::getGroupName() const +QString RenameAttributeMatrix::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -203,7 +200,7 @@ const QString RenameAttributeMatrix::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid RenameAttributeMatrix::getUuid() +QUuid RenameAttributeMatrix::getUuid() const { return QUuid("{ee29e6d6-1f59-551b-9350-a696523261d5}"); } @@ -211,7 +208,7 @@ const QUuid RenameAttributeMatrix::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameAttributeMatrix::getSubGroupName() const +QString RenameAttributeMatrix::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -219,7 +216,7 @@ const QString RenameAttributeMatrix::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameAttributeMatrix::getHumanLabel() const +QString RenameAttributeMatrix::getHumanLabel() const { return "Rename Attribute Matrix"; } @@ -234,7 +231,60 @@ DataArrayPath::RenameContainer RenameAttributeMatrix::getRenamedPaths() newPath.setAttributeMatrixName(getNewAttributeMatrix()); DataArrayPath::RenameContainer container; - container.push_back(DataArrayPath::RenameType(oldPath, newPath)); + container.push_back(std::make_pair(oldPath, newPath)); return container; } + +// ----------------------------------------------------------------------------- +RenameAttributeMatrix::Pointer RenameAttributeMatrix::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr RenameAttributeMatrix::New() +{ + struct make_shared_enabler : public RenameAttributeMatrix + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString RenameAttributeMatrix::getNameOfClass() const +{ + return QString("RenameAttributeMatrix"); +} + +// ----------------------------------------------------------------------------- +QString RenameAttributeMatrix::ClassName() +{ + return QString("RenameAttributeMatrix"); +} + +// ----------------------------------------------------------------------------- +void RenameAttributeMatrix::setSelectedAttributeMatrixPath(const DataArrayPath& value) +{ + m_SelectedAttributeMatrixPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath RenameAttributeMatrix::getSelectedAttributeMatrixPath() const +{ + return m_SelectedAttributeMatrixPath; +} + +// ----------------------------------------------------------------------------- +void RenameAttributeMatrix::setNewAttributeMatrix(const QString& value) +{ + m_NewAttributeMatrix = value; +} + +// ----------------------------------------------------------------------------- +QString RenameAttributeMatrix::getNewAttributeMatrix() const +{ + return m_NewAttributeMatrix; +} diff --git a/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.h b/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.h old mode 100755 new mode 100644 index 417f001eaa..8f1400e5ac --- a/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.h +++ b/Source/SIMPLib/CoreFilters/RenameAttributeMatrix.h @@ -1,179 +1,194 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The RenameAttributeMatrix class. See [Filter documentation](@ref renameattributematrix) for details. */ class SIMPLib_EXPORT RenameAttributeMatrix : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(RenameAttributeMatrix SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath SelectedAttributeMatrixPath READ getSelectedAttributeMatrixPath WRITE setSelectedAttributeMatrixPath) - PYB11_PROPERTY(QString NewAttributeMatrix READ getNewAttributeMatrix WRITE setNewAttributeMatrix) - - public: - SIMPL_SHARED_POINTERS(RenameAttributeMatrix) - SIMPL_FILTER_NEW_MACRO(RenameAttributeMatrix) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(RenameAttributeMatrix, AbstractFilter) - - ~RenameAttributeMatrix() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedAttributeMatrixPath) - Q_PROPERTY(DataArrayPath SelectedAttributeMatrixPath READ getSelectedAttributeMatrixPath WRITE setSelectedAttributeMatrixPath) - - SIMPL_FILTER_PARAMETER(QString, NewAttributeMatrix) - Q_PROPERTY(QString NewAttributeMatrix READ getNewAttributeMatrix WRITE setNewAttributeMatrix) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - /** - * @brief Returns a list of DataArrayPaths that have been renamed along with their corresponding renamed value - * @return - */ - DataArrayPath::RenameContainer getRenamedPaths() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - RenameAttributeMatrix(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - public: - RenameAttributeMatrix(const RenameAttributeMatrix&) = delete; // Copy Constructor Not Implemented - RenameAttributeMatrix(RenameAttributeMatrix&&) = delete; // Move Constructor Not Implemented - RenameAttributeMatrix& operator=(const RenameAttributeMatrix&) = delete; // Copy Assignment Not Implemented - RenameAttributeMatrix& operator=(RenameAttributeMatrix&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(RenameAttributeMatrix SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(RenameAttributeMatrix) + PYB11_FILTER_NEW_MACRO(RenameAttributeMatrix) + PYB11_PROPERTY(DataArrayPath SelectedAttributeMatrixPath READ getSelectedAttributeMatrixPath WRITE setSelectedAttributeMatrixPath) + PYB11_PROPERTY(QString NewAttributeMatrix READ getNewAttributeMatrix WRITE setNewAttributeMatrix) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = RenameAttributeMatrix; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for RenameAttributeMatrix + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for RenameAttributeMatrix + */ + static QString ClassName(); + + ~RenameAttributeMatrix() override; + + /** + * @brief Setter property for SelectedAttributeMatrixPath + */ + void setSelectedAttributeMatrixPath(const DataArrayPath& value); + /** + * @brief Getter property for SelectedAttributeMatrixPath + * @return Value of SelectedAttributeMatrixPath + */ + DataArrayPath getSelectedAttributeMatrixPath() const; + + Q_PROPERTY(DataArrayPath SelectedAttributeMatrixPath READ getSelectedAttributeMatrixPath WRITE setSelectedAttributeMatrixPath) + + /** + * @brief Setter property for NewAttributeMatrix + */ + void setNewAttributeMatrix(const QString& value); + /** + * @brief Getter property for NewAttributeMatrix + * @return Value of NewAttributeMatrix + */ + QString getNewAttributeMatrix() const; + + Q_PROPERTY(QString NewAttributeMatrix READ getNewAttributeMatrix WRITE setNewAttributeMatrix) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + + /** + * @brief Returns a list of DataArrayPaths that have been renamed along with their corresponding renamed value + * @return + */ + DataArrayPath::RenameContainer getRenamedPaths() override; + +protected: + RenameAttributeMatrix(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + DataArrayPath m_SelectedAttributeMatrixPath = {"", "", ""}; + QString m_NewAttributeMatrix = {""}; + + QString m_LastMatrixName = ""; + +public: + RenameAttributeMatrix(const RenameAttributeMatrix&) = delete; // Copy Constructor Not Implemented + RenameAttributeMatrix(RenameAttributeMatrix&&) = delete; // Move Constructor Not Implemented + RenameAttributeMatrix& operator=(const RenameAttributeMatrix&) = delete; // Copy Assignment Not Implemented + RenameAttributeMatrix& operator=(RenameAttributeMatrix&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/RenameDataContainer.cpp b/Source/SIMPLib/CoreFilters/RenameDataContainer.cpp index 9c36d452a6..69216f8aba 100644 --- a/Source/SIMPLib/CoreFilters/RenameDataContainer.cpp +++ b/Source/SIMPLib/CoreFilters/RenameDataContainer.cpp @@ -1,54 +1,53 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "RenameDataContainer.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" +#include "SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h" #include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" -#include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -RenameDataContainer::RenameDataContainer() -: m_SelectedDataContainerName("") -, m_NewDataContainerName("") -{ -} +RenameDataContainer::RenameDataContainer() = default; // ----------------------------------------------------------------------------- // @@ -60,29 +59,18 @@ RenameDataContainer::~RenameDataContainer() = default; // ----------------------------------------------------------------------------- void RenameDataContainer::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { DataContainerSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container to Rename", SelectedDataContainerName, FilterParameter::RequiredArray, RenameDataContainer, req)); + parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container to Rename", SelectedDataContainerName, FilterParameter::Category::RequiredArray, RenameDataContainer, req)); } - parameters.push_back(SIMPL_NEW_STRING_FP("New Data Container Name", NewDataContainerName, FilterParameter::Parameter, RenameDataContainer)); + parameters.push_back(SIMPL_NEW_DC_CREATION_FP("New Data Container Name", NewDataContainerName, FilterParameter::Category::Parameter, RenameDataContainer)); setFilterParameters(parameters); } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void RenameDataContainer::readFilterParameters(AbstractFilterParametersReader* reader, int index) -{ - reader->openFilterGroup(this, index); - setSelectedDataContainerName(reader->readString("SelectedDataContainerName", getSelectedDataContainerName())); - setNewDataContainerName(reader->readString("NewDataContainerName", getNewDataContainerName())); - reader->closeFilterGroup(); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -95,19 +83,26 @@ void RenameDataContainer::initialize() // ----------------------------------------------------------------------------- void RenameDataContainer::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(getNewDataContainerName().isEmpty()) { - setErrorCondition(-11001); QString ss = QObject::tr("The new Data Container name must be set"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11001, ss); return; } + if(m_LastContainerName != m_NewDataContainerName) + { + DataArrayPath oldContainerPath = m_LastContainerName; + DataArrayPath newContainerPath = getNewDataContainerName(); + addPathRename(oldContainerPath, newContainerPath); + m_LastContainerName = getNewDataContainerName(); + } + getDataContainerArray()->getPrereqDataContainer(this, getSelectedDataContainerName()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -115,23 +110,15 @@ void RenameDataContainer::dataCheck() bool check = getDataContainerArray()->renameDataContainer(getSelectedDataContainerName(), getNewDataContainerName()); if(!check) { - setErrorCondition(-11006); - QString ss = QObject::tr("Attempt to rename DataContainer '%1' to '%2' failed").arg(getSelectedDataContainerName()).arg(getNewDataContainerName()); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + QString ss = QObject::tr("Attempt to rename DataContainer '%1' to '%2' failed").arg(getSelectedDataContainerName().getDataContainerName()).arg(getNewDataContainerName().getDataContainerName()); + setErrorCondition(-11006, ss); + } + else + { + DataArrayPath oldPath = getSelectedDataContainerName(); + DataArrayPath newPath = getNewDataContainerName(); + addPathRename(oldPath, newPath); } -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void RenameDataContainer::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); } // ----------------------------------------------------------------------------- @@ -139,14 +126,11 @@ void RenameDataContainer::preflight() // ----------------------------------------------------------------------------- void RenameDataContainer::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); // calling the dataCheck will rename the array, so nothing is required here - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - } // ----------------------------------------------------------------------------- // @@ -164,7 +148,7 @@ AbstractFilter::Pointer RenameDataContainer::newFilterInstance(bool copyFilterPa // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameDataContainer::getCompiledLibraryName() const +QString RenameDataContainer::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -172,7 +156,7 @@ const QString RenameDataContainer::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameDataContainer::getBrandingString() const +QString RenameDataContainer::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -180,7 +164,7 @@ const QString RenameDataContainer::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameDataContainer::getFilterVersion() const +QString RenameDataContainer::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -191,7 +175,7 @@ const QString RenameDataContainer::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameDataContainer::getGroupName() const +QString RenameDataContainer::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -199,7 +183,7 @@ const QString RenameDataContainer::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid RenameDataContainer::getUuid() +QUuid RenameDataContainer::getUuid() const { return QUuid("{d53c808f-004d-5fac-b125-0fffc8cc78d6}"); } @@ -207,7 +191,7 @@ const QUuid RenameDataContainer::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameDataContainer::getSubGroupName() const +QString RenameDataContainer::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -215,7 +199,7 @@ const QString RenameDataContainer::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RenameDataContainer::getHumanLabel() const +QString RenameDataContainer::getHumanLabel() const { return "Rename Data Container"; } @@ -225,11 +209,64 @@ const QString RenameDataContainer::getHumanLabel() const // ----------------------------------------------------------------------------- DataArrayPath::RenameContainer RenameDataContainer::getRenamedPaths() { - DataArrayPath oldPath(getSelectedDataContainerName(), "", ""); - DataArrayPath newPath(getNewDataContainerName(), "", ""); + DataArrayPath oldPath = getSelectedDataContainerName(); + DataArrayPath newPath = getNewDataContainerName(); DataArrayPath::RenameContainer container; - container.push_back(DataArrayPath::RenameType(oldPath, newPath)); + container.push_back(std::make_pair(oldPath, newPath)); return container; } + +// ----------------------------------------------------------------------------- +RenameDataContainer::Pointer RenameDataContainer::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr RenameDataContainer::New() +{ + struct make_shared_enabler : public RenameDataContainer + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString RenameDataContainer::getNameOfClass() const +{ + return QString("RenameDataContainer"); +} + +// ----------------------------------------------------------------------------- +QString RenameDataContainer::ClassName() +{ + return QString("RenameDataContainer"); +} + +// ----------------------------------------------------------------------------- +void RenameDataContainer::setSelectedDataContainerName(const DataArrayPath& value) +{ + m_SelectedDataContainerName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath RenameDataContainer::getSelectedDataContainerName() const +{ + return m_SelectedDataContainerName; +} + +// ----------------------------------------------------------------------------- +void RenameDataContainer::setNewDataContainerName(const DataArrayPath& value) +{ + m_NewDataContainerName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath RenameDataContainer::getNewDataContainerName() const +{ + return m_NewDataContainerName; +} diff --git a/Source/SIMPLib/CoreFilters/RenameDataContainer.h b/Source/SIMPLib/CoreFilters/RenameDataContainer.h old mode 100755 new mode 100644 index 8ed3792957..b05e8161fe --- a/Source/SIMPLib/CoreFilters/RenameDataContainer.h +++ b/Source/SIMPLib/CoreFilters/RenameDataContainer.h @@ -1,179 +1,189 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The RenameDataContainer class. See [Filter documentation](@ref renamedatacontainer) for details. */ class SIMPLib_EXPORT RenameDataContainer : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(RenameDataContainer SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) - PYB11_PROPERTY(QString NewDataContainerName READ getNewDataContainerName WRITE setNewDataContainerName) - - public: - SIMPL_SHARED_POINTERS(RenameDataContainer) - SIMPL_FILTER_NEW_MACRO(RenameDataContainer) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(RenameDataContainer, AbstractFilter) - - ~RenameDataContainer() override; - - SIMPL_FILTER_PARAMETER(QString, SelectedDataContainerName) - Q_PROPERTY(QString SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) - - SIMPL_FILTER_PARAMETER(QString, NewDataContainerName) - Q_PROPERTY(QString NewDataContainerName READ getNewDataContainerName WRITE setNewDataContainerName) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - /** - * @brief Returns a list of DataArrayPaths that have been renamed along with their corresponding renamed value - * @return - */ - DataArrayPath::RenameContainer getRenamedPaths() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - RenameDataContainer(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - public: - RenameDataContainer(const RenameDataContainer&) = delete; // Copy Constructor Not Implemented - RenameDataContainer(RenameDataContainer&&) = delete; // Move Constructor Not Implemented - RenameDataContainer& operator=(const RenameDataContainer&) = delete; // Copy Assignment Not Implemented - RenameDataContainer& operator=(RenameDataContainer&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(RenameDataContainer SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(RenameDataContainer) + PYB11_FILTER_NEW_MACRO(RenameDataContainer) + PYB11_PROPERTY(DataArrayPath SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) + PYB11_PROPERTY(DataArrayPath NewDataContainerName READ getNewDataContainerName WRITE setNewDataContainerName) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = RenameDataContainer; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for RenameDataContainer + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for RenameDataContainer + */ + static QString ClassName(); + + ~RenameDataContainer() override; + + /** + * @brief Setter property for SelectedDataContainerName + */ + void setSelectedDataContainerName(const DataArrayPath& value); + /** + * @brief Getter property for SelectedDataContainerName + * @return Value of SelectedDataContainerName + */ + DataArrayPath getSelectedDataContainerName() const; + + Q_PROPERTY(DataArrayPath SelectedDataContainerName READ getSelectedDataContainerName WRITE setSelectedDataContainerName) + + /** + * @brief Setter property for NewDataContainerName + */ + void setNewDataContainerName(const DataArrayPath& value); + /** + * @brief Getter property for NewDataContainerName + * @return Value of NewDataContainerName + */ + DataArrayPath getNewDataContainerName() const; + + Q_PROPERTY(DataArrayPath NewDataContainerName READ getNewDataContainerName WRITE setNewDataContainerName) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + + /** + * @brief Returns a list of DataArrayPaths that have been renamed along with their corresponding renamed value + * @return + */ + DataArrayPath::RenameContainer getRenamedPaths() override; + +protected: + RenameDataContainer(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + DataArrayPath m_SelectedDataContainerName = {"", "", ""}; + DataArrayPath m_NewDataContainerName = {"", "", ""}; + + DataArrayPath m_LastContainerName; + +public: + RenameDataContainer(const RenameDataContainer&) = delete; // Copy Constructor Not Implemented + RenameDataContainer(RenameDataContainer&&) = delete; // Move Constructor Not Implemented + RenameDataContainer& operator=(const RenameDataContainer&) = delete; // Copy Assignment Not Implemented + RenameDataContainer& operator=(RenameDataContainer&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/ReplaceValueInArray.cpp b/Source/SIMPLib/CoreFilters/ReplaceValueInArray.cpp index 3ad88da2e6..72f4a707a1 100644 --- a/Source/SIMPLib/CoreFilters/ReplaceValueInArray.cpp +++ b/Source/SIMPLib/CoreFilters/ReplaceValueInArray.cpp @@ -1,56 +1,54 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ReplaceValueInArray.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" +#include "SIMPLib/DataArrays/IDataArray.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/DoubleFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ReplaceValueInArray::ReplaceValueInArray() -: m_SelectedArray("", "", "") -, m_RemoveValue(0.0) -, m_ReplaceValue(0.0) -{ -} +ReplaceValueInArray::ReplaceValueInArray() = default; // ----------------------------------------------------------------------------- // @@ -62,13 +60,13 @@ ReplaceValueInArray::~ReplaceValueInArray() = default; // ----------------------------------------------------------------------------- void ReplaceValueInArray::setupFilterParameters() { - FilterParameterVector parameters; - parameters.push_back(SIMPL_NEW_DOUBLE_FP("Value to Replace", RemoveValue, FilterParameter::Parameter, ReplaceValueInArray)); + FilterParameterVectorType parameters; + parameters.push_back(SIMPL_NEW_DOUBLE_FP("Value to Replace", RemoveValue, FilterParameter::Category::Parameter, ReplaceValueInArray)); - parameters.push_back(SIMPL_NEW_DOUBLE_FP("New Value", ReplaceValue, FilterParameter::Parameter, ReplaceValueInArray)); + parameters.push_back(SIMPL_NEW_DOUBLE_FP("New Value", ReplaceValue, FilterParameter::Category::Parameter, ReplaceValueInArray)); { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateCategoryRequirement(SIMPL::Defaults::AnyPrimitive, 1, AttributeMatrix::Category::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Attribute Array", SelectedArray, FilterParameter::RequiredArray, ReplaceValueInArray, req)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Attribute Array", SelectedArray, FilterParameter::Category::RequiredArray, ReplaceValueInArray, req)); } setFilterParameters(parameters); } @@ -88,28 +86,28 @@ void ReplaceValueInArray::readFilterParameters(AbstractFilterParametersReader* r // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void checkValuesInt(AbstractFilter* filter, double removeValue, double replaceValue, QString strType) +template +void checkValuesInt(AbstractFilter* filter, double removeValue, double replaceValue, QString strType) { QString ss; if(!((removeValue >= std::numeric_limits::min()) && (removeValue <= std::numeric_limits::max()))) { ss = QObject::tr("The %1 remove value was invalid. The valid range is %2 to %3").arg(strType).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - filter->setErrorCondition(-100); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-100, ss); } if(!((replaceValue >= std::numeric_limits::min()) && (replaceValue <= std::numeric_limits::max()))) { ss = QObject::tr("The %1 replace value was invalid. The valid range is %2 to %3").arg(strType).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - filter->setErrorCondition(-100); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-100, ss); } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template void checkValuesFloatDouble(AbstractFilter* filter, double removeValue, double replaceValue, QString strType) +template +void checkValuesFloatDouble(AbstractFilter* filter, double removeValue, double replaceValue, QString strType) { QString ss; @@ -117,15 +115,13 @@ template void checkValuesFloatDouble(AbstractFilter* filter, double ((removeValue >= std::numeric_limits::min()) && (removeValue <= std::numeric_limits::max())))) { ss = QObject::tr("The %1 remove value was invalid. The valid ranges are -%3 to -%2, 0, %2 to %3").arg(strType).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - filter->setErrorCondition(-101); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-101, ss); } if(!(((replaceValue >= static_cast(-1) * std::numeric_limits::max()) && (replaceValue <= static_cast(-1) * std::numeric_limits::min())) || (replaceValue == 0) || ((replaceValue >= std::numeric_limits::min()) && (replaceValue <= std::numeric_limits::max())))) { ss = QObject::tr("The %1 replace value was invalid. The valid ranges are -%3 to -%2, 0, %2 to %3").arg(strType).arg(std::numeric_limits::min()).arg(std::numeric_limits::max()); - filter->setErrorCondition(-101); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-101, ss); } } @@ -133,7 +129,8 @@ template void checkValuesFloatDouble(AbstractFilter* filter, double // // ----------------------------------------------------------------------------- -template void replaceValue(AbstractFilter* filter, IDataArray::Pointer inDataPtr, double removeValue, double replaceValue) +template +void replaceValue(AbstractFilter* filter, IDataArray::Pointer inDataPtr, double removeValue, double replaceValue) { typename DataArray::Pointer inputArrayPtr = std::dynamic_pointer_cast>(inDataPtr); @@ -164,11 +161,11 @@ void ReplaceValueInArray::initialize() // ----------------------------------------------------------------------------- void ReplaceValueInArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - m_ArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArray()); - if(getErrorCondition() < 0) + m_ArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getSelectedArray()); + if(getErrorCode() < 0) { return; } @@ -178,8 +175,7 @@ void ReplaceValueInArray::dataCheck() QString ss = QObject::tr("Selected array '%1' must be a scalar array (1 component). The number of components is %2") .arg(getSelectedArray().getDataArrayName()) .arg(m_ArrayPtr.lock()->getNumberOfComponents()); - setErrorCondition(-11002); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); return; } @@ -237,34 +233,18 @@ void ReplaceValueInArray::dataCheck() } else { - setErrorCondition(-4060); QString ss = QObject::tr("Incorrect data scalar type"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-4060, ss); } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void ReplaceValueInArray::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ReplaceValueInArray::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -288,7 +268,7 @@ AbstractFilter::Pointer ReplaceValueInArray::newFilterInstance(bool copyFilterPa // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ReplaceValueInArray::getCompiledLibraryName() const +QString ReplaceValueInArray::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -296,7 +276,7 @@ const QString ReplaceValueInArray::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ReplaceValueInArray::getBrandingString() const +QString ReplaceValueInArray::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -304,7 +284,7 @@ const QString ReplaceValueInArray::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ReplaceValueInArray::getFilterVersion() const +QString ReplaceValueInArray::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -315,7 +295,7 @@ const QString ReplaceValueInArray::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ReplaceValueInArray::getGroupName() const +QString ReplaceValueInArray::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -323,7 +303,7 @@ const QString ReplaceValueInArray::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid ReplaceValueInArray::getUuid() +QUuid ReplaceValueInArray::getUuid() const { return QUuid("{a37f2e24-7400-5005-b9a7-b2224570cbe9}"); } @@ -331,7 +311,7 @@ const QUuid ReplaceValueInArray::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ReplaceValueInArray::getSubGroupName() const +QString ReplaceValueInArray::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -339,7 +319,72 @@ const QString ReplaceValueInArray::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ReplaceValueInArray::getHumanLabel() const +QString ReplaceValueInArray::getHumanLabel() const { return "Replace Value in Array"; } + +// ----------------------------------------------------------------------------- +ReplaceValueInArray::Pointer ReplaceValueInArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr ReplaceValueInArray::New() +{ + struct make_shared_enabler : public ReplaceValueInArray + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString ReplaceValueInArray::getNameOfClass() const +{ + return QString("ReplaceValueInArray"); +} + +// ----------------------------------------------------------------------------- +QString ReplaceValueInArray::ClassName() +{ + return QString("ReplaceValueInArray"); +} + +// ----------------------------------------------------------------------------- +void ReplaceValueInArray::setSelectedArray(const DataArrayPath& value) +{ + m_SelectedArray = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ReplaceValueInArray::getSelectedArray() const +{ + return m_SelectedArray; +} + +// ----------------------------------------------------------------------------- +void ReplaceValueInArray::setRemoveValue(double value) +{ + m_RemoveValue = value; +} + +// ----------------------------------------------------------------------------- +double ReplaceValueInArray::getRemoveValue() const +{ + return m_RemoveValue; +} + +// ----------------------------------------------------------------------------- +void ReplaceValueInArray::setReplaceValue(double value) +{ + m_ReplaceValue = value; +} + +// ----------------------------------------------------------------------------- +double ReplaceValueInArray::getReplaceValue() const +{ + return m_ReplaceValue; +} diff --git a/Source/SIMPLib/CoreFilters/ReplaceValueInArray.h b/Source/SIMPLib/CoreFilters/ReplaceValueInArray.h old mode 100755 new mode 100644 index ec16485633..5d002c63a7 --- a/Source/SIMPLib/CoreFilters/ReplaceValueInArray.h +++ b/Source/SIMPLib/CoreFilters/ReplaceValueInArray.h @@ -1,181 +1,207 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +class IDataArray; +using IDataArrayWkPtrType = std::weak_ptr; + +class IDataArray; /** * @brief The ReplaceValueInArray class. See [Filter documentation](@ref replacevalueinarray) for details. */ class SIMPLib_EXPORT ReplaceValueInArray : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(ReplaceValueInArray SUPERCLASS AbstractFilter) - PYB11_PROPERTY(DataArrayPath SelectedArray READ getSelectedArray WRITE setSelectedArray) - PYB11_PROPERTY(double RemoveValue READ getRemoveValue WRITE setRemoveValue) - PYB11_PROPERTY(double ReplaceValue READ getReplaceValue WRITE setReplaceValue) - - public: - - SIMPL_SHARED_POINTERS(ReplaceValueInArray) - SIMPL_FILTER_NEW_MACRO(ReplaceValueInArray) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ReplaceValueInArray, AbstractFilter) - - ~ReplaceValueInArray() override; - - SIMPL_FILTER_PARAMETER(DataArrayPath, SelectedArray) - Q_PROPERTY(DataArrayPath SelectedArray READ getSelectedArray WRITE setSelectedArray) - - SIMPL_FILTER_PARAMETER(double, RemoveValue) - Q_PROPERTY(double RemoveValue READ getRemoveValue WRITE setRemoveValue) - - SIMPL_FILTER_PARAMETER(double, ReplaceValue) - Q_PROPERTY(double ReplaceValue READ getReplaceValue WRITE setReplaceValue) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - ReplaceValueInArray(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - DEFINE_IDATAARRAY_WEAKPTR(Array) - - public: - ReplaceValueInArray(const ReplaceValueInArray&) = delete; // Copy Constructor Not Implemented - ReplaceValueInArray(ReplaceValueInArray&&) = delete; // Move Constructor Not Implemented - ReplaceValueInArray& operator=(const ReplaceValueInArray&) = delete; // Copy Assignment Not Implemented - ReplaceValueInArray& operator=(ReplaceValueInArray&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ReplaceValueInArray SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(ReplaceValueInArray) + PYB11_FILTER_NEW_MACRO(ReplaceValueInArray) + PYB11_PROPERTY(DataArrayPath SelectedArray READ getSelectedArray WRITE setSelectedArray) + PYB11_PROPERTY(double RemoveValue READ getRemoveValue WRITE setRemoveValue) + PYB11_PROPERTY(double ReplaceValue READ getReplaceValue WRITE setReplaceValue) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = ReplaceValueInArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for ReplaceValueInArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ReplaceValueInArray + */ + static QString ClassName(); + + ~ReplaceValueInArray() override; + + /** + * @brief Setter property for SelectedArray + */ + void setSelectedArray(const DataArrayPath& value); + /** + * @brief Getter property for SelectedArray + * @return Value of SelectedArray + */ + DataArrayPath getSelectedArray() const; + + Q_PROPERTY(DataArrayPath SelectedArray READ getSelectedArray WRITE setSelectedArray) + + /** + * @brief Setter property for RemoveValue + */ + void setRemoveValue(double value); + /** + * @brief Getter property for RemoveValue + * @return Value of RemoveValue + */ + double getRemoveValue() const; + + Q_PROPERTY(double RemoveValue READ getRemoveValue WRITE setRemoveValue) + + /** + * @brief Setter property for ReplaceValue + */ + void setReplaceValue(double value); + /** + * @brief Getter property for ReplaceValue + * @return Value of ReplaceValue + */ + double getReplaceValue() const; + + Q_PROPERTY(double ReplaceValue READ getReplaceValue WRITE setReplaceValue) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + ReplaceValueInArray(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + IDataArrayWkPtrType m_ArrayPtr; + + DataArrayPath m_SelectedArray = {"", "", ""}; + double m_RemoveValue = {0.0}; + double m_ReplaceValue = {0.0}; + +public: + ReplaceValueInArray(const ReplaceValueInArray&) = delete; // Copy Constructor Not Implemented + ReplaceValueInArray(ReplaceValueInArray&&) = delete; // Move Constructor Not Implemented + ReplaceValueInArray& operator=(const ReplaceValueInArray&) = delete; // Copy Assignment Not Implemented + ReplaceValueInArray& operator=(ReplaceValueInArray&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/RequiredZThickness.cpp b/Source/SIMPLib/CoreFilters/RequiredZThickness.cpp index 0f4cbbb287..c44d6d13e5 100644 --- a/Source/SIMPLib/CoreFilters/RequiredZThickness.cpp +++ b/Source/SIMPLib/CoreFilters/RequiredZThickness.cpp @@ -1,41 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "RequiredZThickness.h" +#include + #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/BooleanFilterParameter.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" @@ -47,12 +51,7 @@ // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -RequiredZThickness::RequiredZThickness() -: m_DataContainerSelection("") -, m_NumZVoxels(-1) -, m_PreflightCheck(false) -{ -} +RequiredZThickness::RequiredZThickness() = default; // ----------------------------------------------------------------------------- // @@ -64,14 +63,14 @@ RequiredZThickness::~RequiredZThickness() = default; // ----------------------------------------------------------------------------- void RequiredZThickness::setupFilterParameters() { - FilterParameterVector parameters = getFilterParameters(); + FilterParameterVectorType parameters = getFilterParameters(); { DataContainerSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("DataContainer", DataContainerSelection, FilterParameter::RequiredArray, RequiredZThickness, req)); + parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("DataContainer", DataContainerSelection, FilterParameter::Category::RequiredArray, RequiredZThickness, req)); } - parameters.push_back(SIMPL_NEW_INTEGER_FP("Minimum Z Dimension", NumZVoxels, FilterParameter::Parameter, RequiredZThickness, 0)); - parameters.push_back(SIMPL_NEW_BOOL_FP("Preflight Check", PreflightCheck, FilterParameter::Parameter, RequiredZThickness)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Minimum Z Dimension", NumZVoxels, FilterParameter::Category::Parameter, RequiredZThickness, 0)); + parameters.push_back(SIMPL_NEW_BOOL_FP("Preflight Check", PreflightCheck, FilterParameter::Category::Parameter, RequiredZThickness)); setFilterParameters(parameters); } @@ -82,7 +81,7 @@ void RequiredZThickness::readFilterParameters(AbstractFilterParametersReader* re { AbstractDecisionFilter::readFilterParameters(reader, index); reader->openFilterGroup(this, index); - setDataContainerSelection(reader->readString("DataContainerSelection", getDataContainerSelection())); + setDataContainerSelection(reader->readDataArrayPath("DataContainerSelection", getDataContainerSelection())); setNumZVoxels(reader->readValue("NumZVoxels", getNumZVoxels())); setPreflightCheck(reader->readValue("PreflightCheck", getPreflightCheck())); reader->closeFilterGroup(); @@ -100,15 +99,15 @@ void RequiredZThickness::initialize() // ----------------------------------------------------------------------------- void RequiredZThickness::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); - if(getErrorCondition() < 0) + clearErrorCode(); + clearWarningCode(); + if(getErrorCode() < 0) { return; } DataContainer::Pointer dataContainer = getDataContainerArray()->getPrereqDataContainer(this, getDataContainerSelection()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -116,24 +115,21 @@ void RequiredZThickness::dataCheck() ImageGeom::Pointer image = dataContainer->getGeometryAs(); if(nullptr == image.get()) { - setErrorCondition(-7789); - notifyErrorMessage(getHumanLabel(), "Missing Image Geometry in the selected DataContainer", getErrorCondition()); + setErrorCondition(-7789, "Missing Image Geometry in the selected DataContainer"); return; } - size_t dims[3] = {0, 0, 0}; - std::tie(dims[0], dims[1], dims[2]) = image->getDimensions(); + SizeVec3Type dims = image->getDimensions(); if(dims[2] < getNumZVoxels() && m_PreflightCheck) { - setErrorCondition(-7787); QString str; QTextStream ss(&str); ss << "Number of Z Voxels does not meet required value during preflight of the filter. \n"; ss << " Required Z Voxels: " << m_NumZVoxels << "\n"; ss << " Current Z Voxels: " << dims[2]; - notifyErrorMessage(getHumanLabel(), str, getErrorCondition()); + setErrorCondition(-7787, str); } else if(dims[2] < getNumZVoxels() && !m_PreflightCheck) { @@ -143,47 +139,30 @@ void RequiredZThickness::dataCheck() ss << " Required Z Voxels: " << m_NumZVoxels << "\n"; ss << " Current Z Voxels: " << dims[2]; - setWarningCondition(-7788); - notifyWarningMessage(getHumanLabel(), str, getWarningCondition()); + setWarningCondition(-7788, str); } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void RequiredZThickness::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void RequiredZThickness::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } DataContainer::Pointer dataContainer = getDataContainerArray()->getPrereqDataContainer(this, getDataContainerSelection()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } ImageGeom::Pointer image = dataContainer->getGeometryAs(); - size_t dims[3] = {0, 0, 0}; - std::tie(dims[0], dims[1], dims[2]) = image->getDimensions(); + SizeVec3Type dims = image->getDimensions(); if(dims[2] < getNumZVoxels()) { @@ -193,12 +172,10 @@ void RequiredZThickness::execute() ss << " Required Z Voxels: " << m_NumZVoxels << "\n"; ss << " Current Z Voxels: " << dims[2]; - setErrorCondition(-7788); - notifyErrorMessage(getHumanLabel(), str, getErrorCondition()); + setErrorCondition(-7788, str); bool needMoreData = true; - emit decisionMade(needMoreData); + Q_EMIT decisionMade(needMoreData); } - } // ----------------------------------------------------------------------------- @@ -217,7 +194,7 @@ AbstractFilter::Pointer RequiredZThickness::newFilterInstance(bool copyFilterPar // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RequiredZThickness::getCompiledLibraryName() const +QString RequiredZThickness::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -225,7 +202,7 @@ const QString RequiredZThickness::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RequiredZThickness::getGroupName() const +QString RequiredZThickness::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -233,7 +210,7 @@ const QString RequiredZThickness::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid RequiredZThickness::getUuid() +QUuid RequiredZThickness::getUuid() const { return QUuid("{1fe19578-6856-55f2-adc8-2236fac22c25}"); } @@ -241,7 +218,7 @@ const QUuid RequiredZThickness::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RequiredZThickness::getSubGroupName() const +QString RequiredZThickness::getSubGroupName() const { return SIMPL::FilterSubGroups::MiscFilters; } @@ -249,7 +226,68 @@ const QString RequiredZThickness::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString RequiredZThickness::getHumanLabel() const +QString RequiredZThickness::getHumanLabel() const { return "Required Z Dimension (Image Geometry)"; } + +// ----------------------------------------------------------------------------- +RequiredZThickness::Pointer RequiredZThickness::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +RequiredZThickness::Pointer RequiredZThickness::New() +{ + Pointer sharedPtr(new(RequiredZThickness)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString RequiredZThickness::getNameOfClass() const +{ + return QString("RequiredZThickness"); +} + +// ----------------------------------------------------------------------------- +QString RequiredZThickness::ClassName() +{ + return QString("RequiredZThickness"); +} + +// ----------------------------------------------------------------------------- +void RequiredZThickness::setDataContainerSelection(const DataArrayPath& value) +{ + m_DataContainerSelection = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath RequiredZThickness::getDataContainerSelection() const +{ + return m_DataContainerSelection; +} + +// ----------------------------------------------------------------------------- +void RequiredZThickness::setNumZVoxels(int value) +{ + m_NumZVoxels = value; +} + +// ----------------------------------------------------------------------------- +int RequiredZThickness::getNumZVoxels() const +{ + return m_NumZVoxels; +} + +// ----------------------------------------------------------------------------- +void RequiredZThickness::setPreflightCheck(bool value) +{ + m_PreflightCheck = value; +} + +// ----------------------------------------------------------------------------- +bool RequiredZThickness::getPreflightCheck() const +{ + return m_PreflightCheck; +} diff --git a/Source/SIMPLib/CoreFilters/RequiredZThickness.h b/Source/SIMPLib/CoreFilters/RequiredZThickness.h old mode 100755 new mode 100644 index 9b2534cb6a..4edb4acbfc --- a/Source/SIMPLib/CoreFilters/RequiredZThickness.h +++ b/Source/SIMPLib/CoreFilters/RequiredZThickness.h @@ -1,148 +1,193 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/SIMPLib.h" +#include +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/AbstractDecisionFilter.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The RequiredZThickness class. See [Filter documentation](@ref requiredzthickness) for details. */ class SIMPLib_EXPORT RequiredZThickness : public AbstractDecisionFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(RequiredZThickness SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) - PYB11_PROPERTY(int NumZVoxels READ getNumZVoxels WRITE setNumZVoxels) - PYB11_PROPERTY(bool PreflightCheck READ getPreflightCheck WRITE setPreflightCheck) - - public: - SIMPL_SHARED_POINTERS(RequiredZThickness) - SIMPL_STATIC_NEW_MACRO(RequiredZThickness) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(RequiredZThickness, AbstractDecisionFilter) - - ~RequiredZThickness() override; - - SIMPL_FILTER_PARAMETER(QString, DataContainerSelection) - Q_PROPERTY(QString DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) - - SIMPL_FILTER_PARAMETER(int, NumZVoxels) - Q_PROPERTY(int NumZVoxels READ getNumZVoxels WRITE setNumZVoxels) - - SIMPL_FILTER_PARAMETER(bool, PreflightCheck) - Q_PROPERTY(bool PreflightCheck READ getPreflightCheck WRITE setPreflightCheck) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - // signals: - // void decisionMade(bool& dm); - - protected: - RequiredZThickness(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - DEFINE_DATAARRAY_WEAKPTR(int32_t, FeatureIds) - - public: - RequiredZThickness(const RequiredZThickness&) = delete; // Copy Constructor Not Implemented - RequiredZThickness(RequiredZThickness&&) = delete; // Move Constructor Not Implemented - RequiredZThickness& operator=(const RequiredZThickness&) = delete; // Copy Assignment Not Implemented - RequiredZThickness& operator=(RequiredZThickness&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(RequiredZThickness SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(RequiredZThickness) + PYB11_STATIC_NEW_MACRO(RequiredZThickness) + PYB11_PROPERTY(DataArrayPath DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) + PYB11_PROPERTY(int NumZVoxels READ getNumZVoxels WRITE setNumZVoxels) + PYB11_PROPERTY(bool PreflightCheck READ getPreflightCheck WRITE setPreflightCheck) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = RequiredZThickness; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for RequiredZThickness + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for RequiredZThickness + */ + static QString ClassName(); + + ~RequiredZThickness() override; + + /** + * @brief Setter property for DataContainerSelection + */ + void setDataContainerSelection(const DataArrayPath& value); + /** + * @brief Getter property for DataContainerSelection + * @return Value of DataContainerSelection + */ + DataArrayPath getDataContainerSelection() const; + + Q_PROPERTY(DataArrayPath DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) + + /** + * @brief Setter property for NumZVoxels + */ + void setNumZVoxels(int value); + /** + * @brief Getter property for NumZVoxels + * @return Value of NumZVoxels + */ + int getNumZVoxels() const; + + Q_PROPERTY(int NumZVoxels READ getNumZVoxels WRITE setNumZVoxels) + + /** + * @brief Setter property for PreflightCheck + */ + void setPreflightCheck(bool value); + /** + * @brief Getter property for PreflightCheck + * @return Value of PreflightCheck + */ + bool getPreflightCheck() const; + + Q_PROPERTY(bool PreflightCheck READ getPreflightCheck WRITE setPreflightCheck) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + + // Q_SIGNALS: + // void decisionMade(bool& dm); + +protected: + RequiredZThickness(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + std::weak_ptr> m_FeatureIdsPtr; + + DataArrayPath m_DataContainerSelection = {"", "", ""}; + int m_NumZVoxels = {-1}; + bool m_PreflightCheck = {false}; + +public: + RequiredZThickness(const RequiredZThickness&) = delete; // Copy Constructor Not Implemented + RequiredZThickness(RequiredZThickness&&) = delete; // Move Constructor Not Implemented + RequiredZThickness& operator=(const RequiredZThickness&) = delete; // Copy Assignment Not Implemented + RequiredZThickness& operator=(RequiredZThickness&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/RotateSampleRefFrame.cpp b/Source/SIMPLib/CoreFilters/RotateSampleRefFrame.cpp new file mode 100644 index 0000000000..cf7c513132 --- /dev/null +++ b/Source/SIMPLib/CoreFilters/RotateSampleRefFrame.cpp @@ -0,0 +1,799 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Air Force Prime Contract FA8650-15-D-5231 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "RotateSampleRefFrame.h" + +#include + +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS +#include +#include +#include +#endif + +#include + +#include + +#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" +#include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" +#include "SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h" +#include "SIMPLib/FilterParameters/DynamicTableFilterParameter.h" +#include "SIMPLib/FilterParameters/FloatFilterParameter.h" +#include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" +#include "SIMPLib/FilterParameters/LinkedChoicesFilterParameter.h" +#include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" +#include "SIMPLib/Geometry/ImageGeom.h" +#include "SIMPLib/Math/MatrixMath.h" + +namespace +{ +struct RotateArgs +{ + int64_t xp = 0; + int64_t yp = 0; + int64_t zp = 0; + float xRes = 0.0f; + float yRes = 0.0f; + float zRes = 0.0f; + int64_t xpNew = 0; + int64_t ypNew = 0; + int64_t zpNew = 0; + float xResNew = 0.0f; + float yResNew = 0.0f; + float zResNew = 0.0f; + float xMinNew = 0.0f; + float yMinNew = 0.0f; + float zMinNew = 0.0f; +}; + +using Matrix3fR = Eigen::Matrix; + +constexpr float k_Threshold = 0.0001f; + +const Eigen::Vector3f k_XAxis = Eigen::Vector3f::UnitX(); +const Eigen::Vector3f k_YAxis = Eigen::Vector3f::UnitY(); +const Eigen::Vector3f k_ZAxis = Eigen::Vector3f::UnitZ(); + +// Requires table to be 3 x 3 +Matrix3fR tableToMatrix(const std::vector>& table) +{ + Matrix3fR matrix; + + for(size_t i = 0; i < table.size(); i++) + { + const auto& row = table[i]; + for(size_t j = 0; j < row.size(); j++) + { + matrix(i, j) = row[j]; + } + } + + return matrix; +} + +void determineMinMax(const Matrix3fR& rotationMatrix, const FloatVec3Type& spacing, size_t col, size_t row, size_t plane, float& xMin, float& xMax, float& yMin, float& yMax, float& zMin, float& zMax) +{ + Eigen::Vector3f coords(static_cast(col) * spacing[0], static_cast(row) * spacing[1], static_cast(plane) * spacing[2]); + + Eigen::Vector3f newCoords = rotationMatrix * coords; + + xMin = std::min(newCoords[0], xMin); + xMax = std::max(newCoords[0], xMax); + + yMin = std::min(newCoords[1], yMin); + yMax = std::max(newCoords[1], yMax); + + zMin = std::min(newCoords[2], zMin); + zMax = std::max(newCoords[2], zMax); +} + +float cosBetweenVectors(const Eigen::Vector3f& a, const Eigen::Vector3f& b) +{ + float normA = a.norm(); + float normB = b.norm(); + + if(normA == 0.0f || normB == 0.0f) + { + return 1.0f; + } + + return a.dot(b) / (normA * normB); +} + +float determineSpacing(const FloatVec3Type& spacing, const Eigen::Vector3f& axisNew) +{ + float xAngle = std::abs(cosBetweenVectors(k_XAxis, axisNew)); + float yAngle = std::abs(cosBetweenVectors(k_YAxis, axisNew)); + float zAngle = std::abs(cosBetweenVectors(k_ZAxis, axisNew)); + + std::array axes = {xAngle, yAngle, zAngle}; + + auto iter = std::max_element(axes.cbegin(), axes.cend()); + + size_t index = std::distance(axes.cbegin(), iter); + + return spacing[index]; +} + +RotateArgs createRotateParams(const ImageGeom& imageGeom, const Matrix3fR& rotationMatrix) +{ + const SizeVec3Type origDims = imageGeom.getDimensions(); + const FloatVec3Type spacing = imageGeom.getSpacing(); + // const FloatVec3Type origin = imageGeom.getOrigin(); + + float xMin = std::numeric_limits::max(); + float xMax = std::numeric_limits::min(); + float yMin = std::numeric_limits::max(); + float yMax = std::numeric_limits::min(); + float zMin = std::numeric_limits::max(); + float zMax = std::numeric_limits::min(); + + const std::vector> coords{{0, 0, 0}, + {origDims[0] - 1, 0, 0}, + {0, origDims[1] - 1, 0}, + {origDims[0] - 1, origDims[1] - 1, 0}, + {0, 0, origDims[2] - 1}, + {origDims[0] - 1, 0, origDims[2] - 1}, + {0, origDims[1] - 1, origDims[2] - 1}, + {origDims[0] - 1, origDims[1] - 1, origDims[2] - 1}}; + + for(const auto& item : coords) + { + determineMinMax(rotationMatrix, spacing, item[0], item[1], item[2], xMin, xMax, yMin, yMax, zMin, zMax); + } + + Eigen::Vector3f xAxisNew = rotationMatrix * k_XAxis; + Eigen::Vector3f yAxisNew = rotationMatrix * k_YAxis; + Eigen::Vector3f zAxisNew = rotationMatrix * k_ZAxis; + + float xResNew = determineSpacing(spacing, xAxisNew); + float yResNew = determineSpacing(spacing, yAxisNew); + float zResNew = determineSpacing(spacing, zAxisNew); + + MeshIndexType xpNew = static_cast(std::nearbyint((xMax - xMin) / xResNew) + 1); + MeshIndexType ypNew = static_cast(std::nearbyint((yMax - yMin) / yResNew) + 1); + MeshIndexType zpNew = static_cast(std::nearbyint((zMax - zMin) / zResNew) + 1); + + RotateArgs params; + + params.xp = origDims[0]; + params.xRes = spacing[0]; + params.yp = origDims[1]; + params.yRes = spacing[1]; + params.zp = origDims[2]; + params.zRes = spacing[2]; + + params.xpNew = xpNew; + params.xResNew = xResNew; + params.xMinNew = xMin; + params.ypNew = ypNew; + params.yResNew = yResNew; + params.yMinNew = yMin; + params.zpNew = zpNew; + params.zResNew = zResNew; + params.zMinNew = zMin; + + return params; +} + +void updateGeometry(ImageGeom& imageGeom, const RotateArgs& params) +{ + FloatVec3Type origin = imageGeom.getOrigin(); + + imageGeom.setSpacing(params.xResNew, params.yResNew, params.zResNew); + imageGeom.setDimensions(params.xpNew, params.ypNew, params.zpNew); + origin[0] += params.xMinNew; + origin[1] += params.yMinNew; + origin[2] += params.zMinNew; + imageGeom.setOrigin(origin); +} + +/** + * @brief The RotateSampleRefFrameImpl class implements a threaded algorithm to do the + * actual computation of the rotation by applying the rotation to each Euler angle + */ +class SampleRefFrameRotator +{ + DataArray::Pointer m_NewIndicesPtr; + float m_RotMatrixInv[3][3] = {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}}; + bool m_SliceBySlice = false; + RotateArgs m_Params; + +public: + SampleRefFrameRotator(DataArray::Pointer newindices, const RotateArgs& args, const Matrix3fR& rotationMatrix, bool sliceBySlice) + : m_NewIndicesPtr(newindices) + , m_SliceBySlice(sliceBySlice) + , m_Params(args) + { + // We have to inline the 3x3 Maxtrix transpose here because of the "const" nature of the 'convert' function + Matrix3fR transpose = rotationMatrix.transpose(); + // Need to use row based Eigen matrix so that the values get mapped to the right place in the raw array + // Raw array is faster than Eigen + Eigen::Map(&m_RotMatrixInv[0][0], transpose.rows(), transpose.cols()) = transpose; + } + + ~SampleRefFrameRotator() = default; + + void convert(int64_t zStart, int64_t zEnd, int64_t yStart, int64_t yEnd, int64_t xStart, int64_t xEnd) const + { + int64_t* newindicies = m_NewIndicesPtr->getPointer(0); + + for(int64_t k = zStart; k < zEnd; k++) + { + int64_t ktot = (m_Params.xpNew * m_Params.ypNew) * k; + for(int64_t j = yStart; j < yEnd; j++) + { + int64_t jtot = (m_Params.xpNew) * j; + for(int64_t i = xStart; i < xEnd; i++) + { + int64_t index = ktot + jtot + i; + newindicies[index] = -1; + + float coords[3] = {0.0f, 0.0f, 0.0f}; + float coordsNew[3] = {0.0f, 0.0f, 0.0f}; + + coords[0] = (static_cast(i) * m_Params.xResNew) + m_Params.xMinNew; + coords[1] = (static_cast(j) * m_Params.yResNew) + m_Params.yMinNew; + coords[2] = (static_cast(k) * m_Params.zResNew) + m_Params.zMinNew; + + MatrixMath::Multiply3x3with3x1(m_RotMatrixInv, coords, coordsNew); + + int64_t colOld = static_cast(std::nearbyint(coordsNew[0] / m_Params.xRes)); + int64_t rowOld = static_cast(std::nearbyint(coordsNew[1] / m_Params.yRes)); + int64_t planeOld = static_cast(std::nearbyint(coordsNew[2] / m_Params.zRes)); + + if(m_SliceBySlice) + { + planeOld = k; + } + + if(colOld >= 0 && colOld < m_Params.xp && rowOld >= 0 && rowOld < m_Params.yp && planeOld >= 0 && planeOld < m_Params.zp) + { + newindicies[index] = (m_Params.xp * m_Params.yp * planeOld) + (m_Params.xp * rowOld) + colOld; + } + } + } + } + } + +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS + void operator()(const tbb::blocked_range3d& r) const + { + convert(r.pages().begin(), r.pages().end(), r.rows().begin(), r.rows().end(), r.cols().begin(), r.cols().end()); + } +#endif +}; + +} // namespace + +struct RotateSampleRefFrame::Impl +{ + Matrix3fR m_RotationMatrix = Matrix3fR::Zero(); + RotateArgs m_Params; + + void reset() + { + m_RotationMatrix.setZero(); + + m_Params = RotateArgs(); + } +}; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +RotateSampleRefFrame::RotateSampleRefFrame() +: p_Impl(std::make_unique()) +{ + std::vector> defaultTable{{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}; + + m_RotationTable.setTableData(defaultTable); + m_RotationTable.setDynamicRows(false); + m_RotationTable.setDynamicCols(false); + m_RotationTable.setDefaultColCount(3); + m_RotationTable.setDefaultRowCount(3); + m_RotationTable.setMinCols(3); + m_RotationTable.setMinRows(3); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +RotateSampleRefFrame::~RotateSampleRefFrame() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void RotateSampleRefFrame::setupFilterParameters() +{ + FilterParameterVectorType parameters; + + { + LinkedChoicesFilterParameter::Pointer parameter = LinkedChoicesFilterParameter::New(); + parameter->setHumanLabel("Rotation Representation"); + parameter->setPropertyName("RotationRepresentationChoice"); + parameter->setSetterCallback(SIMPL_BIND_SETTER(RotateSampleRefFrame, this, RotationRepresentationChoice)); + parameter->setGetterCallback(SIMPL_BIND_GETTER(RotateSampleRefFrame, this, RotationRepresentationChoice)); + std::vector choices{"Axis Angle", "Rotation Matrix"}; + parameter->setChoices(choices); + std::vector linkedProps{"RotationAngle", "RotationAxis", "RotationTable"}; + parameter->setLinkedProperties(linkedProps); + parameter->setEditable(false); + parameter->setCategory(FilterParameter::Category::Parameter); + parameters.push_back(parameter); + } + + // Axis Angle Parameters + + parameters.push_back(SIMPL_NEW_FLOAT_FP("Rotation Angle (Degrees)", RotationAngle, FilterParameter::Category::Parameter, RotateSampleRefFrame, 0)); + parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Rotation Axis (ijk)", RotationAxis, FilterParameter::Category::Parameter, RotateSampleRefFrame, 0)); + + // Rotation Matrix Parameters + + parameters.push_back(SIMPL_NEW_DYN_TABLE_FP("Rotation Matrix", RotationTable, FilterParameter::Category::Parameter, RotateSampleRefFrame, 1)); + + // Required Arrays + + parameters.push_back(SeparatorFilterParameter::Create("Cell Data", FilterParameter::Category::RequiredArray)); + { + AttributeMatrixSelectionFilterParameter::RequirementType req = AttributeMatrixSelectionFilterParameter::CreateRequirement(AttributeMatrix::Type::Cell, IGeometry::Type::Image); + parameters.push_back(SIMPL_NEW_AM_SELECTION_FP("Cell Attribute Matrix", CellAttributeMatrixPath, FilterParameter::Category::RequiredArray, RotateSampleRefFrame, req)); + } + + setFilterParameters(parameters); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void RotateSampleRefFrame::readFilterParameters(AbstractFilterParametersReader* reader, int index) +{ + reader->openFilterGroup(this, index); + setCellAttributeMatrixPath(reader->readDataArrayPath("CellAttributeMatrixPath", getCellAttributeMatrixPath())); + setRotationAxis(reader->readFloatVec3("RotationAxis", getRotationAxis())); + setRotationAngle(reader->readValue("RotationAngle", getRotationAngle())); + reader->closeFilterGroup(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void RotateSampleRefFrame::initialize() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void RotateSampleRefFrame::dataCheck() +{ + clearErrorCode(); + clearWarningCode(); + + p_Impl->reset(); + + if(getErrorCode() < 0) + { + return; + } + + if(!isRotationRepresentationValid(m_RotationRepresentationChoice)) + { + QString ss = QObject::tr("Invalid rotation representation"); + setErrorCondition(-45001, ss); + return; + } + + getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getCellAttributeMatrixPath().getDataContainerName()); + getDataContainerArray()->getPrereqAttributeMatrixFromPath(this, getCellAttributeMatrixPath(), -301); + if(getErrorCode() < 0) + { + return; + } + + DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getCellAttributeMatrixPath().getDataContainerName()); + + if(m == nullptr) + { + QString ss = QObject::tr("Failed to get DataContainer '%1'").arg(getCellAttributeMatrixPath().getDataContainerName()); + setErrorCondition(-45002, ss); + return; + } + + ImageGeom::Pointer imageGeom = m->getGeometryAs(); + + if(imageGeom == nullptr) + { + QString ss = QObject::tr("Failed to get Image Geometry from '%1'").arg(getCellAttributeMatrixPath().getDataContainerName()); + setErrorCondition(-45002, ss); + return; + } + + const RotationRepresentation representation = getRotationRepresentation(); + + switch(representation) + { + case RotationRepresentation::AxisAngle: { + const Eigen::Vector3f rotationAxis(m_RotationAxis.data()); + float norm = rotationAxis.norm(); + if(!SIMPLibMath::closeEnough(rotationAxis.norm(), 1.0f, k_Threshold)) + { + QString ss = QObject::tr("Axis angle is not normalized (norm is %1). Filter will automatically normalize the value.").arg(norm); + setWarningCondition(-45003, ss); + } + + float rotationAngleRadians = m_RotationAngle * SIMPLib::Constants::k_DegToRadD; + + Eigen::AngleAxisf axisAngle(rotationAngleRadians, rotationAxis.normalized()); + + p_Impl->m_RotationMatrix = axisAngle.toRotationMatrix(); + } + break; + case RotationRepresentation::RotationMatrix: { + auto rotationMatrixTable = m_RotationTable.getTableData(); + + if(rotationMatrixTable.size() != 3) + { + QString ss = QObject::tr("Rotation Matrix must be 3 x 3"); + setErrorCondition(-45004, ss); + return; + } + + for(const auto& row : rotationMatrixTable) + { + if(row.size() != 3) + { + QString ss = QObject::tr("Rotation Matrix must be 3 x 3"); + setErrorCondition(-45005, ss); + return; + } + } + + Matrix3fR rotationMatrix = tableToMatrix(rotationMatrixTable); + + float determinant = rotationMatrix.determinant(); + + if(!SIMPLibMath::closeEnough(determinant, 1.0f, k_Threshold)) + { + QString ss = QObject::tr("Rotation Matrix must have a determinant of 1 (is %1)").arg(determinant); + setErrorCondition(-45006, ss); + return; + } + + Matrix3fR transpose = rotationMatrix.transpose(); + Matrix3fR inverse = rotationMatrix.inverse(); + + if(!transpose.isApprox(inverse, k_Threshold)) + { + QString ss = QObject::tr("Rotation Matrix's inverse and transpose must be equal"); + setErrorCondition(-45007, ss); + return; + } + + p_Impl->m_RotationMatrix = rotationMatrix; + } + break; + default: { + QString ss = QObject::tr("Invalid rotation representation"); + setErrorCondition(-45008, ss); + return; + } + } + + p_Impl->m_Params = createRotateParams(*imageGeom, p_Impl->m_RotationMatrix); + + updateGeometry(*imageGeom, p_Impl->m_Params); + + // Resize attribute matrix + + std::vector tDims(3); + tDims[0] = p_Impl->m_Params.xpNew; + tDims[1] = p_Impl->m_Params.ypNew; + tDims[2] = p_Impl->m_Params.zpNew; + QString attrMatName = getCellAttributeMatrixPath().getAttributeMatrixName(); + m->getAttributeMatrix(attrMatName)->resizeAttributeArrays(tDims); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void RotateSampleRefFrame::execute() +{ + dataCheck(); + if(getErrorCode() < 0) + { + return; + } + + DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getCellAttributeMatrixPath().getDataContainerName()); + + if(m == nullptr) + { + QString ss = QObject::tr("Failed to get DataContainer '%1'").arg(getCellAttributeMatrixPath().getDataContainerName()); + setErrorCondition(-45101, ss); + return; + } + + int64_t newNumCellTuples = p_Impl->m_Params.xpNew * p_Impl->m_Params.ypNew * p_Impl->m_Params.zpNew; + + DataArray::Pointer newIndiciesPtr = DataArray::CreateArray(newNumCellTuples, std::string("_INTERNAL_USE_ONLY_RotateSampleRef_NewIndicies"), true); + newIndiciesPtr->initializeWithValue(-1); + int64_t* newindicies = newIndiciesPtr->getPointer(0); + +#ifdef SIMPL_USE_PARALLEL_ALGORITHMS + tbb::parallel_for(tbb::blocked_range3d(0, p_Impl->m_Params.zpNew, 0, p_Impl->m_Params.ypNew, 0, p_Impl->m_Params.xpNew), + SampleRefFrameRotator(newIndiciesPtr, p_Impl->m_Params, p_Impl->m_RotationMatrix, m_SliceBySlice), tbb::auto_partitioner()); +#else + { + SampleRefFrameRotator serial(newIndiciesPtr, p_Impl->m_Params, p_Impl->m_RotationMatrix, m_SliceBySlice); + serial.convert(0, p_Impl->m_Params.zpNew, 0, p_Impl->m_Params.ypNew, 0, p_Impl->m_Params.xpNew); + } +#endif + + // This could technically be parallelized also where each thread takes an array to adjust. Except + // that the DataContainer is NOT thread safe or re-entrant so that would actually be a BAD idea. + + QString attrMatName = getCellAttributeMatrixPath().getAttributeMatrixName(); + QList voxelArrayNames = m->getAttributeMatrix(attrMatName)->getAttributeArrayNames(); + + for(const auto& attrArrayName : voxelArrayNames) + { + IDataArray::Pointer p = m->getAttributeMatrix(attrMatName)->getAttributeArray(attrArrayName); + + // Make a copy of the 'p' array that has the same name. When placed into + // the data container this will over write the current array with + // the same name. + + IDataArray::Pointer data = p->createNewArray(newNumCellTuples, p->getComponentDimensions(), p->getName()); + int64_t newIndicies_I = 0; + for(size_t i = 0; i < static_cast(newNumCellTuples); i++) + { + newIndicies_I = newindicies[i]; + if(newIndicies_I >= 0) + { + if(!data->copyFromArray(i, p, newIndicies_I, 1)) + { + QString ss = QObject::tr("copyFromArray Failed: "); + QTextStream out(&ss); + out << "Source Array Name: " << p->getName() << " Source Tuple Index: " << newIndicies_I << "\n"; + out << "Dest Array Name: " << data->getName() << " Dest. Tuple Index: " << i << "\n"; + setErrorCondition(-45102, ss); + return; + } + } + else + { + int var = 0; + data->initializeTuple(i, &var); + } + } + m->getAttributeMatrix(attrMatName)->insertOrAssign(data); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AbstractFilter::Pointer RotateSampleRefFrame::newFilterInstance(bool copyFilterParameters) const +{ + RotateSampleRefFrame::Pointer filter = RotateSampleRefFrame::New(); + if(copyFilterParameters) + { + copyFilterParameterInstanceVariables(filter.get()); + } + return filter; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString RotateSampleRefFrame::getCompiledLibraryName() const +{ + return Core::CoreBaseName; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString RotateSampleRefFrame::getBrandingString() const +{ + return "SIMPLib Core Filter"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString RotateSampleRefFrame::getFilterVersion() const +{ + QString version; + QTextStream vStream(&version); + vStream << SIMPLib::Version::Major() << "." << SIMPLib::Version::Minor() << "." << SIMPLib::Version::Patch(); + return version; +} +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString RotateSampleRefFrame::getGroupName() const +{ + return SIMPL::FilterGroups::SamplingFilters; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QUuid RotateSampleRefFrame::getUuid() const +{ + return QUuid("{e25d9b4c-2b37-578c-b1de-cf7032b5ef19}"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString RotateSampleRefFrame::getSubGroupName() const +{ + return SIMPL::FilterSubGroups::RotationTransformationFilters; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString RotateSampleRefFrame::getHumanLabel() const +{ + return "Rotate Sample Reference Frame"; +} + +// ----------------------------------------------------------------------------- +RotateSampleRefFrame::Pointer RotateSampleRefFrame::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr RotateSampleRefFrame::New() +{ + struct make_shared_enabler : public RotateSampleRefFrame + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString RotateSampleRefFrame::getNameOfClass() const +{ + return QString("RotateSampleRefFrame"); +} + +// ----------------------------------------------------------------------------- +QString RotateSampleRefFrame::ClassName() +{ + return QString("RotateSampleRefFrame"); +} + +// ----------------------------------------------------------------------------- +void RotateSampleRefFrame::setCellAttributeMatrixPath(const DataArrayPath& value) +{ + m_CellAttributeMatrixPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath RotateSampleRefFrame::getCellAttributeMatrixPath() const +{ + return m_CellAttributeMatrixPath; +} + +// ----------------------------------------------------------------------------- +void RotateSampleRefFrame::setRotationAxis(const FloatVec3Type& value) +{ + m_RotationAxis = value; +} + +// ----------------------------------------------------------------------------- +FloatVec3Type RotateSampleRefFrame::getRotationAxis() const +{ + return m_RotationAxis; +} + +// ----------------------------------------------------------------------------- +void RotateSampleRefFrame::setRotationAngle(float value) +{ + m_RotationAngle = value; +} + +// ----------------------------------------------------------------------------- +float RotateSampleRefFrame::getRotationAngle() const +{ + return m_RotationAngle; +} + +// ----------------------------------------------------------------------------- +void RotateSampleRefFrame::setSliceBySlice(bool value) +{ + m_SliceBySlice = value; +} + +// ----------------------------------------------------------------------------- +bool RotateSampleRefFrame::getSliceBySlice() const +{ + return m_SliceBySlice; +} + +// ----------------------------------------------------------------------------- +void RotateSampleRefFrame::setRotationTable(const DynamicTableData& value) +{ + m_RotationTable = value; +} + +// ----------------------------------------------------------------------------- +DynamicTableData RotateSampleRefFrame::getRotationTable() const +{ + return m_RotationTable; +} + +// ----------------------------------------------------------------------------- +void RotateSampleRefFrame::setRotationRepresentationChoice(int value) +{ + m_RotationRepresentationChoice = value; +} + +// ----------------------------------------------------------------------------- +int RotateSampleRefFrame::getRotationRepresentationChoice() const +{ + return m_RotationRepresentationChoice; +} + +// ----------------------------------------------------------------------------- +RotateSampleRefFrame::RotationRepresentation RotateSampleRefFrame::getRotationRepresentation() const +{ + return static_cast(m_RotationRepresentationChoice); +} + +// ----------------------------------------------------------------------------- +void RotateSampleRefFrame::setRotationRepresentation(RotationRepresentation value) +{ + m_RotationRepresentationChoice = static_cast(value); +} + +// ----------------------------------------------------------------------------- +bool RotateSampleRefFrame::isRotationRepresentationValid(int value) const +{ + return (value >= 0) && (value <= 1); +} diff --git a/Source/SIMPLib/CoreFilters/RotateSampleRefFrame.h b/Source/SIMPLib/CoreFilters/RotateSampleRefFrame.h new file mode 100644 index 0000000000..0e2a3c3250 --- /dev/null +++ b/Source/SIMPLib/CoreFilters/RotateSampleRefFrame.h @@ -0,0 +1,298 @@ +/* ============================================================================ + * Copyright (c) 2009-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Air Force Prime Contract FA8650-15-D-5231 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/FilterParameters/DynamicTableData.h" +#include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +/** + * @brief The RotateSampleRefFrame class. See [Filter documentation](@ref rotatesamplerefframe) for details. + */ +class SIMPLib_EXPORT RotateSampleRefFrame : public AbstractFilter +{ + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(RotateSampleRefFrame SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(RotateSampleRefFrame) + PYB11_FILTER_NEW_MACRO(RotateSampleRefFrame) + PYB11_ENUMERATION(RotationRepresentation) + PYB11_PROPERTY(DataArrayPath CellAttributeMatrixPath READ getCellAttributeMatrixPath WRITE setCellAttributeMatrixPath) + PYB11_PROPERTY(FloatVec3Type RotationAxis READ getRotationAxis WRITE setRotationAxis) + PYB11_PROPERTY(float RotationAngle READ getRotationAngle WRITE setRotationAngle) + PYB11_PROPERTY(bool SliceBySlice READ getSliceBySlice WRITE setSliceBySlice) + PYB11_PROPERTY(DynamicTableData RotationTable READ getRotationTable WRITE setRotationTable) + PYB11_PROPERTY(int RotationRepresentationChoice READ getRotationRepresentationChoice WRITE setRotationRepresentationChoice) + PYB11_METHOD(RotationRepresentation getRotationRepresentation) + PYB11_METHOD(void setRotationRepresentation ARGS value) + PYB11_METHOD(bool isRotationRepresentationValid ARGS value) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = RotateSampleRefFrame; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for RotateSampleRefFrame + */ + QString getNameOfClass() const override; + + /** + * @brief Returns the name of the class for RotateSampleRefFrame + */ + static QString ClassName(); + + ~RotateSampleRefFrame() override; + + enum class RotationRepresentation : int + { + AxisAngle = 0, + RotationMatrix = 1 + }; + + /** + * @brief Returns the current rotation representation in enum form. + * @return + */ + RotationRepresentation getRotationRepresentation() const; + + /** + * @brief Sets the rotation representation value to the given enum value + * @param value + */ + void setRotationRepresentation(RotationRepresentation value); + + /** + * @brief Returns true if the selected index for the rotation representation choice widget is a valid enum value. + * @param value + * @return + */ + bool isRotationRepresentationValid(int value) const; + + /** + * @brief Setter property for CellAttributeMatrixPath + */ + void setCellAttributeMatrixPath(const DataArrayPath& value); + + /** + * @brief Getter property for CellAttributeMatrixPath + * @return Value of CellAttributeMatrixPath + */ + DataArrayPath getCellAttributeMatrixPath() const; + + Q_PROPERTY(DataArrayPath CellAttributeMatrixPath READ getCellAttributeMatrixPath WRITE setCellAttributeMatrixPath) + + /** + * @brief Setter property for RotationAxis + */ + void setRotationAxis(const FloatVec3Type& value); + + /** + * @brief Getter property for RotationAxis + * @return Value of RotationAxis + */ + FloatVec3Type getRotationAxis() const; + + Q_PROPERTY(FloatVec3Type RotationAxis READ getRotationAxis WRITE setRotationAxis) + + /** + * @brief Setter property for RotationAngle + */ + void setRotationAngle(float value); + + /** + * @brief Getter property for RotationAngle + * @return Value of RotationAngle + */ + float getRotationAngle() const; + + Q_PROPERTY(float RotationAngle READ getRotationAngle WRITE setRotationAngle) + + // This is getting exposed because other filters that are calling this filter needs to set this value + /** + * @brief Setter property for SliceBySlice + */ + void setSliceBySlice(bool value); + + /** + * @brief Getter property for SliceBySlice + * @return Value of SliceBySlice + */ + bool getSliceBySlice() const; + + Q_PROPERTY(bool SliceBySlice READ getSliceBySlice WRITE setSliceBySlice) + + /** + * @brief Setter property for RotationTable + * @param value + */ + void setRotationTable(const DynamicTableData& value); + + /** + * @brief Setter property for RotationRepresentationChoice + * @param value + */ + void setRotationRepresentationChoice(int value); + + /** + * @brief Getter property for RotationRepresentationChoice + * @return + */ + int getRotationRepresentationChoice() const; + + Q_PROPERTY(int RotationRepresentationChoice READ getRotationRepresentationChoice WRITE setRotationRepresentationChoice) + + /** + * @brief Getter property for RotationTable + * @return + */ + DynamicTableData getRotationTable() const; + + Q_PROPERTY(DynamicTableData RotationTable READ getRotationTable WRITE setRotationTable) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + RotateSampleRefFrame(); + + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +public: + RotateSampleRefFrame(const RotateSampleRefFrame&) = delete; // Copy Constructor Not Implemented + RotateSampleRefFrame(RotateSampleRefFrame&&) = delete; // Move Constructor Not Implemented + RotateSampleRefFrame& operator=(const RotateSampleRefFrame&) = delete; // Copy Assignment Not Implemented + RotateSampleRefFrame& operator=(RotateSampleRefFrame&&) = delete; // Move Assignment Not Implemented + +private: + struct Impl; + std::unique_ptr p_Impl; + + DataArrayPath m_CellAttributeMatrixPath = {SIMPL::Defaults::ImageDataContainerName, SIMPL::Defaults::CellAttributeMatrixName, ""}; + FloatVec3Type m_RotationAxis = {0.0f, 0.0f, 1.0f}; + float m_RotationAngle = 0.0f; + bool m_SliceBySlice = false; + DynamicTableData m_RotationTable; + int m_RotationRepresentationChoice = 0; +}; diff --git a/Source/SIMPLib/CoreFilters/ScaleVolume.cpp b/Source/SIMPLib/CoreFilters/ScaleVolume.cpp index e5a92f27f1..95332877dc 100644 --- a/Source/SIMPLib/CoreFilters/ScaleVolume.cpp +++ b/Source/SIMPLib/CoreFilters/ScaleVolume.cpp @@ -1,56 +1,52 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ScaleVolume.h" -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS -#include -#include -#include -#include -#endif +#include +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" -#include "SIMPLib/SIMPLibVersion.h" - #include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" #include "SIMPLib/FilterParameters/LinkedBooleanFilterParameter.h" #include "SIMPLib/Geometry/IGeometry2D.h" #include "SIMPLib/Geometry/ImageGeom.h" +#include "SIMPLib/Utilities/ParallelDataAlgorithm.h" /** * @brief The CalculateCentroidsImpl class implements a threaded algorithm that scales the @@ -60,10 +56,10 @@ class ScaleVolumeUpdateVerticesImpl { float* m_Nodes; float* m_Min; - FloatVec3_t m_ScaleFactor; + FloatVec3Type m_ScaleFactor; public: - ScaleVolumeUpdateVerticesImpl(float* nodes, float* min, FloatVec3_t scale) + ScaleVolumeUpdateVerticesImpl(float* nodes, float* min, FloatVec3Type scale) : m_Nodes(nodes) , m_Min(min) , m_ScaleFactor(scale) @@ -75,33 +71,26 @@ class ScaleVolumeUpdateVerticesImpl { for(size_t i = start; i < end; i++) { - m_Nodes[3 * i] = m_Min[0] + (m_Nodes[3 * i] - m_Min[0]) * m_ScaleFactor.x; - m_Nodes[3 * i + 1] = m_Min[1] + (m_Nodes[3 * i + 1] - m_Min[1]) * m_ScaleFactor.y; - m_Nodes[3 * i + 2] = m_Min[2] + (m_Nodes[3 * i + 2] - m_Min[2]) * m_ScaleFactor.z; + m_Nodes[3 * i] = m_Min[0] + (m_Nodes[3 * i] - m_Min[0]) * m_ScaleFactor[0]; + m_Nodes[3 * i + 1] = m_Min[1] + (m_Nodes[3 * i + 1] - m_Min[1]) * m_ScaleFactor[1]; + m_Nodes[3 * i + 2] = m_Min[2] + (m_Nodes[3 * i + 2] - m_Min[2]) * m_ScaleFactor[2]; } } -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - void operator()(const tbb::blocked_range& r) const + void operator()(const SIMPLRange& range) const { - generate(r.begin(), r.end()); + generate(range.min(), range.max()); } -#endif }; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- ScaleVolume::ScaleVolume() -: m_DataContainerName("") -, m_SurfaceDataContainerName("") -, m_ApplyToVoxelVolume(true) -, m_ApplyToSurfaceMesh(true) { - m_ScaleFactor.x = 1.0f; - m_ScaleFactor.y = 1.0f; - m_ScaleFactor.z = 1.0f; - + m_ScaleFactor[0] = 1.0f; + m_ScaleFactor[1] = 1.0f; + m_ScaleFactor[2] = 1.0f; } // ----------------------------------------------------------------------------- @@ -114,27 +103,27 @@ ScaleVolume::~ScaleVolume() = default; // ----------------------------------------------------------------------------- void ScaleVolume::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Scaling Factor", ScaleFactor, FilterParameter::Parameter, ScaleVolume)); + parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Scaling Factor", ScaleFactor, FilterParameter::Category::Parameter, ScaleVolume)); - QStringList linkedProps("DataContainerName"); - parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Apply to Image Geometry", ApplyToVoxelVolume, FilterParameter::Parameter, ScaleVolume, linkedProps)); + std::vector linkedProps = {"DataContainerName"}; + parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Apply to Image Geometry", ApplyToVoxelVolume, FilterParameter::Category::Parameter, ScaleVolume, linkedProps)); { DataContainerSelectionFilterParameter::RequirementType req; req.dcGeometryTypes = IGeometry::Types(1, IGeometry::Type::Image); - parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container Image Geometry to Scale", DataContainerName, FilterParameter::RequiredArray, ScaleVolume, req)); + parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container Image Geometry to Scale", DataContainerName, FilterParameter::Category::RequiredArray, ScaleVolume, req)); } linkedProps.clear(); - linkedProps << "SurfaceDataContainerName"; - parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Apply to Surface Geometry", ApplyToSurfaceMesh, FilterParameter::Parameter, ScaleVolume, linkedProps)); + linkedProps.push_back("SurfaceDataContainerName"); + parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Apply to Surface Geometry", ApplyToSurfaceMesh, FilterParameter::Category::Parameter, ScaleVolume, linkedProps)); { DataContainerSelectionFilterParameter::RequirementType req; IGeometry::Types dcGeometryTypes; dcGeometryTypes.push_back(IGeometry::Type::Triangle); dcGeometryTypes.push_back(IGeometry::Type::Quad); req.dcGeometryTypes = dcGeometryTypes; - parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container Surface Geometry to Scale", SurfaceDataContainerName, FilterParameter::RequiredArray, ScaleVolume, req)); + parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container Surface Geometry to Scale", SurfaceDataContainerName, FilterParameter::Category::RequiredArray, ScaleVolume, req)); } setFilterParameters(parameters); @@ -149,8 +138,8 @@ void ScaleVolume::readFilterParameters(AbstractFilterParametersReader* reader, i setApplyToVoxelVolume(reader->readValue("ApplyToVoxelVolume", getApplyToVoxelVolume())); setApplyToSurfaceMesh(reader->readValue("ApplyToSurfaceMesh", getApplyToSurfaceMesh())); setScaleFactor(reader->readFloatVec3("ScaleFactor", getScaleFactor())); - setDataContainerName(reader->readString("DataContainerName", getDataContainerName())); - setSurfaceDataContainerName(reader->readString("SurfaceDataContainerName", getSurfaceDataContainerName())); + setDataContainerName(reader->readDataArrayPath("DataContainerName", getDataContainerName())); + setSurfaceDataContainerName(reader->readDataArrayPath("SurfaceDataContainerName", getSurfaceDataContainerName())); reader->closeFilterGroup(); } @@ -166,45 +155,27 @@ void ScaleVolume::initialize() // ----------------------------------------------------------------------------- void ScaleVolume::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); if(m_ApplyToVoxelVolume) { - getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getDataContainerName()); + getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getDataContainerName()); } if(m_ApplyToSurfaceMesh) { - getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getSurfaceDataContainerName()); + getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getSurfaceDataContainerName()); } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void ScaleVolume::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ScaleVolume::updateSurfaceMesh() { - setErrorCondition(0); - setWarningCondition(0); - -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - tbb::task_scheduler_init init; - bool doParallel = true; -#endif + clearErrorCode(); + clearWarningCode(); IGeometry2D::Pointer geom2D = getDataContainerArray()->getDataContainer(getSurfaceDataContainerName())->getGeometryAs(); float* nodes = geom2D->getVertexPointer(0); @@ -244,17 +215,9 @@ void ScaleVolume::updateSurfaceMesh() } } -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - if(doParallel) - { - tbb::parallel_for(tbb::blocked_range(0, count), ScaleVolumeUpdateVerticesImpl(nodes, min, m_ScaleFactor), tbb::auto_partitioner()); - } - else -#endif - { - ScaleVolumeUpdateVerticesImpl serial(nodes, min, m_ScaleFactor); - serial.generate(0, count); - } + ParallelDataAlgorithm dataAlg = ParallelDataAlgorithm(); + dataAlg.setRange(0, count); + dataAlg.execute(ScaleVolumeUpdateVerticesImpl(nodes, min, m_ScaleFactor)); } // ----------------------------------------------------------------------------- @@ -262,10 +225,8 @@ void ScaleVolume::updateSurfaceMesh() // ----------------------------------------------------------------------------- void ScaleVolume::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -275,19 +236,17 @@ void ScaleVolume::execute() DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getDataContainerName()); ImageGeom::Pointer image = m->getGeometryAs(); - float resolution[3] = {0.0f, 0.0f, 0.0f}; - image->getResolution(resolution); - resolution[0] *= m_ScaleFactor.x; - resolution[1] *= m_ScaleFactor.y; - resolution[2] *= m_ScaleFactor.z; - image->setResolution(resolution); + FloatVec3Type spacing = image->getSpacing(); + spacing[0] *= m_ScaleFactor[0]; + spacing[1] *= m_ScaleFactor[1]; + spacing[2] *= m_ScaleFactor[2]; + image->setSpacing(spacing); } if(m_ApplyToSurfaceMesh) { updateSurfaceMesh(); } - } // ----------------------------------------------------------------------------- @@ -306,7 +265,7 @@ AbstractFilter::Pointer ScaleVolume::newFilterInstance(bool copyFilterParameters // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ScaleVolume::getCompiledLibraryName() const +QString ScaleVolume::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -314,7 +273,7 @@ const QString ScaleVolume::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ScaleVolume::getBrandingString() const +QString ScaleVolume::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -322,7 +281,7 @@ const QString ScaleVolume::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ScaleVolume::getFilterVersion() const +QString ScaleVolume::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -333,7 +292,7 @@ const QString ScaleVolume::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ScaleVolume::getGroupName() const +QString ScaleVolume::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -341,7 +300,7 @@ const QString ScaleVolume::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid ScaleVolume::getUuid() +QUuid ScaleVolume::getUuid() const { return QUuid("{3cf44c27-9149-5548-945a-deef1dc994a8}"); } @@ -349,7 +308,7 @@ const QUuid ScaleVolume::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ScaleVolume::getSubGroupName() const +QString ScaleVolume::getSubGroupName() const { return SIMPL::FilterSubGroups::SpatialFilters; } @@ -357,7 +316,96 @@ const QString ScaleVolume::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString ScaleVolume::getHumanLabel() const +QString ScaleVolume::getHumanLabel() const { return "Change Scaling of Volume"; } + +// ----------------------------------------------------------------------------- +ScaleVolume::Pointer ScaleVolume::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr ScaleVolume::New() +{ + struct make_shared_enabler : public ScaleVolume + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString ScaleVolume::getNameOfClass() const +{ + return QString("ScaleVolume"); +} + +// ----------------------------------------------------------------------------- +QString ScaleVolume::ClassName() +{ + return QString("ScaleVolume"); +} + +// ----------------------------------------------------------------------------- +void ScaleVolume::setDataContainerName(const DataArrayPath& value) +{ + m_DataContainerName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ScaleVolume::getDataContainerName() const +{ + return m_DataContainerName; +} + +// ----------------------------------------------------------------------------- +void ScaleVolume::setSurfaceDataContainerName(const DataArrayPath& value) +{ + m_SurfaceDataContainerName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath ScaleVolume::getSurfaceDataContainerName() const +{ + return m_SurfaceDataContainerName; +} + +// ----------------------------------------------------------------------------- +void ScaleVolume::setApplyToVoxelVolume(bool value) +{ + m_ApplyToVoxelVolume = value; +} + +// ----------------------------------------------------------------------------- +bool ScaleVolume::getApplyToVoxelVolume() const +{ + return m_ApplyToVoxelVolume; +} + +// ----------------------------------------------------------------------------- +void ScaleVolume::setApplyToSurfaceMesh(bool value) +{ + m_ApplyToSurfaceMesh = value; +} + +// ----------------------------------------------------------------------------- +bool ScaleVolume::getApplyToSurfaceMesh() const +{ + return m_ApplyToSurfaceMesh; +} + +// ----------------------------------------------------------------------------- +void ScaleVolume::setScaleFactor(const FloatVec3Type& value) +{ + m_ScaleFactor = value; +} + +// ----------------------------------------------------------------------------- +FloatVec3Type ScaleVolume::getScaleFactor() const +{ + return m_ScaleFactor; +} diff --git a/Source/SIMPLib/CoreFilters/ScaleVolume.h b/Source/SIMPLib/CoreFilters/ScaleVolume.h old mode 100755 new mode 100644 index 4076ad3bc8..4274c145c8 --- a/Source/SIMPLib/CoreFilters/ScaleVolume.h +++ b/Source/SIMPLib/CoreFilters/ScaleVolume.h @@ -1,191 +1,234 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" #include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/SIMPLib.h" /** * @brief The ScaleVolume class. See [Filter documentation](@ref scalevolume) for details. */ class SIMPLib_EXPORT ScaleVolume : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(ScaleVolume SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) - PYB11_PROPERTY(QString SurfaceDataContainerName READ getSurfaceDataContainerName WRITE setSurfaceDataContainerName) - PYB11_PROPERTY(bool ApplyToVoxelVolume READ getApplyToVoxelVolume WRITE setApplyToVoxelVolume) - PYB11_PROPERTY(bool ApplyToSurfaceMesh READ getApplyToSurfaceMesh WRITE setApplyToSurfaceMesh) - PYB11_PROPERTY(FloatVec3_t ScaleFactor READ getScaleFactor WRITE setScaleFactor) - - public: - SIMPL_SHARED_POINTERS(ScaleVolume) - SIMPL_FILTER_NEW_MACRO(ScaleVolume) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ScaleVolume, AbstractFilter) - - ~ScaleVolume() override; - - SIMPL_FILTER_PARAMETER(QString, DataContainerName) - Q_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) - - SIMPL_FILTER_PARAMETER(QString, SurfaceDataContainerName) - Q_PROPERTY(QString SurfaceDataContainerName READ getSurfaceDataContainerName WRITE setSurfaceDataContainerName) - - SIMPL_FILTER_PARAMETER(bool, ApplyToVoxelVolume) - Q_PROPERTY(bool ApplyToVoxelVolume READ getApplyToVoxelVolume WRITE setApplyToVoxelVolume) - - SIMPL_FILTER_PARAMETER(bool, ApplyToSurfaceMesh) - Q_PROPERTY(bool ApplyToSurfaceMesh READ getApplyToSurfaceMesh WRITE setApplyToSurfaceMesh) - - SIMPL_FILTER_PARAMETER(FloatVec3_t, ScaleFactor) - Q_PROPERTY(FloatVec3_t ScaleFactor READ getScaleFactor WRITE setScaleFactor) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - ScaleVolume(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - /** - * @brief updateSurfaceMesh updates the mesh coordinates - */ - void updateSurfaceMesh(); - - public: - ScaleVolume(const ScaleVolume&) = delete; // Copy Constructor Not Implemented - ScaleVolume(ScaleVolume&&) = delete; // Move Constructor Not Implemented - ScaleVolume& operator=(const ScaleVolume&) = delete; // Copy Assignment Not Implemented - ScaleVolume& operator=(ScaleVolume&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ScaleVolume SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(ScaleVolume) + PYB11_FILTER_NEW_MACRO(ScaleVolume) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_PROPERTY(DataArrayPath SurfaceDataContainerName READ getSurfaceDataContainerName WRITE setSurfaceDataContainerName) + PYB11_PROPERTY(bool ApplyToVoxelVolume READ getApplyToVoxelVolume WRITE setApplyToVoxelVolume) + PYB11_PROPERTY(bool ApplyToSurfaceMesh READ getApplyToSurfaceMesh WRITE setApplyToSurfaceMesh) + PYB11_PROPERTY(FloatVec3Type ScaleFactor READ getScaleFactor WRITE setScaleFactor) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = ScaleVolume; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for ScaleVolume + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ScaleVolume + */ + static QString ClassName(); + + ~ScaleVolume() override; + + /** + * @brief Setter property for DataContainerName + */ + void setDataContainerName(const DataArrayPath& value); + /** + * @brief Getter property for DataContainerName + * @return Value of DataContainerName + */ + DataArrayPath getDataContainerName() const; + + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + + /** + * @brief Setter property for SurfaceDataContainerName + */ + void setSurfaceDataContainerName(const DataArrayPath& value); + /** + * @brief Getter property for SurfaceDataContainerName + * @return Value of SurfaceDataContainerName + */ + DataArrayPath getSurfaceDataContainerName() const; + + Q_PROPERTY(DataArrayPath SurfaceDataContainerName READ getSurfaceDataContainerName WRITE setSurfaceDataContainerName) + + /** + * @brief Setter property for ApplyToVoxelVolume + */ + void setApplyToVoxelVolume(bool value); + /** + * @brief Getter property for ApplyToVoxelVolume + * @return Value of ApplyToVoxelVolume + */ + bool getApplyToVoxelVolume() const; + + Q_PROPERTY(bool ApplyToVoxelVolume READ getApplyToVoxelVolume WRITE setApplyToVoxelVolume) + + /** + * @brief Setter property for ApplyToSurfaceMesh + */ + void setApplyToSurfaceMesh(bool value); + /** + * @brief Getter property for ApplyToSurfaceMesh + * @return Value of ApplyToSurfaceMesh + */ + bool getApplyToSurfaceMesh() const; + + Q_PROPERTY(bool ApplyToSurfaceMesh READ getApplyToSurfaceMesh WRITE setApplyToSurfaceMesh) + + /** + * @brief Setter property for ScaleFactor + */ + void setScaleFactor(const FloatVec3Type& value); + /** + * @brief Getter property for ScaleFactor + * @return Value of ScaleFactor + */ + FloatVec3Type getScaleFactor() const; + + Q_PROPERTY(FloatVec3Type ScaleFactor READ getScaleFactor WRITE setScaleFactor) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + ScaleVolume(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + + /** + * @brief updateSurfaceMesh updates the mesh coordinates + */ + void updateSurfaceMesh(); + +public: + ScaleVolume(const ScaleVolume&) = delete; // Copy Constructor Not Implemented + ScaleVolume(ScaleVolume&&) = delete; // Move Constructor Not Implemented + ScaleVolume& operator=(const ScaleVolume&) = delete; // Copy Assignment Not Implemented + ScaleVolume& operator=(ScaleVolume&&) = delete; // Move Assignment Not Implemented + +private: + DataArrayPath m_DataContainerName = {"", "", ""}; + DataArrayPath m_SurfaceDataContainerName = {"", "", ""}; + bool m_ApplyToVoxelVolume = {true}; + bool m_ApplyToSurfaceMesh = {true}; + FloatVec3Type m_ScaleFactor = {}; }; - diff --git a/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.cpp b/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.cpp index f39d35375a..513afe73b8 100644 --- a/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.cpp +++ b/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.cpp @@ -1,55 +1,50 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "SetOriginResolutionImageGeom.h" -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS -#include -#include -#include -#include -#endif +#include +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" -#include "SIMPLib/SIMPLibVersion.h" - #include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" #include "SIMPLib/FilterParameters/LinkedBooleanFilterParameter.h" #include "SIMPLib/Geometry/ImageGeom.h" +#include "SIMPLib/Utilities/ParallelDataAlgorithm.h" /** * @brief The SetOriginResolutionImageUpdateVerticesImpl class implements a threaded algorithm that adjusts the @@ -80,30 +75,24 @@ class SetOriginResolutionImageUpdateVerticesImpl } } -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - void operator()(const tbb::blocked_range& r) const + void operator()(const SIMPLRange& range) const { - generate(r.begin(), r.end()); + generate(range.min(), range.max()); } -#endif }; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- SetOriginResolutionImageGeom::SetOriginResolutionImageGeom() -: m_DataContainerName("") -, m_ChangeOrigin(false) -, m_ChangeResolution(false) { - m_Origin.x = 0.0f; - m_Origin.y = 0.0f; - m_Origin.z = 0.0f; - - m_Resolution.x = 1.0f; - m_Resolution.y = 1.0f; - m_Resolution.z = 1.0f; + m_Origin[0] = 0.0f; + m_Origin[1] = 0.0f; + m_Origin[2] = 0.0f; + m_Spacing[0] = 1.0f; + m_Spacing[1] = 1.0f; + m_Spacing[2] = 1.0f; } // ----------------------------------------------------------------------------- @@ -116,21 +105,22 @@ SetOriginResolutionImageGeom::~SetOriginResolutionImageGeom() = default; // ----------------------------------------------------------------------------- void SetOriginResolutionImageGeom::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { DataContainerSelectionFilterParameter::RequirementType req; req.dcGeometryTypes = IGeometry::Types(1, IGeometry::Type::Image); - parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container Image Geometry to Modify", DataContainerName, FilterParameter::RequiredArray, SetOriginResolutionImageGeom, req)); + parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("Data Container Image Geometry to Modify", DataContainerName, FilterParameter::Category::RequiredArray, SetOriginResolutionImageGeom, req)); } - QStringList linkedProps("Origin"); - parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Change Origin", ChangeOrigin, FilterParameter::Parameter, SetOriginResolutionImageGeom, linkedProps)); - parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Origin", Origin, FilterParameter::Parameter, SetOriginResolutionImageGeom)); + std::vector linkedProps = {"Origin"}; + parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Change Origin", ChangeOrigin, FilterParameter::Category::Parameter, SetOriginResolutionImageGeom, linkedProps)); + parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Origin", Origin, FilterParameter::Category::Parameter, SetOriginResolutionImageGeom)); linkedProps.clear(); - linkedProps << "Resolution"; - parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Change Resolution", ChangeResolution, FilterParameter::Parameter, SetOriginResolutionImageGeom, linkedProps)); - parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Resolution", Resolution, FilterParameter::Parameter, SetOriginResolutionImageGeom)); + linkedProps.push_back("Spacing"); + parameters.push_back(SIMPL_NEW_LINKED_BOOL_FP("Change Spacing", ChangeResolution, FilterParameter::Category::Parameter, SetOriginResolutionImageGeom, linkedProps)); + parameters.push_back(SIMPL_NEW_FLOAT_VEC3_FP("Spacing", Spacing, FilterParameter::Category::Parameter, SetOriginResolutionImageGeom)); + parameters.back()->setLegacyPropertyName("Resolution"); setFilterParameters(parameters); } @@ -144,8 +134,8 @@ void SetOriginResolutionImageGeom::readFilterParameters(AbstractFilterParameters setChangeOrigin(reader->readValue("ChangeOrigin", getChangeOrigin())); setChangeResolution(reader->readValue("ChangeResolution", getChangeResolution())); setOrigin(reader->readFloatVec3("Origin", getOrigin())); - setResolution(reader->readFloatVec3("Resolution", getResolution())); - setDataContainerName(reader->readString("DataContainerName", getDataContainerName())); + setSpacing(reader->readFloatVec3("Spacing", getSpacing())); + setDataContainerName(reader->readDataArrayPath("DataContainerName", getDataContainerName())); reader->closeFilterGroup(); } @@ -161,50 +151,34 @@ void SetOriginResolutionImageGeom::initialize() // ----------------------------------------------------------------------------- void SetOriginResolutionImageGeom::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); - ImageGeom::Pointer image = getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getDataContainerName()); - if(getErrorCondition() < 0) + ImageGeom::Pointer image = getDataContainerArray()->getPrereqGeometryFromDataContainer(this, getDataContainerName()); + if(getErrorCode() < 0) { return; } if(getChangeOrigin()) { - image->setOrigin(std::make_tuple(m_Origin.x, m_Origin.y, m_Origin.z)); + image->setOrigin(std::make_tuple(m_Origin[0], m_Origin[1], m_Origin[2])); } if(getChangeResolution()) { - image->setResolution(std::make_tuple(m_Resolution.x, m_Resolution.y, m_Resolution.z)); + image->setSpacing(std::make_tuple(m_Spacing[0], m_Spacing[1], m_Spacing[2])); } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void SetOriginResolutionImageGeom::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void SetOriginResolutionImageGeom::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - } // ----------------------------------------------------------------------------- @@ -223,7 +197,7 @@ AbstractFilter::Pointer SetOriginResolutionImageGeom::newFilterInstance(bool cop // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString SetOriginResolutionImageGeom::getCompiledLibraryName() const +QString SetOriginResolutionImageGeom::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -231,7 +205,7 @@ const QString SetOriginResolutionImageGeom::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString SetOriginResolutionImageGeom::getBrandingString() const +QString SetOriginResolutionImageGeom::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -239,7 +213,7 @@ const QString SetOriginResolutionImageGeom::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString SetOriginResolutionImageGeom::getFilterVersion() const +QString SetOriginResolutionImageGeom::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -250,7 +224,7 @@ const QString SetOriginResolutionImageGeom::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString SetOriginResolutionImageGeom::getGroupName() const +QString SetOriginResolutionImageGeom::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -258,7 +232,7 @@ const QString SetOriginResolutionImageGeom::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid SetOriginResolutionImageGeom::getUuid() +QUuid SetOriginResolutionImageGeom::getUuid() const { return QUuid("{6d3a3852-6251-5d2e-b749-6257fd0d8951}"); } @@ -266,7 +240,7 @@ const QUuid SetOriginResolutionImageGeom::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString SetOriginResolutionImageGeom::getSubGroupName() const +QString SetOriginResolutionImageGeom::getSubGroupName() const { return SIMPL::FilterSubGroups::SpatialFilters; } @@ -274,7 +248,96 @@ const QString SetOriginResolutionImageGeom::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString SetOriginResolutionImageGeom::getHumanLabel() const +QString SetOriginResolutionImageGeom::getHumanLabel() const +{ + return "Set Origin & Spacing (Image)"; +} + +// ----------------------------------------------------------------------------- +SetOriginResolutionImageGeom::Pointer SetOriginResolutionImageGeom::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr SetOriginResolutionImageGeom::New() +{ + struct make_shared_enabler : public SetOriginResolutionImageGeom + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString SetOriginResolutionImageGeom::getNameOfClass() const +{ + return QString("SetOriginResolutionImageGeom"); +} + +// ----------------------------------------------------------------------------- +QString SetOriginResolutionImageGeom::ClassName() +{ + return QString("SetOriginResolutionImageGeom"); +} + +// ----------------------------------------------------------------------------- +void SetOriginResolutionImageGeom::setDataContainerName(const DataArrayPath& value) +{ + m_DataContainerName = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath SetOriginResolutionImageGeom::getDataContainerName() const +{ + return m_DataContainerName; +} + +// ----------------------------------------------------------------------------- +void SetOriginResolutionImageGeom::setChangeOrigin(bool value) +{ + m_ChangeOrigin = value; +} + +// ----------------------------------------------------------------------------- +bool SetOriginResolutionImageGeom::getChangeOrigin() const +{ + return m_ChangeOrigin; +} + +// ----------------------------------------------------------------------------- +void SetOriginResolutionImageGeom::setOrigin(const FloatVec3Type& value) +{ + m_Origin = value; +} + +// ----------------------------------------------------------------------------- +FloatVec3Type SetOriginResolutionImageGeom::getOrigin() const +{ + return m_Origin; +} + +// ----------------------------------------------------------------------------- +void SetOriginResolutionImageGeom::setChangeResolution(bool value) +{ + m_ChangeResolution = value; +} + +// ----------------------------------------------------------------------------- +bool SetOriginResolutionImageGeom::getChangeResolution() const +{ + return m_ChangeResolution; +} + +// ----------------------------------------------------------------------------- +void SetOriginResolutionImageGeom::setSpacing(const FloatVec3Type& value) +{ + m_Spacing = value; +} + +// ----------------------------------------------------------------------------- +FloatVec3Type SetOriginResolutionImageGeom::getSpacing() const { - return "Set Origin & Resolution (Image)"; + return m_Spacing; } diff --git a/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.h b/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.h old mode 100755 new mode 100644 index 0f2514704a..dce43cf11e --- a/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.h +++ b/Source/SIMPLib/CoreFilters/SetOriginResolutionImageGeom.h @@ -1,191 +1,234 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" #include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/SIMPLib.h" /** * @brief The SetOriginResolutionImageGeom class. See [Filter documentation](@ref adjustvolumeorigin) for details. */ class SIMPLib_EXPORT SetOriginResolutionImageGeom : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(SetOriginResolutionImageGeom SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) - PYB11_PROPERTY(bool ChangeOrigin READ getChangeOrigin WRITE setChangeOrigin) - PYB11_PROPERTY(FloatVec3_t Origin READ getOrigin WRITE setOrigin) - PYB11_PROPERTY(bool ChangeResolution READ getChangeResolution WRITE setChangeResolution) - PYB11_PROPERTY(FloatVec3_t Resolution READ getResolution WRITE setResolution) - - public: - SIMPL_SHARED_POINTERS(SetOriginResolutionImageGeom) - SIMPL_FILTER_NEW_MACRO(SetOriginResolutionImageGeom) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(SetOriginResolutionImageGeom, AbstractFilter) - - ~SetOriginResolutionImageGeom() override; - - SIMPL_FILTER_PARAMETER(QString, DataContainerName) - Q_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) - - SIMPL_FILTER_PARAMETER(bool, ChangeOrigin) - Q_PROPERTY(bool ChangeOrigin READ getChangeOrigin WRITE setChangeOrigin) - - SIMPL_FILTER_PARAMETER(FloatVec3_t, Origin) - Q_PROPERTY(FloatVec3_t Origin READ getOrigin WRITE setOrigin) - - SIMPL_FILTER_PARAMETER(bool, ChangeResolution) - Q_PROPERTY(bool ChangeResolution READ getChangeResolution WRITE setChangeResolution) - - SIMPL_FILTER_PARAMETER(FloatVec3_t, Resolution) - Q_PROPERTY(FloatVec3_t Resolution READ getResolution WRITE setResolution) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - SetOriginResolutionImageGeom(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - /** - * @brief updateSurfaceMesh Updates the mesh coordinates - */ - void updateSurfaceMesh(); - - public: - SetOriginResolutionImageGeom(const SetOriginResolutionImageGeom&) = delete; // Copy Constructor Not Implemented - SetOriginResolutionImageGeom(SetOriginResolutionImageGeom&&) = delete; // Move Constructor Not Implemented - SetOriginResolutionImageGeom& operator=(const SetOriginResolutionImageGeom&) = delete; // Copy Assignment Not Implemented - SetOriginResolutionImageGeom& operator=(SetOriginResolutionImageGeom&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(SetOriginResolutionImageGeom SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(SetOriginResolutionImageGeom) + PYB11_FILTER_NEW_MACRO(SetOriginResolutionImageGeom) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_PROPERTY(bool ChangeOrigin READ getChangeOrigin WRITE setChangeOrigin) + PYB11_PROPERTY(FloatVec3Type Origin READ getOrigin WRITE setOrigin) + PYB11_PROPERTY(bool ChangeResolution READ getChangeResolution WRITE setChangeResolution) + PYB11_PROPERTY(FloatVec3Type Spacing READ getSpacing WRITE setSpacing) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = SetOriginResolutionImageGeom; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for SetOriginResolutionImageGeom + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for SetOriginResolutionImageGeom + */ + static QString ClassName(); + + ~SetOriginResolutionImageGeom() override; + + /** + * @brief Setter property for DataContainerName + */ + void setDataContainerName(const DataArrayPath& value); + /** + * @brief Getter property for DataContainerName + * @return Value of DataContainerName + */ + DataArrayPath getDataContainerName() const; + + Q_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) + + /** + * @brief Setter property for ChangeOrigin + */ + void setChangeOrigin(bool value); + /** + * @brief Getter property for ChangeOrigin + * @return Value of ChangeOrigin + */ + bool getChangeOrigin() const; + + Q_PROPERTY(bool ChangeOrigin READ getChangeOrigin WRITE setChangeOrigin) + + /** + * @brief Setter property for Origin + */ + void setOrigin(const FloatVec3Type& value); + /** + * @brief Getter property for Origin + * @return Value of Origin + */ + FloatVec3Type getOrigin() const; + + Q_PROPERTY(FloatVec3Type Origin READ getOrigin WRITE setOrigin) + + /** + * @brief Setter property for ChangeResolution + */ + void setChangeResolution(bool value); + /** + * @brief Getter property for ChangeResolution + * @return Value of ChangeResolution + */ + bool getChangeResolution() const; + + Q_PROPERTY(bool ChangeResolution READ getChangeResolution WRITE setChangeResolution) + + /** + * @brief Setter property for Spacing + */ + void setSpacing(const FloatVec3Type& value); + /** + * @brief Getter property for Spacing + * @return Value of Spacing + */ + FloatVec3Type getSpacing() const; + + Q_PROPERTY(FloatVec3Type Spacing READ getSpacing WRITE setSpacing) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + SetOriginResolutionImageGeom(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + + /** + * @brief updateSurfaceMesh Updates the mesh coordinates + */ + void updateSurfaceMesh(); + +public: + SetOriginResolutionImageGeom(const SetOriginResolutionImageGeom&) = delete; // Copy Constructor Not Implemented + SetOriginResolutionImageGeom(SetOriginResolutionImageGeom&&) = delete; // Move Constructor Not Implemented + SetOriginResolutionImageGeom& operator=(const SetOriginResolutionImageGeom&) = delete; // Copy Assignment Not Implemented + SetOriginResolutionImageGeom& operator=(SetOriginResolutionImageGeom&&) = delete; // Move Assignment Not Implemented + +private: + DataArrayPath m_DataContainerName = {"", "", ""}; + bool m_ChangeOrigin = {false}; + FloatVec3Type m_Origin = {}; + bool m_ChangeResolution = {false}; + FloatVec3Type m_Spacing = {}; }; - diff --git a/Source/SIMPLib/CoreFilters/SourceList.cmake b/Source/SIMPLib/CoreFilters/SourceList.cmake index 8749c9c55a..354ae0ce0e 100755 --- a/Source/SIMPLib/CoreFilters/SourceList.cmake +++ b/Source/SIMPLib/CoreFilters/SourceList.cmake @@ -24,6 +24,7 @@ SIMPL_START_FILTER_GROUP( # List your public filters here set(_PublicFilters + GenerateVertexCoordinates ArrayCalculator CombineAttributeArrays CombineAttributeMatrices @@ -37,6 +38,7 @@ set(_PublicFilters CreateDataContainer CreateFeatureArrayFromElementArray CreateImageGeometry + CreateGridMontage CreateStringArray CopyObject CreateGeometry @@ -50,6 +52,7 @@ set(_PublicFilters FeatureDataCSVWriter FindDerivatives GenerateColorTable + GenerateTiltSeries ImportAsciDataArray ImportHDF5Dataset InitializeData @@ -70,6 +73,7 @@ set(_PublicFilters RenameDataContainer ReplaceValueInArray RequiredZThickness + RotateSampleRefFrame ScaleVolume SetOriginResolutionImageGeom SplitAttributeArray @@ -77,6 +81,11 @@ set(_PublicFilters WriteTriangleGeometry ) +if( SIMPL_USE_ITK ) + set(_PublicFilters ${_PublicFilters} + + ) +endif() list(LENGTH _PublicFilters PluginNumFilters) @@ -88,8 +97,7 @@ set_property(GLOBAL PROPERTY PluginNumFilters ${PluginNumFilters}) foreach(f ${_PublicFilters} ) ADD_SIMPL_FILTER( "SIMPLib" "FilterWidgetsLib" ${_filterGroupName} ${f} - ${SIMPLib_FILTER_DOC_DIR}/${_filterGroupName}/${f}.md TRUE - ${SIMPLProj_BINARY_DIR}) + ${SIMPLib_FILTER_DOC_DIR}/${_filterGroupName}/${f}.md TRUE) endforeach() @@ -97,10 +105,12 @@ endforeach() # This is the list of Private Filters. These filters are available from other filters but the user will not # be able to use them from the DREAM3D user interface. set(_PrivateFilters + ApplyImageTransforms Breakpoint EmptyFilter FileReader FileWriter + MassCreateData ) #----------------- @@ -108,8 +118,7 @@ set(_PrivateFilters foreach(f ${_PrivateFilters} ) ADD_SIMPL_FILTER( "SIMPLib" "FilterWidgetsLib" ${_filterGroupName} ${f} - ${SIMPLib_FILTER_DOC_DIR}/${_filterGroupName}/${f}.md FALSE - ${SIMPLProj_BINARY_DIR}) + ${SIMPLib_FILTER_DOC_DIR}/${_filterGroupName}/${f}.md FALSE) endforeach() source_group("${SIMPLib_SOURCE_DIR} ${_filterGroupName} util" FILES ${HEADERS} ${SOURCES}) diff --git a/Source/SIMPLib/CoreFilters/SplitAttributeArray.cpp b/Source/SIMPLib/CoreFilters/SplitAttributeArray.cpp index ec0ad90009..ea99e40968 100644 --- a/Source/SIMPLib/CoreFilters/SplitAttributeArray.cpp +++ b/Source/SIMPLib/CoreFilters/SplitAttributeArray.cpp @@ -26,28 +26,34 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - #include "SplitAttributeArray.h" +#include + +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" +#include "SIMPLib/DataArrays/IDataArray.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" + +enum createdPathID : RenameDataPath::DataID_t +{ + SplitArrayID = 1 +}; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- SplitAttributeArray::SplitAttributeArray() -: m_InputArrayPath("", "", "") -, m_SplitArraysSuffix("Component") { initialize(); } @@ -62,11 +68,11 @@ SplitAttributeArray::~SplitAttributeArray() = default; // ----------------------------------------------------------------------------- void SplitAttributeArray::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; DataArraySelectionFilterParameter::RequirementType dasReq = DataArraySelectionFilterParameter::CreateRequirement(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, AttributeMatrix::Type::Any, IGeometry::Type::Any); - parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Multicomponent Attribute Array", InputArrayPath, FilterParameter::RequiredArray, SplitAttributeArray, dasReq)); - parameters.push_back(SIMPL_NEW_STRING_FP("Postfix", SplitArraysSuffix, FilterParameter::Parameter, SplitAttributeArray)); + parameters.push_back(SIMPL_NEW_DA_SELECTION_FP("Multicomponent Attribute Array", InputArrayPath, FilterParameter::Category::RequiredArray, SplitAttributeArray, dasReq)); + parameters.push_back(SIMPL_NEW_STRING_FP("Postfix", SplitArraysSuffix, FilterParameter::Category::Parameter, SplitAttributeArray)); setFilterParameters(parameters); } @@ -94,13 +100,13 @@ void SplitAttributeArray::initialize() // ----------------------------------------------------------------------------- void SplitAttributeArray::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); initialize(); - m_InputArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getInputArrayPath()); + m_InputArrayPtr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, getInputArrayPath()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -111,35 +117,32 @@ void SplitAttributeArray::dataCheck() if(numComps <= 1) { QString ss = QObject::tr("Selected Attribute Array must have more than 1 component"); - setErrorCondition(-11000); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11000, ss); return; } - QVector cDims(1, 1); + std::vector cDims(1, 1); for(int32_t i = 0; i < numComps; i++) { QString arrayName = getInputArrayPath().getDataArrayName() + getSplitArraysSuffix() + QString::number(i); DataArrayPath path(getInputArrayPath().getDataContainerName(), getInputArrayPath().getAttributeMatrixName(), arrayName); - IDataArray::WeakPointer ptr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, path, cDims, m_InputArrayPtr.lock()); - if(getErrorCondition() >= 0) + IDataArray::WeakPointer ptr = TemplateHelpers::CreateNonPrereqArrayFromArrayType()(this, path, cDims, m_InputArrayPtr.lock(), SplitArrayID + i); + if(getErrorCode() >= 0) { m_SplitArraysPtrVector.push_back(ptr.lock()); } else { QString ss = QObject::tr("Unable to create an Attribute Array for component %1 in the selected multicomponent Attribute Array").arg(i); - setErrorCondition(-11051); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11051, ss); } } if(numComps != m_SplitArraysPtrVector.size()) { QString ss = QObject::tr("The number of created arrays %1 does not match the number of components %2").arg(m_SplitArraysPtrVector.size()).arg(numComps); - setErrorCondition(-11001); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11001, ss); } } } @@ -147,21 +150,8 @@ void SplitAttributeArray::dataCheck() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void SplitAttributeArray::preflight() -{ - // These are the REQUIRED lines of CODE to make sure the filter behaves correctly - setInPreflight(true); // Set the fact that we are preflighting. - emit preflightAboutToExecute(); // Emit this signal so that other widgets can do one file update - emit updateFilterParameters(this); // Emit this signal to have the widgets push their values down to the filter - dataCheck(); // Run our DataCheck to make sure everthing is setup correctly - emit preflightExecuted(); // We are done preflighting this filter - setInPreflight(false); // Inform the system this filter is NOT in preflight mode anymore. -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -template void splitMulticomponentArray(IDataArray::Pointer inputArray, std::vector& splitArrays) +template +void splitMulticomponentArray(IDataArray::Pointer inputArray, std::vector& splitArrays) { typename DataArray::Pointer inputPtr = std::dynamic_pointer_cast>(inputArray); T* iPtr = inputPtr->getPointer(0); @@ -191,16 +181,13 @@ template void splitMulticomponentArray(IDataArray::Pointer inputArr // ----------------------------------------------------------------------------- void SplitAttributeArray::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } EXECUTE_FUNCTION_TEMPLATE(this, splitMulticomponentArray, m_InputArrayPtr.lock(), m_InputArrayPtr.lock(), m_SplitArraysPtrVector) - } // ----------------------------------------------------------------------------- @@ -219,7 +206,7 @@ AbstractFilter::Pointer SplitAttributeArray::newFilterInstance(bool copyFilterPa // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString SplitAttributeArray::getCompiledLibraryName() const +QString SplitAttributeArray::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -227,7 +214,7 @@ const QString SplitAttributeArray::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString SplitAttributeArray::getBrandingString() const +QString SplitAttributeArray::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -235,7 +222,7 @@ const QString SplitAttributeArray::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString SplitAttributeArray::getFilterVersion() const +QString SplitAttributeArray::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -246,7 +233,7 @@ const QString SplitAttributeArray::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString SplitAttributeArray::getGroupName() const +QString SplitAttributeArray::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -254,7 +241,7 @@ const QString SplitAttributeArray::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid SplitAttributeArray::getUuid() +QUuid SplitAttributeArray::getUuid() const { return QUuid("{5ecf77f4-a38a-52ab-b4f6-0fb8a9c5cb9c}"); } @@ -262,7 +249,7 @@ const QUuid SplitAttributeArray::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString SplitAttributeArray::getSubGroupName() const +QString SplitAttributeArray::getSubGroupName() const { return SIMPL::FilterSubGroups::MemoryManagementFilters; } @@ -270,7 +257,60 @@ const QString SplitAttributeArray::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString SplitAttributeArray::getHumanLabel() const +QString SplitAttributeArray::getHumanLabel() const { return "Split Multicomponent Attribute Array"; } + +// ----------------------------------------------------------------------------- +SplitAttributeArray::Pointer SplitAttributeArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr SplitAttributeArray::New() +{ + struct make_shared_enabler : public SplitAttributeArray + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString SplitAttributeArray::getNameOfClass() const +{ + return QString("SplitAttributeArray"); +} + +// ----------------------------------------------------------------------------- +QString SplitAttributeArray::ClassName() +{ + return QString("SplitAttributeArray"); +} + +// ----------------------------------------------------------------------------- +void SplitAttributeArray::setInputArrayPath(const DataArrayPath& value) +{ + m_InputArrayPath = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath SplitAttributeArray::getInputArrayPath() const +{ + return m_InputArrayPath; +} + +// ----------------------------------------------------------------------------- +void SplitAttributeArray::setSplitArraysSuffix(const QString& value) +{ + m_SplitArraysSuffix = value; +} + +// ----------------------------------------------------------------------------- +QString SplitAttributeArray::getSplitArraysSuffix() const +{ + return m_SplitArraysSuffix; +} diff --git a/Source/SIMPLib/CoreFilters/SplitAttributeArray.h b/Source/SIMPLib/CoreFilters/SplitAttributeArray.h index 21988ea614..70bdfe9210 100644 --- a/Source/SIMPLib/CoreFilters/SplitAttributeArray.h +++ b/Source/SIMPLib/CoreFilters/SplitAttributeArray.h @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,9 +35,16 @@ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +class IDataArray; +using IDataArrayShPtrType = std::shared_ptr; + +class IDataArray; +using IDataArrayWkPtrType = std::weak_ptr; /** * @brief The SplitAttributeArray class. See [Filter documentation](@ref splitattributearray) for details. @@ -45,41 +52,89 @@ class SIMPLib_EXPORT SplitAttributeArray : public AbstractFilter { Q_OBJECT - PYB11_CREATE_BINDINGS(SplitAttributeArray SUPERCLASS AbstractFilter) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(SplitAttributeArray SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(SplitAttributeArray) + PYB11_FILTER_NEW_MACRO(SplitAttributeArray) PYB11_PROPERTY(DataArrayPath InputArrayPath READ getInputArrayPath WRITE setInputArrayPath) PYB11_PROPERTY(QString SplitArraysSuffix READ getSplitArraysSuffix WRITE setSplitArraysSuffix) + PYB11_END_BINDINGS() + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(SplitAttributeArray) - SIMPL_FILTER_NEW_MACRO(SplitAttributeArray) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(SplitAttributeArray, AbstractFilter) + using Self = SplitAttributeArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for SplitAttributeArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for SplitAttributeArray + */ + static QString ClassName(); ~SplitAttributeArray() override; - SIMPL_FILTER_PARAMETER(DataArrayPath, InputArrayPath) + /** + * @brief Setter property for InputArrayPath + */ + void setInputArrayPath(const DataArrayPath& value); + /** + * @brief Getter property for InputArrayPath + * @return Value of InputArrayPath + */ + DataArrayPath getInputArrayPath() const; + Q_PROPERTY(DataArrayPath InputArrayPath READ getInputArrayPath WRITE setInputArrayPath) - SIMPL_FILTER_PARAMETER(QString, SplitArraysSuffix) + /** + * @brief Setter property for SplitArraysSuffix + */ + void setSplitArraysSuffix(const QString& value); + /** + * @brief Getter property for SplitArraysSuffix + * @return Value of SplitArraysSuffix + */ + QString getSplitArraysSuffix() const; + Q_PROPERTY(QString SplitArraysSuffix READ getSplitArraysSuffix WRITE setSplitArraysSuffix) /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class */ - const QString getCompiledLibraryName() const override; + QString getCompiledLibraryName() const override; /** * @brief getBrandingString Returns the branding string for the filter, which is a tag * used to denote the filter's association with specific plugins * @return Branding string */ - const QString getBrandingString() const override; + QString getBrandingString() const override; /** * @brief getFilterVersion Returns a version string for this filter. Default * value is an empty string. * @return */ - const QString getFilterVersion() const override; + QString getFilterVersion() const override; /** * @brief newFilterInstance Reimplemented from @see AbstractFilter class @@ -89,23 +144,23 @@ class SIMPLib_EXPORT SplitAttributeArray : public AbstractFilter /** * @brief getGroupName Reimplemented from @see AbstractFilter class */ - const QString getGroupName() const override; + QString getGroupName() const override; /** * @brief getSubGroupName Reimplemented from @see AbstractFilter class */ - const QString getSubGroupName() const override; + QString getSubGroupName() const override; /** * @brief getUuid Return the unique identifier for this filter. * @return A QUuid object. */ - const QUuid getUuid() override; + QUuid getUuid() const override; /** * @brief getHumanLabel Reimplemented from @see AbstractFilter class */ - const QString getHumanLabel() const override; + QString getHumanLabel() const override; /** * @brief setupFilterParameters Reimplemented from @see AbstractFilter class @@ -122,41 +177,13 @@ class SIMPLib_EXPORT SplitAttributeArray : public AbstractFilter */ void execute() override; - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - -signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - protected: SplitAttributeArray(); /** * @brief dataCheck Checks for the appropriate parameter values and availability of arrays */ - void dataCheck(); + void dataCheck() override; /** * @brief Initializes all the private instance variables. @@ -164,9 +191,13 @@ class SIMPLib_EXPORT SplitAttributeArray : public AbstractFilter void initialize(); private: - DEFINE_IDATAARRAY_VARIABLE(InputArray) + IDataArrayWkPtrType m_InputArrayPtr; + void* m_InputArray = nullptr; + + DataArrayPath m_InputArrayPath = {"", "", ""}; + QString m_SplitArraysSuffix = {"Component"}; - std::vector m_SplitArraysPtrVector; + std::vector m_SplitArraysPtrVector; public: SplitAttributeArray(const SplitAttributeArray&) = delete; // Copy Constructor Not Implemented diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ApplyImageTransformsTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ApplyImageTransformsTest.cpp new file mode 100644 index 0000000000..7443ec2ab9 --- /dev/null +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ApplyImageTransformsTest.cpp @@ -0,0 +1,62 @@ +// ----------------------------------------------------------------------------- +// Insert your license & copyright information here +// ----------------------------------------------------------------------------- +#pragma once + +#include "SIMPLib/CoreFilters/ApplyImageTransforms.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/Filtering/FilterFactory.hpp" +#include "SIMPLib/Filtering/FilterManager.h" +#include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Plugin/ISIMPLibPlugin.h" +#include "SIMPLib/Plugin/SIMPLibPluginLoader.h" +#include "SIMPLib/Testing/SIMPLTestFileLocations.h" +#include "SIMPLib/Testing/UnitTestSupport.hpp" + +class ApplyImageTransformsTest +{ + +public: + ApplyImageTransformsTest() = default; + ~ApplyImageTransformsTest() = default; + ApplyImageTransformsTest(const ApplyImageTransformsTest&) = delete; // Copy Constructor + ApplyImageTransformsTest(ApplyImageTransformsTest&&) = delete; // Move Constructor + ApplyImageTransformsTest& operator=(const ApplyImageTransformsTest&) = delete; // Copy Assignment + ApplyImageTransformsTest& operator=(ApplyImageTransformsTest&&) = delete; // Move Assignment + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void TestFilterAvailability() + { + ApplyImageTransforms::Pointer filter = ApplyImageTransforms::New(); + filter->preflight(); + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + int TestApplyImageTransformsTest() + { + int foo = 0; + DREAM3D_REQUIRE_EQUAL(foo, 0) + + return EXIT_SUCCESS; + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void operator()() + { + int err = EXIT_SUCCESS; + + DREAM3D_REGISTER_TEST(TestFilterAvailability()); + + DREAM3D_REGISTER_TEST(TestApplyImageTransformsTest()) + } + +private: +}; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ArrayCalculatorTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ArrayCalculatorTest.cpp index 2e55f42dae..36ede74d2d 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ArrayCalculatorTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ArrayCalculatorTest.cpp @@ -1,41 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "SIMPLib/CoreFilters/ArrayCalculator.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/CoreFilters/CreateDataArray.h" +#include "SIMPLib/CoreFilters/util/CalculatorOperator.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/DynamicTableData.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" @@ -44,35 +48,41 @@ #include "SIMPLib/Math/SIMPLibMath.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/SIMPLibVersion.h" - -#include "SIMPLib/CoreFilters/ArrayCalculator.h" -#include "SIMPLib/CoreFilters/CreateDataArray.h" - #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/util/CalculatorOperator.h" - class DummyObserver : public Observer { public: - DummyObserver() - : Observer() + DummyObserver() = default; + ~DummyObserver() override = default; + + /** + * @brief Returns the name of the class for DummyObserver + */ + QString getNameOfClass() const { + return QString("DummyObserver"); + } + + /** + * @brief Returns the name of the class for DummyObserver + */ + QString ClassName() + { + return QString("DummyObserver"); } - ~DummyObserver() override = default; - SIMPL_TYPE_MACRO(DummyObserver) - void processPipelineMessage(const PipelineMessage& pm) override + void processPipelineMessage(const AbstractMessage::Pointer& pm) override { // Don't do anything...this class only exists to stifle the messages being dumped to the console } -private: - DummyObserver(const DummyObserver&); // Copy Constructor Not Implemented - void operator=(const DummyObserver&); // Move assignment Not Implemented +public: + DummyObserver(const DummyObserver&) = delete; // Copy Constructor Not Implemented + DummyObserver(DummyObserver&&) = delete; // Move Constructor Not Implemented + DummyObserver& operator=(const DummyObserver&) = delete; // Copy Assignment Not Implemented + DummyObserver& operator=(DummyObserver&&) = delete; // Move Assignment Not Implemented }; class ArrayCalculatorTest @@ -80,7 +90,24 @@ class ArrayCalculatorTest public: ArrayCalculatorTest() = default; virtual ~ArrayCalculatorTest() = default; - SIMPL_TYPE_MACRO(ArrayCalculatorTest) + /** + * @brief Returns the name of the class for ArrayCalculatorTest + */ + /** + * @brief Returns the name of the class for ArrayCalculatorTest + */ + QString getNameOfClass() const + { + return QString("ArrayCalculatorTest"); + } + + /** + * @brief Returns the name of the class for ArrayCalculatorTest + */ + QString ClassName() + { + return QString("ArrayCalculatorTest"); + } // ----------------------------------------------------------------------------- // @@ -89,16 +116,16 @@ class ArrayCalculatorTest { DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc = DataContainer::New("DataContainer"); - AttributeMatrix::Pointer am1 = AttributeMatrix::New(QVector(1, 10), "AttributeMatrix", AttributeMatrix::Type::Cell); - AttributeMatrix::Pointer am2 = AttributeMatrix::New(QVector(1, 1), "NumericMatrix", AttributeMatrix::Type::Cell); - FloatArrayType::Pointer array1 = FloatArrayType::CreateArray(10, "InputArray1"); - array1->initializeWithValue(-12, 0); - UInt32ArrayType::Pointer array2 = UInt32ArrayType::CreateArray(10, "InputArray2"); - array2->initializeWithValue(10, 0); - UInt32ArrayType::Pointer sArray = UInt32ArrayType::CreateArray(10, "Spaced Array"); - sArray->initializeWithValue(2, 0); - - UInt32ArrayType::Pointer mcArray1 = UInt32ArrayType::CreateArray(QVector(1, 10), QVector(1, 3), "MultiComponent Array1"); + AttributeMatrix::Pointer am1 = AttributeMatrix::New(std::vector(1, 10), "AttributeMatrix", AttributeMatrix::Type::Cell); + AttributeMatrix::Pointer am2 = AttributeMatrix::New(std::vector(1, 1), "NumericMatrix", AttributeMatrix::Type::Cell); + FloatArrayType::Pointer array1 = FloatArrayType::CreateArray(10, std::string("InputArray1"), true); + array1->initializeWithValue(-12); + UInt32ArrayType::Pointer array2 = UInt32ArrayType::CreateArray(10, std::string("InputArray2"), true); + array2->initializeWithValue(10); + UInt32ArrayType::Pointer sArray = UInt32ArrayType::CreateArray(10, std::string("Spaced Array"), true); + sArray->initializeWithValue(2); + + UInt32ArrayType::Pointer mcArray1 = UInt32ArrayType::CreateArray(std::vector(1, 10), std::vector(1, 3), "MultiComponent Array1", true); int num = 0; for(int i = 0; i < mcArray1->getNumberOfTuples() * mcArray1->getNumberOfComponents(); i++) { @@ -106,7 +133,7 @@ class ArrayCalculatorTest num++; } - UInt32ArrayType::Pointer mcArray2 = UInt32ArrayType::CreateArray(QVector(1, 10), QVector(1, 3), "MultiComponent Array2"); + UInt32ArrayType::Pointer mcArray2 = UInt32ArrayType::CreateArray(std::vector(1, 10), std::vector(1, 3), "MultiComponent Array2", true); num = 0; for(int i = 0; i < mcArray2->getNumberOfTuples() * mcArray2->getNumberOfComponents(); i++) { @@ -120,16 +147,16 @@ class ArrayCalculatorTest IDataArray::Pointer signArray = mcArray1->deepCopy(); signArray->setName("*"); - am1->addAttributeArray("InputArray1", array1); - am1->addAttributeArray("InputArray2", array2); - am1->addAttributeArray("Spaced Array", sArray); - am1->addAttributeArray("MultiComponent Array1", mcArray1); - am1->addAttributeArray("MultiComponent Array2", mcArray2); - am1->addAttributeArray("4", numberArray); - am1->addAttributeArray("*", signArray); - dc->addAttributeMatrix("AttributeMatrix", am1); - dc->addAttributeMatrix("NumericMatrix", am2); - dca->addDataContainer(dc); + am1->insertOrAssign(array1); + am1->insertOrAssign(array2); + am1->insertOrAssign(sArray); + am1->insertOrAssign(mcArray1); + am1->insertOrAssign(mcArray2); + am1->insertOrAssign(numberArray); + am1->insertOrAssign(signArray); + dc->addOrReplaceAttributeMatrix(am1); + dc->addOrReplaceAttributeMatrix(am2); + dca->addOrReplaceDataContainer(dc); return dca; } @@ -137,7 +164,7 @@ class ArrayCalculatorTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - AbstractFilter::Pointer createArrayCalculatorFilter(DataArrayPath calculatedPath) + AbstractFilter::Pointer createArrayCalculatorFilter(const DataArrayPath& calculatedPath) { QString filtName = "ArrayCalculator"; FilterManager* fm = FilterManager::Instance(); @@ -170,9 +197,11 @@ class ArrayCalculatorTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void runTest(QString equation, DataArrayPath targetArrayPath, CalculatorItem::ErrorCode expectedErrorCondition, CalculatorItem::WarningCode expectedWarningCondition, - int* expectedNumberOfTuples = nullptr, double* expectedValue = nullptr, ArrayCalculator::AngleUnits units = ArrayCalculator::Radians) + void runTest(const QString& equation, const DataArrayPath& targetArrayPath, CalculatorItem::ErrorCode expectedErrorCondition, CalculatorItem::WarningCode expectedWarningCondition, + const int* expectedNumberOfTuples = nullptr, const double* expectedValue = nullptr, ArrayCalculator::AngleUnits units = ArrayCalculator::Radians) { + std::cout << " Testing equation: ==>" << equation.toStdString() << "<==" << std::endl; + bool propWasSet = false; AbstractFilter::Pointer filter = createArrayCalculatorFilter(targetArrayPath); @@ -182,12 +211,15 @@ class ArrayCalculatorTest propWasSet = filter->setProperty("Units", units); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); + if(filter->getErrorCode() < 0 && expectedErrorCondition == CalculatorItem::ErrorCode::SUCCESS) + { + std::cout << " Error " << filter->getErrorCode() << " executing filter." << std::endl; + } - std::cout << "Testing equation: " << equation.toStdString() << std::endl; - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(expectedErrorCondition)); - DREAM3D_REQUIRE_EQUAL(filter->getWarningCondition(), static_cast(expectedWarningCondition)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(expectedErrorCondition)); + DREAM3D_REQUIRE_EQUAL(filter->getWarningCode(), static_cast(expectedWarningCondition)); - DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), targetArrayPath); + DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), targetArrayPath); if(nullptr != expectedNumberOfTuples) { @@ -202,7 +234,7 @@ class ArrayCalculatorTest for(size_t i = 0; i < arrayPtr->getNumberOfTuples(); i++) { - DREAM3D_REQUIRE(SIMPLibMath::closeEnough(arrayPtr->getValue(i), value, 0.01) == true); + DREAM3D_REQUIRED(SIMPLibMath::closeEnough(arrayPtr->getValue(i), value, 0.01), ==, true); } } } @@ -215,7 +247,6 @@ class ArrayCalculatorTest DataArrayPath numericArrayPath("DataContainer", "NumericMatrix", "NewArray"); DataArrayPath arrayPath("DataContainer", "AttributeMatrix", "NewArray"); - QVariant var; bool propWasSet = false; // Multi-Component Array Tests @@ -223,16 +254,16 @@ class ArrayCalculatorTest AbstractFilter::Pointer filter = createArrayCalculatorFilter(arrayPath); UInt32ArrayType::Pointer mcArray1 = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array1")); + filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array1")); UInt32ArrayType::Pointer mcArray2 = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array2")); + filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array2")); propWasSet = filter->setProperty("InfixEquation", "MultiComponent Array1 + MultiComponent Array2"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); - DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == mcArray1->getNumberOfTuples()); DREAM3D_REQUIRE(arrayPtr->getNumberOfComponents() == mcArray1->getNumberOfComponents()); for(int t = 0; t < arrayPtr->getNumberOfTuples(); t++) @@ -249,16 +280,16 @@ class ArrayCalculatorTest AbstractFilter::Pointer filter = createArrayCalculatorFilter(arrayPath); UInt32ArrayType::Pointer mcArray1 = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array1")); + filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array1")); UInt32ArrayType::Pointer mcArray2 = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array2")); + filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array2")); propWasSet = filter->setProperty("InfixEquation", "MultiComponent Array1[1] + MultiComponent Array2[0]"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); - DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == mcArray1->getNumberOfTuples()); DREAM3D_REQUIRE(arrayPtr->getNumberOfComponents() == 1); for(int t = 0; t < arrayPtr->getNumberOfTuples(); t++) @@ -273,17 +304,15 @@ class ArrayCalculatorTest { AbstractFilter::Pointer filter = createArrayCalculatorFilter(arrayPath); - UInt32ArrayType::Pointer nArray = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "4")); + UInt32ArrayType::Pointer nArray = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "4")); - UInt32ArrayType::Pointer sArray = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "*")); + UInt32ArrayType::Pointer sArray = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "*")); propWasSet = filter->setProperty("InfixEquation", "\"4\" + 2"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); - DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == nArray->getNumberOfTuples()); DREAM3D_REQUIRE(arrayPtr->getNumberOfComponents() == nArray->getNumberOfComponents()); for(int t = 0; t < arrayPtr->getNumberOfTuples(); t++) @@ -299,17 +328,15 @@ class ArrayCalculatorTest { AbstractFilter::Pointer filter = createArrayCalculatorFilter(arrayPath); - UInt32ArrayType::Pointer nArray = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "4")); + UInt32ArrayType::Pointer nArray = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "4")); - UInt32ArrayType::Pointer sArray = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "*")); + UInt32ArrayType::Pointer sArray = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "*")); propWasSet = filter->setProperty("InfixEquation", "\"4\" + \"*\""); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); - DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == nArray->getNumberOfTuples()); DREAM3D_REQUIRE(arrayPtr->getNumberOfComponents() == nArray->getNumberOfComponents()); for(int t = 0; t < arrayPtr->getNumberOfTuples(); t++) @@ -325,17 +352,15 @@ class ArrayCalculatorTest { AbstractFilter::Pointer filter = createArrayCalculatorFilter(arrayPath); - UInt32ArrayType::Pointer nArray = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "4")); + UInt32ArrayType::Pointer nArray = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "4")); - UInt32ArrayType::Pointer sArray = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "*")); + UInt32ArrayType::Pointer sArray = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "*")); propWasSet = filter->setProperty("InfixEquation", "\"4\"[0] + \"*\"[1]"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); - DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == nArray->getNumberOfTuples()); DREAM3D_REQUIRE(arrayPtr->getNumberOfComponents() == 1); for(int t = 0; t < arrayPtr->getNumberOfTuples(); t++) @@ -350,32 +375,28 @@ class ArrayCalculatorTest { AbstractFilter::Pointer filter = createArrayCalculatorFilter(arrayPath); - UInt32ArrayType::Pointer nArray = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "4")); + UInt32ArrayType::Pointer nArray = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "4")); - UInt32ArrayType::Pointer sArray = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "*")); + UInt32ArrayType::Pointer sArray = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "*")); propWasSet = filter->setProperty("InfixEquation", "\"4\" + \"*\"[1]"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::INCONSISTENT_COMP_DIMS)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::INCONSISTENT_COMP_DIMS)); } // Out of bounds error { AbstractFilter::Pointer filter = createArrayCalculatorFilter(arrayPath); - UInt32ArrayType::Pointer nArray = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "4")); + UInt32ArrayType::Pointer nArray = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "4")); - UInt32ArrayType::Pointer sArray = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "*")); + UInt32ArrayType::Pointer sArray = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "*")); propWasSet = filter->setProperty("InfixEquation", "\"4\"[0] + \"*\"[3]"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::COMPONENT_OUT_OF_RANGE)); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::COMPONENT_OUT_OF_RANGE)); } } @@ -387,7 +408,6 @@ class ArrayCalculatorTest DataArrayPath numericArrayPath("DataContainer", "NumericMatrix", "NewArray"); DataArrayPath arrayPath("DataContainer", "AttributeMatrix", "NewArray"); - QVariant var; bool propWasSet = false; // Empty Tests @@ -444,14 +464,13 @@ class ArrayCalculatorTest { AbstractFilter::Pointer filter = createArrayCalculatorFilter(arrayPath); - FloatArrayType::Pointer inputArray1 = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "InputArray1")); + FloatArrayType::Pointer inputArray1 = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "InputArray1")); propWasSet = filter->setProperty("InfixEquation", "-InputArray1"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); - DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == inputArray1->getNumberOfTuples()); for(int i = 0; i < arrayPtr->getNumberOfTuples(); i++) { @@ -461,14 +480,13 @@ class ArrayCalculatorTest { AbstractFilter::Pointer filter = createArrayCalculatorFilter(arrayPath); - UInt32ArrayType::Pointer inputArray2 = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "InputArray2")); + UInt32ArrayType::Pointer inputArray2 = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "InputArray2")); propWasSet = filter->setProperty("InfixEquation", "InputArray2"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); - DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == inputArray2->getNumberOfTuples()); for(int i = 0; i < arrayPtr->getNumberOfTuples(); i++) { @@ -480,18 +498,16 @@ class ArrayCalculatorTest { AbstractFilter::Pointer filter = createArrayCalculatorFilter(arrayPath); - FloatArrayType::Pointer inputArray1 = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "InputArray1")); + FloatArrayType::Pointer inputArray1 = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "InputArray1")); - UInt32ArrayType::Pointer spacedArray = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "Spaced Array")); + UInt32ArrayType::Pointer spacedArray = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "Spaced Array")); propWasSet = filter->setProperty("InfixEquation", "Spaced Array + InputArray1"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); - DREAM3D_REQUIRE_EQUAL(filter->getWarningCondition(), static_cast(CalculatorItem::WarningCode::NONE)); - DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DREAM3D_REQUIRE_EQUAL(filter->getWarningCode(), static_cast(CalculatorItem::WarningCode::NONE)); + DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == spacedArray->getNumberOfTuples()); for(int i = 0; i < arrayPtr->getNumberOfTuples(); i++) { @@ -501,18 +517,16 @@ class ArrayCalculatorTest { AbstractFilter::Pointer filter = createArrayCalculatorFilter(arrayPath); - FloatArrayType::Pointer inputArray1 = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "InputArray1")); + FloatArrayType::Pointer inputArray1 = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "InputArray1")); - UInt32ArrayType::Pointer inputArray2 = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "InputArray2")); + UInt32ArrayType::Pointer inputArray2 = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "InputArray2")); propWasSet = filter->setProperty("InfixEquation", "sqrt((InputArray1^2)+(InputArray2^2))"); DREAM3D_REQUIRE_EQUAL(propWasSet, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); - DREAM3D_REQUIRE_EQUAL(filter->getWarningCondition(), static_cast(CalculatorItem::WarningCode::NONE)); - DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqIDataArrayFromPath(filter.get(), arrayPath); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), static_cast(CalculatorItem::ErrorCode::SUCCESS)); + DREAM3D_REQUIRE_EQUAL(filter->getWarningCode(), static_cast(CalculatorItem::WarningCode::NONE)); + DoubleArrayType::Pointer arrayPtr = filter->getDataContainerArray()->getPrereqArrayFromPath(filter.get(), arrayPath); DREAM3D_REQUIRE(arrayPtr->getNumberOfTuples() == inputArray2->getNumberOfTuples()); for(int i = 0; i < arrayPtr->getNumberOfTuples(); i++) { diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeArraysTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeArraysTest.cpp index 48438aa604..1f5c442fb1 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeArraysTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeArraysTest.cpp @@ -1,50 +1,52 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -54,11 +56,11 @@ #define CREATE_DATA_ARRAY(type, attrMat, tDims, cDimsVec, cDimsScalar, vecName, scalarName, err) \ DataArray::Pointer _##type##VectorArray = DataArray::CreateArray(tDims, cDimsVec, #vecName, true); \ - err = attrMat->addAttributeArray(#vecName, _##type##VectorArray); \ + err = attrMat->insertOrAssign(_##type##VectorArray); \ _##type##VectorArray->initializeWithZeros(); \ DREAM3D_REQUIRE(err >= 0); \ DataArray::Pointer _##type##ScalarArray = DataArray::CreateArray(tDims, cDimsScalar, #scalarName, true); \ - err = attrMat->addAttributeArray(#scalarName, _##type##ScalarArray); \ + err = attrMat->insertOrAssign(_##type##ScalarArray); \ _##type##ScalarArray->initializeWithZeros(); \ DREAM3D_REQUIRE(err >= 0); @@ -67,12 +69,30 @@ class CombineAttributeArraysTest public: CombineAttributeArraysTest() = default; virtual ~CombineAttributeArraysTest() = default; - SIMPL_TYPE_MACRO(CombineAttributeArraysTest) + /** + * @brief Returns the name of the class for CombineAttributeArraysTest + */ + /** + * @brief Returns the name of the class for CombineAttributeArraysTest + */ + QString getNameOfClass() const + { + return QString("CombineAttributeArraysTest"); + } + + /** + * @brief Returns the name of the class for CombineAttributeArraysTest + */ + QString ClassName() + { + return QString("CombineAttributeArraysTest"); + } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void initializeData(IDataArray::Pointer inputPtr) + template + void initializeData(IDataArray::Pointer inputPtr) { auto inputDataPtr = std::dynamic_pointer_cast>(inputPtr); T* inputData = static_cast(inputDataPtr->getPointer(0)); @@ -118,13 +138,13 @@ class CombineAttributeArraysTest DataContainer::Pointer m = DataContainer::New("CombineAttributeArraysTest"); - QVector tDims(1, 100); + std::vector tDims(1, 100); AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tDims, "CombineAttributeArraysTest", AttributeMatrix::Type::Cell); - m->addAttributeMatrix("CombineAttributeArraysTest", attrMat); - dca->addDataContainer(m); + m->addOrReplaceAttributeMatrix(attrMat); + dca->addOrReplaceDataContainer(m); - QVector cDimsVec(1, 3); - QVector cDimsScalar(1, 1); + std::vector cDimsVec(1, 3); + std::vector cDimsScalar(1, 1); CREATE_DATA_ARRAY(uint8_t, attrMat, tDims, cDimsVec, cDimsScalar, uint8_tVectorArray, uint8_tScalarArray, err); CREATE_DATA_ARRAY(int8_t, attrMat, tDims, cDimsVec, cDimsScalar, int8_tVectorArray, int8_tScalarArray, err); @@ -153,12 +173,13 @@ class CombineAttributeArraysTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void checkCombineAttributeArraysFilter(AbstractFilter::Pointer filter, DataArrayPath vectorArrayPath, DataArrayPath scalarArrayPath) + template + void checkCombineAttributeArraysFilter(AbstractFilter::Pointer filter, DataArrayPath vectorArrayPath, DataArrayPath scalarArrayPath) { int32_t err = 0; - QVector dataArrayPathsVecFirst = {vectorArrayPath, scalarArrayPath}; - QVector dataArrayPathsScalarFirst = {scalarArrayPath, vectorArrayPath}; + std::vector dataArrayPathsVecFirst = {vectorArrayPath, scalarArrayPath}; + std::vector dataArrayPathsScalarFirst = {scalarArrayPath, vectorArrayPath}; bool isBool = false; @@ -214,7 +235,7 @@ class CombineAttributeArraysTest } filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0); auto outputArrayPtr = filter->getDataContainerArray()->getDataContainer("CombineAttributeArraysTest")->getAttributeMatrix("CombineAttributeArraysTest")->getAttributeArray("CombinedData"); @@ -242,7 +263,7 @@ class CombineAttributeArraysTest } filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0); outputArrayPtr = filter->getDataContainerArray()->getDataContainer("CombineAttributeArraysTest")->getAttributeMatrix("CombineAttributeArraysTest")->getAttributeArray("CombinedData"); @@ -272,7 +293,7 @@ class CombineAttributeArraysTest } filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0); outputArrayPtr = filter->getDataContainerArray()->getDataContainer("CombineAttributeArraysTest")->getAttributeMatrix("CombineAttributeArraysTest")->getAttributeArray("CombinedData"); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeMatricesTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeMatricesTest.cpp index 902721d95d..d857f9691a 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeMatricesTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CombineAttributeMatricesTest.cpp @@ -1,50 +1,50 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include + +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -54,7 +54,7 @@ #define CREATE_DATA_ARRAY(type, attrMat, tDims, cDims, initVal, name, err) \ DataArray::Pointer name##Array = DataArray::CreateArray(tDims, cDims, name, true); \ - err = attrMat->addAttributeArray(name, name##Array); \ + err = attrMat->insertOrAssign(name##Array); \ name##Array->initializeWithValue(initVal); \ DREAM3D_REQUIRE(err >= 0); @@ -96,7 +96,7 @@ qDebug() << "Unable to set property CombinedAttributeMatrixName"; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, errVal); #define CHECK_FOR_PASS1(filter, featureIds1, featureIds2, attrMat1, attrMat2, newIndex, newAttrMat) \ @@ -137,7 +137,7 @@ qDebug() << "Unable to set property CombinedAttributeMatrixName"; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, 0); \ validateCombinedEnsembleAMs(filter, featureIds1, featureIds2, attrMat1, attrMat2, newIndex, newAttrMat); @@ -179,7 +179,7 @@ qDebug() << "Unable to set property CombinedAttributeMatrixName"; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, 0); \ validateCombinedFeatureAMs(filter, featureIds1, featureIds2, attrMat1, attrMat2, newIndex, newAttrMat); @@ -221,16 +221,16 @@ class CombineAttributeMatricesTest DataContainer::Pointer m2 = DataContainer::New("CombineAttributeMatricesTest2"); // Create Attribute Matrices with different tDims to test validation of tuple compatibility - QVector tDims(3, 0); + std::vector tDims(3, 0); tDims[0] = 2; tDims[1] = 2; tDims[2] = 1; - QVector cDims(1, 1); + std::vector cDims(1, 1); int32_t initVal = 10; // Make Cell AM AttributeMatrix::Pointer cellAttrMat = AttributeMatrix::New(tDims, "cellAttrMat", AttributeMatrix::Type::Cell); - m->addAttributeMatrix("cellAttrMat", cellAttrMat); + m->addOrReplaceAttributeMatrix(cellAttrMat); // Create 2 featureIds arrays in the Cell AM QString featureIds1 = "featureIds1"; @@ -258,14 +258,14 @@ class CombineAttributeMatricesTest tDims.resize(1); tDims[0] = 3; AttributeMatrix::Pointer featureAttrMat1 = AttributeMatrix::New(tDims, "featureAttrMat1", AttributeMatrix::Type::CellFeature); - m->addAttributeMatrix("featureAttrMat1", featureAttrMat1); + m->addOrReplaceAttributeMatrix(featureAttrMat1); QString fAM1AA1 = "ensembleIds"; QString fAM1AA2 = "sizes"; CREATE_DATA_ARRAY(int32_t, featureAttrMat1, tDims, cDims, initVal, fAM1AA1, err); CREATE_DATA_ARRAY(float, featureAttrMat1, tDims, cDims, initVal, fAM1AA2, err); tDims[0] = 2; AttributeMatrix::Pointer ensembleAttrMat1 = AttributeMatrix::New(tDims, "ensembleAttrMat1", AttributeMatrix::Type::CellEnsemble); - m->addAttributeMatrix("ensembleAttrMat1", ensembleAttrMat1); + m->addOrReplaceAttributeMatrix(ensembleAttrMat1); QString eAM1AA1 = "crystalStructures"; CREATE_DATA_ARRAY(int32_t, ensembleAttrMat1, tDims, cDims, initVal, eAM1AA1, err); @@ -288,14 +288,14 @@ class CombineAttributeMatricesTest // Make a feature and ensemble AM for the second featureIds array and add some arrays tDims[0] = 3; AttributeMatrix::Pointer featureAttrMat2 = AttributeMatrix::New(tDims, "featureAttrMat2", AttributeMatrix::Type::CellFeature); - m->addAttributeMatrix("featureAttrMat2", featureAttrMat2); + m->addOrReplaceAttributeMatrix(featureAttrMat2); QString fAM2AA1 = "ensembleIds"; QString fAM2AA2 = "surfaceFeatures"; CREATE_DATA_ARRAY(int32_t, featureAttrMat2, tDims, cDims, initVal, fAM2AA1, err); CREATE_DATA_ARRAY(bool, featureAttrMat2, tDims, cDims, initVal, fAM2AA2, err); tDims[0] = 2; AttributeMatrix::Pointer ensembleAttrMat2 = AttributeMatrix::New(tDims, "ensembleAttrMat2", AttributeMatrix::Type::CellEnsemble); - m->addAttributeMatrix("ensembleAttrMat2", ensembleAttrMat2); + m->addOrReplaceAttributeMatrix(ensembleAttrMat2); QString eAM2AA1 = "crystalStructures"; CREATE_DATA_ARRAY(int32_t, ensembleAttrMat2, tDims, cDims, initVal, eAM2AA1, err); @@ -315,11 +315,11 @@ class CombineAttributeMatricesTest crystStructs2[0] = 0; crystStructs2[1] = 1; - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); // add a feature AM to the second DC to allow for check that AMs are in same DC - m2->addAttributeMatrix("featureAttrMat2", featureAttrMat2); - dca->addDataContainer(m2); + m2->addOrReplaceAttributeMatrix(featureAttrMat2->deepCopy()); + dca->addOrReplaceDataContainer(m2); return dca; } diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ConditionalSetValueTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ConditionalSetValueTest.cpp index ec53f6bc6a..be571a7657 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ConditionalSetValueTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ConditionalSetValueTest.cpp @@ -1,50 +1,51 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/CoreFilters/ConditionalSetValue.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -54,7 +55,7 @@ #define CREATE_DATA_ARRAY(type, attrMat, tDims, cDims, initVal, comps, err) \ DataArray::Pointer _##type##_##comps##_##attrMat##Array = DataArray::CreateArray(tDims, cDims, #type #comps, true); \ - err = attrMat->addAttributeArray(#type #comps, _##type##_##comps##_##attrMat##Array); \ + err = attrMat->insertOrAssign(_##type##_##comps##_##attrMat##Array); \ _##type##_##comps##_##attrMat##Array->initializeWithValue(initVal); \ DREAM3D_REQUIRE(err >= 0); @@ -82,7 +83,7 @@ qDebug() << "Unable to set property ReplaceValue"; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, errVal); #ifdef SET_PROPERTIES_AND_CHECK_EQ @@ -109,7 +110,7 @@ qDebug() << "Unable to set property ReplaceValue"; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, 0); \ dataArray = dc->getAttributeMatrix(selectedArray.getAttributeMatrixName())->getAttributeArray(selectedArray.getDataArrayName()); \ DREAM3D_REQUIRE_EQUAL(err, 0); \ @@ -153,14 +154,14 @@ class ConditionalSetValueTest DataContainer::Pointer m = DataContainer::New("ConditionalSetValueTest"); // Create Attribute Matrices with different tDims to test validation of tuple compatibility - QVector tDims(1, 10); + std::vector tDims(1, 10); AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tDims, "ConditionalSetValueAttrMat", AttributeMatrix::Type::Cell); - m->addAttributeMatrix("ConditionalSetValueAttrMat", attrMat); + m->addOrReplaceAttributeMatrix(attrMat); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); - QVector cDims(1, 3); + std::vector cDims(1, 3); int32_t initVal = 10; CREATE_DATA_ARRAY(uint8_t, attrMat, tDims, cDims, initVal, 3, err); @@ -191,8 +192,8 @@ class ConditionalSetValueTest // this is the conditional array QString name = "ConditionalArray"; - BoolArrayType::Pointer condArrayPtr = BoolArrayType::CreateArray(tDims, cDims, name); - attrMat->addAttributeArray(name, condArrayPtr); + BoolArrayType::Pointer condArrayPtr = BoolArrayType::CreateArray(tDims, cDims, name, true); + attrMat->insertOrAssign(condArrayPtr); condArrayPtr->initializeWithValue(true); // Set some of the values to false int he conditional array bool* condArray = condArrayPtr->getPointer(0); @@ -208,7 +209,8 @@ class ConditionalSetValueTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void validateReplacedValues(IDataArray::Pointer iArray, IDataArray::Pointer cArray) + template + void validateReplacedValues(IDataArray::Pointer iArray, IDataArray::Pointer cArray) { typename DataArray::Pointer dataArrayPtr = std::dynamic_pointer_cast>(iArray); typename DataArray::Pointer condArrayPtr = std::dynamic_pointer_cast>(cArray); @@ -238,14 +240,42 @@ class ConditionalSetValueTest } // ----------------------------------------------------------------------------- - // + void setPropertyAndCheckNE(ConditionalSetValue* filter, double replaceValue, const DataArrayPath& selectedArrayPath, const DataArrayPath& conditionalArrayPath, int32_t errCompare) + { + filter->setSelectedArrayPath(selectedArrayPath); + + filter->setConditionalArrayPath(conditionalArrayPath); + + filter->setReplaceValue(replaceValue); + + filter->execute(); + int32_t err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, errCompare); + } + // ----------------------------------------------------------------------------- - void validateReplaceValue(AbstractFilter::Pointer filter, DataContainerArray::Pointer dca) + template + void setPropertyAndCheckEQ(ConditionalSetValue* filter, DataContainer::Pointer dc, double replaceValue, const DataArrayPath& selectedArrayPath, const DataArrayPath& conditionalArrayPath) { - QVariant var; - bool propWasSet; - int err = 0; + filter->setSelectedArrayPath(selectedArrayPath); + + filter->setConditionalArrayPath(conditionalArrayPath); + filter->setReplaceValue(replaceValue); + filter->execute(); + int32_t err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0); + + IDataArray::Pointer dataArray = dc->getAttributeMatrix(selectedArrayPath.getAttributeMatrixName())->getAttributeArray(selectedArrayPath.getDataArrayName()); + IDataArray::Pointer condArray = dc->getAttributeMatrix(conditionalArrayPath.getAttributeMatrixName())->getAttributeArray(conditionalArrayPath.getDataArrayName()); + validateReplacedValues(dataArray, condArray); + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void validateReplaceValue(ConditionalSetValue* filter, DataContainerArray::Pointer dca) + { DataContainer::Pointer dc = dca->getDataContainer("ConditionalSetValueTest"); IDataArray::Pointer dataArray; IDataArray::Pointer condArray; @@ -276,32 +306,29 @@ class ConditionalSetValueTest DataArrayPath conditionalArray("ConditionalSetValueTest", "ConditionalSetValueAttrMat", "ConditionalArray"); - // Fail if an input array is not scalar - SET_PROPERTIES_AND_CHECK_NE(filter, 5.0, attrMat_uint8_3, conditionalArray, -11002) - // Fail if the replace value is out of range - SET_PROPERTIES_AND_CHECK_NE(filter, 256.0, attrMat_uint8_1, conditionalArray, -100) - SET_PROPERTIES_AND_CHECK_NE(filter, 128.0, attrMat_int8_1, conditionalArray, -100) - SET_PROPERTIES_AND_CHECK_NE(filter, 65536.0, attrMat_uint16_1, conditionalArray, -100) - SET_PROPERTIES_AND_CHECK_NE(filter, 32768.0, attrMat_int16_1, conditionalArray, -100) - SET_PROPERTIES_AND_CHECK_NE(filter, 4294967296.0, attrMat_uint32_1, conditionalArray, -100) - SET_PROPERTIES_AND_CHECK_NE(filter, 2147483648.0, attrMat_int32_1, conditionalArray, -100) - SET_PROPERTIES_AND_CHECK_NE(filter, 20000000000000000000.0, attrMat_uint64_1, conditionalArray, -100) - SET_PROPERTIES_AND_CHECK_NE(filter, 10000000000000000000.0, attrMat_int64_1, conditionalArray, -100) - SET_PROPERTIES_AND_CHECK_NE(filter, 3.41e38, attrMat_float_1, conditionalArray, -101) + setPropertyAndCheckNE(filter, 256.0, attrMat_uint8_1, conditionalArray, -100); + setPropertyAndCheckNE(filter, 128.0, attrMat_int8_1, conditionalArray, -100); + setPropertyAndCheckNE(filter, 65536.0, attrMat_uint16_1, conditionalArray, -100); + setPropertyAndCheckNE(filter, 32768.0, attrMat_int16_1, conditionalArray, -100); + setPropertyAndCheckNE(filter, 4294967296.0, attrMat_uint32_1, conditionalArray, -100); + setPropertyAndCheckNE(filter, 2147483648.0, attrMat_int32_1, conditionalArray, -100); + setPropertyAndCheckNE(filter, 20000000000000000000.0, attrMat_uint64_1, conditionalArray, -100); + setPropertyAndCheckNE(filter, 10000000000000000000.0, attrMat_int64_1, conditionalArray, -100); + setPropertyAndCheckNE(filter, 3.41e38, attrMat_float_1, conditionalArray, -101); // not checking double, because cannot make a value outside of the range // Succeed for all possible test combinations - SET_PROPERTIES_AND_CHECK_EQ(filter, 5.0, attrMat_uint8_1, conditionalArray, dataArray, condArray, uint8_t) - SET_PROPERTIES_AND_CHECK_EQ(filter, 5.0, attrMat_int8_1, conditionalArray, dataArray, condArray, int8_t) - SET_PROPERTIES_AND_CHECK_EQ(filter, 5.0, attrMat_uint16_1, conditionalArray, dataArray, condArray, uint16_t) - SET_PROPERTIES_AND_CHECK_EQ(filter, 5.0, attrMat_int16_1, conditionalArray, dataArray, condArray, int16_t) - SET_PROPERTIES_AND_CHECK_EQ(filter, 5.0, attrMat_uint32_1, conditionalArray, dataArray, condArray, uint32_t) - SET_PROPERTIES_AND_CHECK_EQ(filter, 5.0, attrMat_int32_1, conditionalArray, dataArray, condArray, int32_t) - SET_PROPERTIES_AND_CHECK_EQ(filter, 5.0, attrMat_uint64_1, conditionalArray, dataArray, condArray, uint64_t) - SET_PROPERTIES_AND_CHECK_EQ(filter, 5.0, attrMat_int64_1, conditionalArray, dataArray, condArray, int64_t) - SET_PROPERTIES_AND_CHECK_EQ(filter, 5.0, attrMat_float_1, conditionalArray, dataArray, condArray, float) - SET_PROPERTIES_AND_CHECK_EQ(filter, 5.0, attrMat_double_1, conditionalArray, dataArray, condArray, double) + setPropertyAndCheckEQ(filter, dc, 5.0, attrMat_uint8_1, conditionalArray); + setPropertyAndCheckEQ(filter, dc, 5.0, attrMat_int8_1, conditionalArray); + setPropertyAndCheckEQ(filter, dc, 5.0, attrMat_uint16_1, conditionalArray); + setPropertyAndCheckEQ(filter, dc, 5.0, attrMat_int16_1, conditionalArray); + setPropertyAndCheckEQ(filter, dc, 5.0, attrMat_uint32_1, conditionalArray); + setPropertyAndCheckEQ(filter, dc, 5.0, attrMat_int32_1, conditionalArray); + setPropertyAndCheckEQ(filter, dc, 5.0, attrMat_uint64_1, conditionalArray); + setPropertyAndCheckEQ(filter, dc, 5.0, attrMat_int64_1, conditionalArray); + setPropertyAndCheckEQ(filter, dc, 5.0, attrMat_float_1, conditionalArray); + setPropertyAndCheckEQ(filter, dc, 5.0, attrMat_double_1, conditionalArray); } // ----------------------------------------------------------------------------- @@ -311,17 +338,12 @@ class ConditionalSetValueTest { DataContainerArray::Pointer dca = initializeDataContainerArray(); - QString filtName = "ConditionalSetValue"; - FilterManager* fm = FilterManager::Instance(); - IFilterFactory::Pointer factory = fm->getFactoryFromClassName(filtName); - DREAM3D_REQUIRE(factory.get() != nullptr) - - AbstractFilter::Pointer conditionalSetValueFilter = factory->create(); + ConditionalSetValue::Pointer conditionalSetValueFilter = ConditionalSetValue::New(); DREAM3D_REQUIRE(conditionalSetValueFilter.get() != nullptr) conditionalSetValueFilter->setDataContainerArray(dca); - validateReplaceValue(conditionalSetValueFilter, dca); + validateReplaceValue(conditionalSetValueFilter.get(), dca); return EXIT_SUCCESS; } diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertColorToGrayScaleTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertColorToGrayScaleTest.cpp index d6dc7940d6..bd04fdbe10 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertColorToGrayScaleTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertColorToGrayScaleTest.cpp @@ -27,46 +27,46 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include -#include #include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLArray.hpp" +#include "SIMPLib/CoreFilters/ConvertColorToGrayScale.h" #include "SIMPLib/DataArrays/DataArray.hpp" -#include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Geometry/EdgeGeom.h" #include "SIMPLib/Geometry/ImageGeom.h" #include "SIMPLib/Geometry/TriangleGeom.h" #include "SIMPLib/Geometry/VertexGeom.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include - - class ConvertColorToGrayScaleTest { - const FloatVec3_t m_defaultWeights{0.2125f, 0.7154f, 0.0721f}; + const FloatVec3Type m_defaultWeights{0.2125f, 0.7154f, 0.0721f}; const bool m_createNewAM = false; const QString m_filtName = "ConvertColorToGrayScale"; const QString m_outputArrayPrefix = "grayTestImage"; const QString m_outputAMName = "grayTestAM"; - AbstractFilter::Pointer m_colorToGrayscaleFilter; - DataContainerArray::Pointer m_dca; + // ConvertColorToGrayScale::Pointer m_colorToGrayscaleFilter; + // DataContainerArray::Pointer m_dca; enum Algorithms { @@ -286,6 +286,7 @@ class ConvertColorToGrayScaleTest checkGChannelColors, checkBChannelColors}; + //------------------------------------------------------------------------------ void SetDataArrayTestValues(DataArray::Pointer& aa) { aa->initializeWithValue(0); @@ -296,30 +297,32 @@ class ConvertColorToGrayScaleTest } } - static DataContainer::Pointer createVertexGeometryDataContainer(const DataArray::Pointer& aa, const QVector& tDims) + //------------------------------------------------------------------------------ + static DataContainer::Pointer createVertexGeometryDataContainer(const DataArray::Pointer& aa, const std::vector& tDims) { AttributeMatrix::Pointer am = AttributeMatrix::New(tDims, SIMPL::Defaults::VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - am->addAttributeArray(aa->getName(), aa); + am->insertOrAssign(aa); DataContainer::Pointer dc = DataContainer::New(SIMPL::Defaults::VertexDataContainerName); - dc->addAttributeMatrix(SIMPL::Defaults::VertexAttributeMatrixName, am); + dc->insertOrAssign(am); dc->setGeometry(VertexGeom::CreateGeometry(static_cast(aa->getNumberOfTuples()), SIMPL::Geometry::VertexGeometry)); return dc; } - int CheckFilterParameters(const QVariant& algorithm, const FloatVec3_t& cws, const uint8_t& cc) + //------------------------------------------------------------------------------ + int CheckFilterParameters(ConvertColorToGrayScale::Pointer filter, const QVariant& algorithm, const FloatVec3Type& cws, const uint8_t& cc) { - QVariant conversionAlgorithm{m_colorToGrayscaleFilter->property("ConversionAlgorithm")}; - FloatVec3_t colorWeights = (m_colorToGrayscaleFilter->property("ColorWeights").value()); - QVariant outputArrayPrefix{m_colorToGrayscaleFilter->property("OutputArrayPrefix")}; - QVariant colorChannel{m_colorToGrayscaleFilter->property("ColorChannel")}; - QVariant createNewAM{m_colorToGrayscaleFilter->property("CreateNewAttributeMatrix")}; - QVariant outputAMName{m_colorToGrayscaleFilter->property("OutputAttributeMatrixName")}; + QVariant conversionAlgorithm{filter->property("ConversionAlgorithm")}; + FloatVec3Type colorWeights = (filter->property("ColorWeights").value()); + QVariant outputArrayPrefix{filter->property("OutputArrayPrefix")}; + QVariant colorChannel{filter->property("ColorChannel")}; + QVariant createNewAM{filter->property("CreateNewAttributeMatrix")}; + QVariant outputAMName{filter->property("OutputAttributeMatrixName")}; int wrongParameters = 0; wrongParameters += (conversionAlgorithm == algorithm) ? 0 : 1; float epsilon = 0.000000001f; - wrongParameters += (abs(colorWeights.x - cws.x) < epsilon && abs(colorWeights.y - cws.y) < epsilon && abs(colorWeights.z - cws.z) < epsilon) ? 0 : 1; + wrongParameters += (abs(colorWeights.getX() - cws.getX()) < epsilon && abs(colorWeights.getY() - cws.getY()) < epsilon && abs(colorWeights.getZ() - cws.getZ()) < epsilon) ? 0 : 1; wrongParameters += (outputArrayPrefix == m_outputArrayPrefix) ? 0 : 1; wrongParameters += (colorChannel == cc) ? 0 : 1; wrongParameters += (createNewAM == m_createNewAM) ? 0 : 1; @@ -328,13 +331,13 @@ class ConvertColorToGrayScaleTest return wrongParameters; } - int CompareResults(const uint8_t& algoMapIndex) const + //------------------------------------------------------------------------------ + int CompareResults(const uint8_t& algoMapIndex, DataContainer::Pointer dc) const { QString amName = m_outputAMName; - DataContainer::Pointer dc = m_dca->getDataContainers().first(); if(!m_createNewAM) { - amName = dc->getAttributeMatrices().first()->getName(); + amName = dc->getAttributeMatrices().front()->getName(); } AttributeMatrix::Pointer am = dc->getAttributeMatrix(amName); @@ -350,27 +353,32 @@ class ConvertColorToGrayScaleTest std::vector colorArray{algorithmMap[algoMapIndex]}; int wrongValues = 0; - tbb::parallel_for(tbb::blocked_range(0, colorArray.size()), [&](const tbb::blocked_range& r) { - for(size_t index = r.begin(); index < r.end(); ++index) - { - wrongValues += (testArray->getValue(index) == colorArray[index]) ? 0 : 1; - } - }); + for(size_t index = 0; index < colorArray.size(); ++index) + { + wrongValues += (testArray->getValue(index) == colorArray[index]) ? 0 : 1; + } + return wrongValues; } - /** - @brief Creates the input data array path from the data container and - assigns it, the passed data container, and any other relevant parameters - to the filter - @details The DCA can hold multiple geometries; as long as the data container - of the desired geometry is passed in here this method will sort out the input - data array path and should work as expected - */ - void SetUp(const QVariant& algorithm, const DataContainer::Pointer& dc, const FloatVec3_t& colorWeights = {0.2125f, 0.7154f, 0.0721f}, const uint8_t& colorChannel = 0) + //------------------------------------------------------------------------------ + int RunTest(const uint8_t& algoMapIndex, const Algorithms& algorithm, const FloatVec3Type& colorWeights, const uint8_t& colorChannel) { - m_dca->addDataContainer(dc); - QVector daps{}; + const QString aaName = SIMPL::VertexData::SurfaceMeshNodes; + const std::vector tDims{16}; + const std::vector cDims{3, 1, 1}; + + UInt8ArrayType::Pointer testAA = UInt8ArrayType::CreateArray(tDims, cDims, aaName, true); + SetDataArrayTestValues(testAA); + + // NOTE: This filter has no geometry requirements + DataContainer::Pointer dc = createVertexGeometryDataContainer(testAA, tDims); + + // Setup + DataContainerArray::Pointer m_dca = DataContainerArray::New(); + m_dca->setName("TEST DATA CONTAINER ARRAY"); + m_dca->insertOrAssign(dc); + std::vector daps; for(const AttributeMatrix::Pointer& eachAM : dc->getAttributeMatrices()) { QString amName = eachAM->getName(); @@ -379,173 +387,99 @@ class ConvertColorToGrayScaleTest // Make sure not to add an output AA if(!eachAAName.contains(m_outputArrayPrefix)) { - daps.append(DataArrayPath(dc->getName(), amName, eachAAName)); + daps.push_back(DataArrayPath(dc->getName(), amName, eachAAName)); } } } - QVariant dataArrayVector{}; - dataArrayVector.setValue(daps); - - QVariant cw{}; - cw.setValue(colorWeights); + ConvertColorToGrayScale::Pointer m_colorToGrayscaleFilter = ConvertColorToGrayScale::New(); + DREAM3D_REQUIRE(m_colorToGrayscaleFilter.get() != nullptr); - m_colorToGrayscaleFilter->setProperty("ConversionAlgorithm", algorithm); - m_colorToGrayscaleFilter->setProperty("OutputArrayPrefix", static_cast(m_outputArrayPrefix)); - m_colorToGrayscaleFilter->setProperty("ColorWeights", cw); - m_colorToGrayscaleFilter->setProperty("ColorChannel", colorChannel); - m_colorToGrayscaleFilter->setProperty("CreateNewAttributeMatrix", m_createNewAM); - m_colorToGrayscaleFilter->setProperty("OutputAttributeMatrixName", static_cast(m_outputAMName)); - m_colorToGrayscaleFilter->setProperty("InputDataArrayVector", dataArrayVector); + m_colorToGrayscaleFilter->setConversionAlgorithm(algorithm); + m_colorToGrayscaleFilter->setOutputArrayPrefix(m_outputArrayPrefix); + m_colorToGrayscaleFilter->setColorWeights(colorWeights); + m_colorToGrayscaleFilter->setColorChannel(colorChannel); + m_colorToGrayscaleFilter->setCreateNewAttributeMatrix(m_createNewAM); + m_colorToGrayscaleFilter->setOutputAttributeMatrixName(m_outputAMName); + m_colorToGrayscaleFilter->setInputDataArrayVector(daps); m_colorToGrayscaleFilter->setDataContainerArray(m_dca); - int wrongParameters = CheckFilterParameters(algorithm, colorWeights, colorChannel); + int wrongParameters = CheckFilterParameters(m_colorToGrayscaleFilter, algorithm, colorWeights, colorChannel); DREAM3D_REQUIRE_EQUAL(0, wrongParameters) - } - void SetUp(const QVariant& algorithm, const DataContainer::Pointer& dc, const uint8_t& colorChannel) - { - SetUp(algorithm, dc, m_defaultWeights, colorChannel); - } + // RunTest - int RunTest(const uint8_t& algoMapIndex) - { + Observer obs; + m_colorToGrayscaleFilter->connect(m_colorToGrayscaleFilter.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); m_colorToGrayscaleFilter->execute(); - int erred = m_colorToGrayscaleFilter->getErrorCondition(); + int erred = m_colorToGrayscaleFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(erred, 0); - int wrongValues = CompareResults(algoMapIndex); + int wrongValues = CompareResults(algoMapIndex, dc); DREAM3D_REQUIRE_EQUAL(wrongValues, 0) return erred + wrongValues; } - /** - * @brief Resets the environment for another test - */ - void TearDown(const DataContainer::Pointer& dc) const - { - for(const auto& eachDC : m_dca->getDataContainers()) - { - for(const auto& eachAM : eachDC->getAttributeMatrices()) - { - for(const auto& eachAAName : eachAM->getAttributeArrayNames()) - { - if(eachAAName.contains(m_outputArrayPrefix)) - { - eachAM->getAttributeArray(eachAAName)->releaseOwnership(); - eachAM->removeAttributeArray(eachAAName); - bool doesAAStillExist = m_dca->doesAttributeArrayExist(DataArrayPath(eachDC->getName(), eachAM->getName(), eachAAName)); - DREAM3D_REQUIRE_EQUAL(false, doesAAStillExist) - } - } - eachDC->removeAttributeMatrix(m_outputAMName); - bool doesAMStillExist = eachDC->doesAttributeMatrixExist(m_outputAMName); - DREAM3D_REQUIRE_EQUAL(false, doesAMStillExist) - } - } - - m_dca->removeDataContainer(dc->getName()); - -#if REMOVE_TEST_FILES -// QFile::remove(UnitTest::ConvertColorToGrayScale::TestOutputPath); -#endif - } - public: ConvertColorToGrayScaleTest(const ConvertColorToGrayScaleTest&) = delete; // Copy Constructor ConvertColorToGrayScaleTest(ConvertColorToGrayScaleTest&&) = delete; // Move Constructor ConvertColorToGrayScaleTest& operator=(const ConvertColorToGrayScaleTest&) = delete; // Copy Assignment ConvertColorToGrayScaleTest& operator=(ConvertColorToGrayScaleTest&&) = delete; // Move Assignment - ConvertColorToGrayScaleTest() - : m_dca{DataContainerArray::New()} - { - IFilterFactory::Pointer colorToGrayscaleFactory = FilterManager::Instance()->getFactoryFromClassName(m_filtName); - DREAM3D_REQUIRE(colorToGrayscaleFactory.get() != nullptr); - - m_colorToGrayscaleFilter = colorToGrayscaleFactory->create(); - DREAM3D_REQUIRE(m_colorToGrayscaleFilter.get() != nullptr); - } + ConvertColorToGrayScaleTest() = default; ~ConvertColorToGrayScaleTest() = default; + //------------------------------------------------------------------------------ void operator()() { - int err = 0; + std::cout << "#### ConvertColorToGrayScaleTest Starting ####" << std::endl; - const QString aaName = SIMPL::VertexData::SurfaceMeshNodes; - const QVector tDims{16}; - const QVector cDims{3, 1, 1}; - - DataArray::Pointer testAA{DataArray::CreateArray(tDims, cDims, aaName)}; - SetDataArrayTestValues(testAA); - - // NOTE: This filter has no geometry requirements - DataContainer::Pointer vertexDC{createVertexGeometryDataContainer(testAA, tDims)}; + int err = 0; // Luminosity Algorithm testing // Test defaults qDebug() << "Testing luminosity algorithm..."; qDebug() << "Default weights (0.2125, 0.7154, 0.0721)..."; - SetUp(Algorithms::LUMINOSITY, vertexDC); - DREAM3D_REGISTER_TEST(RunTest(0)) - TearDown(vertexDC); + DREAM3D_REGISTER_TEST(RunTest(0, Algorithms::LUMINOSITY, {0.2125f, 0.7154f, 0.0721f}, 0)) // Test custom - FloatVec3_t colorWeights{0.75, 0.75, 0.75}; + FloatVec3Type colorWeights{0.75, 0.75, 0.75}; qDebug() << "Custom weights (0.75, 0.75, 0.75)..."; - SetUp(Algorithms::LUMINOSITY, vertexDC, colorWeights); - DREAM3D_REGISTER_TEST(RunTest(1)) - TearDown(vertexDC); + DREAM3D_REGISTER_TEST(RunTest(1, Algorithms::LUMINOSITY, colorWeights, 0)) // Test <0 colorWeights = {-0.75, -0.75, -0.75}; qDebug() << "Testing weights < 0 (-0.75, -0.75, -0.75)..."; - SetUp(Algorithms::LUMINOSITY, vertexDC, colorWeights); - DREAM3D_REGISTER_TEST(RunTest(2)) - TearDown(vertexDC); + DREAM3D_REGISTER_TEST(RunTest(2, Algorithms::LUMINOSITY, colorWeights, 0)) // Test >1 colorWeights = {1.75, 1.75, 1.75}; qDebug() << "Testing weights > 1 (1.75, 1.75, 1.75)..."; - SetUp(Algorithms::LUMINOSITY, vertexDC, colorWeights); - DREAM3D_REGISTER_TEST(RunTest(3)) - TearDown(vertexDC); + DREAM3D_REGISTER_TEST(RunTest(3, Algorithms::LUMINOSITY, colorWeights, 0)) // Test <-1 colorWeights = {-1.75, -1.75, -1.75}; qDebug() << "Testing weights < -1 (-1.75, -1.75, -1.75)..."; - SetUp(Algorithms::LUMINOSITY, vertexDC, colorWeights); - DREAM3D_REGISTER_TEST(RunTest(4)) - TearDown(vertexDC); + DREAM3D_REGISTER_TEST(RunTest(4, Algorithms::LUMINOSITY, colorWeights, 0)) // Average Algorithm testing qDebug() << "Testing average algorithm..."; - SetUp(Algorithms::AVERAGE, vertexDC); - DREAM3D_REGISTER_TEST(RunTest(5)) - TearDown(vertexDC); + DREAM3D_REGISTER_TEST(RunTest(5, Algorithms::AVERAGE, {0.2125f, 0.7154f, 0.0721f}, 0)) // Lightness Algorithm testing qDebug() << "Testing lightness algorithm..."; - SetUp(Algorithms::LIGHTNESS, vertexDC); - DREAM3D_REGISTER_TEST(RunTest(6)) - TearDown(vertexDC); + DREAM3D_REGISTER_TEST(RunTest(6, Algorithms::LIGHTNESS, {0.2125f, 0.7154f, 0.0721f}, 0)) // Single Channel Algorithm testing // Red channel qDebug() << "Testing red channel algorithm..."; - SetUp(Algorithms::SINGLE_CHANNEL, vertexDC); - DREAM3D_REGISTER_TEST(RunTest(7)) - TearDown(vertexDC); + DREAM3D_REGISTER_TEST(RunTest(7, Algorithms::SINGLE_CHANNEL, {0.2125f, 0.7154f, 0.0721f}, 0)) // Green channel qDebug() << "Testing green channel algorithm..."; - SetUp(Algorithms::SINGLE_CHANNEL, vertexDC, 1); - DREAM3D_REGISTER_TEST(RunTest(8)) - TearDown(vertexDC); + DREAM3D_REGISTER_TEST(RunTest(8, Algorithms::SINGLE_CHANNEL, {0.2125f, 0.7154f, 0.0721f}, 1)) // Blue channel qDebug() << "Testing blue channel algorithm..."; - SetUp(Algorithms::SINGLE_CHANNEL, vertexDC, 2); - DREAM3D_REGISTER_TEST(RunTest(9)) - TearDown(vertexDC); + DREAM3D_REGISTER_TEST(RunTest(9, Algorithms::SINGLE_CHANNEL, {0.2125f, 0.7154f, 0.0721f}, 2)) } }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertDataTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertDataTest.cpp index f9873df6a8..ce1b0f7545 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertDataTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ConvertDataTest.cpp @@ -1,55 +1,55 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include + +#include +#include +#include + +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/CoreFilters/ConvertData.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" - #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -67,60 +67,60 @@ class ConvertDataTest DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); - QVector dims; + std::vector dims; dims.push_back(2); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); - QVector cdims; + std::vector cdims; cdims.push_back(2); IDataArray::Pointer da; switch(dataType) { case SIMPL::NumericTypes::Type::Int8: - da = DataArray::CreateArray(2, cdims, "DataArray"); + da = DataArray::CreateArray(2, cdims, "DataArray", true); break; case SIMPL::NumericTypes::Type::UInt8: - da = DataArray::CreateArray(2, cdims, "DataArray"); + da = DataArray::CreateArray(2, cdims, "DataArray", true); break; case SIMPL::NumericTypes::Type::Int16: - da = DataArray::CreateArray(2, cdims, "DataArray"); + da = DataArray::CreateArray(2, cdims, "DataArray", true); break; case SIMPL::NumericTypes::Type::UInt16: - da = DataArray::CreateArray(2, cdims, "DataArray"); + da = DataArray::CreateArray(2, cdims, "DataArray", true); break; case SIMPL::NumericTypes::Type::Int32: - da = DataArray::CreateArray(2, cdims, "DataArray"); + da = DataArray::CreateArray(2, cdims, "DataArray", true); break; case SIMPL::NumericTypes::Type::UInt32: - da = DataArray::CreateArray(2, cdims, "DataArray"); + da = DataArray::CreateArray(2, cdims, "DataArray", true); break; case SIMPL::NumericTypes::Type::Int64: - da = DataArray::CreateArray(2, cdims, "DataArray"); + da = DataArray::CreateArray(2, cdims, "DataArray", true); break; case SIMPL::NumericTypes::Type::UInt64: - da = DataArray::CreateArray(2, cdims, "DataArray"); + da = DataArray::CreateArray(2, cdims, "DataArray", true); break; case SIMPL::NumericTypes::Type::Float: - da = DataArray::CreateArray(2, cdims, "DataArray"); + da = DataArray::CreateArray(2, cdims, "DataArray", true); break; case SIMPL::NumericTypes::Type::Double: - da = DataArray::CreateArray(2, cdims, "DataArray"); + da = DataArray::CreateArray(2, cdims, "DataArray", true); break; case SIMPL::NumericTypes::Type::Bool: - da = DataArray::CreateArray(2, cdims, "DataArray"); + da = DataArray::CreateArray(2, cdims, "DataArray", true); break; case SIMPL::NumericTypes::Type::SizeT: - da = DataArray::CreateArray(2, cdims, "DataArray"); + da = DataArray::CreateArray(2, cdims, "DataArray", true); break; case SIMPL::NumericTypes::Type::UnknownNumType: break; } da->initializeWithZeros(); - am->addAttributeArray("DataArray", da); + am->insertOrAssign(da); return dca; } @@ -173,7 +173,8 @@ class ConvertDataTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template std::shared_ptr> getDataArray(AttributeMatrix::Pointer am, QString dataArray) + template + std::shared_ptr> getDataArray(AttributeMatrix::Pointer am, QString dataArray) { typename DataArray::Pointer da = std::dynamic_pointer_cast>(am->getAttributeArray(dataArray)); @@ -183,7 +184,8 @@ class ConvertDataTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void checkConvertedArray(std::shared_ptr> originalDataArray, std::shared_ptr> convertedDataArray) + template + void checkConvertedArray(std::shared_ptr> originalDataArray, std::shared_ptr> convertedDataArray) { DREAM3D_ASSERT(nullptr != originalDataArray.get()); DREAM3D_ASSERT(nullptr != convertedDataArray.get()); @@ -215,7 +217,7 @@ class ConvertDataTest { setValues(filter, arrayName, newType, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); if(checkArray) { @@ -583,7 +585,7 @@ class ConvertDataTest setValues(filter, "Array1", SIMPL::NumericTypes::Type::Int8, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -90002); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -90002); } // ----------------------------------------------------------------------------- @@ -600,7 +602,7 @@ class ConvertDataTest setValues(filter, "DataArray", SIMPL::NumericTypes::Type::Int8, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyFeatureArrayToElementArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyFeatureArrayToElementArrayTest.cpp index a2e9c1a6f6..24275df5e6 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyFeatureArrayToElementArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyFeatureArrayToElementArrayTest.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,20 +35,21 @@ #pragma once -#include -#include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" - -#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -83,9 +84,10 @@ class CopyFeatureArrayToElementArrayTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template std::shared_ptr> createDataArray(const QString& daName, const std::vector>& data, const QVector& tupleDims, const QVector& cDims) + template + std::shared_ptr> createDataArray(const QString& daName, const std::vector>& data, const std::vector& tupleDims, const std::vector& cDims) { - typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName); + typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName, true); for(int i = 0; i < da->getNumberOfTuples(); i++) { da->setTuple(i, data[i]); @@ -93,18 +95,20 @@ class CopyFeatureArrayToElementArrayTest return da; } - template void TestCopyFeatureArrayToElementArrayForType() + template + void TestCopyFeatureArrayToElementArrayForType() { // Names and Constants static const QString k_DataContainerName("DataContainer"); - static const QString k_FeatureDataMatrixName("FeatureDataMatrix"); - static const QString k_FeatureIDMatrixName("FeatureIDMatrix"); + static const QString k_Cell_AMName("Cell Attribute Matrix"); + static const QString k_Feature_AMName("Feature Attribute Matrix"); - static const QString k_FeatureDataArrayName("FeatureData"); - static const QString k_FeatureIDArrayName("FeatureIDArray"); - static const QString k_ElementArrayName("ElementArray"); + static const QString k_CellFeatureIdsArrayName("FeatureIds"); + static const QString k_CellTempArrayName("Temperature"); + + static const QString k_FeatureDataArrayName("Temperature"); // Create DataContainerArray @@ -113,33 +117,36 @@ class CopyFeatureArrayToElementArrayTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices + std::vector tDims = {{10, 3}}; + AttributeMatrix::Pointer cellAM = AttributeMatrix::New(tDims, k_Cell_AMName, AttributeMatrix::Type::Cell); + dc->addOrReplaceAttributeMatrix(cellAM); - AttributeMatrix::Pointer dataAM = AttributeMatrix::New(m_Dims10, k_FeatureDataMatrixName, AttributeMatrix::Type::VertexFeature); - dc->addAttributeMatrix(k_FeatureDataMatrixName, dataAM); - - AttributeMatrix::Pointer idsAM = AttributeMatrix::New(m_Dims10, k_FeatureIDMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(k_FeatureIDMatrixName, idsAM); + AttributeMatrix::Pointer featureAM = AttributeMatrix::New(m_Dims3, k_Feature_AMName, AttributeMatrix::Type::CellFeature); + dc->addOrReplaceAttributeMatrix(featureAM); - // Create feature data and feature IDs + // Create Cell FeatureIds array + typename DataArray::Pointer cellFeatureIds = DataArray::CreateArray(cellAM->getNumberOfTuples(), k_CellFeatureIdsArrayName, true); + cellAM->insertOrAssign(cellFeatureIds); - typename DataArray::Pointer daFeatures = DataArray::CreateArray(m_Dims10, m_Dims3, k_FeatureDataArrayName); - for(int i = 0; i < daFeatures->getSize(); i++) + for(size_t y = 0; y < 3; y++) { - daFeatures->setValue(i, static_cast(i + 2.13)); + for(size_t x = 0; x < 10; x++) + { + size_t index = (10 * y) + x; + cellFeatureIds->setValue(index, static_cast(y)); + } } - dataAM->addAttributeArray(k_FeatureDataArrayName, daFeatures); - // Use reverse ordering on the ID list to test that the filter moves data to the appropriate location - - DataArray::Pointer daIDList = DataArray::CreateArray(m_Dims10, m_Dims1, k_FeatureIDArrayName); - for(int i = 0; i < daIDList->getNumberOfTuples(); i++) + // Create an array in teh Feature Attribute Matrix with 3 values since we created 3 features in the cell attribute matrix + typename DataArray::Pointer avgTempValue = DataArray::CreateArray(3, k_FeatureDataArrayName, true); + featureAM->insertOrAssign(avgTempValue); + for(int i = 0; i < 3; i++) { - daIDList->setValue(daIDList->getNumberOfTuples() - i - 1, i); + avgTempValue->setValue(i, static_cast(0)); } - idsAM->addAttributeArray(k_FeatureIDArrayName, daIDList); // Create Filter @@ -149,41 +156,50 @@ class CopyFeatureArrayToElementArrayTest copyFeatureArrayToElementArray->setDataContainerArray(dca); - // Set up filter - QVariant var; - DataArrayPath dap(k_DataContainerName, k_FeatureDataMatrixName, k_FeatureDataArrayName); + DataArrayPath dap(k_DataContainerName, k_Feature_AMName, k_FeatureDataArrayName); var.setValue(dap); bool propWasSet = copyFeatureArrayToElementArray->setProperty("SelectedFeatureArrayPath", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) - dap = DataArrayPath(k_DataContainerName, k_FeatureIDMatrixName, k_FeatureIDArrayName); + dap = DataArrayPath(k_DataContainerName, k_Cell_AMName, k_CellFeatureIdsArrayName); var.setValue(dap); propWasSet = copyFeatureArrayToElementArray->setProperty("FeatureIdsArrayPath", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) - var.setValue(k_ElementArrayName); + var.setValue(k_CellTempArrayName); propWasSet = copyFeatureArrayToElementArray->setProperty("CreatedArrayName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) // Run filter copyFeatureArrayToElementArray->execute(); - DREAM3D_REQUIRED(copyFeatureArrayToElementArray->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(copyFeatureArrayToElementArray->getErrorCode(), >=, 0); // Check filter results + QString dbg; + QTextStream ss(&dbg); + typename DataArray::Pointer createdElementArray = cellAM->getAttributeArrayAs>(k_CellTempArrayName); - typename DataArray::Pointer createdElementArray = idsAM->getAttributeArrayAs>(k_ElementArrayName); - - for(size_t i = 0; i < daFeatures->getNumberOfTuples(); i++) + for(size_t i = 0; i < createdElementArray->getNumberOfTuples(); i++) { - for(size_t j = 0; j < daFeatures->getNumberOfComponents(); j++) - { - T oldValue = daFeatures->getComponent(i, j); - T newValue = createdElementArray->getComponent(daIDList->getValue(i), j); - DREAM3D_REQUIRE_EQUAL(newValue, oldValue) - } + // daFeatures->printTuple(ss , i); + // createdElementArray->printTuple(ss, i); + // ss << "---\n"; + + int32_t featureId = cellFeatureIds->getValue(i); + T value = createdElementArray->getValue(i); + T featureValue = avgTempValue->getValue(featureId); + DREAM3D_REQUIRE_EQUAL(value, featureValue); + + // for(size_t j = 0; j < daFeatures->getNumberOfComponents(); j++) + // { + + // T oldValue = daFeatures->getComponent(i, j); + // T newValue = createdElementArray->getComponent(daIDList->getValue(i), j); + // DREAM3D_REQUIRE_EQUAL(newValue, oldValue) + // } } } @@ -220,7 +236,7 @@ class CopyFeatureArrayToElementArrayTest private: QString m_FilterName = QString("CopyFeatureArrayToElementArray"); - QVector m_Dims1 = {1}; - QVector m_Dims3 = {3}; - QVector m_Dims10 = {10}; + std::vector m_Dims1 = {1}; + std::vector m_Dims3 = {3}; + std::vector m_Dims10 = {10}; }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyObjectTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyObjectTest.cpp index e40b4f0fa6..40849af2a2 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyObjectTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CopyObjectTest.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,23 +35,18 @@ #pragma once -#include -#include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/CoreFilters/CopyObject.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" -#include "SIMPLib/Plugin/ISIMPLibPlugin.h" -#include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" - #include "SIMPLib/Filtering/QMetaObjectUtilities.h" - -#include "SIMPLib/Testing/SIMPLTestFileLocations.h" -#include "SIMPLib/Testing/UnitTestSupport.hpp" - #include "SIMPLib/Geometry/EdgeGeom.h" #include "SIMPLib/Geometry/HexahedralGeom.h" #include "SIMPLib/Geometry/ImageGeom.h" @@ -60,8 +55,10 @@ #include "SIMPLib/Geometry/TetrahedralGeom.h" #include "SIMPLib/Geometry/TriangleGeom.h" #include "SIMPLib/Geometry/VertexGeom.h" - -#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Plugin/ISIMPLibPlugin.h" +#include "SIMPLib/Plugin/SIMPLibPluginLoader.h" +#include "SIMPLib/Testing/SIMPLTestFileLocations.h" +#include "SIMPLib/Testing/UnitTestSupport.hpp" class CopyObjectTest { @@ -77,26 +74,10 @@ class CopyObjectTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - int TestFilterAvailability() + template + std::shared_ptr> createDataArray(const QString& daName, const std::vector>& data, const std::vector& tupleDims, const std::vector& cDims) { - // Now instantiate the CopyObjectTest Filter from the FilterManager - FilterManager* fm = FilterManager::Instance(); - IFilterFactory::Pointer filterFactory = fm->getFactoryFromClassName(m_FilterName); - if(nullptr == filterFactory.get()) - { - std::stringstream ss; - ss << "The CopyObjectTest Requires the use of the " << m_FilterName.toStdString() << " filter which is found in Core Filters"; - DREAM3D_TEST_THROW_EXCEPTION(ss.str()) - } - return 0; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template std::shared_ptr> createDataArray(const QString& daName, const std::vector>& data, const QVector& tupleDims, const QVector& cDims) - { - typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName); + typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName, true); for(size_t i = 0; i < da->getNumberOfTuples(); i++) { da->setTuple(i, data[i]); @@ -107,9 +88,10 @@ class CopyObjectTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template std::shared_ptr> createDataArray(const QString& daName, const QVector& tupleDims, const QVector& cDims) + template + std::shared_ptr> createDataArray(const QString& daName, const std::vector& tupleDims, const std::vector& cDims) { - typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName); + typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName, true); for(size_t i = 0; i < da->getSize(); i++) { da->setValue(i, static_cast(i)); @@ -120,7 +102,8 @@ class CopyObjectTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void checkDataArray(IDataArray::Pointer originalData, IDataArray::Pointer newData, bool isRenamed) + template + void checkDataArray(IDataArray::Pointer originalData, IDataArray::Pointer newData, bool isRenamed) { if(originalData == IDataArray::NullPointer() || newData == IDataArray::NullPointer()) { @@ -293,18 +276,18 @@ class CopyObjectTest ImageGeom::Pointer oldImageGeom = std::dynamic_pointer_cast(oldGeom); ImageGeom::Pointer newImageGeom = std::dynamic_pointer_cast(newGeom); - SIMPL::Tuple3SVec oldDims = oldImageGeom->getDimensions(); - SIMPL::Tuple3SVec newDims = newImageGeom->getDimensions(); + SizeVec3Type oldDims = oldImageGeom->getDimensions(); + SizeVec3Type newDims = newImageGeom->getDimensions(); bool sameDims = (oldDims == newDims); DREAM3D_REQUIRE_EQUAL(sameDims, true) - SIMPL::Tuple3FVec oldRes = oldImageGeom->getResolution(); - SIMPL::Tuple3FVec newRes = newImageGeom->getResolution(); + FloatVec3Type oldRes = oldImageGeom->getSpacing(); + FloatVec3Type newRes = newImageGeom->getSpacing(); bool sameRes = (oldRes == newRes); DREAM3D_REQUIRE_EQUAL(sameRes, true) - SIMPL::Tuple3FVec oldOrigin = oldImageGeom->getOrigin(); - SIMPL::Tuple3FVec newOrigin = newImageGeom->getOrigin(); + FloatVec3Type oldOrigin = oldImageGeom->getOrigin(); + FloatVec3Type newOrigin = newImageGeom->getOrigin(); bool sameOrigin = (oldOrigin == newOrigin); DREAM3D_REQUIRE_EQUAL(sameOrigin, true) } @@ -313,8 +296,8 @@ class CopyObjectTest RectGridGeom::Pointer oldRectGridGeom = std::dynamic_pointer_cast(oldGeom); RectGridGeom::Pointer newRectGridGeom = std::dynamic_pointer_cast(newGeom); - SIMPL::Tuple3SVec oldDims = oldRectGridGeom->getDimensions(); - SIMPL::Tuple3SVec newDims = newRectGridGeom->getDimensions(); + SizeVec3Type oldDims = oldRectGridGeom->getDimensions(); + SizeVec3Type newDims = newRectGridGeom->getDimensions(); bool sameDims = (oldDims == newDims); DREAM3D_REQUIRE_EQUAL(sameDims, true) @@ -344,9 +327,9 @@ class CopyObjectTest EdgeGeom::Pointer oldEdgeGeom = std::dynamic_pointer_cast(oldGeom); EdgeGeom::Pointer newEdgeGeom = std::dynamic_pointer_cast(newGeom); - Int64ArrayType::Pointer oldEdges = oldEdgeGeom->getEdges(); - Int64ArrayType::Pointer newEdges = newEdgeGeom->getEdges(); - checkDataArray(oldEdges, newEdges, false); + SharedEdgeList::Pointer oldEdges = oldEdgeGeom->getEdges(); + SharedEdgeList::Pointer newEdges = newEdgeGeom->getEdges(); + checkDataArray(oldEdges, newEdges, false); FloatArrayType::Pointer oldVertices = oldEdgeGeom->getVertices(); FloatArrayType::Pointer newVertices = newEdgeGeom->getVertices(); @@ -369,21 +352,21 @@ class CopyObjectTest TriangleGeom::Pointer oldTriangleGeom = std::dynamic_pointer_cast(oldGeom); TriangleGeom::Pointer newTriangleGeom = std::dynamic_pointer_cast(newGeom); - Int64ArrayType::Pointer oldTriangles = oldTriangleGeom->getTriangles(); - Int64ArrayType::Pointer newTriangles = newTriangleGeom->getTriangles(); - checkDataArray(oldTriangles, newTriangles, false); + SharedTriList::Pointer oldTriangles = oldTriangleGeom->getTriangles(); + SharedTriList::Pointer newTriangles = newTriangleGeom->getTriangles(); + checkDataArray(oldTriangles, newTriangles, false); FloatArrayType::Pointer oldVertices = oldTriangleGeom->getVertices(); FloatArrayType::Pointer newVertices = newTriangleGeom->getVertices(); checkDataArray(oldVertices, newVertices, false); - Int64ArrayType::Pointer oldEdges = oldTriangleGeom->getEdges(); - Int64ArrayType::Pointer newEdges = newTriangleGeom->getEdges(); - checkDataArray(oldEdges, newEdges, false); + SharedEdgeList::Pointer oldEdges = oldTriangleGeom->getEdges(); + SharedEdgeList::Pointer newEdges = newTriangleGeom->getEdges(); + checkDataArray(oldEdges, newEdges, false); - Int64ArrayType::Pointer oldUnsharedEdges = oldTriangleGeom->getUnsharedEdges(); - Int64ArrayType::Pointer newUnsharedEdges = newTriangleGeom->getUnsharedEdges(); - checkDataArray(oldUnsharedEdges, newUnsharedEdges, false); + SharedEdgeList::Pointer oldUnsharedEdges = oldTriangleGeom->getUnsharedEdges(); + SharedEdgeList::Pointer newUnsharedEdges = newTriangleGeom->getUnsharedEdges(); + checkDataArray(oldUnsharedEdges, newUnsharedEdges, false); ElementDynamicList::Pointer oldElementsContainingVert = oldTriangleGeom->getElementsContainingVert(); ElementDynamicList::Pointer newElementsContainingVert = newTriangleGeom->getElementsContainingVert(); @@ -402,21 +385,21 @@ class CopyObjectTest QuadGeom::Pointer oldQuadGeom = std::dynamic_pointer_cast(oldGeom); QuadGeom::Pointer newQuadGeom = std::dynamic_pointer_cast(newGeom); - Int64ArrayType::Pointer oldQuads = oldQuadGeom->getQuads(); - Int64ArrayType::Pointer newQuads = newQuadGeom->getQuads(); - checkDataArray(oldQuads, newQuads, false); + SharedQuadList::Pointer oldQuads = oldQuadGeom->getQuads(); + SharedQuadList::Pointer newQuads = newQuadGeom->getQuads(); + checkDataArray(oldQuads, newQuads, false); FloatArrayType::Pointer oldVertices = oldQuadGeom->getVertices(); FloatArrayType::Pointer newVertices = newQuadGeom->getVertices(); checkDataArray(oldVertices, newVertices, false); - Int64ArrayType::Pointer oldEdges = oldQuadGeom->getEdges(); - Int64ArrayType::Pointer newEdges = newQuadGeom->getEdges(); - checkDataArray(oldEdges, newEdges, false); + SharedEdgeList::Pointer oldEdges = oldQuadGeom->getEdges(); + SharedEdgeList::Pointer newEdges = newQuadGeom->getEdges(); + checkDataArray(oldEdges, newEdges, false); - Int64ArrayType::Pointer oldUnsharedEdges = oldQuadGeom->getUnsharedEdges(); - Int64ArrayType::Pointer newUnsharedEdges = newQuadGeom->getUnsharedEdges(); - checkDataArray(oldUnsharedEdges, newUnsharedEdges, false); + SharedEdgeList::Pointer oldUnsharedEdges = oldQuadGeom->getUnsharedEdges(); + SharedEdgeList::Pointer newUnsharedEdges = newQuadGeom->getUnsharedEdges(); + checkDataArray(oldUnsharedEdges, newUnsharedEdges, false); ElementDynamicList::Pointer oldElementsContainingVert = oldQuadGeom->getElementsContainingVert(); ElementDynamicList::Pointer newElementsContainingVert = newQuadGeom->getElementsContainingVert(); @@ -435,29 +418,29 @@ class CopyObjectTest TetrahedralGeom::Pointer oldTetrahedralGeom = std::dynamic_pointer_cast(oldGeom); TetrahedralGeom::Pointer newTetrahedralGeom = std::dynamic_pointer_cast(newGeom); - Int64ArrayType::Pointer oldTetrahedra = oldTetrahedralGeom->getTetrahedra(); - Int64ArrayType::Pointer newTetrahedra = newTetrahedralGeom->getTetrahedra(); - checkDataArray(oldTetrahedra, newTetrahedra, false); + SharedTetList::Pointer oldTetrahedra = oldTetrahedralGeom->getTetrahedra(); + SharedTetList::Pointer newTetrahedra = newTetrahedralGeom->getTetrahedra(); + checkDataArray(oldTetrahedra, newTetrahedra, false); FloatArrayType::Pointer oldVertices = oldTetrahedralGeom->getVertices(); FloatArrayType::Pointer newVertices = newTetrahedralGeom->getVertices(); checkDataArray(oldVertices, newVertices, false); - Int64ArrayType::Pointer oldEdges = oldTetrahedralGeom->getEdges(); - Int64ArrayType::Pointer newEdges = newTetrahedralGeom->getEdges(); - checkDataArray(oldEdges, newEdges, false); + SharedEdgeList::Pointer oldEdges = oldTetrahedralGeom->getEdges(); + SharedEdgeList::Pointer newEdges = newTetrahedralGeom->getEdges(); + checkDataArray(oldEdges, newEdges, false); - Int64ArrayType::Pointer oldUnsharedEdges = oldTetrahedralGeom->getUnsharedEdges(); - Int64ArrayType::Pointer newUnsharedEdges = newTetrahedralGeom->getUnsharedEdges(); - checkDataArray(oldUnsharedEdges, newUnsharedEdges, false); + SharedEdgeList::Pointer oldUnsharedEdges = oldTetrahedralGeom->getUnsharedEdges(); + SharedEdgeList::Pointer newUnsharedEdges = newTetrahedralGeom->getUnsharedEdges(); + checkDataArray(oldUnsharedEdges, newUnsharedEdges, false); - Int64ArrayType::Pointer oldTriangles = oldTetrahedralGeom->getTriangles(); - Int64ArrayType::Pointer newTriangles = newTetrahedralGeom->getTriangles(); - checkDataArray(oldTriangles, newTriangles, false); + SharedTriList::Pointer oldTriangles = oldTetrahedralGeom->getTriangles(); + SharedTriList::Pointer newTriangles = newTetrahedralGeom->getTriangles(); + checkDataArray(oldTriangles, newTriangles, false); - Int64ArrayType::Pointer oldUnsharedFaces = oldTetrahedralGeom->getUnsharedFaces(); - Int64ArrayType::Pointer newUnsharedFaces = newTetrahedralGeom->getUnsharedFaces(); - checkDataArray(oldUnsharedFaces, newUnsharedFaces, false); + SharedTriList::Pointer oldUnsharedFaces = oldTetrahedralGeom->getUnsharedFaces(); + SharedTriList::Pointer newUnsharedFaces = newTetrahedralGeom->getUnsharedFaces(); + checkDataArray(oldUnsharedFaces, newUnsharedFaces, false); ElementDynamicList::Pointer oldElementsContainingVert = oldTetrahedralGeom->getElementsContainingVert(); ElementDynamicList::Pointer newElementsContainingVert = newTetrahedralGeom->getElementsContainingVert(); @@ -476,29 +459,29 @@ class CopyObjectTest HexahedralGeom::Pointer oldHexahedralGeom = std::dynamic_pointer_cast(oldGeom); HexahedralGeom::Pointer newHexahedralGeom = std::dynamic_pointer_cast(newGeom); - Int64ArrayType::Pointer oldHexahedra = oldHexahedralGeom->getHexahedra(); - Int64ArrayType::Pointer newHexahedra = newHexahedralGeom->getHexahedra(); - checkDataArray(oldHexahedra, newHexahedra, false); + SharedHexList::Pointer oldHexahedra = oldHexahedralGeom->getHexahedra(); + SharedHexList::Pointer newHexahedra = newHexahedralGeom->getHexahedra(); + checkDataArray(oldHexahedra, newHexahedra, false); FloatArrayType::Pointer oldVertices = oldHexahedralGeom->getVertices(); FloatArrayType::Pointer newVertices = newHexahedralGeom->getVertices(); checkDataArray(oldVertices, newVertices, false); - Int64ArrayType::Pointer oldEdges = oldHexahedralGeom->getEdges(); - Int64ArrayType::Pointer newEdges = newHexahedralGeom->getEdges(); - checkDataArray(oldEdges, newEdges, false); + SharedEdgeList::Pointer oldEdges = oldHexahedralGeom->getEdges(); + SharedEdgeList::Pointer newEdges = newHexahedralGeom->getEdges(); + checkDataArray(oldEdges, newEdges, false); - Int64ArrayType::Pointer oldUnsharedEdges = oldHexahedralGeom->getUnsharedEdges(); - Int64ArrayType::Pointer newUnsharedEdges = newHexahedralGeom->getUnsharedEdges(); - checkDataArray(oldUnsharedEdges, newUnsharedEdges, false); + SharedEdgeList::Pointer oldUnsharedEdges = oldHexahedralGeom->getUnsharedEdges(); + SharedEdgeList::Pointer newUnsharedEdges = newHexahedralGeom->getUnsharedEdges(); + checkDataArray(oldUnsharedEdges, newUnsharedEdges, false); - Int64ArrayType::Pointer oldQuads = oldHexahedralGeom->getQuads(); - Int64ArrayType::Pointer newQuads = newHexahedralGeom->getQuads(); - checkDataArray(oldQuads, newQuads, false); + SharedQuadList::Pointer oldQuads = oldHexahedralGeom->getQuads(); + SharedQuadList::Pointer newQuads = newHexahedralGeom->getQuads(); + checkDataArray(oldQuads, newQuads, false); - Int64ArrayType::Pointer oldUnsharedFaces = oldHexahedralGeom->getUnsharedFaces(); - Int64ArrayType::Pointer newUnsharedFaces = newHexahedralGeom->getUnsharedFaces(); - checkDataArray(oldUnsharedFaces, newUnsharedFaces, false); + SharedQuadList::Pointer oldUnsharedFaces = oldHexahedralGeom->getUnsharedFaces(); + SharedQuadList::Pointer newUnsharedFaces = newHexahedralGeom->getUnsharedFaces(); + checkDataArray(oldUnsharedFaces, newUnsharedFaces, false); ElementDynamicList::Pointer oldElementsContainingVert = oldHexahedralGeom->getElementsContainingVert(); ElementDynamicList::Pointer newElementsContainingVert = newHexahedralGeom->getElementsContainingVert(); @@ -533,13 +516,13 @@ class CopyObjectTest bool sameArrayNames = (newMatrixNames == oldMatrixNames); DREAM3D_REQUIRE_EQUAL(sameArrayNames, true) - QMap oldAttrMatrices = oldDC->getAttributeMatrices(); - QMap newAttrMatrices = newDC->getAttributeMatrices(); + // DataContainer::Container_t oldAttrMatrices = oldDC->getAttributeMatrices(); + // DataContainer::Container_t newAttrMatrices = newDC->getAttributeMatrices(); for(int i = 0; i < newMatrixNames.size(); i++) { - AttributeMatrix::Pointer oldAM = oldAttrMatrices[oldMatrixNames[i]]; - AttributeMatrix::Pointer newAM = newAttrMatrices[newMatrixNames[i]]; + AttributeMatrix::Pointer oldAM = *oldDC->find(oldMatrixNames[i]); + AttributeMatrix::Pointer newAM = *newDC->find(newMatrixNames[i]); checkAttributeMatrix(oldAM, newAM, false); } } @@ -550,48 +533,40 @@ class CopyObjectTest void TestCase(DataContainerArray::Pointer dca, DataArrayPath dap, int objectToCopy, const QString& copyName) { // Create Filter + std::cout << " TestCase: " << dca->getName().toStdString() << " " << dap.serialize("/").toStdString() << " " << copyName.toStdString(); - FilterManager* fm = FilterManager::Instance(); - IFilterFactory::Pointer filterFactory = fm->getFactoryFromClassName(m_FilterName); - AbstractFilter::Pointer extractAttributeArraysFromGeometry = filterFactory->create(); - - extractAttributeArraysFromGeometry->setDataContainerArray(dca); + if(dca->getDataContainer(dap)->getGeometry().get() != nullptr) + { + std::cout << " " << dca->getDataContainer(dap)->getGeometry()->getName().toStdString(); + } + std::cout << std::endl; - // Setup Filter + CopyObject::Pointer copyObject = CopyObject::New(); - QVariant var; + copyObject->setDataContainerArray(dca); - var.setValue(objectToCopy); - bool propWasSet = extractAttributeArraysFromGeometry->setProperty("ObjectToCopy", var); - DREAM3D_REQUIRE_EQUAL(propWasSet, true) + // Setup Filter + copyObject->setObjectToCopy(objectToCopy); - var.setValue(copyName); - propWasSet = extractAttributeArraysFromGeometry->setProperty("CopiedObjectName", var); - DREAM3D_REQUIRE_EQUAL(propWasSet, true) + copyObject->setCopiedObjectName(copyName); if(objectToCopy == 0) // DataContainer { - var.setValue(dap.getDataContainerName()); - propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerToCopy", var); - DREAM3D_REQUIRE_EQUAL(propWasSet, true) + copyObject->setDataContainerToCopy(dap); } else if(objectToCopy == 1) // AttributeMatrix { - var.setValue(dap); - propWasSet = extractAttributeArraysFromGeometry->setProperty("AttributeMatrixToCopy", var); - DREAM3D_REQUIRE_EQUAL(propWasSet, true) + copyObject->setAttributeMatrixToCopy(dap); } else if(objectToCopy == 2) // DataArray { - var.setValue(dap); - propWasSet = extractAttributeArraysFromGeometry->setProperty("AttributeArrayToCopy", var); - DREAM3D_REQUIRE_EQUAL(propWasSet, true) + copyObject->setAttributeArrayToCopy(dap); } // Run Filter - extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + copyObject->execute(); + DREAM3D_REQUIRED(copyObject->getErrorCode(), >=, 0); // Check Filter Results @@ -726,21 +701,21 @@ class CopyObjectTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); DataContainer::Pointer emptyDC = DataContainer::New(k_EmptyDataContainerName); - dca->addDataContainer(emptyDC); + dca->addOrReplaceDataContainer(emptyDC); // Create AttributeMatrix AttributeMatrix::Pointer am1 = AttributeMatrix::New(m_Dims8, k_AttributeMatrix1Name, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(k_AttributeMatrix1Name, am1); + dc->addOrReplaceAttributeMatrix(am1); AttributeMatrix::Pointer am2 = AttributeMatrix::New(m_Dims8, k_AttributeMatrix2Name, AttributeMatrix::Type::Cell); - dc->addAttributeMatrix(k_AttributeMatrix2Name, am2); + dc->addOrReplaceAttributeMatrix(am2); AttributeMatrix::Pointer emptyAM = AttributeMatrix::New(m_Dims1, k_EmptyAttributeMatrixName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_EmptyAttributeMatrixName, emptyAM); + dc->addOrReplaceAttributeMatrix(emptyAM); // Create DataArray @@ -760,9 +735,10 @@ class CopyObjectTest // Image ImageGeom::Pointer imageGeom = ImageGeom::CreateGeometry(SIMPL::Geometry::ImageGeometry); - imageGeom->setDimensions(std::forward_as_tuple(5, 5, 5)); - imageGeom->setResolution(std::forward_as_tuple(5, 5, 5)); - imageGeom->setOrigin(std::forward_as_tuple(5, 5, 5)); + imageGeom->setDimensions(SizeVec3Type(5, 5, 5)); + imageGeom->setSpacing(FloatVec3Type(5, 5, 5)); + imageGeom->setOrigin(FloatVec3Type(5, 5, 5)); + imageGeom->setName("Image Geom"); // RectGrid @@ -774,6 +750,7 @@ class CopyObjectTest rectGridGeom->setXBounds(daXBounds); rectGridGeom->setYBounds(daYBounds); rectGridGeom->setZBounds(daZBounds); + rectGridGeom->setName("rectGridGeom"); // Vertex @@ -782,14 +759,15 @@ class CopyObjectTest DataArray::Pointer daVert = createDataArray(k_VerticesDAName, vertices, m_Dims2, m_Dims3); VertexGeom::Pointer vertexGeom = VertexGeom::CreateGeometry(daVert, SIMPL::Geometry::VertexGeometry); + vertexGeom->setName("vertexGeom"); // Edge vertices = {{1.0f, 1.0f, 0.0f}, {3.0f, 1.0f, 0.0f}}; - std::vector> elements = {{0, 1}}; + std::vector> elements = {{0, 1}}; DataArray::Pointer daEdgeVert = createDataArray(k_VerticesDAName, vertices, m_Dims2, m_Dims3); - DataArray::Pointer daEdgeList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims2); + SharedEdgeList::Pointer daEdgeList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims2); EdgeGeom::Pointer edgeGeom = EdgeGeom::CreateGeometry(daEdgeList, daEdgeVert, SIMPL::Geometry::EdgeGeometry); @@ -799,9 +777,10 @@ class CopyObjectTest elements = {{0, 1, 2}}; DataArray::Pointer daTriVert = createDataArray(k_VerticesDAName, vertices, m_Dims3, m_Dims3); - DataArray::Pointer daTriList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims3); + SharedTriList::Pointer daTriList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims3); TriangleGeom::Pointer triGeom = TriangleGeom::CreateGeometry(daTriList, daTriVert, SIMPL::Geometry::TriangleGeometry); + triGeom->setName("triGeom"); // Quad @@ -809,9 +788,10 @@ class CopyObjectTest elements = {{0, 1, 2, 3}}; DataArray::Pointer daQuadVert = createDataArray(k_VerticesDAName, vertices, m_Dims4, m_Dims3); - DataArray::Pointer daQuadList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims4); + SharedQuadList::Pointer daQuadList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims4); QuadGeom::Pointer quadGeom = QuadGeom::CreateGeometry(daQuadList, daQuadVert, SIMPL::Geometry::QuadGeometry); + quadGeom->setName("quadGeom"); // Tetrahedral @@ -820,9 +800,10 @@ class CopyObjectTest elements = {{0, 1, 2, 3}}; DataArray::Pointer daTetVert = createDataArray(k_VerticesDAName, vertices, m_Dims4, m_Dims3); - DataArray::Pointer daTetList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims4); + SharedTetList::Pointer daTetList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims4); TetrahedralGeom::Pointer tetGeom = TetrahedralGeom::CreateGeometry(daTetList, daTetVert, SIMPL::Geometry::TetrahedralGeometry); + tetGeom->setName("tetGeom"); // Hexahedral @@ -831,23 +812,24 @@ class CopyObjectTest elements = {{0, 1, 2, 3, 4, 5, 6, 7}}; DataArray::Pointer daHexVert = createDataArray(k_VerticesDAName, vertices, m_Dims8, m_Dims3); - DataArray::Pointer daHexList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims8); + SharedHexList::Pointer daHexList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims8); HexahedralGeom::Pointer hexGeom = HexahedralGeom::CreateGeometry(daHexList, daHexVert, SIMPL::Geometry::HexahedralGeometry); + hexGeom->setName("hexGeom"); // Add DataArrays to AttributeMatrices - am1->addAttributeArray(k_uint8ArrayName, daUint8); - am1->addAttributeArray(k_int8ArrayName, daInt8); - am1->addAttributeArray(k_uint16ArrayName, daUint16); - am1->addAttributeArray(k_int16ArrayName, daInt16); - am1->addAttributeArray(k_uint32ArrayName, daUint32); + am1->insertOrAssign(daUint8); + am1->insertOrAssign(daInt8); + am1->insertOrAssign(daUint16); + am1->insertOrAssign(daInt16); + am1->insertOrAssign(daUint32); - am2->addAttributeArray(k_int32ArrayName, daInt32); - am2->addAttributeArray(k_uint64ArrayName, daUint64); - am2->addAttributeArray(k_int64ArrayName, daInt64); - am2->addAttributeArray(k_floatArrayName, daFloat); - am2->addAttributeArray(k_doubleArrayName, daDouble); + am2->insertOrAssign(daInt32); + am2->insertOrAssign(daUint64); + am2->insertOrAssign(daInt64); + am2->insertOrAssign(daFloat); + am2->insertOrAssign(daDouble); dc->setGeometry(hexGeom); @@ -887,19 +869,18 @@ class CopyObjectTest hexGeom->findUnsharedEdges(); hexGeom->findUnsharedFaces(); emptyDC->setGeometry(hexGeom); + TestCase(dca, DataArrayPath(k_EmptyDataContainerName), 0, k_CopiedObjectName); // Test Copy AttributeMatrices - TestCase(dca, DataArrayPath(k_DataContainerName, k_AttributeMatrix1Name, ""), 1, k_CopiedObjectName); TestCase(dca, DataArrayPath(k_DataContainerName, k_AttributeMatrix2Name, ""), 1, k_CopiedObjectName); - emptyDC->addAttributeMatrix(k_EmptyAttributeMatrixName, emptyAM); + emptyDC->addOrReplaceAttributeMatrix(emptyAM); TestCase(dca, DataArrayPath(k_EmptyDataContainerName, k_EmptyAttributeMatrixName, ""), 1, k_CopiedObjectName); // Test Copy DataArrays - TestCase(dca, DataArrayPath(k_DataContainerName, k_AttributeMatrix1Name, k_uint8ArrayName), 2, k_CopiedObjectName); TestCase(dca, DataArrayPath(k_DataContainerName, k_AttributeMatrix1Name, k_int8ArrayName), 2, k_CopiedObjectName); @@ -922,24 +903,47 @@ class CopyObjectTest } // ----------------------------------------------------------------------------- - // + void TestHexahedralGeometry() + { + static const QString k_VerticesDAName("VertexCoordinates"); + static const QString k_ElementListDAName("Connectivity"); + + std::vector> vertices = {{1.0f, 1.0f, 1.55f}, {3.0f, 1.0f, 1.55f}, {2.0f, 3.0f, 1.55f}, {2.0f, 2.0f, 3.55f}, + {2.5f, 1.0f, 1.55f}, {4.3f, 1.0f, 1.55f}, {5.1f, 3.0f, 1.55f}, {7.63f, 2.0f, 3.55f}}; + + std::vector> elements = {{0, 1, 2, 3, 4, 5, 6, 7}}; + + DataArray::Pointer daHexVert = createDataArray(k_VerticesDAName, vertices, m_Dims8, m_Dims3); + SharedHexList::Pointer daHexList = createDataArray(k_ElementListDAName, elements, m_Dims1, m_Dims8); + + HexahedralGeom::Pointer hexGeom = HexahedralGeom::CreateGeometry(daHexList, daHexVert, SIMPL::Geometry::HexahedralGeometry); + hexGeom->setName("hexGeom"); + + hexGeom->findEdges(); + hexGeom->findElementCentroids(); + hexGeom->findElementNeighbors(); + hexGeom->findElementsContainingVert(); + hexGeom->findElementSizes(); + hexGeom->findFaces(); + hexGeom->findUnsharedEdges(); + hexGeom->findUnsharedFaces(); + } + // ----------------------------------------------------------------------------- void operator()() { int err = EXIT_SUCCESS; std::cout << "#### CopyObjectTest Starting ####" << std::endl; - - DREAM3D_REGISTER_TEST(TestFilterAvailability()); + DREAM3D_REGISTER_TEST(TestHexahedralGeometry()) DREAM3D_REGISTER_TEST(TestCopyObjectTest()) } private: - QString m_FilterName = QString("CopyObject"); - QVector m_Dims1 = {1}; - QVector m_Dims2 = {2}; - QVector m_Dims3 = {3}; - QVector m_Dims4 = {4}; - QVector m_Dims8 = {8}; + std::vector m_Dims1 = {1}; + std::vector m_Dims2 = {2}; + std::vector m_Dims3 = {3}; + std::vector m_Dims4 = {4}; + std::vector m_Dims8 = {8}; }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateAttributeMatrixTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateAttributeMatrixTest.cpp index 2b2d81403a..61ec354888 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateAttributeMatrixTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateAttributeMatrixTest.cpp @@ -1,44 +1,41 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/CoreFilters/CreateAttributeMatrix.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" @@ -46,10 +43,9 @@ #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" - -#include "SIMPLib/CoreFilters/CreateAttributeMatrix.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -67,7 +63,7 @@ class CreateAttributeMatrixTest DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); return dca; } @@ -166,7 +162,7 @@ class CreateAttributeMatrixTest setValues(filter, "DataContainer", amName, tableDims, type); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0) TestMatrixTupleDims(filter, tableDims, amName); } @@ -305,7 +301,7 @@ class CreateAttributeMatrixTest setValues(filter, "DataContainer2", "AttributeMatrix", tableDims, AttributeMatrix::Type::Any); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -999); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -999); } // ----------------------------------------------------------------------------- @@ -320,11 +316,11 @@ class CreateAttributeMatrixTest setValues(filter, "DataContainer", "AttributeMatrix", tableDims, AttributeMatrix::Type::Any); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); TestMatrixTupleDims(filter, tableDims, "AttributeMatrix"); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -10014); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -10014); } // ----------------------------------------------------------------------------- @@ -346,16 +342,27 @@ class CreateAttributeMatrixTest setValues(filter, "DataContainer", "AttributeMatrix", tableDims, AttributeMatrix::Type::Any); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11000); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11000); tableDims.clear(); tableDims.resize(0); setValues(filter, "DataContainer", "AttributeMatrix", tableDims, AttributeMatrix::Type::Any); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11000); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11000); } + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void TestOperators() + { + std::vector tDims = {10, 10}; + AttributeMatrix::Pointer am = AttributeMatrix::New(tDims, "Test", AttributeMatrix::Type::Cell); + + FloatArrayType::Pointer floatArray = FloatArrayType::CreateArray(100, std::string("Float"), true); + Int32ArrayType::Pointer int32Array = Int32ArrayType::CreateArray(100, std::string("Int32"), true); + } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -364,6 +371,7 @@ class CreateAttributeMatrixTest std::cout << "#### CreateAttributeMatrixTest Starting ####" << std::endl; int err = EXIT_SUCCESS; + DREAM3D_REGISTER_TEST(TestOperators()); DREAM3D_REGISTER_TEST(TestVertexMatrix()); DREAM3D_REGISTER_TEST(TestVertexFeatureMatrix()); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataArrayTest.cpp index 3531a9b6db..55d7848135 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataArrayTest.cpp @@ -1,53 +1,51 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + #include "SIMPLib/CoreFilters/CreateDataArray.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/CoreFilters/CreateAttributeMatrix.h" +#include "SIMPLib/CoreFilters/CreateDataContainer.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" - #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -58,48 +56,8 @@ class CreateDataArrayTest virtual ~CreateDataArrayTest() = default; static const int k_NoError = 0; static const int k_Int8Error = -4050; - - - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - int TestFilterAvailability() - { - // Now instantiate the CreateDataArray Filter from the FilterManager - QString filtName = "CreateDataArray"; - FilterManager* fm = FilterManager::Instance(); - IFilterFactory::Pointer filterFactory = fm->getFactoryFromClassName(filtName); - if(nullptr == filterFactory.get()) - { - std::stringstream ss; - ss << "The CreateDataArrayTest Requires the use of the " << filtName.toStdString() << " filter which is found in the IO Plugin"; - DREAM3D_TEST_THROW_EXCEPTION(ss.str()) - } - - // Now instantiate the CreateDataContainer Filter from the FilterManager - filtName = "CreateDataContainer"; - filterFactory = fm->getFactoryFromClassName(filtName); - if(nullptr == filterFactory.get()) - { - std::stringstream ss; - ss << "The CreateDataArrayTest Requires the use of the " << filtName.toStdString() << " filter which is found in the IO Plugin"; - DREAM3D_TEST_THROW_EXCEPTION(ss.str()) - } - - // Now instantiate the CreateDataContainer Filter from the FilterManager - filtName = "CreateAttributeMatrix"; - fm = FilterManager::Instance(); - filterFactory = fm->getFactoryFromClassName(filtName); - if(nullptr == filterFactory.get()) - { - std::stringstream ss; - ss << "The CreateDataArrayTest Requires the use of the " << filtName.toStdString() << " filter which is found in the IO Plugin"; - DREAM3D_TEST_THROW_EXCEPTION(ss.str()) - } - - return EXIT_SUCCESS; - } + const size_t k_NumTuples = 5; + const size_t k_NumComponents = 3; // ----------------------------------------------------------------------------- // @@ -108,55 +66,27 @@ class CreateDataArrayTest { int err = 0; - bool propWasSet = false; // bool ok = false; QVariant var; DataContainerArray::Pointer dca = DataContainerArray::New(); - - // Now instantiate the CreateDataArray Filter from the FilterManager - FilterManager* fm = FilterManager::Instance(); - - QString filtName = "CreateDataContainer"; - IFilterFactory::Pointer filterFactory = fm->getFactoryFromClassName(filtName); - if(nullptr != filterFactory.get()) { - // If we get this far, the Factory is good so creating the filter should not fail unless something has - // horribly gone wrong in which case the system is going to come down quickly after this. - AbstractFilter::Pointer filter = filterFactory->create(); - + CreateDataContainer::Pointer filter = CreateDataContainer::New(); + filter->setDataContainerName({"Test Data Container", "", ""}); filter->setDataContainerArray(dca); - // Test 1 set int32 array with an initialization of -5 and read value for comparison - var.setValue(QString::fromLatin1("Test Data Container")); - propWasSet = filter->setProperty("CreatedDataContainer", var); - DREAM3D_REQUIRE_EQUAL(propWasSet, true) - filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) } - - filtName = "CreateAttributeMatrix"; - filterFactory = fm->getFactoryFromClassName(filtName); - if(nullptr != filterFactory.get()) { - // If we get this far, the Factory is good so creating the filter should not fail unless something has - // horribly gone wrong in which case the system is going to come down quickly after this. - AbstractFilter::Pointer filter = filterFactory->create(); + CreateAttributeMatrix::Pointer filter = CreateAttributeMatrix::New(); filter->setDataContainerArray(dca); - - var.setValue(QString::fromLatin1("Test Data Container")); - propWasSet = filter->setProperty("CreatedDataContainer", var); - DREAM3D_REQUIRE_EQUAL(propWasSet, true) - - var.setValue(QString::fromLatin1("Cell Attribute Matrix")); - propWasSet = filter->setProperty("CreatedAttributeMatrix", var); - DREAM3D_REQUIRE_EQUAL(propWasSet, true) + filter->setCreatedAttributeMatrix({"Test Data Container", "Cell Attribute Matrix", ""}); filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) } @@ -170,174 +100,533 @@ class CreateDataArrayTest { DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - dca->addDataContainer(m); - AttributeMatrix::Pointer attrMatrix = AttributeMatrix::New(QVector(1, 1), SIMPL::Defaults::AttributeMatrixName, AttributeMatrix::Type::Generic); - m->addAttributeMatrix(SIMPL::Defaults::AttributeMatrixName, attrMatrix); + dca->addOrReplaceDataContainer(m); + AttributeMatrix::Pointer attrMatrix = AttributeMatrix::New({k_NumTuples}, SIMPL::Defaults::AttributeMatrixName, AttributeMatrix::Type::Generic); + m->addOrReplaceAttributeMatrix(attrMatrix); return dca; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void TestScalarType(AbstractFilter::Pointer filter, SIMPL::ScalarTypes::Type scalarType) + template + void TestBasicParsing(SIMPL::ScalarTypes::Type scalarType) { + CreateDataArray::Pointer filter = CreateDataArray::New(); + int32_t err = 0; + DataContainerArray::Pointer dca = DataContainerArray::NullPointer(); QString dsName = QString("TestArray-%1").arg(static_cast(scalarType)); + std::cout << " Testing Basic Parsing" << dsName.toStdString() << std::endl; DataArrayPath path = DataArrayPath(SIMPL::Defaults::DataContainerName, SIMPL::Defaults::AttributeMatrixName, dsName); - DataContainerArray::Pointer dca = CreateDataContainerArray(); + filter->setScalarType(scalarType); + filter->setNewArray(path); + filter->setInitializationType(0); + filter->setNumberOfComponents(k_NumComponents); + + // test multiple components with multiple init values + dca = CreateDataContainerArray(); filter->setDataContainerArray(dca); + filter->setNumberOfComponents(k_NumComponents); + filter->setInitializationValue("2;3;4"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0); - QVariant var; - int err = 0; - bool propWasSet = false; + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("2;4"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, -5548); - var.setValue(scalarType); - propWasSet = filter->setProperty("ScalarType", var); // - DREAM3D_REQUIRE_EQUAL(propWasSet, true) + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("2;3;hfi4"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, -5400); - var.setValue(1); - propWasSet = filter->setProperty("NumberOfComponents", var); // 1 component - DREAM3D_REQUIRE_EQUAL(propWasSet, true) + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("2;3;hfi4"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, -5400); + } + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + template + void TestUnsignedIntegers(SIMPL::ScalarTypes::Type scalarType) + { + CreateDataArray::Pointer filter = CreateDataArray::New(); + int32_t err = 0; + using DataArrayType = DataArray; + DataContainerArray::Pointer dca = DataContainerArray::NullPointer(); - var.setValue(path); - propWasSet = filter->setProperty("NewArray", var); // array path - DREAM3D_REQUIRE_EQUAL(propWasSet, true) + QString dsName = QString("TestArray-%1").arg(static_cast(scalarType)); + std::cout << " Testing Unsigned Integer" << dsName.toStdString() << std::endl; + DataArrayPath path = DataArrayPath(SIMPL::Defaults::DataContainerName, SIMPL::Defaults::AttributeMatrixName, dsName); + + filter->setScalarType(scalarType); + filter->setNewArray(path); + filter->setInitializationType(0); + filter->setNumberOfComponents(k_NumComponents); + + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("65.333;78.666;88.432347"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, -5400); - /* ==== Test The Maximum Value for the primitive type ===== */ - T max = std::numeric_limits::max(); - var.setValue(QString::number(max)); - propWasSet = filter->setProperty("InitializationValue", var); // initialize with - DREAM3D_REQUIRE_EQUAL(propWasSet, true); + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("-65;78;88"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, -5400); + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("65;78;88"); filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0); + + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->execute(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); + // Now verify the data was correctly written to the data array + std::vector exemplar = {static_cast(65), static_cast(78), static_cast(88)}; + typename DataArrayType::Pointer output = dca->getPrereqArrayFromPath(nullptr, path, {3}); + size_t outNumTuples = output->getNumberOfTuples(); + for(size_t t = 0; t < outNumTuples; t++) + { + T* tPtr = output->getTuplePointer(t); + int32_t cmp = std::memcmp(tPtr, exemplar.data(), sizeof(T) * k_NumComponents); + if(cmp != 0) + { + std::cout << "##################################################################################################" << std::endl; + std::cout << "CreateDataArrayTest Failure:(" << __LINE__ << ")" << std::endl; + std::cout << output->getInfoString(SIMPL::MarkDown).toStdString() << std::endl; + QString str; + QTextStream out(&str); + output->printTuple(out, t); + std::cout << "Data: " << str.toStdString() << std::endl; + std::cout << "Exemplar:" << exemplar[0] << ", " << exemplar[1] << ", " << exemplar[2] << std::endl; + std::cout << "##################################################################################################" << std::endl; + } + DREAM3D_REQUIRE_EQUAL(cmp, 0) + } + + //------------------------------------------------------------------------- + // Now try with muliple components but a single value in the string + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("-65"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, -5400); + + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("65"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0); + + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->execute(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, k_NoError); + + // Now verify the data was correctly written to the data array + exemplar = {static_cast(65), static_cast(65), static_cast(65)}; + output = dca->getPrereqArrayFromPath(nullptr, path, {3}); + outNumTuples = output->getNumberOfTuples(); + for(size_t t = 0; t < outNumTuples; t++) + { + T* tPtr = output->getTuplePointer(t); + int32_t cmp = std::memcmp(tPtr, exemplar.data(), sizeof(T) * k_NumComponents); + if(cmp != 0) + { + std::cout << "##################################################################################################" << std::endl; + std::cout << "CreateDataArrayTest Failure:(" << __LINE__ << ")" << std::endl; + std::cout << output->getInfoString(SIMPL::MarkDown).toStdString() << std::endl; + QString str; + QTextStream out(&str); + output->printTuple(out, t); + std::cout << "Data: " << str.toStdString() << std::endl; + std::cout << "Exemplar:" << exemplar[0] << ", " << exemplar[1] << ", " << exemplar[2] << std::endl; + std::cout << "##################################################################################################" << std::endl; + } + DREAM3D_REQUIRE_EQUAL(cmp, 0) + } + + //------------------------------------------------------------------------- + // Now try with muliple components but a single value in the string + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("-65"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, -5400); + + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("65"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0); + dca = CreateDataContainerArray(); filter->setDataContainerArray(dca); filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); + // Now verify the data was correctly written to the data array + exemplar = {static_cast(65), static_cast(65), static_cast(65)}; + output = dca->getPrereqArrayFromPath(nullptr, path, {3}); + outNumTuples = output->getNumberOfTuples(); + for(size_t t = 0; t < outNumTuples; t++) { - IDataArray::Pointer testArrayPtr = dca->getDataContainer(SIMPL::Defaults::DataContainerName)->getAttributeMatrix(path.getAttributeMatrixName())->getAttributeArray(path.getDataArrayName()); - typedef DataArray DataArrayType; - typename DataArrayType::Pointer inputArray = std::dynamic_pointer_cast(testArrayPtr); - DREAM3D_REQUIRE_VALID_POINTER(inputArray.get()); - T* inputArrayPtr = inputArray->getPointer(0); // pointer to the int array created from the filter - DREAM3D_REQUIRE_EQUAL(inputArrayPtr[0], max) + T* tPtr = output->getTuplePointer(t); + int32_t cmp = std::memcmp(tPtr, exemplar.data(), sizeof(T) * k_NumComponents); + if(cmp != 0) + { + std::cout << "##################################################################################################" << std::endl; + std::cout << "CreateDataArrayTest Failure:(" << __LINE__ << ")" << std::endl; + std::cout << output->getInfoString(SIMPL::MarkDown).toStdString() << std::endl; + QString str; + QTextStream out(&str); + output->printTuple(out, t); + std::cout << "Data: " << str.toStdString() << std::endl; + std::cout << "Exemplar:" << exemplar[0] << ", " << exemplar[1] << ", " << exemplar[2] << std::endl; + std::cout << "##################################################################################################" << std::endl; + } + DREAM3D_REQUIRE_EQUAL(cmp, 0) } + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + template + void TestSignedIntegers(SIMPL::ScalarTypes::Type scalarType) + { + CreateDataArray::Pointer filter = CreateDataArray::New(); + int32_t err = 0; + using DataArrayType = DataArray; + DataContainerArray::Pointer dca = DataContainerArray::NullPointer(); + + QString dsName = QString("TestArray-%1").arg(static_cast(scalarType)); + std::cout << " Testing Signed Integer" << dsName.toStdString() << std::endl; + DataArrayPath path = DataArrayPath(SIMPL::Defaults::DataContainerName, SIMPL::Defaults::AttributeMatrixName, dsName); + + filter->setScalarType(scalarType); + filter->setNewArray(path); + filter->setInitializationType(0); + filter->setNumberOfComponents(k_NumComponents); + + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("65.333;78.666;88.432347"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, -5400); + + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("-65;78;88"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0); dca = CreateDataContainerArray(); filter->setDataContainerArray(dca); + filter->execute(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, k_NoError); - /* ==== Test The Minmum Value for the primitive type ===== */ - T min = std::numeric_limits::min(); - var.setValue(QString::number(min)); - propWasSet = filter->setProperty("InitializationValue", var); // initialize with - DREAM3D_REQUIRE_EQUAL(propWasSet, true) + // Now verify the data was correctly written to the data array + std::vector exemplar = {static_cast(-65), static_cast(78), static_cast(88)}; + typename DataArrayType::Pointer output = dca->getPrereqArrayFromPath(nullptr, path, {3}); + size_t outNumTuples = output->getNumberOfTuples(); + for(size_t t = 0; t < outNumTuples; t++) + { + T* tPtr = output->getTuplePointer(t); + int32_t cmp = std::memcmp(tPtr, exemplar.data(), sizeof(T) * k_NumComponents); + if(cmp != 0) + { + std::cout << "##################################################################################################" << std::endl; + std::cout << "CreateDataArrayTest Failure:(" << __LINE__ << ")" << std::endl; + std::cout << output->getInfoString(SIMPL::MarkDown).toStdString() << std::endl; + QString str; + QTextStream out(&str); + output->printTuple(out, t); + std::cout << "Data: " << str.toStdString() << std::endl; + std::cout << "Exemplar:" << exemplar[0] << ", " << exemplar[1] << ", " << exemplar[2] << std::endl; + std::cout << "##################################################################################################" << std::endl; + } + DREAM3D_REQUIRE_EQUAL(cmp, 0) + } + //------------------------------------------------------------------------- + // Now try with muliple components but a single value in the string + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("-65"); filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0); + + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->execute(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); + // Now verify the data was correctly written to the data array + exemplar = {static_cast(-65), static_cast(-65), static_cast(-65)}; + output = dca->getPrereqArrayFromPath(nullptr, path, {3}); + outNumTuples = output->getNumberOfTuples(); + for(size_t t = 0; t < outNumTuples; t++) + { + T* tPtr = output->getTuplePointer(t); + int32_t cmp = std::memcmp(tPtr, exemplar.data(), sizeof(T) * k_NumComponents); + if(cmp != 0) + { + std::cout << "##################################################################################################" << std::endl; + std::cout << "CreateDataArrayTest Failure:(" << __LINE__ << ")" << std::endl; + std::cout << output->getInfoString(SIMPL::MarkDown).toStdString() << std::endl; + QString str; + QTextStream out(&str); + output->printTuple(out, t); + std::cout << "Data: " << str.toStdString() << std::endl; + std::cout << "Exemplar:" << exemplar[0] << ", " << exemplar[1] << ", " << exemplar[2] << std::endl; + std::cout << "##################################################################################################" << std::endl; + } + DREAM3D_REQUIRE_EQUAL(cmp, 0) + } + + //------------------------------------------------------------------------- + // Now try with muliple components but a single value in the string dca = CreateDataContainerArray(); filter->setDataContainerArray(dca); + filter->setInitializationValue("65"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0); + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); + // Now verify the data was correctly written to the data array + exemplar = {static_cast(65), static_cast(65), static_cast(65)}; + output = dca->getPrereqArrayFromPath(nullptr, path, {3}); + outNumTuples = output->getNumberOfTuples(); + for(size_t t = 0; t < outNumTuples; t++) { - IDataArray::Pointer testArrayPtr = dca->getDataContainer(SIMPL::Defaults::DataContainerName)->getAttributeMatrix(path.getAttributeMatrixName())->getAttributeArray(path.getDataArrayName()); - typedef DataArray DataArrayType; - typename DataArrayType::Pointer inputArray = std::dynamic_pointer_cast(testArrayPtr); - DREAM3D_REQUIRE_VALID_POINTER(inputArray.get()); - T* inputArrayPtr = inputArray->getPointer(0); // pointer to the int array created from the filter - DREAM3D_REQUIRE_EQUAL(inputArrayPtr[0], min) + T* tPtr = output->getTuplePointer(t); + int32_t cmp = std::memcmp(tPtr, exemplar.data(), sizeof(T) * k_NumComponents); + if(cmp != 0) + { + std::cout << "##################################################################################################" << std::endl; + std::cout << "CreateDataArrayTest Failure:(" << __LINE__ << ")" << std::endl; + std::cout << output->getInfoString(SIMPL::MarkDown).toStdString() << std::endl; + QString str; + QTextStream out(&str); + output->printTuple(out, t); + std::cout << "Data: " << str.toStdString() << std::endl; + std::cout << "Exemplar:" << exemplar[0] << ", " << exemplar[1] << ", " << exemplar[2] << std::endl; + std::cout << "##################################################################################################" << std::endl; + } + DREAM3D_REQUIRE_EQUAL(cmp, 0) } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - int TestCreateDataArray() + template + void TestReals(SIMPL::ScalarTypes::Type scalarType) { - // bool propWasSet = false; - // bool ok = false; - // int err = 0; - - // Now instantiate the CreateDataArray Filter from the FilterManager - QString filtName = "CreateDataArray"; - FilterManager* fm = FilterManager::Instance(); - IFilterFactory::Pointer filterFactory = fm->getFactoryFromClassName(filtName); - if(nullptr != filterFactory.get()) + CreateDataArray::Pointer filter = CreateDataArray::New(); + int32_t err = 0; + using DataArrayType = DataArray; + DataContainerArray::Pointer dca = DataContainerArray::NullPointer(); + + QString dsName = QString("TestArray-%1").arg(static_cast(scalarType)); + std::cout << " Testing Reals" << dsName.toStdString() << std::endl; + DataArrayPath path = DataArrayPath(SIMPL::Defaults::DataContainerName, SIMPL::Defaults::AttributeMatrixName, dsName); + + filter->setScalarType(scalarType); + filter->setNewArray(path); + filter->setInitializationType(0); + filter->setNumberOfComponents(k_NumComponents); + + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("65.333;78.666;88.432347"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0); + + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("65;78;88"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0); + + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->execute(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, k_NoError); + + // Now verify the data was correctly written to the data array + std::vector exemplar = {static_cast(65), static_cast(78), static_cast(88)}; + typename DataArrayType::Pointer output = dca->getPrereqArrayFromPath(nullptr, path, {3}); + size_t outNumTuples = output->getNumberOfTuples(); + for(size_t t = 0; t < outNumTuples; t++) { - // If we get this far, the Factory is good so creating the filter should not fail unless something has - // horribly gone wrong in which case the system is going to come down quickly after this. - AbstractFilter::Pointer filter = filterFactory->create(); - // DataArrayPath path1 = DataArrayPath(SIMPL::Defaults::DataContainerName, SIMPL::Defaults::AttributeMatrixName, "testArray"); - - TestScalarType(filter, SIMPL::ScalarTypes::Type::UInt64); - TestScalarType(filter, SIMPL::ScalarTypes::Type::Int8); - TestScalarType(filter, SIMPL::ScalarTypes::Type::UInt8); - TestScalarType(filter, SIMPL::ScalarTypes::Type::Int16); - TestScalarType(filter, SIMPL::ScalarTypes::Type::UInt16); - TestScalarType(filter, SIMPL::ScalarTypes::Type::Int32); - TestScalarType(filter, SIMPL::ScalarTypes::Type::UInt32); - TestScalarType(filter, SIMPL::ScalarTypes::Type::Int64); - -// TestScalarType(filter, 8); -// TestScalarType(filter, path1, 9); - -#if 0 - // Test 2 set a bool array with a non-zero value and compare to 1 - filter->setDataContainerArray(dca); - filter->getDataContainerArray()->getAttributeMatrix(path1)->removeAttributeArray(path1.getDataArrayName()); - QVariant var; - var.setValue(10); - propWasSet = filter->setProperty("ScalarType", var); // bool - DREAM3D_REQUIRE_EQUAL(propWasSet, true) - - double d = QString("0.000001").toDouble(&ok); - var.setValue(d); - propWasSet = filter->setProperty("InitializationValue", var); // initialize with d (9.9999999999999995e-007 Visual Studio) - DREAM3D_REQUIRE_EQUAL(propWasSet, true) - - filter->execute(); - err = filter->getErrorCondition(); - DREAM3D_REQUIRE_EQUAL(err, k_NoError); - - IDataArray::Pointer boolArray = m->getAttributeMatrix(path.getAttributeMatrixName())->getAttributeArray(path.getDataArrayName()); - DataArray::Pointer inputArrayBool = std::dynamic_pointer_cast>(boolArray); - bool* inputArrayPtrBool = inputArrayBool->getPointer(0); // pointer to the bool array created from the filter - if (*inputArrayPtrBool != 1) // check the initialization value from the bool array - { - DREAM3D_REQUIRE_EQUAL(0, 1) - } - - // Test 3 set int8 array with an initialization of 128 for out of range error - filter->setDataContainerArray(dca); - var.setValue(0); - propWasSet = filter->setProperty("ScalarType", var); // int8 - DREAM3D_REQUIRE_EQUAL(propWasSet, true) - - var.setValue(128); - propWasSet = filter->setProperty("InitializationValue", var); // initialize with 128 - DREAM3D_REQUIRE_EQUAL(propWasSet, true) - - filter->execute(); - err = filter->getErrorCondition(); - DREAM3D_REQUIRE_EQUAL(err, k_Int8Error); - -#endif + T* tPtr = output->getTuplePointer(t); + int32_t cmp = std::memcmp(tPtr, exemplar.data(), sizeof(T) * k_NumComponents); + if(cmp != 0) + { + std::cout << "##################################################################################################" << std::endl; + std::cout << "CreateDataArrayTest Failure:(" << __LINE__ << ")" << std::endl; + std::cout << output->getInfoString(SIMPL::MarkDown).toStdString() << std::endl; + QString str; + QTextStream out(&str); + output->printTuple(out, t); + std::cout << "Data: " << str.toStdString() << std::endl; + std::cout << "Exemplar:" << exemplar[0] << ", " << exemplar[1] << ", " << exemplar[2] << std::endl; + std::cout << "##################################################################################################" << std::endl; + } + DREAM3D_REQUIRE_EQUAL(cmp, 0) } - else + + //------------------------------------------------------------------------- + // Now try with muliple components but a single value in the string + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("65"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0); + + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->execute(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, k_NoError); + + // Now verify the data was correctly written to the data array + exemplar = {static_cast(65), static_cast(65), static_cast(65)}; + output = dca->getPrereqArrayFromPath(nullptr, path, {3}); + outNumTuples = output->getNumberOfTuples(); + for(size_t t = 0; t < outNumTuples; t++) { - QString ss = QObject::tr("CreateDataArrayTest Error creating filter '%1'. Filter was not created/executed. Please notify the developers.").arg(filtName); - DREAM3D_REQUIRE_EQUAL(0, 1) + T* tPtr = output->getTuplePointer(t); + int32_t cmp = std::memcmp(tPtr, exemplar.data(), sizeof(T) * k_NumComponents); + if(cmp != 0) + { + std::cout << "##################################################################################################" << std::endl; + std::cout << "CreateDataArrayTest Failure:(" << __LINE__ << ")" << std::endl; + std::cout << output->getInfoString(SIMPL::MarkDown).toStdString() << std::endl; + QString str; + QTextStream out(&str); + output->printTuple(out, t); + std::cout << "Data: " << str.toStdString() << std::endl; + std::cout << "Exemplar:" << exemplar[0] << ", " << exemplar[1] << ", " << exemplar[2] << std::endl; + std::cout << "##################################################################################################" << std::endl; + } + DREAM3D_REQUIRE_EQUAL(cmp, 0) } + + //------------------------------------------------------------------------- + // Now try with muliple components but a single value in the string + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setInitializationValue("65"); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0); + + dca = CreateDataContainerArray(); + filter->setDataContainerArray(dca); + filter->execute(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, k_NoError); + + // Now verify the data was correctly written to the data array + exemplar = {static_cast(65), static_cast(65), static_cast(65)}; + output = dca->getPrereqArrayFromPath(nullptr, path, {3}); + outNumTuples = output->getNumberOfTuples(); + for(size_t t = 0; t < outNumTuples; t++) + { + T* tPtr = output->getTuplePointer(t); + int32_t cmp = std::memcmp(tPtr, exemplar.data(), sizeof(T) * k_NumComponents); + if(cmp != 0) + { + std::cout << "##################################################################################################" << std::endl; + std::cout << "CreateDataArrayTest Failure:(" << __LINE__ << ")" << std::endl; + std::cout << output->getInfoString(SIMPL::MarkDown).toStdString() << std::endl; + QString str; + QTextStream out(&str); + output->printTuple(out, t); + std::cout << "Data: " << str.toStdString() << std::endl; + std::cout << "Exemplar:" << exemplar[0] << ", " << exemplar[1] << ", " << exemplar[2] << std::endl; + std::cout << "##################################################################################################" << std::endl; + } + DREAM3D_REQUIRE_EQUAL(cmp, 0) + } + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + int TestCreateDataArray() + { + TestBasicParsing(SIMPL::ScalarTypes::Type::Int8); + TestBasicParsing(SIMPL::ScalarTypes::Type::UInt8); + TestBasicParsing(SIMPL::ScalarTypes::Type::Int16); + TestBasicParsing(SIMPL::ScalarTypes::Type::UInt16); + TestBasicParsing(SIMPL::ScalarTypes::Type::Int32); + TestBasicParsing(SIMPL::ScalarTypes::Type::UInt32); + TestBasicParsing(SIMPL::ScalarTypes::Type::Int64); + TestBasicParsing(SIMPL::ScalarTypes::Type::UInt64); + TestBasicParsing(SIMPL::ScalarTypes::Type::Float); + TestBasicParsing(SIMPL::ScalarTypes::Type::Double); + + TestSignedIntegers(SIMPL::ScalarTypes::Type::Int8); + TestSignedIntegers(SIMPL::ScalarTypes::Type::Int16); + TestSignedIntegers(SIMPL::ScalarTypes::Type::Int32); + TestSignedIntegers(SIMPL::ScalarTypes::Type::Int64); + + TestUnsignedIntegers(SIMPL::ScalarTypes::Type::UInt8); + TestUnsignedIntegers(SIMPL::ScalarTypes::Type::UInt16); + TestUnsignedIntegers(SIMPL::ScalarTypes::Type::UInt32); + TestUnsignedIntegers(SIMPL::ScalarTypes::Type::UInt64); + + TestReals(SIMPL::ScalarTypes::Type::Float); + TestReals(SIMPL::ScalarTypes::Type::Double); + + // // TestIntegers(filter, SIMPL::ScalarTypes::Type::Bool); + // TestIntegers(SIMPL::ScalarTypes::Type::SizeT); return EXIT_SUCCESS; } @@ -350,8 +639,6 @@ class CreateDataArrayTest int err = EXIT_SUCCESS; - DREAM3D_REGISTER_TEST(TestFilterAvailability()); - DREAM3D_REGISTER_TEST(TestCreateDataArray()) } diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataContainerTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataContainerTest.cpp index ab06f24482..75792ad163 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataContainerTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateDataContainerTest.cpp @@ -1,58 +1,53 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" - +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/CoreFilters/CreateDataContainer.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/CreateDataContainer.h" - class CreateDataContainerTest { public: @@ -94,7 +89,7 @@ class CreateDataContainerTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void setValues(CreateDataContainer::Pointer filter, QString dataContainer) + void setValues(CreateDataContainer::Pointer filter, const DataArrayPath& dataContainer) { if(nullptr == filter.get()) { @@ -104,20 +99,21 @@ class CreateDataContainerTest QVariant value; value.setValue(dataContainer); - filter->setProperty("DataContainerName", value); + bool propWasSet = filter->setProperty("DataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void TestFilter(QString dataContainer, int errorCode) + void TestFilter(const DataArrayPath& dataContainer, int errorCode) { CreateDataContainer::Pointer filter = createFilter(); filter->setDataContainerArray(createDataContainerArray()); setValues(filter, dataContainer); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), errorCode) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), errorCode) } // ----------------------------------------------------------------------------- @@ -125,7 +121,7 @@ class CreateDataContainerTest // ----------------------------------------------------------------------------- void TestValidDataContainer() { - TestFilter("DataContainer", 0); + TestFilter(DataArrayPath("DataContainer", "", ""), 0); } // ----------------------------------------------------------------------------- @@ -133,17 +129,17 @@ class CreateDataContainerTest // ----------------------------------------------------------------------------- void TestExistingDataContainer() { - QString dataContainer = "DataContainer"; + DataArrayPath dataContainer("DataContainer", "", ""); CreateDataContainer::Pointer filter = createFilter(); filter->setDataContainerArray(createDataContainerArray()); setValues(filter, dataContainer); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0) filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -889) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -889) } // ----------------------------------------------------------------------------- @@ -151,7 +147,7 @@ class CreateDataContainerTest // ----------------------------------------------------------------------------- void TestMissingDataContainerName() { - TestFilter("", -887); + TestFilter(DataArrayPath(), -887); } // ----------------------------------------------------------------------------- @@ -159,7 +155,7 @@ class CreateDataContainerTest // ----------------------------------------------------------------------------- void TestInvalidName() { - TestFilter("Data/Container", -888); + TestFilter(DataArrayPath("Data/Container", "", ""), -888); } // ----------------------------------------------------------------------------- @@ -179,6 +175,6 @@ class CreateDataContainerTest } private: - CreateDataContainerTest(const CreateDataContainerTest&); // Copy Constructor Not Implemented - void operator=(const CreateDataContainerTest&); // Move assignment Not Implemented + CreateDataContainerTest(const CreateDataContainerTest&) = delete; // Copy Constructor Not Implemented + void operator=(const CreateDataContainerTest&) = delete; // Move assignment Not Implemented }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateFeatureArrayFromElementArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateFeatureArrayFromElementArrayTest.cpp index af528364ca..18643ecf52 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateFeatureArrayFromElementArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateFeatureArrayFromElementArrayTest.cpp @@ -1,51 +1,48 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -95,10 +92,10 @@ class CreateFeatureArrayFromElementArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - AttributeMatrix::Pointer cellAttr = AttributeMatrix::New(QVector(1, 16), "Cell Attribute Matrix", AttributeMatrix::Type::Cell); - AttributeMatrix::Pointer featureAttr = AttributeMatrix::New(QVector(1, 5), "Feature Attribute Matrix", AttributeMatrix::Type::Cell); + AttributeMatrix::Pointer cellAttr = AttributeMatrix::New(std::vector(1, 16), "Cell Attribute Matrix", AttributeMatrix::Type::Cell); + AttributeMatrix::Pointer featureAttr = AttributeMatrix::New(std::vector(1, 5), "Feature Attribute Matrix", AttributeMatrix::Type::Cell); - DataArray::Pointer featureIds = DataArray::CreateArray(16, "FeatureIds"); + DataArray::Pointer featureIds = DataArray::CreateArray(16, std::string("FeatureIds"), true); size_t numTuples = featureIds->getNumberOfTuples(); int32_t value = 1; featureIds->initializeTuple(0, &value); @@ -125,7 +122,7 @@ class CreateFeatureArrayFromElementArrayTest featureIds->initializeTuple(14, &value); featureIds->initializeTuple(15, &value); - DataArray::Pointer cellDataArray = DataArray::CreateArray(16, "CellData"); + DataArray::Pointer cellDataArray = DataArray::CreateArray(16, std::string("CellData"), true); numTuples = cellDataArray->getNumberOfTuples(); for(size_t i = 0; i < numTuples; i++) { @@ -133,11 +130,11 @@ class CreateFeatureArrayFromElementArrayTest cellDataArray->initializeTuple(i, &temp); } - cellAttr->addAttributeArray("CellData", cellDataArray); - cellAttr->addAttributeArray("FeatureIds", featureIds); - dc->addAttributeMatrix("Cell Attribute Matrix", cellAttr); - dc->addAttributeMatrix("Feature Attribute Matrix", featureAttr); - dca->addDataContainer(dc); + cellAttr->insertOrAssign(cellDataArray); + cellAttr->insertOrAssign(featureIds); + dc->addOrReplaceAttributeMatrix(cellAttr); + dc->addOrReplaceAttributeMatrix(featureAttr); + dca->addOrReplaceDataContainer(dc); DataArrayPath path = DataArrayPath(dc->getName(), cellAttr->getName(), cellDataArray->getName()); QVariant var; @@ -185,10 +182,10 @@ class CreateFeatureArrayFromElementArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - AttributeMatrix::Pointer cellAttr = AttributeMatrix::New(QVector(1, 16), "Cell Attribute Matrix", AttributeMatrix::Type::Cell); - AttributeMatrix::Pointer featureAttr = AttributeMatrix::New(QVector(1, 5), "Feature Attribute Matrix", AttributeMatrix::Type::Cell); + AttributeMatrix::Pointer cellAttr = AttributeMatrix::New(std::vector(1, 16), "Cell Attribute Matrix", AttributeMatrix::Type::Cell); + AttributeMatrix::Pointer featureAttr = AttributeMatrix::New(std::vector(1, 5), "Feature Attribute Matrix", AttributeMatrix::Type::Cell); - DataArray::Pointer featureIds = DataArray::CreateArray(16, "FeatureIds"); + DataArray::Pointer featureIds = DataArray::CreateArray(16, std::string("FeatureIds"), true); size_t numTuples = featureIds->getNumberOfTuples(); int32_t value = 1; featureIds->initializeTuple(0, &value); @@ -215,8 +212,8 @@ class CreateFeatureArrayFromElementArrayTest featureIds->initializeTuple(14, &value); featureIds->initializeTuple(15, &value); - QVector cDims = QVector(1, 3); - DataArray::Pointer cellDataArray = DataArray::CreateArray(16, cDims, "CellData"); + std::vector cDims = std::vector(1, 3); + DataArray::Pointer cellDataArray = DataArray::CreateArray(16, cDims, "CellData", true); numTuples = cellDataArray->getNumberOfTuples(); for(size_t i = 0; i < numTuples; i++) { @@ -224,11 +221,11 @@ class CreateFeatureArrayFromElementArrayTest cellDataArray->initializeTuple(i, &temp); } - cellAttr->addAttributeArray("CellData", cellDataArray); - cellAttr->addAttributeArray("FeatureIds", featureIds); - dc->addAttributeMatrix("Cell Attribute Matrix", cellAttr); - dc->addAttributeMatrix("Feature Attribute Matrix", featureAttr); - dca->addDataContainer(dc); + cellAttr->insertOrAssign(cellDataArray); + cellAttr->insertOrAssign(featureIds); + dc->addOrReplaceAttributeMatrix(cellAttr); + dc->addOrReplaceAttributeMatrix(featureAttr); + dca->addOrReplaceDataContainer(dc); DataArrayPath path = DataArrayPath(dc->getName(), cellAttr->getName(), cellDataArray->getName()); QVariant var; @@ -276,10 +273,10 @@ class CreateFeatureArrayFromElementArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - AttributeMatrix::Pointer cellAttr = AttributeMatrix::New(QVector(1, 16), "Cell Attribute Matrix", AttributeMatrix::Type::Cell); - AttributeMatrix::Pointer featureAttr = AttributeMatrix::New(QVector(1, 5), "Feature Attribute Matrix", AttributeMatrix::Type::Cell); + AttributeMatrix::Pointer cellAttr = AttributeMatrix::New(std::vector(1, 16), "Cell Attribute Matrix", AttributeMatrix::Type::Cell); + AttributeMatrix::Pointer featureAttr = AttributeMatrix::New(std::vector(1, 5), "Feature Attribute Matrix", AttributeMatrix::Type::Cell); - DataArray::Pointer featureIds = DataArray::CreateArray(16, "FeatureIds"); + DataArray::Pointer featureIds = DataArray::CreateArray(16, std::string("FeatureIds"), true); int32_t value = 1; featureIds->initializeTuple(0, &value); featureIds->initializeTuple(1, &value); @@ -305,10 +302,10 @@ class CreateFeatureArrayFromElementArrayTest featureIds->initializeTuple(14, &value); featureIds->initializeTuple(15, &value); - cellAttr->addAttributeArray("FeatureIds", featureIds); - dc->addAttributeMatrix("Cell Attribute Matrix", cellAttr); - dc->addAttributeMatrix("Feature Attribute Matrix", featureAttr); - dca->addDataContainer(dc); + cellAttr->insertOrAssign(featureIds); + dc->addOrReplaceAttributeMatrix(cellAttr); + dc->addOrReplaceAttributeMatrix(featureAttr); + dca->addOrReplaceDataContainer(dc); DataArrayPath path = DataArrayPath(dc->getName(), cellAttr->getName(), featureIds->getName()); QVariant var; @@ -328,7 +325,7 @@ class CreateFeatureArrayFromElementArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) createFeatureArrayFromElementArrayFilter->execute(); - int err = createFeatureArrayFromElementArrayFilter->getErrorCondition(); + int err = createFeatureArrayFromElementArrayFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0); } else diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateGeometryTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateGeometryTest.cpp index 89c837207f..f911821505 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateGeometryTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateGeometryTest.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,26 +35,22 @@ #pragma once -#include -#include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Filtering/QMetaObjectUtilities.h" - -#include "SIMPLib/Testing/SIMPLTestFileLocations.h" -#include "SIMPLib/Testing/UnitTestSupport.hpp" - -#include "SIMPLib/FilterParameters/IntVec3FilterParameter.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" - +#include "SIMPLib/FilterParameters/IntVec3FilterParameter.h" #include "SIMPLib/Geometry/EdgeGeom.h" #include "SIMPLib/Geometry/HexahedralGeom.h" #include "SIMPLib/Geometry/ImageGeom.h" @@ -63,8 +59,8 @@ #include "SIMPLib/Geometry/TetrahedralGeom.h" #include "SIMPLib/Geometry/TriangleGeom.h" #include "SIMPLib/Geometry/VertexGeom.h" - -#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Testing/SIMPLTestFileLocations.h" +#include "SIMPLib/Testing/UnitTestSupport.hpp" class CreateGeometryTest { @@ -97,9 +93,10 @@ class CreateGeometryTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template std::shared_ptr> createDataArray(const QString& daName, const std::vector>& data, const QVector& tupleDims, const QVector& cDims) + template + std::shared_ptr> createDataArray(const QString& daName, const std::vector>& data, const std::vector& tupleDims, const std::vector& cDims) { - typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName); + typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName, true); for(int i = 0; i < da->getNumberOfTuples(); i++) { da->setTuple(i, data[i]); @@ -110,11 +107,12 @@ class CreateGeometryTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void checkDataArray(std::shared_ptr> originalData, std::shared_ptr> newData) + template + void checkDataArray(std::shared_ptr> originalData, std::shared_ptr> newData) { DREAM3D_REQUIRE_EQUAL(originalData->getSize(), newData->getSize()) - for(int i = 0; i < originalData->getSize(); i++) + for(size_t i = 0; i < originalData->getSize(); i++) { T* valueOld = originalData->getPointer(i); T* valueNew = newData->getPointer(i); @@ -152,7 +150,7 @@ class CreateGeometryTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void testCaseImage(AbstractFilter::Pointer createGeometry, DataContainer::Pointer dc, IGeometry::Type geomType, IntVec3_t numDimensions, FloatVec3_t originPos, FloatVec3_t imgResolution) + void testCaseImage(AbstractFilter::Pointer createGeometry, DataContainer::Pointer dc, IGeometry::Type geomType, IntVec3Type numDimensions, FloatVec3Type originPos, FloatVec3Type imgResolution) { if(geomType != IGeometry::Type::Image) { @@ -166,28 +164,28 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) createGeometry->execute(); - DREAM3D_REQUIRED(createGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(createGeometry->getErrorCode(), >=, 0); bool correctGeom = (geomType == dc->getGeometry()->getGeometryType()); DREAM3D_REQUIRE_EQUAL(correctGeom, true) ImageGeom::Pointer imageGeom = dc->getGeometryAs(); - SIMPL::Tuple3SVec dim = imageGeom->getDimensions(); - SIMPL::Tuple3FVec origin = imageGeom->getOrigin(); - SIMPL::Tuple3FVec res = imageGeom->getResolution(); + SizeVec3Type dim = imageGeom->getDimensions(); + FloatVec3Type origin = imageGeom->getOrigin(); + FloatVec3Type res = imageGeom->getSpacing(); - DREAM3D_REQUIRE_EQUAL(std::get<0>(dim), numDimensions.x) - DREAM3D_REQUIRE_EQUAL(std::get<1>(dim), numDimensions.y) - DREAM3D_REQUIRE_EQUAL(std::get<2>(dim), numDimensions.z) + DREAM3D_REQUIRE_EQUAL(dim[0], numDimensions[0]) + DREAM3D_REQUIRE_EQUAL(dim[1], numDimensions[1]) + DREAM3D_REQUIRE_EQUAL(dim[2], numDimensions[2]) - DREAM3D_REQUIRE_EQUAL(std::get<0>(origin), originPos.x) - DREAM3D_REQUIRE_EQUAL(std::get<1>(origin), originPos.y) - DREAM3D_REQUIRE_EQUAL(std::get<2>(origin), originPos.z) + DREAM3D_REQUIRE_EQUAL(origin[0], originPos[0]) + DREAM3D_REQUIRE_EQUAL(origin[1], originPos[1]) + DREAM3D_REQUIRE_EQUAL(origin[2], originPos[2]) - DREAM3D_REQUIRE_EQUAL(std::get<0>(res), imgResolution.x) - DREAM3D_REQUIRE_EQUAL(std::get<1>(res), imgResolution.y) - DREAM3D_REQUIRE_EQUAL(std::get<2>(res), imgResolution.z) + DREAM3D_REQUIRE_EQUAL(res[0], imgResolution[0]) + DREAM3D_REQUIRE_EQUAL(res[1], imgResolution[1]) + DREAM3D_REQUIRE_EQUAL(res[2], imgResolution[2]) removeGeometry(dc); } @@ -221,11 +219,11 @@ class CreateGeometryTest if(treatWarningsAsErrors) { - DREAM3D_REQUIRED(createGeometry->getErrorCondition(), ==, -1) + DREAM3D_REQUIRED(createGeometry->getErrorCode(), ==, -1) } else { - DREAM3D_REQUIRED(createGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(createGeometry->getErrorCode(), >=, 0); bool correctGeom = (geomType == dc->getGeometry()->getGeometryType()); DREAM3D_REQUIRE_EQUAL(correctGeom, true) @@ -255,7 +253,7 @@ class CreateGeometryTest // // ----------------------------------------------------------------------------- void testCase(AbstractFilter::Pointer createGeometry, DataContainer::Pointer dc, AttributeMatrix::Pointer am, IGeometry::Type geomType, FloatArrayType::Pointer daVertices, - Int64ArrayType::Pointer daElements, bool treatWarningsAsErrors, bool arrayHandling) + MeshIndexArrayType::Pointer daElements, bool treatWarningsAsErrors, bool arrayHandling) { int geomChoice = 2; @@ -263,11 +261,13 @@ class CreateGeometryTest { return; } - else if(geomType == IGeometry::Type::RectGrid) + + if(geomType == IGeometry::Type::RectGrid) { return; } - else if(geomType == IGeometry::Type::Vertex) + + if(geomType == IGeometry::Type::Vertex) { geomChoice = 2; } @@ -312,18 +312,18 @@ class CreateGeometryTest if(treatWarningsAsErrors && geomType != IGeometry::Type::Vertex) { - DREAM3D_REQUIRED(createGeometry->getErrorCondition(), ==, -1) + DREAM3D_REQUIRED(createGeometry->getErrorCode(), ==, -1) } else { - DREAM3D_REQUIRED(createGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(createGeometry->getErrorCode(), >=, 0); bool correctGeom = (geomType == dc->getGeometry()->getGeometryType()); DREAM3D_REQUIRE_EQUAL(correctGeom, true) FloatArrayType::Pointer vert = FloatArrayType::NullPointer(); - Int64ArrayType::Pointer elements = Int64ArrayType::NullPointer(); + MeshIndexArrayType::Pointer elements = MeshIndexArrayType::NullPointer(); if(geomType == IGeometry::Type::Vertex) { @@ -336,46 +336,46 @@ class CreateGeometryTest { EdgeGeom::Pointer edgeGeom = dc->getGeometryAs(); FloatArrayType::Pointer vert = edgeGeom->getVertices(); - Int64ArrayType::Pointer edges = edgeGeom->getEdges(); + SharedEdgeList::Pointer edges = edgeGeom->getEdges(); checkDataArray(vert, daVertices); - checkDataArray(edges, daElements); + checkDataArray(edges, daElements); } else if(geomType == IGeometry::Type::Triangle) { TriangleGeom::Pointer triGeom = dc->getGeometryAs(); FloatArrayType::Pointer vert = triGeom->getVertices(); - Int64ArrayType::Pointer triangles = triGeom->getTriangles(); + SharedTriList::Pointer triangles = triGeom->getTriangles(); checkDataArray(vert, daVertices); - checkDataArray(triangles, daElements); + checkDataArray(triangles, daElements); } else if(geomType == IGeometry::Type::Quad) { QuadGeom::Pointer quadGeom = dc->getGeometryAs(); FloatArrayType::Pointer vert = quadGeom->getVertices(); - Int64ArrayType::Pointer quads = quadGeom->getQuads(); + SharedQuadList::Pointer quads = quadGeom->getQuads(); checkDataArray(vert, daVertices); - checkDataArray(quads, daElements); + checkDataArray(quads, daElements); } else if(geomType == IGeometry::Type::Tetrahedral) { TetrahedralGeom::Pointer tetraGeom = dc->getGeometryAs(); FloatArrayType::Pointer vert = tetraGeom->getVertices(); - Int64ArrayType::Pointer tetrahedra = tetraGeom->getTetrahedra(); + SharedTetList::Pointer tetrahedra = tetraGeom->getTetrahedra(); checkDataArray(vert, daVertices); - checkDataArray(tetrahedra, daElements); + checkDataArray(tetrahedra, daElements); } else if(geomType == IGeometry::Type::Hexahedral) { HexahedralGeom::Pointer hexaGeom = dc->getGeometryAs(); FloatArrayType::Pointer vert = hexaGeom->getVertices(); - Int64ArrayType::Pointer hexahedra = hexaGeom->getHexahedra(); + SharedHexList::Pointer hexahedra = hexaGeom->getHexahedra(); checkDataArray(vert, daVertices); - checkDataArray(hexahedra, daElements); + checkDataArray(hexahedra, daElements); } if(arrayHandling) @@ -383,10 +383,11 @@ class CreateGeometryTest QList names = am->getAttributeArrayNames(); DREAM3D_REQUIRE_EQUAL(names.contains(daVertices->getName()), false) - if(geomType != IGeometry::Type::Vertex) - { - DREAM3D_REQUIRE_EQUAL(names.contains(daElements->getName()), false) - } + // daElements is renamed by the geometries, causing names.contains(daElements->getName()) to return true. + // if(geomType != IGeometry::Type::Vertex) + //{ + // DREAM3D_REQUIRE_EQUAL(names.contains(daElements->getName()), false) + //} } } @@ -421,24 +422,24 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // ImageGeom Parameters - IntVec3_t numDimensions; - numDimensions.x = 5; - numDimensions.y = 15; - numDimensions.z = 25; + IntVec3Type numDimensions; + numDimensions[0] = 5; + numDimensions[1] = 15; + numDimensions[2] = 25; - FloatVec3_t originPos; - originPos.x = 5; - originPos.y = 15; - originPos.z = 25; + FloatVec3Type originPos; + originPos[0] = 5; + originPos[1] = 15; + originPos[2] = 25; - FloatVec3_t imgResolution; - imgResolution.x = 5; - imgResolution.y = 15; - imgResolution.z = 25; + FloatVec3Type imgResolution; + imgResolution[0] = 5; + imgResolution[1] = 15; + imgResolution[2] = 25; // Create Filter @@ -461,7 +462,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -480,7 +481,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) var.setValue(imgResolution); - propWasSet = createGeometry->setProperty("Resolution", var); + propWasSet = createGeometry->setProperty("Spacing", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) createGeometry->setDataContainerArray(dca); @@ -499,9 +500,9 @@ class CreateGeometryTest static const QString k_DataContainerName("DataContainer"); static const QString k_BoundsMatrixName("BoundsMatrix"); - static const QString k_XBoundsDAName("XBounds"); - static const QString k_YBoundsDAName("YBounds"); - static const QString k_ZBoundsDAName("ZBounds"); + static const QString k_XBoundsDAName(SIMPL::Geometry::xBoundsList); + static const QString k_YBoundsDAName(SIMPL::Geometry::yBoundsList); + static const QString k_ZBoundsDAName(SIMPL::Geometry::zBoundsList); static const QString k_BadXBoundsDAName("BadXBounds"); // Create DataContainerArray @@ -511,45 +512,45 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices AttributeMatrix::Pointer boundsAM = AttributeMatrix::New(m_Dims4, k_BoundsMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_BoundsMatrixName, boundsAM); + dc->addOrReplaceAttributeMatrix(boundsAM); // Create Bounds Arrays - DataArray::Pointer daXBounds = DataArray::CreateArray(m_Dims4, m_Dims1, k_XBoundsDAName); + DataArray::Pointer daXBounds = DataArray::CreateArray(m_Dims4, m_Dims1, k_XBoundsDAName, true); for(size_t i = 0; i < daXBounds->getSize(); i++) { daXBounds->setValue(i, i); } - boundsAM->addAttributeArray(k_XBoundsDAName, daXBounds); + boundsAM->insertOrAssign(daXBounds); - DataArray::Pointer daYBounds = DataArray::CreateArray(m_Dims4, m_Dims1, k_YBoundsDAName); + DataArray::Pointer daYBounds = DataArray::CreateArray(m_Dims4, m_Dims1, k_YBoundsDAName, true); for(size_t i = 0; i < daYBounds->getSize(); i++) { daYBounds->setValue(i, i); } - boundsAM->addAttributeArray(k_YBoundsDAName, daYBounds); + boundsAM->insertOrAssign(daYBounds); - DataArray::Pointer daZBounds = DataArray::CreateArray(m_Dims4, m_Dims1, k_ZBoundsDAName); + DataArray::Pointer daZBounds = DataArray::CreateArray(m_Dims4, m_Dims1, k_ZBoundsDAName, true); for(size_t i = 0; i < daZBounds->getSize(); i++) { daZBounds->setValue(i, i); } - boundsAM->addAttributeArray(k_ZBoundsDAName, daZBounds); + boundsAM->insertOrAssign(daZBounds); // Create bad xBounds arrays - DataArray::Pointer daBadXBounds = DataArray::CreateArray(m_Dims4, m_Dims1, k_BadXBoundsDAName); + DataArray::Pointer daBadXBounds = DataArray::CreateArray(m_Dims4, m_Dims1, k_BadXBoundsDAName, true); for(size_t i = 0; i < daBadXBounds->getSize(); i++) { daBadXBounds->setValue(i, i); } daBadXBounds->setValue(0, 100); - boundsAM->addAttributeArray(k_BadXBoundsDAName, daBadXBounds); + boundsAM->insertOrAssign(daBadXBounds); // Create Filter @@ -572,7 +573,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -666,19 +667,19 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(m_Dims2, k_VertexMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_VertexMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); // Create Vertex Data Arrays std::vector> vertices = {{1.0f, 1.0f, 0.0f}, {3.0f, 1.0f, 0.0f}}; DataArray::Pointer daVert = createDataArray(k_VertexListDAName, vertices, m_Dims2, m_Dims3); - vertexAM->addAttributeArray(k_VertexListDAName, daVert); + vertexAM->insertOrAssign(daVert); // Create Filter @@ -701,7 +702,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -718,7 +719,7 @@ class CreateGeometryTest // Vertex test cases - testCase(createGeometry, dc, vertexAM, IGeometry::Type::Vertex, daVert, Int64ArrayType::NullPointer(), false, false); + testCase(createGeometry, dc, vertexAM, IGeometry::Type::Vertex, daVert, MeshIndexArrayType::NullPointer(), false, false); } // ----------------------------------------------------------------------------- @@ -742,32 +743,32 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices AttributeMatrix::Pointer edgeVertexAM = AttributeMatrix::New(m_Dims2, k_EdgeVertexMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_EdgeVertexMatrixName, edgeVertexAM); + dc->addOrReplaceAttributeMatrix(edgeVertexAM); AttributeMatrix::Pointer edgeElementAM = AttributeMatrix::New(m_Dims1, k_EdgeElementAttributeMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_EdgeElementAttributeMatrixName, edgeElementAM); + dc->addOrReplaceAttributeMatrix(edgeElementAM); // Create Edge Data Arrays std::vector> vertices = {{1.0f, 1.0f, 0.0f}, {3.0f, 1.0f, 0.0f}}; - std::vector> elements = {{0, 1}}; + std::vector> elements = {{0, 1}}; DataArray::Pointer daEdgeVert = createDataArray(k_EdgeVertexListDAName, vertices, m_Dims2, m_Dims3); - DataArray::Pointer daEdgeList = createDataArray(k_EdgeListDAName, elements, m_Dims1, m_Dims2); - edgeVertexAM->addAttributeArray(k_EdgeVertexListDAName, daEdgeVert); - edgeElementAM->addAttributeArray(k_EdgeListDAName, daEdgeList); + SharedEdgeList::Pointer daEdgeList = createDataArray(k_EdgeListDAName, elements, m_Dims1, m_Dims2); + edgeVertexAM->insertOrAssign(daEdgeVert); + edgeElementAM->insertOrAssign(daEdgeList); // Create Bad EdgeList elements = {{0, 2}}; - DataArray::Pointer daBadEdgeList = createDataArray(k_BadEdgeListDAName, elements, m_Dims1, m_Dims2); - edgeElementAM->addAttributeArray(k_BadEdgeListDAName, daBadEdgeList); + SharedEdgeList::Pointer daBadEdgeList = createDataArray(k_BadEdgeListDAName, elements, m_Dims1, m_Dims2); + edgeElementAM->insertOrAssign(daBadEdgeList); // Create Filter @@ -790,7 +791,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -858,32 +859,32 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices AttributeMatrix::Pointer triVertexAM = AttributeMatrix::New(m_Dims3, k_TriVertexMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_TriVertexMatrixName, triVertexAM); + dc->addOrReplaceAttributeMatrix(triVertexAM); AttributeMatrix::Pointer triElementAM = AttributeMatrix::New(m_Dims1, k_TriElementAttributeMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_TriElementAttributeMatrixName, triElementAM); + dc->addOrReplaceAttributeMatrix(triElementAM); // Create Triangle Data Arrays std::vector> vertices = {{1.0, 1.0, 0.0}, {3.0, 1.0, 0.0}, {2.0, 3.0, 0.0}}; - std::vector> elements = {{0, 1, 2}}; + std::vector> elements = {{0, 1, 2}}; DataArray::Pointer daTriVert = createDataArray(k_TriVertexListDAName, vertices, m_Dims3, m_Dims3); - DataArray::Pointer daTriList = createDataArray(k_TriListDAName, elements, m_Dims1, m_Dims3); - triVertexAM->addAttributeArray(k_TriVertexListDAName, daTriVert); - triElementAM->addAttributeArray(k_TriListDAName, daTriList); + SharedTriList::Pointer daTriList = createDataArray(k_TriListDAName, elements, m_Dims1, m_Dims3); + triVertexAM->insertOrAssign(daTriVert); + triElementAM->insertOrAssign(daTriList); // Create Bad TriangleList elements = {{0, 3, 2}}; - DataArray::Pointer daBadTriList = createDataArray(k_BadTriListDAName, elements, m_Dims1, m_Dims3); - triElementAM->addAttributeArray(k_BadTriListDAName, daBadTriList); + SharedTriList::Pointer daBadTriList = createDataArray(k_BadTriListDAName, elements, m_Dims1, m_Dims3); + triElementAM->insertOrAssign(daBadTriList); // Create Filter @@ -906,7 +907,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -974,32 +975,32 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices AttributeMatrix::Pointer quadVertexAM = AttributeMatrix::New(m_Dims4, k_QuadVertexMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_QuadVertexMatrixName, quadVertexAM); + dc->addOrReplaceAttributeMatrix(quadVertexAM); AttributeMatrix::Pointer quadElementAM = AttributeMatrix::New(m_Dims1, k_QuadElementAttributeMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_QuadElementAttributeMatrixName, quadElementAM); + dc->addOrReplaceAttributeMatrix(quadElementAM); // Create Quadrilateral Data Arrays std::vector> vertices = {{1.0, 1.0, 0.0}, {3.0, 1.0, 0.0}, {2.0, 3.0, 0.0}, {2.0, 2.0, 0.0}}; - std::vector> elements = {{0, 1, 2, 3}}; + std::vector> elements = {{0, 1, 2, 3}}; DataArray::Pointer daQuadVert = createDataArray(k_QuadVertexListDAName, vertices, m_Dims4, m_Dims3); - DataArray::Pointer daQuadList = createDataArray(k_QuadListDAName, elements, m_Dims1, m_Dims4); - quadVertexAM->addAttributeArray(k_QuadVertexListDAName, daQuadVert); - quadElementAM->addAttributeArray(k_QuadListDAName, daQuadList); + SharedQuadList::Pointer daQuadList = createDataArray(k_QuadListDAName, elements, m_Dims1, m_Dims4); + quadVertexAM->insertOrAssign(daQuadVert); + quadElementAM->insertOrAssign(daQuadList); // Create Bad QuadrilateralList elements = {{0, 1, 7, 3}}; - DataArray::Pointer daBadQuadList = createDataArray(k_BadQuadListDAName, elements, m_Dims1, m_Dims4); - quadElementAM->addAttributeArray(k_BadQuadListDAName, daBadQuadList); + SharedQuadList::Pointer daBadQuadList = createDataArray(k_BadQuadListDAName, elements, m_Dims1, m_Dims4); + quadElementAM->insertOrAssign(daBadQuadList); // Create Filter @@ -1022,7 +1023,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -1090,33 +1091,33 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices AttributeMatrix::Pointer tetVertexAM = AttributeMatrix::New(m_Dims4, k_TetVertexMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_TetVertexMatrixName, tetVertexAM); + dc->addOrReplaceAttributeMatrix(tetVertexAM); AttributeMatrix::Pointer tetElementAM = AttributeMatrix::New(m_Dims1, k_TetElementAttributeMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_TetElementAttributeMatrixName, tetElementAM); + dc->addOrReplaceAttributeMatrix(tetElementAM); // Create Tetrahedron Data Arrays std::vector> vertices = {{1.0f, 1.0f, 1.55f}, {3.0f, 1.0f, 1.55f}, {2.0f, 3.0f, 1.55f}, {2.0f, 2.0f, 3.55f}}; - std::vector> elements = {{0, 1, 2, 3}}; + std::vector> elements = {{0, 1, 2, 3}}; DataArray::Pointer daTetVert = createDataArray(k_TetVertexListDAName, vertices, m_Dims4, m_Dims3); - DataArray::Pointer daTetList = createDataArray(k_TetListDAName, elements, m_Dims1, m_Dims4); - tetVertexAM->addAttributeArray(k_TetVertexListDAName, daTetVert); - tetElementAM->addAttributeArray(k_TetListDAName, daTetList); + SharedTetList::Pointer daTetList = createDataArray(k_TetListDAName, elements, m_Dims1, m_Dims4); + tetVertexAM->insertOrAssign(daTetVert); + tetElementAM->insertOrAssign(daTetList); // Create Bad TetrahedronList elements = {{0, 10, 2, 3}}; - DataArray::Pointer daBadTetList = createDataArray(k_BadTetListDAName, elements, m_Dims1, m_Dims4); - tetElementAM->addAttributeArray(k_BadTetListDAName, daBadTetList); + SharedTetList::Pointer daBadTetList = createDataArray(k_BadTetListDAName, elements, m_Dims1, m_Dims4); + tetElementAM->insertOrAssign(daBadTetList); // Create Filter @@ -1139,7 +1140,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -1207,33 +1208,34 @@ class CreateGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrices AttributeMatrix::Pointer hexVertexAM = AttributeMatrix::New(m_Dims8, k_HexVertexMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_HexVertexMatrixName, hexVertexAM); + dc->addOrReplaceAttributeMatrix(hexVertexAM); AttributeMatrix::Pointer hexElementAM = AttributeMatrix::New(m_Dims1, k_HexElementAttributeMatrixName, AttributeMatrix::Type::Any); - dc->addAttributeMatrix(k_HexElementAttributeMatrixName, hexElementAM); + dc->addOrReplaceAttributeMatrix(hexElementAM); // Create Hexahedron Data Arrays - std::vector> vertices = {{1.0f, 1.0f, 1.55f}, {3.0f, 1.0f, 1.55f}, {2.0f, 3.0f, 1.55f}, {2.0f, 2.0f, 3.55f}, {2.5f, 1.0f, 1.55f}, {4.3f, 1.0f, 1.55f}, {5.1f, 3.0f, 1.55f}, {7.63f, 2.0f, 3.55f}}; + std::vector> vertices = {{1.0f, 1.0f, 1.55f}, {3.0f, 1.0f, 1.55f}, {2.0f, 3.0f, 1.55f}, {2.0f, 2.0f, 3.55f}, + {2.5f, 1.0f, 1.55f}, {4.3f, 1.0f, 1.55f}, {5.1f, 3.0f, 1.55f}, {7.63f, 2.0f, 3.55f}}; - std::vector> elements = {{0, 1, 2, 3, 4, 5, 6, 7}}; + std::vector> elements = {{0, 1, 2, 3, 4, 5, 6, 7}}; DataArray::Pointer daHexVert = createDataArray(k_HexVertexListDAName, vertices, m_Dims8, m_Dims3); - DataArray::Pointer daHexList = createDataArray(k_HexListDAName, elements, m_Dims1, m_Dims8); - hexVertexAM->addAttributeArray(k_HexVertexListDAName, daHexVert); - hexElementAM->addAttributeArray(k_HexListDAName, daHexList); + SharedHexList::Pointer daHexList = createDataArray(k_HexListDAName, elements, m_Dims1, m_Dims8); + hexVertexAM->insertOrAssign(daHexVert); + hexElementAM->insertOrAssign(daHexList); // Create Bad HexahedronList elements = {{0, 1, 2, 32, 4, 5, 6, 7}}; - DataArray::Pointer daBadHexList = createDataArray(k_BadHexListDAName, elements, m_Dims1, m_Dims8); - hexElementAM->addAttributeArray(k_BadHexListDAName, daBadHexList); + SharedHexList::Pointer daBadHexList = createDataArray(k_BadHexListDAName, elements, m_Dims1, m_Dims8); + hexElementAM->insertOrAssign(daBadHexList); // Create Filter @@ -1256,7 +1258,7 @@ class CreateGeometryTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); propWasSet = createGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -1326,9 +1328,9 @@ class CreateGeometryTest private: QString m_FilterName = QString("CreateGeometry"); - QVector m_Dims1 = {1}; - QVector m_Dims2 = {2}; - QVector m_Dims3 = {3}; - QVector m_Dims4 = {4}; - QVector m_Dims8 = {8}; + std::vector m_Dims1 = {1}; + std::vector m_Dims2 = {2}; + std::vector m_Dims3 = {3}; + std::vector m_Dims4 = {4}; + std::vector m_Dims8 = {8}; }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateImageGeometryTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateImageGeometryTest.cpp index 9c3ce5ad64..bf49e0c74b 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateImageGeometryTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateImageGeometryTest.cpp @@ -1,49 +1,48 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "SIMPLib/CoreFilters/CreateImageGeometry.h" - +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" -#include "SIMPLib/SIMPLibVersion.h" - #include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" #include "SIMPLib/FilterParameters/IntVec3FilterParameter.h" #include "SIMPLib/FilterParameters/LinkedBooleanFilterParameter.h" #include "SIMPLib/Geometry/ImageGeom.h" - #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -60,20 +59,20 @@ class CreateImageGeometryTest { CreateImageGeometry::Pointer imageGeometry = CreateImageGeometry::New(); - QVector attributeMatrixSize = QVector(); + std::vector attributeMatrixSize = std::vector(); attributeMatrixSize.push_back(3); attributeMatrixSize.push_back(3); attributeMatrixSize.push_back(3); AttributeMatrix::Pointer am = AttributeMatrix::New(attributeMatrixSize, "Attribute Matrix", AttributeMatrix::Type::Any); DataContainer::Pointer dc = DataContainer::New("Data Container"); - dc->addAttributeMatrix("Attribute Matrix", am); + dc->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); imageGeometry->setDataContainerArray(dca); - imageGeometry->setSelectedDataContainer("Data Container"); + imageGeometry->setSelectedDataContainer(DataArrayPath("Data Container", "", "")); return imageGeometry; } @@ -84,18 +83,18 @@ class CreateImageGeometryTest { CreateImageGeometry::Pointer imageGeometry = initializeData(); - IntVec3_t numDimensions; - numDimensions.x = 5; - numDimensions.y = 15; - numDimensions.z = 25; + IntVec3Type numDimensions; + numDimensions[0] = 5; + numDimensions[1] = 15; + numDimensions[2] = 25; imageGeometry->setDimensions(numDimensions); - IntVec3_t dimensions = imageGeometry->getDimensions(); + IntVec3Type dimensions = imageGeometry->getDimensions(); - DREAM3D_REQUIRE_EQUAL(numDimensions.x, dimensions.x); - DREAM3D_REQUIRE_EQUAL(numDimensions.y, dimensions.y); - DREAM3D_REQUIRE_EQUAL(numDimensions.z, dimensions.z); + DREAM3D_REQUIRE_EQUAL(numDimensions[0], dimensions[0]); + DREAM3D_REQUIRE_EQUAL(numDimensions[1], dimensions[1]); + DREAM3D_REQUIRE_EQUAL(numDimensions[2], dimensions[2]); } // ----------------------------------------------------------------------------- @@ -105,18 +104,18 @@ class CreateImageGeometryTest { CreateImageGeometry::Pointer imageGeometry = initializeData(); - FloatVec3_t originPos; - originPos.x = 5; - originPos.y = 15; - originPos.z = 25; + FloatVec3Type originPos; + originPos[0] = 5; + originPos[1] = 15; + originPos[2] = 25; imageGeometry->setOrigin(originPos); - FloatVec3_t origin = imageGeometry->getOrigin(); + FloatVec3Type origin = imageGeometry->getOrigin(); - DREAM3D_REQUIRE_EQUAL(originPos.x, origin.x); - DREAM3D_REQUIRE_EQUAL(originPos.y, origin.y); - DREAM3D_REQUIRE_EQUAL(originPos.z, origin.z); + DREAM3D_REQUIRE_EQUAL(originPos[0], origin[0]); + DREAM3D_REQUIRE_EQUAL(originPos[1], origin[1]); + DREAM3D_REQUIRE_EQUAL(originPos[2], origin[2]); } // ----------------------------------------------------------------------------- @@ -126,18 +125,18 @@ class CreateImageGeometryTest { CreateImageGeometry::Pointer imageGeometry = initializeData(); - FloatVec3_t imgResolution; - imgResolution.x = 5; - imgResolution.y = 15; - imgResolution.z = 25; + FloatVec3Type imgResolution; + imgResolution[0] = 5; + imgResolution[1] = 15; + imgResolution[2] = 25; - imageGeometry->setResolution(imgResolution); + imageGeometry->setSpacing(imgResolution); - FloatVec3_t resolution = imageGeometry->getResolution(); + FloatVec3Type resolution = imageGeometry->getSpacing(); - DREAM3D_REQUIRE_EQUAL(imgResolution.x, resolution.x); - DREAM3D_REQUIRE_EQUAL(imgResolution.y, resolution.y); - DREAM3D_REQUIRE_EQUAL(imgResolution.z, resolution.z); + DREAM3D_REQUIRE_EQUAL(imgResolution[0], resolution[0]); + DREAM3D_REQUIRE_EQUAL(imgResolution[1], resolution[1]); + DREAM3D_REQUIRE_EQUAL(imgResolution[2], resolution[2]); } // ----------------------------------------------------------------------------- @@ -147,23 +146,23 @@ class CreateImageGeometryTest { CreateImageGeometry::Pointer imageGeometry = initializeData(); - IntVec3_t numDimensions; - numDimensions.x = 5; - numDimensions.y = 15; - numDimensions.z = 25; + IntVec3Type numDimensions; + numDimensions[0] = 5; + numDimensions[1] = 15; + numDimensions[2] = 25; imageGeometry->setDimensions(numDimensions); - FloatVec3_t originPos; - originPos.x = 5; - originPos.y = 15; - originPos.z = 25; + FloatVec3Type originPos; + originPos[0] = 5; + originPos[1] = 15; + originPos[2] = 25; imageGeometry->setOrigin(originPos); - FloatVec3_t imgResolution; - imgResolution.x = 5; - imgResolution.y = 15; - imgResolution.z = 25; - imageGeometry->setResolution(imgResolution); + FloatVec3Type imgResolution; + imgResolution[0] = 5; + imgResolution[1] = 15; + imgResolution[2] = 25; + imageGeometry->setSpacing(imgResolution); imageGeometry->execute(); @@ -174,36 +173,27 @@ class CreateImageGeometryTest DREAM3D_REQUIRE(nullptr != geometry.get()); { - float* res = new float[3]; - geometry->getResolution(res); + FloatVec3Type res = geometry->getSpacing(); - DREAM3D_REQUIRE_EQUAL(res[0], imgResolution.x); - DREAM3D_REQUIRE_EQUAL(res[1], imgResolution.y); - DREAM3D_REQUIRE_EQUAL(res[2], imgResolution.z); - - delete[] res; + DREAM3D_REQUIRE_EQUAL(res[0], imgResolution[0]); + DREAM3D_REQUIRE_EQUAL(res[1], imgResolution[1]); + DREAM3D_REQUIRE_EQUAL(res[2], imgResolution[2]); } { - float* origin = new float[3]; - geometry->getOrigin(origin); - - DREAM3D_REQUIRE_EQUAL(origin[0], originPos.x); - DREAM3D_REQUIRE_EQUAL(origin[1], originPos.y); - DREAM3D_REQUIRE_EQUAL(origin[2], originPos.z); + FloatVec3Type origin = geometry->getOrigin(); - delete[] origin; + DREAM3D_REQUIRE_EQUAL(origin[0], originPos[0]); + DREAM3D_REQUIRE_EQUAL(origin[1], originPos[1]); + DREAM3D_REQUIRE_EQUAL(origin[2], originPos[2]); } { - size_t* dims = new size_t[3]; - std::tie(dims[0], dims[1], dims[2]) = geometry->getDimensions(); + SizeVec3Type dims = geometry->getDimensions(); - DREAM3D_REQUIRE_EQUAL(dims[0], numDimensions.x); - DREAM3D_REQUIRE_EQUAL(dims[1], numDimensions.y); - DREAM3D_REQUIRE_EQUAL(dims[2], numDimensions.z); - - delete[] dims; + DREAM3D_REQUIRE_EQUAL(dims[0], numDimensions[0]); + DREAM3D_REQUIRE_EQUAL(dims[1], numDimensions[1]); + DREAM3D_REQUIRE_EQUAL(dims[2], numDimensions[2]); } } @@ -235,7 +225,9 @@ class CreateImageGeometryTest DREAM3D_REGISTER_TEST(testExecution()) } -private: - CreateImageGeometryTest(const CreateImageGeometryTest&); // Copy Constructor Not Implemented - void operator=(const CreateImageGeometryTest&); // Move assignment Not Implemented +public: + CreateImageGeometryTest(const CreateImageGeometryTest&) = delete; // Copy Constructor Not Implemented + CreateImageGeometryTest(CreateImageGeometryTest&&) = delete; // Move Constructor Not Implemented + CreateImageGeometryTest& operator=(const CreateImageGeometryTest&) = delete; // Copy Assignment Not Implemented + CreateImageGeometryTest& operator=(CreateImageGeometryTest&&) = delete; // Move Assignment Not Implemented }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateStringArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateStringArrayTest.cpp index 0d6ae301c3..d4cc387657 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateStringArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CreateStringArrayTest.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,25 +35,21 @@ #pragma once -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" - -#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/Common/Constants.h" - class CreateStringArrayTest { @@ -95,7 +91,7 @@ class CreateStringArrayTest static const QString k_StringInitialValue("Test String"); static const QString k_EmptyQString(""); - QVector tupleDims(1, 5); + std::vector tupleDims(1, 5); // Create DataContainerArray @@ -104,12 +100,12 @@ class CreateStringArrayTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer am = AttributeMatrix::New(tupleDims, k_AttributeMatrixName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixName, am); + dc->addOrReplaceAttributeMatrix(am); // Create Filter @@ -135,7 +131,7 @@ class CreateStringArrayTest // Run Filter createStringArray->execute(); - DREAM3D_REQUIRED(createStringArray->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(createStringArray->getErrorCode(), >=, 0); // Check Filter Results @@ -156,7 +152,7 @@ class CreateStringArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) createStringArray->execute(); - DREAM3D_REQUIRED(createStringArray->getErrorCondition(), ==, -5759); + DREAM3D_REQUIRED(createStringArray->getErrorCode(), ==, -5759); // Test invalid array path; should yield error -8152 @@ -170,7 +166,7 @@ class CreateStringArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) createStringArray->execute(); - DREAM3D_REQUIRED(createStringArray->getErrorCondition(), ==, -8152); + DREAM3D_REQUIRED(createStringArray->getErrorCode(), ==, -8152); // Test negative number of components; should yield error -8150 @@ -184,7 +180,7 @@ class CreateStringArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) createStringArray->execute(); - DREAM3D_REQUIRED(createStringArray->getErrorCondition(), ==, -8150); + DREAM3D_REQUIRED(createStringArray->getErrorCode(), ==, -8150); // Test zero components; should yield error -8151 @@ -193,7 +189,7 @@ class CreateStringArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) createStringArray->execute(); - DREAM3D_REQUIRED(createStringArray->getErrorCondition(), ==, -8151); + DREAM3D_REQUIRED(createStringArray->getErrorCode(), ==, -8151); } // ----------------------------------------------------------------------------- @@ -212,5 +208,4 @@ class CreateStringArrayTest private: QString m_FilterName = QString("CreateStringArray"); - }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/CropVertexGeometryTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/CropVertexGeometryTest.cpp index 3e7a0a7c9b..0e1c649641 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/CropVertexGeometryTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/CropVertexGeometryTest.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,26 +35,24 @@ #pragma once -#include -#include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" - -#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Geometry/VertexGeom.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/Geometry/VertexGeom.h" - #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" class CropVertexGeometryTest { @@ -87,9 +85,10 @@ class CropVertexGeometryTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template std::shared_ptr> createDataArray(const QString& daName, const std::vector>& data, const QVector& tupleDims, const QVector& cDims) + template + std::shared_ptr> createDataArray(const QString& daName, const std::vector>& data, const std::vector& tupleDims, const std::vector& cDims) { - typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName); + typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName, true); for(int i = 0; i < da->getNumberOfTuples(); i++) { da->setTuple(i, data[i]); @@ -100,7 +99,8 @@ class CropVertexGeometryTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void checkDataArray(std::shared_ptr> originalData, std::shared_ptr> newData) + template + void checkDataArray(std::shared_ptr> originalData, std::shared_ptr> newData) { DREAM3D_REQUIRE_EQUAL(originalData->getSize(), newData->getSize()) @@ -129,37 +129,37 @@ class CropVertexGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix - QVector dims(1, vertices.size()); + std::vector dims(1, vertices.size()); AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(dims, k_VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(k_VertexAttributeMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); AttributeMatrix::Pointer nonVertexAM = AttributeMatrix::New(m_Dims4, k_AttributeMatrixName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixName, nonVertexAM); + dc->addOrReplaceAttributeMatrix(nonVertexAM); // Create DataArray used for geometry creation FloatArrayType::Pointer daVert = createDataArray(k_VertexCoordinatesDAName, vertices, dims, m_Dims3); - vertexAM->addAttributeArray(k_VertexCoordinatesDAName, daVert); + vertexAM->insertOrAssign(daVert); // Manually create cropped DataArray for comparison - QVector croppedDims(1, postCropVertices.size()); + std::vector croppedDims(1, postCropVertices.size()); FloatArrayType::Pointer daCroppedVert = createDataArray(k_CroppedVertexCoordinatesDAName, postCropVertices, croppedDims, m_Dims3); // Create extra DataArray to be copied - FloatArrayType::Pointer da = DataArray::CreateArray(m_Dims4, m_Dims3, k_DataArray0Name); + FloatArrayType::Pointer da = DataArray::CreateArray(m_Dims4, m_Dims3, k_DataArray0Name, true); for(int i = 0; i < da->getSize(); i++) { da->setValue(i, i + 0.5f); } - nonVertexAM->addAttributeArray(k_DataArray0Name, da); + nonVertexAM->insertOrAssign(da); // Create Geometry @@ -178,12 +178,13 @@ class CropVertexGeometryTest // Setup Filter QVariant var; - - var.setValue(k_DataContainerName); + DataArrayPath dap(k_DataContainerName); + var.setValue(dap); bool propWasSet = cropVertexGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) - var.setValue(k_CroppedDataContainerName); + dap = DataArrayPath(k_CroppedDataContainerName); + var.setValue(dap); propWasSet = cropVertexGeometry->setProperty("CroppedDataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -214,7 +215,7 @@ class CropVertexGeometryTest // Run Filter cropVertexGeometry->execute(); - DREAM3D_REQUIRED(cropVertexGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(cropVertexGeometry->getErrorCode(), >=, 0); // Check filter results @@ -230,7 +231,7 @@ class CropVertexGeometryTest DREAM3D_REQUIRE_EQUAL((daCroppedVert->getNumberOfTuples() == croppedVertexAM->getNumberOfTuples()), true) - FloatArrayType::Pointer croppedVerticesFromAM = croppedVertexAM->getAttributeArrayAs(k_VertexCoordinatesDAName); + FloatArrayType::Pointer croppedVerticesFromAM = croppedVertexAM->getAttributeArrayAs(SIMPL::Geometry::SharedVertexList); checkDataArray(daCroppedVert, croppedVerticesFromAM); @@ -303,9 +304,9 @@ class CropVertexGeometryTest private: QString m_FilterName = QString("CropVertexGeometry"); - QVector m_Dims1 = {1}; - QVector m_Dims2 = {2}; - QVector m_Dims3 = {3}; - QVector m_Dims4 = {4}; - QVector m_Dims8 = {8}; + std::vector m_Dims1 = {1}; + std::vector m_Dims2 = {2}; + std::vector m_Dims3 = {3}; + std::vector m_Dims4 = {4}; + std::vector m_Dims8 = {8}; }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/DataContainerTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/DataContainerTest.cpp index fa4eef24eb..b31b2df19e 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/DataContainerTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/DataContainerTest.cpp @@ -1,39 +1,40 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include +#include #include #include @@ -43,31 +44,29 @@ #include #include "SIMPLib/SIMPLib.h" - +#include "SIMPLib/CoreFilters/DataContainerReader.h" +#include "SIMPLib/CoreFilters/DataContainerWriter.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataArrays/IDataArray.h" +#include "SIMPLib/DataArrays/StringDataArray.h" #include "SIMPLib/DataArrays/StructArray.hpp" +#include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/DataContainers/DataContainer.h" -#include "SIMPLib/Geometry/ImageGeom.h" - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/CoreFilters/DataContainerReader.h" -#include "SIMPLib/CoreFilters/DataContainerWriter.h" -#include "SIMPLib/DataArrays/StringDataArray.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/H5FilterParametersReader.h" #include "SIMPLib/FilterParameters/H5FilterParametersWriter.h" #include "SIMPLib/FilterParameters/JsonFilterParametersReader.h" #include "SIMPLib/FilterParameters/JsonFilterParametersWriter.h" #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" - +#include "SIMPLib/Geometry/ImageGeom.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" #define helper(a, b) a##b #define MAKE_ARRAY(m_msgType, name) \ - IDataArray::Pointer m_msgType##Ptr = DataArray::CreateArray(5, name); \ + IDataArray::Pointer m_msgType##Ptr = DataArray::CreateArray(5, name, true); \ dataContainer->addCellData(name, m_msgType##Ptr); #define TEST_DATA_CONTAINER(Type, DCType) \ @@ -119,10 +118,18 @@ QString H5File() { return TestDir() + QString::fromLatin1("/DataContainerProxyTest.h5"); } -} +} // namespace DataContainerIOTest class DataContainerTest { + + enum createdPathID : RenameDataPath::DataID_t + { + DataContainerID1 = 1, + DataContainerID2 = 2, + DataContainerID3 = 3 + }; + public: DataContainerTest() = default; virtual ~DataContainerTest() = default; @@ -171,10 +178,11 @@ class DataContainerTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void CreateDataArray(AttributeMatrix::Pointer attrMat, QVector compDims) + template + void CreateDataArray(AttributeMatrix::Pointer attrMat, std::vector compDims) { QString name("["); - for(int i = 0; i < compDims.size(); i++) + for(size_t i = 0; i < compDims.size(); i++) { name = name + QString::number(compDims[i]); if(i < compDims.size() - 1) @@ -183,34 +191,35 @@ class DataContainerTest } } name = name + "]"; - typename DataArray::Pointer foo = DataArray::CreateArray(attrMat->getTupleDimensions(), compDims, "RENAME_ME"); + typename DataArray::Pointer foo = DataArray::CreateArray(attrMat->getTupleDimensions(), compDims, "RENAME_ME", true); foo->setName(foo->getFullNameOfClass() + name); foo->initializeWithValue(static_cast(1)); - attrMat->addAttributeArray(foo->getName(), foo); + attrMat->insertOrAssign(foo); QString autoName = foo->getName() + "_Auto"; - attrMat->createNonPrereqArray, AbstractFilter, T>(nullptr, autoName, static_cast(10), compDims); + attrMat->createNonPrereqArray>(nullptr, autoName, static_cast(10), compDims); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void CreateStringArray(AttributeMatrix::Pointer attrMat, QVector compDims) + void CreateStringArray(AttributeMatrix::Pointer attrMat, std::vector compDims) { + std::ignore = compDims; QString name("ExampleStringDataArray"); - StringDataArray::Pointer data = StringDataArray::CreateArray(attrMat->getNumberOfTuples(), name); + StringDataArray::Pointer data = StringDataArray::CreateArray(attrMat->getNumberOfTuples(), name, true); for(size_t i = 0; i < attrMat->getNumberOfTuples(); i++) { QString value = QString("string_%1").arg(i); data->setValue(i, value); } - attrMat->addAttributeArray(data->getName(), data); + attrMat->insertOrAssign(data); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void FillAttributeMatrix(AttributeMatrix::Pointer attrMat, QVector compDims) + void FillAttributeMatrix(const AttributeMatrix::Pointer& attrMat, const std::vector& compDims) { CreateDataArray(attrMat, compDims); CreateDataArray(attrMat, compDims); @@ -228,11 +237,11 @@ class DataContainerTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void PopulateVolumeDataContainer(DataContainer::Pointer dc, QVector tupleDims, const QString& name) + void PopulateVolumeDataContainer(const DataContainer::Pointer& dc, std::vector tupleDims, const QString& name) { // Create the attribute matrix with the dimensions and name AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tupleDims, name, AttributeMatrix::Type::Cell); - QVector compDims(1, 1); // Create a Single Scalar Component (numComp = 1) Data Array + std::vector compDims(1, 1); // Create a Single Scalar Component (numComp = 1) Data Array FillAttributeMatrix(attrMat, compDims); // Add Data Arrays that have a [1x3] component dimensions @@ -246,7 +255,7 @@ class DataContainerTest FillAttributeMatrix(attrMat, compDims); // Add the AttributeMatrix to the Data Container - dc->addAttributeMatrix(attrMat->getName(), attrMat); + dc->addOrReplaceAttributeMatrix(attrMat); QString autoAddName = name + QString::fromLatin1("_Auto"); AttributeMatrix::Pointer autoAttrMat = dc->createNonPrereqAttributeMatrix(nullptr, autoAddName, tupleDims, AttributeMatrix::Type::Cell); @@ -270,7 +279,7 @@ class DataContainerTest // ----------------------------------------------------------------------------- void TestDataContainerWriter() { - QVector tupleDims; + std::vector tupleDims; DataContainerArray::Pointer dca = DataContainerArray::New(); size_t nx = DataContainerIOTest::XSize; size_t ny = DataContainerIOTest::YSize; @@ -284,68 +293,68 @@ class DataContainerTest // 1D VolumeDataContainer tupleDims.push_back(nx); { - DataContainer::Pointer dc = dca->createNonPrereqDataContainer(nullptr, "1D_VolumeDataContainer"); + DataContainer::Pointer dc = dca->createNonPrereqDataContainer(nullptr, "1D_VolumeDataContainer", DataContainerID1); PopulateVolumeDataContainer(dc, tupleDims, "1D_AttributeMatrix"); } // 2D VolumeDataContainer tupleDims.push_back(ny); { - DataContainer::Pointer dc = dca->createNonPrereqDataContainer(nullptr, "2D_VolumeDataContainer"); + DataContainer::Pointer dc = dca->createNonPrereqDataContainer(nullptr, "2D_VolumeDataContainer", DataContainerID2); PopulateVolumeDataContainer(dc, tupleDims, "2D_AttributeMatrix"); } // 3D VolumeDataContainer tupleDims.push_back(nz); { - DataContainer::Pointer dc = dca->createNonPrereqDataContainer(nullptr, "3D_VolumeDataContainer"); + DataContainer::Pointer dc = dca->createNonPrereqDataContainer(nullptr, "3D_VolumeDataContainer", DataContainerID3); PopulateVolumeDataContainer(dc, tupleDims, "3D_AttributeMatrix"); } // A DataContainer that mimics some real data DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); m->setGeometry(image); AttributeMatrix::Pointer attrMatrix = AttributeMatrix::New(tupleDims, getCellFeatureAttributeMatrixName(), AttributeMatrix::Type::CellFeature); - m->addAttributeMatrix(getCellFeatureAttributeMatrixName(), attrMatrix); + m->addOrReplaceAttributeMatrix(attrMatrix); - int size = nx * ny * nz; - Int32ArrayType::Pointer featureIds = Int32ArrayType::CreateArray(size, SIMPL::CellData::FeatureIds); - for(int i = 0; i < size; ++i) + size_t size = static_cast(nx * ny * nz); + Int32ArrayType::Pointer featureIds = Int32ArrayType::CreateArray(size, SIMPL::CellData::FeatureIds, true); + for(size_t i = 0; i < size; ++i) { - featureIds->setValue(i, i + DataContainerIOTest::Offset); + featureIds->setValue(i, static_cast(i + DataContainerIOTest::Offset)); } - attrMatrix->addAttributeArray(SIMPL::CellData::FeatureIds, featureIds); + attrMatrix->insertOrAssign(featureIds); - BoolArrayType::Pointer boolArray = BoolArrayType::CreateArray(size, SIMPL::CellData::BoundaryCells); - for(int i = 0; i < size; ++i) + BoolArrayType::Pointer boolArray = BoolArrayType::CreateArray(size, SIMPL::CellData::BoundaryCells, true); + for(size_t i = 0; i < size; ++i) { boolArray->setValue(i, i + DataContainerIOTest::Offset); } - attrMatrix->addAttributeArray(SIMPL::CellData::BoundaryCells, boolArray); + attrMatrix->insertOrAssign(boolArray); - QVector dims(1, 3); - FloatArrayType::Pointer avgEuler = FloatArrayType::CreateArray(size, dims, SIMPL::FeatureData::AxisEulerAngles); - for(int32_t i = 0; i < size; ++i) + std::vector dims(1, 3); + FloatArrayType::Pointer avgEuler = FloatArrayType::CreateArray(size, dims, SIMPL::FeatureData::AxisEulerAngles, true); + for(size_t i = 0; i < size; ++i) { avgEuler->setComponent(i, 0, i * 0.665f); avgEuler->setComponent(i, 1, i * 0.325f); avgEuler->setComponent(i, 2, i * 0.165f); } - m->getAttributeMatrix(getCellFeatureAttributeMatrixName())->addAttributeArray(SIMPL::FeatureData::AxisEulerAngles, avgEuler); + m->getAttributeMatrix(getCellFeatureAttributeMatrixName())->insertOrAssign(avgEuler); tupleDims.resize(1); tupleDims[0] = 4; AttributeMatrix::Pointer ensemAttrMat = AttributeMatrix::New(tupleDims, getCellEnsembleAttributeMatrixName(), AttributeMatrix::Type::CellEnsemble); - m->addAttributeMatrix(getCellEnsembleAttributeMatrixName(), ensemAttrMat); + m->addOrReplaceAttributeMatrix(ensemAttrMat); - FloatArrayType::Pointer surfArea = FloatArrayType::CreateArray(4, SIMPL::EnsembleData::TotalSurfaceAreas); - for(int i = 0; i < 4; ++i) + FloatArrayType::Pointer surfArea = FloatArrayType::CreateArray(4, SIMPL::EnsembleData::TotalSurfaceAreas, true); + for(size_t i = 0; i < 4; ++i) { surfArea->setValue(i, i + 41.2f); } - m->getAttributeMatrix(getCellEnsembleAttributeMatrixName())->addAttributeArray(SIMPL::EnsembleData::TotalSurfaceAreas, surfArea); + m->getAttributeMatrix(getCellEnsembleAttributeMatrixName())->insertOrAssign(surfArea); Observer obs; // Send progress messages from PipelineBuilder to this object for display @@ -359,12 +368,12 @@ class DataContainerTest // manually. Normally the Pipeline Object would do this for us. We are NOT using a Pipeline Object because using the // Pipeline Object would over write the DataContainer Array that we have created with a blank one thus defeating the // entire purpose of the test. - QObject::connect(writer.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), &obs, SLOT(processPipelineMessage(const PipelineMessage&))); + QObject::connect(writer.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); writer->execute(); - int err = writer->getErrorCondition(); + int err = writer->getErrorCode(); - DREAM3D_REQUIRE_EQUAL(err, 0); + DREAM3D_REQUIRE_EQUAL(err, 0) } // ----------------------------------------------------------------------------- @@ -384,7 +393,7 @@ class DataContainerTest DataContainerArrayProxy dcaProxy = reader->readDataContainerArrayStructure(DataContainerIOTest::TestFile()); reader->setInputFileDataContainerArrayProxy(dcaProxy); reader->execute(); - int err = reader->getErrorCondition(); + int err = reader->getErrorCode(); DREAM3D_REQUIRE(err >= 0) Observer obs; @@ -399,11 +408,11 @@ class DataContainerTest // manually. Normally the Pipeline Object would do this for us. We are NOT using a Pipeline Object because using the // Pipeline Object would over write the DataContainer Array that we have created with a blank one thus defeating the // entire purpose of the test. - QObject::connect(writer.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), &obs, SLOT(processPipelineMessage(const PipelineMessage&))); + QObject::connect(writer.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); writer->execute(); - err = writer->getErrorCondition(); - DREAM3D_REQUIRE_EQUAL(err, 0); + err = writer->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0) QMap& dcsToRead = dcaProxy.getDataContainers(); // uint32_t dcType = SIMPL::DataContainerType::UnknownDataContainer; @@ -447,39 +456,40 @@ class DataContainerTest reader2->setDataContainerArray(dca2); reader2->setInputFileDataContainerArrayProxy(dcaProxy); reader2->execute(); - err = reader2->getErrorCondition(); + err = reader2->getErrorCode(); DREAM3D_REQUIRE(err >= 0) DataContainerWriter::Pointer writer2 = DataContainerWriter::New(); writer2->setDataContainerArray(dca2); writer2->setOutputFile(DataContainerIOTest::TestFile3()); - QObject::connect(writer.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), &obs, SLOT(processPipelineMessage(const PipelineMessage&))); + QObject::connect(writer.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); writer2->execute(); - err = writer2->getErrorCondition(); - DREAM3D_REQUIRE_EQUAL(err, 0); + err = writer2->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0) } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void insertDeleteArray(DataContainer::Pointer m) + template + void insertDeleteArray(DataContainer::Pointer m) { // This should fail because there is no attribute matrix AttributeMatrix::Pointer attrMatrix = m->getAttributeMatrix(getCellAttributeMatrixName()); DREAM3D_REQUIRE_NULL_POINTER(attrMatrix.get()) // Now add an AttributeMatrix to the DataContainer - QVector tDims(1, 0); + std::vector tDims(1, 0); AttributeMatrix::Pointer attrMat = m->createAndAddAttributeMatrix(tDims, getCellAttributeMatrixName(), AttributeMatrix::Type::Cell); DREAM3D_REQUIRE_VALID_POINTER(attrMat.get()) // Now create an Array and add it to the Attribute Matrix - typename T::Pointer p = T::CreateArray(5, "Test"); + typename T::Pointer p = T::CreateArray(5, std::string("Test"), true); tDims[0] = 5; attrMat->resizeAttributeArrays(tDims); - int err = attrMat->addAttributeArray("Test", p); + int err = attrMat->insertOrAssign(p); DREAM3D_REQUIRED(err, >=, 0) // Now get it back out as the specific type that we put it in as @@ -488,25 +498,25 @@ class DataContainerTest // get the array as an IDataArray IDataArray::Pointer ida = attrMat->getAttributeArray("Test"); - DREAM3D_REQUIRE_VALID_POINTER(ida.get()); + DREAM3D_REQUIRE_VALID_POINTER(ida.get()) - QVector dims(1, 1); - t = attrMat->getPrereqArray(nullptr, "Test", -723, dims); - DREAM3D_REQUIRE_VALID_POINTER(ida.get()); + std::vector dims(1, 1); + t = attrMat->getPrereqArray(nullptr, "Test", -723, dims); + DREAM3D_REQUIRE_VALID_POINTER(ida.get()) // Remove the AttributeArray from the AttributeMatrix ida = attrMat->removeAttributeArray("Test"); - DREAM3D_REQUIRE_VALID_POINTER(ida.get()); + DREAM3D_REQUIRE_VALID_POINTER(ida.get()) // Now try and get the array again. we should fail t = attrMat->getAttributeArrayAs("Test"); - DREAM3D_REQUIRE_NULL_POINTER(t.get()); + DREAM3D_REQUIRE_NULL_POINTER(t.get()) // Try to get it as an IDataArray. We should fail ida = attrMat->getAttributeArray("Test"); - DREAM3D_REQUIRE_NULL_POINTER(ida.get()); + DREAM3D_REQUIRE_NULL_POINTER(ida.get()) - t = attrMat->getPrereqArray(nullptr, "Test", -723, dims); - DREAM3D_REQUIRE_NULL_POINTER(t.get()); + t = attrMat->getPrereqArray(nullptr, "Test", -723, dims); + DREAM3D_REQUIRE_NULL_POINTER(t.get()) // Remove the AttributeMatrix to setup for the next test. m->removeAttributeMatrix(getCellAttributeMatrixName()); @@ -539,7 +549,7 @@ class DataContainerTest } JsonFilterParametersWriter::Pointer jsonWriter = JsonFilterParametersWriter::New(); - jsonWriter->writePipelineToFile(pipeline, jsonFile, nullptr); + jsonWriter->writePipelineToFile(pipeline, jsonFile, {"TEST PIPELINE"}, false); JsonFilterParametersReader::Pointer jsonReader = JsonFilterParametersReader::New(); pipeline = jsonReader->readPipelineFromFile(jsonFile, nullptr); @@ -564,7 +574,7 @@ class DataContainerTest } H5FilterParametersWriter::Pointer h5Writer = H5FilterParametersWriter::New(); - h5Writer->writePipelineToFile(pipeline, h5File, "Pipeline"); + h5Writer->writePipelineToFile(pipeline, h5File, "Pipeline", false); H5FilterParametersReader::Pointer h5Reader = H5FilterParametersReader::New(); pipeline = h5Reader->readPipelineFromFile(h5File, nullptr); @@ -587,8 +597,6 @@ class DataContainerTest { DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - QList nameList; - insertDeleteArray(m); insertDeleteArray(m); insertDeleteArray(m); @@ -643,72 +651,72 @@ class DataContainerTest QVector dims(1, 2); T* ptr = m->createCellData("Test", 10, dims, absFilt.get()); - DREAM3D_REQUIRE_EQUAL(absFilt->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(absFilt->getErrorCode(), 0); DREAM3D_TEST_POINTER(ptr, !=, nullptr); - absFilt->setErrorCondition(0); + absFilt->clearErrorCode(); // First try getting the array, but pass in a bad array name which should produce a null pointer // and negative error condition ptr = m->getCellDataSizeCheck("BAD_ARRAY_NAME", 10, 2, absFilt.get()); DREAM3D_REQUIRE_EQUAL(ptr , nullptr) - DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next try getting the array, but pass in a bad size name which should produce a null pointer // and negative error condition ptr = m->getCellDataSizeCheck("Test", 10, 1, absFilt.get()); DREAM3D_REQUIRE_EQUAL(ptr , nullptr) - DREAM3D_REQUIRE_NE(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_NE(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next try getting the array, but pass in a bad cast type which should produce a null pointer // and negative error condition bool* bool_ptr = m->getCellDataSizeCheck("Test", 10, 2, absFilt.get()); DREAM3D_REQUIRE_EQUAL(bool_ptr , nullptr) - DREAM3D_REQUIRE_NE(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_NE(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next, pass in all the correct values which should produce a Non nullptr pointer value and // Zero Error Condition ptr = m->getCellDataSizeCheck("Test", 10, 2, absFilt.get()); DREAM3D_TEST_POINTER(ptr, !=, nullptr); - DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCondition()); + DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCode()); IDataArray::Pointer t = attrMat->removeAttributeArray( "Test" ); DREAM3D_TEST_POINTER(ptr, !=, nullptr); /********************************* Feature Data Tests *********************************************/ ptr = m->createCellFeatureData("Test", 10, dims, absFilt.get()); - DREAM3D_REQUIRE_EQUAL(absFilt->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(absFilt->getErrorCode(), 0); DREAM3D_TEST_POINTER(ptr, !=, nullptr); - absFilt->setErrorCondition(0); + absFilt->clearErrorCode(); // First try getting the array, but pass in a bad array name which should produce a null pointer // and negative error condition ptr = m->getCellFeatureDataSizeCheck("BAD_ARRAY_NAME", 10, 2, absFilt.get()); DREAM3D_REQUIRE_EQUAL(ptr , nullptr) - DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next try getting the array, but pass in a bad size name which should produce a null pointer // and negative error condition ptr = m->getCellFeatureDataSizeCheck("Test", 10, 1, absFilt.get()); DREAM3D_REQUIRE_EQUAL(ptr , nullptr) - DREAM3D_REQUIRE_NE(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_NE(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next try getting the array, but pass in a bad cast type which should produce a null pointer // and negative error condition bool_ptr = m->getCellFeatureDataSizeCheck("Test", 10, 2, absFilt.get()); DREAM3D_REQUIRE_EQUAL(bool_ptr , nullptr) - DREAM3D_REQUIRE_NE(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_NE(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next, pass in all the correct values which should produce a Non nullptr pointer value and // Zero Error Condition ptr = m->getCellFeatureDataSizeCheck("Test", 10, 2, absFilt.get()); DREAM3D_TEST_POINTER(ptr, !=, nullptr); - DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCondition()); + DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCode()); t = m->removeCellFeatureData( "Test" ); DREAM3D_TEST_POINTER(ptr, !=, nullptr); @@ -716,36 +724,36 @@ class DataContainerTest /********************************* Ensemble Data Tests *********************************************/ ptr = m->createCellEnsembleData("Test", 10, dims, absFilt.get()); - DREAM3D_REQUIRE_EQUAL(absFilt->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(absFilt->getErrorCode(), 0); DREAM3D_TEST_POINTER(ptr, !=, nullptr); - absFilt->setErrorCondition(0); + absFilt->clearErrorCode(); // First try getting the array, but pass in a bad array name which should produce a null pointer // and negative error condition ptr = m->getCellEnsembleDataSizeCheck("BAD_ARRAY_NAME", 10, 2, absFilt.get()); DREAM3D_REQUIRE_EQUAL(ptr , nullptr) - DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next try getting the array, but pass in a bad size name which should produce a null pointer // and negative error condition ptr = m->getCellEnsembleDataSizeCheck("Test", 10, 1, absFilt.get()); DREAM3D_REQUIRE_EQUAL(ptr , nullptr) - DREAM3D_REQUIRE_NE(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_NE(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next try getting the array, but pass in a bad cast type which should produce a null pointer // and negative error condition bool_ptr = m->getCellEnsembleDataSizeCheck("Test", 10, 2, absFilt.get()); DREAM3D_REQUIRE_EQUAL(bool_ptr , nullptr) - DREAM3D_REQUIRE_NE(0, absFilt->getErrorCondition()); - absFilt->setErrorCondition(0); + DREAM3D_REQUIRE_NE(0, absFilt->getErrorCode()); + absFilt->clearErrorCode(); // Next, pass in all the correct values which should produce a Non nullptr pointer value and // Zero Error Condition ptr = m->getCellEnsembleDataSizeCheck("Test", 10, 2, absFilt.get()); DREAM3D_TEST_POINTER(ptr, !=, nullptr); - DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCondition()); + DREAM3D_REQUIRE_EQUAL(0, absFilt->getErrorCode()); t = m->removeCellEnsembleData( "Test" ); @@ -885,6 +893,284 @@ class DataContainerTest } #endif + // ----------------------------------------------------------------------------- + void TestDataContainerArray() + { + bool result = false; + DataContainerArray::Pointer dca = DataContainerArray::New(); + // addDataContainer + // insertOrAssign + // getDataContainer(QString | DataArrayPath) + + // try adding or assigning a null DataContainer + DataContainer::Pointer nullDc = DataContainer::NullPointer(); + result = dca->addOrReplaceDataContainer(nullDc); + DREAM3D_REQUIRED(false, ==, result) + result = dca->insertOrAssign(nullDc); + DREAM3D_REQUIRED(false, ==, result) + DREAM3D_REQUIRED(dca->size(), ==, 0) + + const QString k_DC0("DCO"); + const QString k_DC1("DC1"); + DataContainer::Pointer dc0 = DataContainer::New(k_DC0); + DataContainer::Pointer dc1 = DataContainer::New(k_DC1); + + result = dca->addOrReplaceDataContainer(dc0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dca->size(), ==, 1) + + // Add the same DataContainer a second time. Still returns true. Size stays at 1 + result = dca->insertOrAssign(dc0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dca->size(), ==, 1) + + result = dca->push_back(dc0); + DREAM3D_REQUIRED(false, ==, result) + DREAM3D_REQUIRED(dca->size(), ==, 1) + + result = dca->addOrReplaceDataContainer(dc1); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dca->size(), ==, 2) + + dc0 = dca->removeDataContainer(k_DC0); + dc1 = dca->removeDataContainer(k_DC1); + DREAM3D_REQUIRED(dca->empty(), ==, true) + DREAM3D_REQUIRE_NULL_POINTER(dc0->getParentNode()) + + dca->clear(); + DREAM3D_REQUIRED(dca->empty(), ==, true) + + result = dca->addOrReplaceDataContainer(dc0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dca->size(), ==, 1) + + result = dca->push_back(dc0); + DREAM3D_REQUIRED(false, ==, result) + DREAM3D_REQUIRED(dca->size(), ==, 1) + + result = dca->addOrReplaceDataContainer(dc1); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dca->size(), ==, 2) + + // getDataContainers + DataContainerArray::Container dcContainer = dca->getDataContainers(); + DREAM3D_REQUIRED(dcContainer.size(), ==, 2) + + dc0 = dca->getDataContainer(k_DC0); + DREAM3D_REQUIRE_VALID_POINTER(dc0.get()) + DataArrayPath dap(k_DC0); + dc0 = dca->getDataContainer(dap); + DREAM3D_REQUIRE_VALID_POINTER(dc0.get()) + + DREAM3D_REQUIRED(dca->size(), ==, 2) + dca->clear(); + DREAM3D_REQUIRED(dca->empty(), ==, true) + for(size_t i = 0; i < 10; i++) + { + DataContainer::Pointer dc = DataContainer::New("Foo" + QString::number(i)); + dca->addOrReplaceDataContainer(dc); + // std::cout << dca->size() << std::endl; + DREAM3D_REQUIRED(dca->size(), ==, i + 1) + } + + result = dca->insertOrAssign(dc0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dca->size(), ==, 11) + + result = dca->insertOrAssign(dc0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dca->size(), ==, 11) + result = dca->insertOrAssign(dc1); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dca->size(), ==, 12) + } + + // ----------------------------------------------------------------------------- + void TestDataContainer() + { + bool result = false; + DataContainer::Pointer dc = DataContainer::New("DataContainer"); + // addDataContainer + // insertOrAssign + // getDataContainer(QString | DataArrayPath) + + // try adding or assigning a null DataContainer + AttributeMatrix::Pointer nullAttrMat = AttributeMatrix::NullPointer(); + result = dc->addOrReplaceAttributeMatrix(nullAttrMat); + DREAM3D_REQUIRED(false, ==, result) + result = dc->insertOrAssign(nullAttrMat); + DREAM3D_REQUIRED(false, ==, result) + DREAM3D_REQUIRED(dc->empty(), ==, true) + + const QString k_DC0("DCO"); + const QString k_DC1("DC1"); + std::vector tDims = {10, 10}; + AttributeMatrix::Pointer am0 = AttributeMatrix::New(tDims, k_DC0, AttributeMatrix::Type::Generic); + AttributeMatrix::Pointer am1 = AttributeMatrix::New(tDims, k_DC1, AttributeMatrix::Type::Generic); + + result = dc->addOrReplaceAttributeMatrix(am0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dc->size(), ==, 1) + + // Add the same AttributeMatrix a second time. Still returns true. Size stays at 1 + result = dc->insertOrAssign(am0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dc->size(), ==, 1) + + result = dc->push_back(am0); + DREAM3D_REQUIRED(false, ==, result) + DREAM3D_REQUIRED(dc->size(), ==, 1) + + result = dc->addOrReplaceAttributeMatrix(am1); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dc->size(), ==, 2) + + am0 = dc->removeAttributeMatrix(k_DC0); + am1 = dc->removeAttributeMatrix(k_DC1); + DREAM3D_REQUIRED(dc->empty(), ==, true) + DREAM3D_REQUIRE_NULL_POINTER(am0->getParentNode()) + + dc->clear(); + DREAM3D_REQUIRED(dc->empty(), ==, true) + + result = dc->addOrReplaceAttributeMatrix(am0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dc->size(), ==, 1) + + result = dc->push_back(am0); + DREAM3D_REQUIRED(false, ==, result) + DREAM3D_REQUIRED(dc->size(), ==, 1) + + result = dc->addOrReplaceAttributeMatrix(am1); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dc->size(), ==, 2) + + // getDataContainers + DataContainer::Container_t dcContainer = dc->getAttributeMatrices(); + DREAM3D_REQUIRED(dcContainer.size(), ==, 2) + + am0 = dc->getAttributeMatrix(k_DC0); + DREAM3D_REQUIRE_VALID_POINTER(am0.get()) + DataArrayPath dap("DataContainer", k_DC0, ""); + am0 = dc->getAttributeMatrix(dap); + DREAM3D_REQUIRE_VALID_POINTER(am0.get()) + + DREAM3D_REQUIRED(dc->size(), ==, 2) + dc->clear(); + DREAM3D_REQUIRED(dc->empty(), ==, true) + for(size_t i = 0; i < 10; i++) + { + AttributeMatrix::Pointer am = AttributeMatrix::New(tDims, "Foo" + QString::number(i), AttributeMatrix::Type::Generic); + dc->addOrReplaceAttributeMatrix(am); + // std::cout << dca->size() << std::endl; + DREAM3D_REQUIRED(dc->size(), ==, i + 1) + } + + result = dc->insertOrAssign(am0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dc->size(), ==, 11) + + result = dc->insertOrAssign(am0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dc->size(), ==, 11) + result = dc->insertOrAssign(am1); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(dc->size(), ==, 12) + } + + // ----------------------------------------------------------------------------- + void TestAttributeMatrix() + { + bool result = false; + std::vector tDims = {10, 10}; + AttributeMatrix::Pointer am = AttributeMatrix::New(tDims, "AttributeMatrix", AttributeMatrix::Type::Generic); + // addDataContainer + // insertOrAssign + // getDataContainer(QString | DataArrayPath) + + // try adding or assigning a null DataContainer + Int32ArrayType::Pointer nullAttrMat = Int32ArrayType::NullPointer(); + result = am->addOrReplaceAttributeArray(nullAttrMat); + DREAM3D_REQUIRED(false, ==, result) + result = am->insertOrAssign(nullAttrMat); + DREAM3D_REQUIRED(false, ==, result) + DREAM3D_REQUIRED(am->empty(), ==, true) + + const QString k_DC0("DCO"); + const QString k_DC1("DC1"); + Int32ArrayType::Pointer am0 = Int32ArrayType::CreateArray(100, k_DC0, true); + Int32ArrayType::Pointer am1 = Int32ArrayType::CreateArray(100, k_DC1, true); + + result = am->addOrReplaceAttributeArray(am0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(am->size(), ==, 1) + + // Add the same AttributeMatrix a second time. Still returns true. Size stays at 1 + result = am->insertOrAssign(am0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(am->size(), ==, 1) + + result = am->push_back(am0); + DREAM3D_REQUIRED(false, ==, result) + DREAM3D_REQUIRED(am->size(), ==, 1) + + result = am->addOrReplaceAttributeArray(am1); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(am->size(), ==, 2) + + IDataArray::Pointer da0 = am->removeAttributeArray(k_DC0); + IDataArray::Pointer da1 = am->removeAttributeArray(k_DC1); + DREAM3D_REQUIRED(am->empty(), ==, true) + DREAM3D_REQUIRE_NULL_POINTER(am0->getParentNode()) + + am->clear(); + DREAM3D_REQUIRED(am->empty(), ==, true) + + result = am->addOrReplaceAttributeArray(am0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(am->size(), ==, 1) + + result = am->push_back(am0); + DREAM3D_REQUIRED(false, ==, result) + DREAM3D_REQUIRED(am->size(), ==, 1) + + result = am->addOrReplaceAttributeArray(am1); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(am->size(), ==, 2) + + // getDataContainers + AttributeMatrix::Container_t dcContainer = am->getAttributeArrays(); + DREAM3D_REQUIRED(dcContainer.size(), ==, 2) + + da0 = am->getAttributeArray(k_DC0); + DREAM3D_REQUIRE_VALID_POINTER(am0.get()) + DataArrayPath dap("DataContainer", "AttributeMatrix", k_DC0); + da0 = am->getAttributeArray(dap); + DREAM3D_REQUIRE_VALID_POINTER(am0.get()) + + DREAM3D_REQUIRED(am->size(), ==, 2) + am->clear(); + DREAM3D_REQUIRED(am->empty(), ==, true) + for(int i = 0; i < 10; i++) + { + Int32ArrayType::Pointer aa = Int32ArrayType::CreateArray(100, "Foo" + QString::number(i), true); + am->addOrReplaceAttributeArray(aa); + // std::cout << dca->size() << std::endl; + DREAM3D_REQUIRED(am->size(), ==, i + 1) + } + + result = am->insertOrAssign(am0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(am->size(), ==, 11) + + result = am->insertOrAssign(am0); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(am->size(), ==, 11) + result = am->insertOrAssign(am1); + DREAM3D_REQUIRED(true, ==, result) + DREAM3D_REQUIRED(am->size(), ==, 12) + } + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -899,6 +1185,11 @@ class DataContainerTest DREAM3D_REGISTER_TEST(RemoveTestFiles()) #endif int err = EXIT_SUCCESS; + + DREAM3D_REGISTER_TEST(TestDataContainerArray()) + DREAM3D_REGISTER_TEST(TestDataContainer()) + DREAM3D_REGISTER_TEST(TestAttributeMatrix()) + DREAM3D_REGISTER_TEST(TestInsertDelete()) DREAM3D_REGISTER_TEST(TestDataContainerWriter()) diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ErrorMessageTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ErrorMessageTest.cpp index eeaf1509f1..809cf45d61 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ErrorMessageTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ErrorMessageTest.cpp @@ -1,44 +1,46 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include -#include "SIMPLib/Common/PipelineMessage.h" - -#include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/BadFilter.h" +#include "SIMPLib/Messages/FilterErrorMessage.h" +#include "SIMPLib/Messages/FilterProgressMessage.h" +#include "SIMPLib/Messages/FilterStatusMessage.h" +#include "SIMPLib/Messages/FilterWarningMessage.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -60,26 +62,17 @@ class ErrorMessageTest // ----------------------------------------------------------------------------- void TestErrorMessage() { - PipelineMessage e0; - - QString a0("Some Class Name"); - QString a1("Description"); - int eCode = -10; - PipelineMessage e1; - - PipelineMessage e2(a0, a1, eCode); - - AbstractFilter::Pointer f = AbstractFilter::New(); - f->notifyErrorMessage("Some Test", a1, eCode); - f->notifyErrorMessage("Another Test", "A description", -10); - - PipelineMessage pm("Joey's Test", "Testing Warning Message...", -23, PipelineMessage::MessageType::Warning); - PipelineMessage pm1("Joey's Test", "Testing Error Message...", -23, PipelineMessage::MessageType::Error); - PipelineMessage pm2("Joey's Test", "Testing Status Message...", -23, PipelineMessage::MessageType::StatusMessage); - PipelineMessage pm3("Joey's Test", "Testing Status Message...", -23, PipelineMessage::MessageType::ProgressValue, 23); - f->broadcastPipelineMessage(pm); - f->broadcastPipelineMessage(pm1); - f->broadcastPipelineMessage(pm2); + AbstractFilter::Pointer f = BadFilter::New(); + f->setErrorCondition(-10, "Description"); + + FilterProgressMessage::Pointer progressMessage = FilterProgressMessage::New(f->getNameOfClass(), f->getHumanLabel(), -1, "Testing Warning Message...", -23); + FilterErrorMessage::Pointer errorMessage = FilterErrorMessage::New(f->getNameOfClass(), f->getHumanLabel(), -1, "Testing Error Message...", -23); + FilterStatusMessage::Pointer statusMessage = FilterStatusMessage::New(f->getNameOfClass(), f->getHumanLabel(), -1, "Testing Status Message..."); + FilterWarningMessage::Pointer warningMessage = FilterWarningMessage::New(f->getNameOfClass(), f->getHumanLabel(), -1, "Testing Status Message...", 23); + Q_EMIT f->messageGenerated(progressMessage); + Q_EMIT f->messageGenerated(errorMessage); + Q_EMIT f->messageGenerated(statusMessage); + Q_EMIT f->messageGenerated(warningMessage); if(true) { diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExecuteProcessTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExecuteProcessTest.cpp index 98598a05fb..1c1292da98 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExecuteProcessTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExecuteProcessTest.cpp @@ -1,67 +1,98 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include -#include + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/CoreFilters/ExecuteProcess.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Messages/AbstractMessageHandler.h" +#include "SIMPLib/Messages/FilterStatusMessage.h" +#include "SIMPLib/Messages/PipelineStatusMessage.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/ExecuteProcess.h" +/** + * @brief This message handler is used by the ExecuteProcessTest to append filter and pipeline status messages + * to a standard output string. + */ +class ExecuteProcessMessageHandler : public AbstractMessageHandler +{ +public: + explicit ExecuteProcessMessageHandler(QString* stdOutput) + : m_StdOutput(stdOutput) + { + } + + /** + * @brief Appends incoming FilterStatusMessages to the standard output string + */ + void processMessage(const FilterStatusMessage* msg) const override + { + QString str = msg->generateMessageString(); + m_StdOutput->append(str); + } + + /** + * @brief Appends incoming PipelineStatusMessages to the standard output string + */ + void processMessage(const PipelineStatusMessage* msg) const override + { + QString str = msg->generateMessageString(); + m_StdOutput->append(str); + } + +private: + QString* m_StdOutput = nullptr; +}; /** -* @brief -*/ + * @brief The ExecuteProcessObserver class + */ class ExecuteProcessObserver : public QObject, public IObserver { Q_OBJECT public: ExecuteProcessObserver() = default; - SIMPL_TYPE_MACRO_SUPER(ExecuteProcessObserver, IObserver) ~ExecuteProcessObserver() override = default; @@ -75,28 +106,28 @@ class ExecuteProcessObserver : public QObject, public IObserver m_StdOutput.clear(); } -public slots: - void processPipelineMessage(const PipelineMessage& pm) override +public Q_SLOTS: + void processPipelineMessage(const AbstractMessage::Pointer& pm) override { - if(pm.getType() == PipelineMessage::MessageType::StandardOutputMessage) - { - PipelineMessage msg = pm; - QString str; - QTextStream ss(&str); - ss << msg.generateStandardOutputString(); - m_StdOutput.append(str); - } + ExecuteProcessMessageHandler msgHandler(&m_StdOutput); + pm->visit(&msgHandler); } private: QString m_StdOutput; - ExecuteProcessObserver(const ExecuteProcessObserver&); // Copy Constructor Not Implemented - void operator=(const ExecuteProcessObserver&); // Move assignment Not Implemented +public: + ExecuteProcessObserver(const ExecuteProcessObserver&) = delete; // Copy Constructor Not Implemented + ExecuteProcessObserver(ExecuteProcessObserver&&) = delete; // Move Constructor Not Implemented + ExecuteProcessObserver& operator=(const ExecuteProcessObserver&) = delete; // Copy Assignment Not Implemented + ExecuteProcessObserver& operator=(ExecuteProcessObserver&&) = delete; // Move Assignment Not Implemented }; #include "ExecuteProcessTest.moc" +/** + * @brief The ExecuteProcessTest class + */ class ExecuteProcessTest { @@ -131,11 +162,11 @@ class ExecuteProcessTest ExecuteProcess::Pointer filter = ExecuteProcess::New(); ExecuteProcessObserver obs; - QObject::connect(filter.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), &obs, SLOT(processPipelineMessage(const PipelineMessage&))); + QObject::connect(filter.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); filter->setArguments(QObject::tr("%1 -query QMAKE_VERSION").arg(UnitTest::ExecuteProcessTest::QMakeLocation)); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0) QString stdOutput = obs.getStdOutput(); #ifdef Q_OS_WIN stdOutput.remove('\r'); @@ -153,14 +184,14 @@ class ExecuteProcessTest // ExecuteProcess::Pointer filter = ExecuteProcess::New(); // ExecuteProcessObserver obs; - // QObject::connect(filter.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), &obs, SLOT(processPipelineMessage(const PipelineMessage&))); + // QObject::connect(filter.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); // filter->setArguments(QObject::tr("%1 -version").arg(UnitTest::ExecuteProcessTest::CMakeLocation)); // filter->execute(); // QString stdOutput = obs.getStdOutput(); // stdOutput.remove('\r'); // stdOutput.remove('\n'); - // DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0) + // DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0) // QString versionString = UnitTest::ExecuteProcessTest::CMakeVersionString; // versionString.remove('\r'); // versionString.remove('\n'); @@ -171,14 +202,14 @@ class ExecuteProcessTest ExecuteProcess::Pointer filter = ExecuteProcess::New(); ExecuteProcessObserver obs; - QObject::connect(filter.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), &obs, SLOT(processPipelineMessage(const PipelineMessage&))); + QObject::connect(filter.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); filter->setArguments("sdhsdrtfn"); filter->execute(); QString stdOutput = obs.getStdOutput(); stdOutput.remove('\r'); stdOutput.remove('\n'); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -4005) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -4005) } return EXIT_SUCCESS; @@ -196,7 +227,9 @@ class ExecuteProcessTest DREAM3D_REGISTER_TEST(TestExecuteProcess()) } -private: - ExecuteProcessTest(const ExecuteProcessTest&); // Copy Constructor Not Implemented - void operator=(const ExecuteProcessTest&); // Move assignment Not Implemented +public: + ExecuteProcessTest(const ExecuteProcessTest&) = delete; // Copy Constructor Not Implemented + ExecuteProcessTest(ExecuteProcessTest&&) = delete; // Move Constructor Not Implemented + ExecuteProcessTest& operator=(const ExecuteProcessTest&) = delete; // Copy Assignment Not Implemented + ExecuteProcessTest& operator=(ExecuteProcessTest&&) = delete; // Move Assignment Not Implemented }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExportDataTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExportDataTest.cpp new file mode 100644 index 0000000000..7870e7511d --- /dev/null +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExportDataTest.cpp @@ -0,0 +1,316 @@ +/* ============================================================================ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/CoreFilters/DataContainerReader.h" +#include "SIMPLib/CoreFilters/DataContainerWriter.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" +#include "SIMPLib/Filtering/FilterFactory.hpp" +#include "SIMPLib/Filtering/FilterManager.h" +#include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Plugin/ISIMPLibPlugin.h" +#include "SIMPLib/Plugin/SIMPLibPluginLoader.h" + +#include "SIMPLib/Testing/UnitTestSupport.hpp" + +#include "SIMPLib/Testing/SIMPLTestFileLocations.h" + +class ExportDataTest +{ +public: + ExportDataTest() = default; + virtual ~ExportDataTest() = default; + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void RemoveTestFiles() + { +#if REMOVE_TEST_FILES + QFile::remove(UnitTest::ExportDataTest::TestTempDir + QDir::separator() + "ExportTest.dream3d"); + QFile::remove(UnitTest::ExportDataTest::TestTempDir + QDir::separator() + "ExportTest.xdmf"); + QFile::remove(UnitTest::ExportDataTest::TestTempDir + QDir::separator() + "ConfidenceIndex.txt"); + QFile::remove(UnitTest::ExportDataTest::TestTempDir + QDir::separator() + "Phases.txt"); + QFile::remove(UnitTest::ExportDataTest::TestTempDir + QDir::separator() + "ThresholdArray.txt"); +#endif + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + int TestFilterAvailability() + { + // Now instantiate the WriteASCIIData Filter from the FilterManager + QString filtName = "WriteASCIIData"; + FilterManager* fm = FilterManager::Instance(); + IFilterFactory::Pointer filterFactory = fm->getFactoryFromClassName(filtName); + if(nullptr == filterFactory.get()) + { + std::stringstream ss; + ss << "The ExportDataTest Requires the use of the " << filtName.toStdString() << " filter which is found in the IO Plugin"; + DREAM3D_TEST_THROW_EXCEPTION(ss.str()) + } + return EXIT_SUCCESS; + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + int TestExportDataWriter() + { + DataContainerArray::Pointer dca = DataContainerArray::New(); + + // A DataContainer that mimics some real data + DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); + dca->addOrReplaceDataContainer(m); + + AttributeMatrix::Pointer attrMatrix = AttributeMatrix::New(std::vector(1, 20), SIMPL::Defaults::AttributeMatrixName, AttributeMatrix::Type::Generic); + m->addOrReplaceAttributeMatrix(attrMatrix); + + AttributeMatrix::Pointer attrMatrix2 = AttributeMatrix::New(std::vector(1, 20), SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Cell); + m->addOrReplaceAttributeMatrix(attrMatrix2); + int size = 20; + + { + Int32ArrayType::Pointer intArray = Int32ArrayType::CreateArray(size, SIMPL::CellData::CellPhases, true); + for(int i = 0; i < size; ++i) // create an array with values 20 to 39 + { + intArray->setValue(i, i + 20); + } + attrMatrix->insertOrAssign(intArray); + } + { + Int32ArrayType::Pointer intArray = Int32ArrayType::CreateArray(size, SIMPL::CellData::ConfidenceIndexNoSpace, true); + for(int i = 0; i < size; ++i) // create an array with values 20 to 39 + { + intArray->setValue(i, i + 20); + } + attrMatrix->insertOrAssign(intArray); + } + { + BoolArrayType::Pointer boolArray = BoolArrayType::CreateArray(size, SIMPL::GeneralData::ThresholdArray, true); + for(int i = 0; i < size; ++i) // create an bool array with true and false values + { + if(i % 2 == 0) + { + boolArray->setValue(i, false); + } + else + { + boolArray->setValue(i, true); + } + } + attrMatrix->insertOrAssign(boolArray); + } + { + Int32ArrayType::Pointer intArray = Int32ArrayType::CreateArray(size, SIMPL::CellData::ConfidenceIndexNoSpace, true); + for(int i = 0; i < size; ++i) // create an array with values 20 to 39 + { + intArray->setValue(i, i + 20); + } + attrMatrix2->insertOrAssign(intArray); + } + + Observer obs; + // Send progress messages from PipelineBuilder to this object for display + DataContainerWriter::Pointer writer = DataContainerWriter::New(); + writer->setDataContainerArray(dca); + QString exportArrayFile = UnitTest::ExportDataTest::TestTempDir + QDir::separator() + "ExportTest.dream3d"; + writer->setOutputFile(exportArrayFile); + + // Since we are NOT using the Pipeline Object to execute the filter but instead we are directly executing the filter + // and we want to know about any error/warning/progress messages we need to connect the filter to our Observer object + // manually. Normally the Pipeline Object would do this for us. We are NOT using a Pipeline Object because using the + // Pipeline Object would over write the DataContainer Array that we have created with a blank one thus defeating the + // entire purpose of the test. + QObject::connect(writer.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); + + writer->execute(); + int err = writer->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0); + + // Now instantiate the EnsembleInfoReader Filter from the FilterManager + QString filtName = "WriteASCIIData"; + FilterManager* fm = FilterManager::Instance(); + IFilterFactory::Pointer filterFactory = fm->getFactoryFromClassName(filtName); + if(nullptr != filterFactory.get()) + { + // If we get this far, the Factory is good so creating the filter should not fail unless something has + // horribly gone wrong in which case the system is going to come down quickly after this. + AbstractFilter::Pointer filter = filterFactory->create(); + + QVariant var; + int err = 0; + bool propWasSet; + filter->setDataContainerArray(dca); + + var.setValue(2); + propWasSet = filter->setProperty("Delimiter", var); // delimiter is a space + DREAM3D_REQUIRE_EQUAL(propWasSet, true) + + var.setValue(10); + propWasSet = filter->setProperty("MaxValPerLine", var); // 10 array elements per line + DREAM3D_REQUIRE_EQUAL(propWasSet, true) + + var.setValue(UnitTest::ExportDataTest::TestTempDir); + propWasSet = filter->setProperty("OutputPath", var); // output file to write array + DREAM3D_REQUIRE_EQUAL(propWasSet, true) + + DataArrayPath path1 = DataArrayPath(SIMPL::Defaults::DataContainerName, SIMPL::Defaults::AttributeMatrixName, SIMPL::CellData::CellPhases); + + DataArrayPath path2 = DataArrayPath(SIMPL::Defaults::DataContainerName, SIMPL::Defaults::AttributeMatrixName, SIMPL::CellData::ConfidenceIndexNoSpace); + + DataArrayPath path4 = DataArrayPath(SIMPL::Defaults::DataContainerName, SIMPL::Defaults::AttributeMatrixName, SIMPL::GeneralData::ThresholdArray); + + std::vector vector; + vector.push_back(path1); + vector.push_back(path2); + vector.push_back(path4); + + var.setValue(vector); + propWasSet = filter->setProperty("SelectedDataArrayPaths", var); // arrays just created above + DREAM3D_REQUIRE_EQUAL(propWasSet, true) + + filter->execute(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0); + + DataArrayPath path3 = DataArrayPath(SIMPL::Defaults::DataContainerName, SIMPL::Defaults::CellAttributeMatrixName, SIMPL::CellData::ConfidenceIndexNoSpace); + + vector.push_back(path3); + + var.setValue(vector); + propWasSet = filter->setProperty("SelectedDataArrayPaths", var); // arrays just created above + DREAM3D_REQUIRE_EQUAL(propWasSet, true) + + filter->execute(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, -11008); + } + else + { + QString ss = QObject::tr("ExportDataTest Error creating filter '%1'. Filter was not created/executed. Please notify the developers.").arg(filtName); + DREAM3D_REQUIRE_EQUAL(0, 1) + } + return EXIT_SUCCESS; + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + int TestExportDataReader() + { + { + int num = 0; + FILE* f = nullptr; + QString exportArrayFile = UnitTest::ExportDataTest::TestTempDir + QDir::separator() + SIMPL::CellData::CellPhases + ".txt"; + f = std::fopen(exportArrayFile.toLatin1().data(), "r"); // open file created from array + DREAM3D_REQUIRE_VALID_POINTER(f) + + for(int i = 0; i < 20; i++) // compare file to what was written in array + { + int32_t fieldsRead = std::fscanf(f, "%d,", &num); + DREAM3D_REQUIRE_EQUAL(fieldsRead, 1) + if(i + 20 != num) + { + DREAM3D_REQUIRE_EQUAL(0, -3) + } + } + fclose(f); + } + { + int num = 0; + FILE* f = nullptr; + QString exportArrayFile = UnitTest::ExportDataTest::TestTempDir + QDir::separator() + SIMPL::CellData::ConfidenceIndexNoSpace + ".txt"; + f = std::fopen(exportArrayFile.toLatin1().data(), "r"); // open file created from array + DREAM3D_REQUIRE_VALID_POINTER(f) + + for(int i = 0; i < 20; i++) // compare file to what was written in array + { + int32_t fieldsRead = std::fscanf(f, "%d,", &num); + DREAM3D_REQUIRE_EQUAL(fieldsRead, 1) + if(i + 20 != num) + { + DREAM3D_REQUIRE_EQUAL(0, -3) + } + } + fclose(f); + } + { + int num = 0; + FILE* f = nullptr; + QString exportArrayFile = UnitTest::ExportDataTest::TestTempDir + QDir::separator() + SIMPL::GeneralData::ThresholdArray + ".txt"; + f = std::fopen(exportArrayFile.toLatin1().data(), "r"); // open file created from array + DREAM3D_REQUIRE_VALID_POINTER(f) + for(int i = 0; i < 20; i++) // compare file to what was written in bool array + { + int32_t fieldsRead = std::fscanf(f, "%d,", &num); + DREAM3D_REQUIRE_EQUAL(fieldsRead, 1) + if((i % 2 == 0 && num == 1) || (i % 2 != 0 && num == 0)) + { + DREAM3D_REQUIRE_EQUAL(0, -3) + } + } + fclose(f); + } + return EXIT_SUCCESS; + } + + /** + * @brief + */ + void operator()() + { + int err = EXIT_SUCCESS; + std::cout << "<===== Start ExportDataTest " << std::endl; + DREAM3D_REGISTER_TEST(TestFilterAvailability()); + + DREAM3D_REGISTER_TEST(TestExportDataWriter()) + DREAM3D_REGISTER_TEST(TestExportDataReader()) + + DREAM3D_REGISTER_TEST(RemoveTestFiles()) + } + +private: + ExportDataTest(const ExportDataTest&); // Copy Constructor Not Implemented + void operator=(const ExportDataTest&); // Move assignment Not Implemented +}; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractAttributeArraysFromGeometryTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractAttributeArraysFromGeometryTest.cpp index 3fe8f496b0..070a9a1252 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractAttributeArraysFromGeometryTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractAttributeArraysFromGeometryTest.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,23 +35,20 @@ #pragma once -#include -#include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" - -#include "SIMPLib/Filtering/QMetaObjectUtilities.h" - -#include "SIMPLib/Testing/SIMPLTestFileLocations.h" -#include "SIMPLib/Testing/UnitTestSupport.hpp" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Geometry/EdgeGeom.h" #include "SIMPLib/Geometry/HexahedralGeom.h" #include "SIMPLib/Geometry/QuadGeom.h" @@ -59,8 +56,8 @@ #include "SIMPLib/Geometry/TetrahedralGeom.h" #include "SIMPLib/Geometry/TriangleGeom.h" #include "SIMPLib/Geometry/VertexGeom.h" - -#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Testing/SIMPLTestFileLocations.h" +#include "SIMPLib/Testing/UnitTestSupport.hpp" class ExtractAttributeArraysFromGeometryTest { @@ -93,9 +90,10 @@ class ExtractAttributeArraysFromGeometryTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template std::shared_ptr> createDataArray(const QString& daName, const std::vector>& data, const QVector& tupleDims, const QVector& cDims) + template + std::shared_ptr> createDataArray(const QString& daName, const std::vector>& data, const std::vector& tupleDims, const std::vector& cDims) { - typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName); + typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName, true); for(int i = 0; i < da->getNumberOfTuples(); i++) { da->setTuple(i, data[i]); @@ -106,7 +104,8 @@ class ExtractAttributeArraysFromGeometryTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void checkDataArray(std::shared_ptr> originalData, std::shared_ptr> newData) + template + void checkDataArray(std::shared_ptr> originalData, std::shared_ptr> newData) { DREAM3D_REQUIRE_EQUAL(originalData->getSize(), newData->getSize()) @@ -135,28 +134,28 @@ class ExtractAttributeArraysFromGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer boundsAM = AttributeMatrix::New(m_Dims4, SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Cell); - dc->addAttributeMatrix(SIMPL::Defaults::CellAttributeMatrixName, boundsAM); + dc->addOrReplaceAttributeMatrix(boundsAM); // Create Geometry - DataArray::Pointer daXBounds = DataArray::CreateArray(m_Dims4, m_Dims1, "X"); + DataArray::Pointer daXBounds = DataArray::CreateArray(m_Dims4, m_Dims1, "X", true); for(size_t i = 0; i < daXBounds->getSize(); i++) { daXBounds->setValue(i, i); } - DataArray::Pointer daYBounds = DataArray::CreateArray(m_Dims4, m_Dims1, "Y"); + DataArray::Pointer daYBounds = DataArray::CreateArray(m_Dims4, m_Dims1, "Y", true); for(size_t i = 0; i < daYBounds->getSize(); i++) { daYBounds->setValue(i, i); } - DataArray::Pointer daZBounds = DataArray::CreateArray(m_Dims4, m_Dims1, "Z"); + DataArray::Pointer daZBounds = DataArray::CreateArray(m_Dims4, m_Dims1, "Z", true); for(size_t i = 0; i < daZBounds->getSize(); i++) { daZBounds->setValue(i, i); @@ -183,7 +182,7 @@ class ExtractAttributeArraysFromGeometryTest QVariant var; DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); bool propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -205,7 +204,7 @@ class ExtractAttributeArraysFromGeometryTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results @@ -243,12 +242,12 @@ class ExtractAttributeArraysFromGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(m_Dims2, SIMPL::Defaults::VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(SIMPL::Defaults::VertexAttributeMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); // Create Geometry @@ -273,7 +272,7 @@ class ExtractAttributeArraysFromGeometryTest QVariant var; DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); bool propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -285,7 +284,7 @@ class ExtractAttributeArraysFromGeometryTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results @@ -315,24 +314,24 @@ class ExtractAttributeArraysFromGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(m_Dims2, SIMPL::Defaults::VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(SIMPL::Defaults::VertexAttributeMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); AttributeMatrix::Pointer elementAM = AttributeMatrix::New(m_Dims1, SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Edge); - dc->addAttributeMatrix(SIMPL::Defaults::CellAttributeMatrixName, elementAM); + dc->addOrReplaceAttributeMatrix(elementAM); // Create Geometry std::vector> vertices = {{1.0, 1.0, 0.0}, {3.0, 1.0, 0.0}}; - std::vector> elements = {{0, 1}}; + std::vector> elements = {{0, 1}}; DataArray::Pointer daVert = createDataArray("Vertices", vertices, m_Dims2, m_Dims3); - DataArray::Pointer daList = createDataArray("List", elements, m_Dims1, m_Dims2); + SharedEdgeList::Pointer daList = createDataArray("List", elements, m_Dims1, m_Dims2); EdgeGeom::Pointer geom = EdgeGeom::CreateGeometry(daList, daVert, SIMPL::Geometry::EdgeGeometry); @@ -351,7 +350,7 @@ class ExtractAttributeArraysFromGeometryTest QVariant var; DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); bool propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -368,7 +367,7 @@ class ExtractAttributeArraysFromGeometryTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results @@ -378,13 +377,13 @@ class ExtractAttributeArraysFromGeometryTest DREAM3D_REQUIRE_EQUAL(elementNames.contains(k_ElementListDAName), true) FloatArrayType::Pointer originalVertices = geom->getVertices(); - Int64ArrayType::Pointer originalConnectivity = geom->getEdges(); + SharedEdgeList::Pointer originalConnectivity = geom->getEdges(); FloatArrayType::Pointer newVertices = vertexAM->getAttributeArrayAs(k_VerticesDAName); - Int64ArrayType::Pointer newConnectivity = elementAM->getAttributeArrayAs(k_ElementListDAName); + SharedEdgeList::Pointer newConnectivity = elementAM->getAttributeArrayAs(k_ElementListDAName); checkDataArray(originalVertices, newVertices); - checkDataArray(originalConnectivity, newConnectivity); + checkDataArray(originalConnectivity, newConnectivity); } // ----------------------------------------------------------------------------- @@ -403,24 +402,24 @@ class ExtractAttributeArraysFromGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(m_Dims3, SIMPL::Defaults::VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(SIMPL::Defaults::VertexAttributeMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); AttributeMatrix::Pointer elementAM = AttributeMatrix::New(m_Dims1, SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Face); - dc->addAttributeMatrix(SIMPL::Defaults::CellAttributeMatrixName, elementAM); + dc->addOrReplaceAttributeMatrix(elementAM); // Create Geometry std::vector> vertices = {{1.0, 1.0, 0.0}, {3.0, 1.0, 0.0}, {2.0, 3.0, 0.0}}; - std::vector> elements = {{0, 1, 2}}; + std::vector> elements = {{0, 1, 2}}; DataArray::Pointer daVert = createDataArray("Vertices", vertices, m_Dims3, m_Dims3); - DataArray::Pointer daList = createDataArray("List", elements, m_Dims1, m_Dims3); + SharedTriList::Pointer daList = createDataArray("List", elements, m_Dims1, m_Dims3); TriangleGeom::Pointer geom = TriangleGeom::CreateGeometry(daList, daVert, SIMPL::Geometry::TriangleGeometry); @@ -439,7 +438,7 @@ class ExtractAttributeArraysFromGeometryTest QVariant var; DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); bool propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -456,7 +455,7 @@ class ExtractAttributeArraysFromGeometryTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results @@ -466,13 +465,13 @@ class ExtractAttributeArraysFromGeometryTest DREAM3D_REQUIRE_EQUAL(elementNames.contains(k_ElementListDAName), true) FloatArrayType::Pointer originalVertices = geom->getVertices(); - Int64ArrayType::Pointer originalConnectivity = geom->getTriangles(); + SharedTriList::Pointer originalConnectivity = geom->getTriangles(); FloatArrayType::Pointer newVertices = vertexAM->getAttributeArrayAs(k_VerticesDAName); - Int64ArrayType::Pointer newConnectivity = elementAM->getAttributeArrayAs(k_ElementListDAName); + SharedTriList::Pointer newConnectivity = elementAM->getAttributeArrayAs(k_ElementListDAName); checkDataArray(originalVertices, newVertices); - checkDataArray(originalConnectivity, newConnectivity); + checkDataArray(originalConnectivity, newConnectivity); } // ----------------------------------------------------------------------------- @@ -491,24 +490,24 @@ class ExtractAttributeArraysFromGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(m_Dims4, SIMPL::Defaults::VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(SIMPL::Defaults::VertexAttributeMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); AttributeMatrix::Pointer elementAM = AttributeMatrix::New(m_Dims1, SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Face); - dc->addAttributeMatrix(SIMPL::Defaults::CellAttributeMatrixName, elementAM); + dc->addOrReplaceAttributeMatrix(elementAM); // Create Geometry std::vector> vertices = {{1.0, 1.0, 0.0}, {3.0, 1.0, 0.0}, {2.0, 3.0, 0.0}, {2.0, 2.0, 0.0}}; - std::vector> elements = {{0, 1, 2, 3}}; + std::vector> elements = {{0, 1, 2, 3}}; DataArray::Pointer daVert = createDataArray("Vertices", vertices, m_Dims4, m_Dims3); - DataArray::Pointer daList = createDataArray("List", elements, m_Dims1, m_Dims4); + SharedQuadList::Pointer daList = createDataArray("List", elements, m_Dims1, m_Dims4); QuadGeom::Pointer geom = QuadGeom::CreateGeometry(daList, daVert, SIMPL::Geometry::QuadGeometry); @@ -527,7 +526,7 @@ class ExtractAttributeArraysFromGeometryTest QVariant var; DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); bool propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -544,7 +543,7 @@ class ExtractAttributeArraysFromGeometryTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results @@ -554,13 +553,13 @@ class ExtractAttributeArraysFromGeometryTest DREAM3D_REQUIRE_EQUAL(elementNames.contains(k_ElementListDAName), true) FloatArrayType::Pointer originalVertices = geom->getVertices(); - Int64ArrayType::Pointer originalConnectivity = geom->getQuads(); + SharedQuadList::Pointer originalConnectivity = geom->getQuads(); FloatArrayType::Pointer newVertices = vertexAM->getAttributeArrayAs(k_VerticesDAName); - Int64ArrayType::Pointer newConnectivity = elementAM->getAttributeArrayAs(k_ElementListDAName); + SharedQuadList::Pointer newConnectivity = elementAM->getAttributeArrayAs(k_ElementListDAName); checkDataArray(originalVertices, newVertices); - checkDataArray(originalConnectivity, newConnectivity); + checkDataArray(originalConnectivity, newConnectivity); } // ----------------------------------------------------------------------------- @@ -579,24 +578,24 @@ class ExtractAttributeArraysFromGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(m_Dims4, SIMPL::Defaults::VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(SIMPL::Defaults::VertexAttributeMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); AttributeMatrix::Pointer elementAM = AttributeMatrix::New(m_Dims1, SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Cell); - dc->addAttributeMatrix(SIMPL::Defaults::CellAttributeMatrixName, elementAM); + dc->addOrReplaceAttributeMatrix(elementAM); // Create Geometry std::vector> vertices = {{1.0f, 1.0f, 1.55f}, {3.0f, 1.0f, 1.55f}, {2.0f, 3.0f, 1.55f}, {2.0f, 2.0f, 3.55f}}; - std::vector> elements = {{0, 1, 2, 3}}; + std::vector> elements = {{0, 1, 2, 3}}; DataArray::Pointer daVert = createDataArray("Vertices", vertices, m_Dims4, m_Dims3); - DataArray::Pointer daList = createDataArray("List", elements, m_Dims1, m_Dims4); + SharedTetList::Pointer daList = createDataArray("List", elements, m_Dims1, m_Dims4); TetrahedralGeom::Pointer geom = TetrahedralGeom::CreateGeometry(daList, daVert, SIMPL::Geometry::TetrahedralGeometry); @@ -615,7 +614,7 @@ class ExtractAttributeArraysFromGeometryTest QVariant var; DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); bool propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -632,7 +631,7 @@ class ExtractAttributeArraysFromGeometryTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results @@ -642,13 +641,13 @@ class ExtractAttributeArraysFromGeometryTest DREAM3D_REQUIRE_EQUAL(elementNames.contains(k_ElementListDAName), true) FloatArrayType::Pointer originalVertices = geom->getVertices(); - Int64ArrayType::Pointer originalConnectivity = geom->getTetrahedra(); + SharedTetList::Pointer originalConnectivity = geom->getTetrahedra(); FloatArrayType::Pointer newVertices = vertexAM->getAttributeArrayAs(k_VerticesDAName); - Int64ArrayType::Pointer newConnectivity = elementAM->getAttributeArrayAs(k_ElementListDAName); + SharedTetList::Pointer newConnectivity = elementAM->getAttributeArrayAs(k_ElementListDAName); checkDataArray(originalVertices, newVertices); - checkDataArray(originalConnectivity, newConnectivity); + checkDataArray(originalConnectivity, newConnectivity); } // ----------------------------------------------------------------------------- @@ -667,24 +666,25 @@ class ExtractAttributeArraysFromGeometryTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create AttributeMatrix AttributeMatrix::Pointer vertexAM = AttributeMatrix::New(m_Dims8, SIMPL::Defaults::VertexAttributeMatrixName, AttributeMatrix::Type::Vertex); - dc->addAttributeMatrix(SIMPL::Defaults::VertexAttributeMatrixName, vertexAM); + dc->addOrReplaceAttributeMatrix(vertexAM); AttributeMatrix::Pointer elementAM = AttributeMatrix::New(m_Dims1, SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Cell); - dc->addAttributeMatrix(SIMPL::Defaults::CellAttributeMatrixName, elementAM); + dc->addOrReplaceAttributeMatrix(elementAM); // Create Geometry - std::vector> vertices = {{1.0f, 1.0f, 1.55f}, {3.0f, 1.0f, 1.55f}, {2.0f, 3.0f, 1.55f}, {2.0f, 2.0f, 3.55f}, {2.5f, 1.0f, 1.55f}, {4.3f, 1.0f, 1.55f}, {5.1f, 3.0f, 1.55f}, {7.63f, 2.0f, 3.55f}}; + std::vector> vertices = {{1.0f, 1.0f, 1.55f}, {3.0f, 1.0f, 1.55f}, {2.0f, 3.0f, 1.55f}, {2.0f, 2.0f, 3.55f}, + {2.5f, 1.0f, 1.55f}, {4.3f, 1.0f, 1.55f}, {5.1f, 3.0f, 1.55f}, {7.63f, 2.0f, 3.55f}}; - std::vector> elements = {{0, 1, 2, 3, 4, 5, 6, 7}}; + std::vector> elements = {{0, 1, 2, 3, 4, 5, 6, 7}}; DataArray::Pointer daVert = createDataArray("Vertices", vertices, m_Dims8, m_Dims3); - DataArray::Pointer daList = createDataArray("List", elements, m_Dims1, m_Dims8); + SharedHexList::Pointer daList = createDataArray("List", elements, m_Dims1, m_Dims8); HexahedralGeom::Pointer geom = HexahedralGeom::CreateGeometry(daList, daVert, SIMPL::Geometry::HexahedralGeometry); @@ -703,7 +703,7 @@ class ExtractAttributeArraysFromGeometryTest QVariant var; DataArrayPath dap(k_DataContainerName); - var.setValue(k_DataContainerName); + var.setValue(dap); bool propWasSet = extractAttributeArraysFromGeometry->setProperty("DataContainerName", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -720,7 +720,7 @@ class ExtractAttributeArraysFromGeometryTest // Run Filter extractAttributeArraysFromGeometry->execute(); - DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(extractAttributeArraysFromGeometry->getErrorCode(), >=, 0); // Check Filter Results @@ -730,13 +730,13 @@ class ExtractAttributeArraysFromGeometryTest DREAM3D_REQUIRE_EQUAL(elementNames.contains(k_ElementListDAName), true) FloatArrayType::Pointer originalVertices = geom->getVertices(); - Int64ArrayType::Pointer originalConnectivity = geom->getHexahedra(); + SharedHexList::Pointer originalConnectivity = geom->getHexahedra(); FloatArrayType::Pointer newVertices = vertexAM->getAttributeArrayAs(k_VerticesDAName); - Int64ArrayType::Pointer newConnectivity = elementAM->getAttributeArrayAs(k_ElementListDAName); + SharedHexList::Pointer newConnectivity = elementAM->getAttributeArrayAs(k_ElementListDAName); checkDataArray(originalVertices, newVertices); - checkDataArray(originalConnectivity, newConnectivity); + checkDataArray(originalConnectivity, newConnectivity); } // ----------------------------------------------------------------------------- @@ -761,9 +761,9 @@ class ExtractAttributeArraysFromGeometryTest private: QString m_FilterName = QString("ExtractAttributeArraysFromGeometry"); - QVector m_Dims1 = {1}; - QVector m_Dims2 = {2}; - QVector m_Dims3 = {3}; - QVector m_Dims4 = {4}; - QVector m_Dims8 = {8}; + std::vector m_Dims1 = {1}; + std::vector m_Dims2 = {2}; + std::vector m_Dims3 = {3}; + std::vector m_Dims4 = {4}; + std::vector m_Dims8 = {8}; }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractComponentAsArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractComponentAsArrayTest.cpp index 8a7f3a846e..789bf0282c 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractComponentAsArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractComponentAsArrayTest.cpp @@ -1,56 +1,52 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "SIMPLib/CoreFilters/ExtractComponentAsArray.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/ExtractComponentAsArray.h" - class ExtractComponentAsArrayTest { public: @@ -66,21 +62,21 @@ class ExtractComponentAsArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); - QVector dims; + std::vector dims; dims.push_back(2); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); - QVector cdims; + std::vector cdims; cdims.push_back(2); - DataArray::Pointer da = DataArray::CreateArray(2, cdims, "DataArray"); + DataArray::Pointer da = DataArray::CreateArray(2, cdims, "DataArray", true); da->setComponent(0, 0, 1); da->setComponent(0, 1, 2); da->setComponent(1, 0, 3); da->setComponent(1, 1, 4); - am->addAttributeArray("DataArray", da); + am->insertOrAssign(da); return dca; } @@ -158,7 +154,7 @@ class ExtractComponentAsArrayTest setValues(filter, "DataArray", 1, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); DataContainerArray::Pointer dca = filter->getDataContainerArray(); DataContainer::Pointer dc = dca->getDataContainer("DataContainer"); @@ -179,11 +175,11 @@ class ExtractComponentAsArrayTest setValues(filter, "DataArray", 2, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11004); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11004); setValues(filter, "DataArray", -1, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11005); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11005); } // ----------------------------------------------------------------------------- @@ -198,7 +194,7 @@ class ExtractComponentAsArrayTest setValues(filter, "DataArray1", 1, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -90002); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -90002); } // ----------------------------------------------------------------------------- @@ -213,7 +209,7 @@ class ExtractComponentAsArrayTest setValues(filter, "DataArray", 1, newArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -10002); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -10002); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractVertexGeometryTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractVertexGeometryTest.cpp index 096bee7689..5bd886c2b1 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractVertexGeometryTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ExtractVertexGeometryTest.cpp @@ -6,10 +6,10 @@ #include #include -#include #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/CoreFilters/ExtractVertexGeometry.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" @@ -20,12 +20,11 @@ #include "SIMPLib/Geometry/VertexGeom.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/ExtractVertexGeometry.h" - // This header is auto-generated during cmake time +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" class ExtractVertexGeometryTest @@ -71,14 +70,14 @@ class ExtractVertexGeometryTest DataContainerArray::Pointer dca = DataContainerArray::New(); // Create the DataContainer for the ImageGeometry - DataContainer::Pointer imageGeomDC = DataContainer::New(k_ImageGeomDataContainerName); - dca->addDataContainer(imageGeomDC); + DataContainer::Pointer imageGeomDC = DataContainer::New(k_ImageGeomDataContainerPath); + dca->addOrReplaceDataContainer(imageGeomDC); DataContainer::Pointer badDataContainer = DataContainer::New(k_BadDataContainerName); - dca->addDataContainer(badDataContainer); + dca->addOrReplaceDataContainer(badDataContainer); DataContainer::Pointer wrongGeomDataContainer = DataContainer::New(k_WrongGeomDataContainerName); - dca->addDataContainer(wrongGeomDataContainer); + dca->addOrReplaceDataContainer(wrongGeomDataContainer); TriangleGeom::Pointer triangleGeom = TriangleGeom::New(); wrongGeomDataContainer->setGeometry(triangleGeom); @@ -90,26 +89,26 @@ class ExtractVertexGeometryTest imageGeomDC->setGeometry(imageGeom); // Create the Cell AttributeMatrix - AttributeMatrix::Pointer cellAttrMat = AttributeMatrix::Create(dims, k_CellAttrMatName, AttributeMatrix::Type::Cell); - imageGeomDC->addAttributeMatrix(cellAttrMat->getName(), cellAttrMat); + AttributeMatrix::Pointer cellAttrMat = AttributeMatrix::New(dims, k_CellAttrMatName, AttributeMatrix::Type::Cell); + imageGeomDC->addOrReplaceAttributeMatrix(cellAttrMat); // Create a cell attribute array FloatArrayType::Pointer f32Data = FloatArrayType::CreateArray(cellCount, k_FloatArrayName, true); f32Data->initializeWithValue(45.243f); - cellAttrMat->addAttributeArray(f32Data->getName(), f32Data); + cellAttrMat->insertOrAssign(f32Data); // Create a Feature AttributeMatrix with different dimensions dims[0] = 1; dims[1] = 2; dims[2] = 3; - AttributeMatrix::Pointer featureAttrMat = AttributeMatrix::Create(dims, k_FeatureAttrMatName, AttributeMatrix::Type::CellFeature); - imageGeomDC->addAttributeMatrix(featureAttrMat->getName(), featureAttrMat); + AttributeMatrix::Pointer featureAttrMat = AttributeMatrix::New(dims, k_FeatureAttrMatName, AttributeMatrix::Type::CellFeature); + imageGeomDC->addOrReplaceAttributeMatrix(featureAttrMat); // Create a feature attribute array cellCount = std::accumulate(dims.begin(), dims.end(), static_cast(1), std::multiplies()); Int32ArrayType::Pointer i32Data = Int32ArrayType::CreateArray(cellCount, k_FeatureArrayName, true); i32Data->initializeWithValue(1); - featureAttrMat->addAttributeArray(i32Data->getName(), i32Data); + featureAttrMat->insertOrAssign(i32Data); return dca; } @@ -128,14 +127,14 @@ class ExtractVertexGeometryTest // extVertGeomFilter->setArrayHandling(-10); extVertGeomFilter->preflight(); - int32_t err = extVertGeomFilter->getErrorCondition(); + int32_t err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2002) dca = createDataContainerArray(); extVertGeomFilter->setDataContainerArray(dca); extVertGeomFilter->setArrayHandling(10); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2003) // Empty SelectedDataContainerName @@ -143,58 +142,58 @@ class ExtractVertexGeometryTest extVertGeomFilter->setDataContainerArray(dca); extVertGeomFilter->setArrayHandling(k_MoveArrays); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2004) // Empty VertexDataContainerName dca = createDataContainerArray(); extVertGeomFilter->setDataContainerArray(dca); - extVertGeomFilter->setSelectedDataContainerName(k_ImageGeomDataContainerName); - extVertGeomFilter->setVertexDataContainerName(QString("")); + extVertGeomFilter->setSelectedDataContainerName(k_ImageGeomDataContainerPath); + extVertGeomFilter->setVertexDataContainerName(DataArrayPath("", "", "")); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2006) // Set the Vertex Data Container to an existing DataContainer dca = createDataContainerArray(); extVertGeomFilter->setDataContainerArray(dca); - extVertGeomFilter->setVertexDataContainerName(k_ImageGeomDataContainerName); + extVertGeomFilter->setVertexDataContainerName(k_ImageGeomDataContainerPath); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2007) // Set the Vertex Data Container to an existing DataContainer // Set a DataContainer that does not have a Geometry dca = createDataContainerArray(); extVertGeomFilter->setDataContainerArray(dca); - extVertGeomFilter->setVertexDataContainerName(k_VertexDataContainerName); + extVertGeomFilter->setVertexDataContainerName(k_VertexDataContainerPath); extVertGeomFilter->setSelectedDataContainerName(k_BadDataContainerName); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2008) // Set the Vertex Data Container to an existing DataContainer // Set a DataContainer that does not have the proper geometry dca = createDataContainerArray(); extVertGeomFilter->setDataContainerArray(dca); - extVertGeomFilter->setVertexDataContainerName(k_VertexDataContainerName); + extVertGeomFilter->setVertexDataContainerName(k_VertexDataContainerPath); extVertGeomFilter->setSelectedDataContainerName(k_WrongGeomDataContainerName); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2010) // Set the Vertex Data Container to an existing DataContainer dca = createDataContainerArray(); extVertGeomFilter->setDataContainerArray(dca); - extVertGeomFilter->setVertexDataContainerName(k_VertexDataContainerName); - extVertGeomFilter->setSelectedDataContainerName(k_ImageGeomDataContainerName); + extVertGeomFilter->setVertexDataContainerName(k_VertexDataContainerPath); + extVertGeomFilter->setSelectedDataContainerName(k_ImageGeomDataContainerPath); // Set an incorrect AttributeMatrix/DataArray Path - QVector includePaths; + std::vector includePaths; DataArrayPath dap(k_ImageGeomDataContainerName, k_FeatureAttrMatName, k_FeatureArrayName); includePaths.push_back(dap); extVertGeomFilter->setIncludedDataArrayPaths(includePaths); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -2009) // Set the correct paths. @@ -204,14 +203,14 @@ class ExtractVertexGeometryTest includePaths[0] = dap; extVertGeomFilter->setIncludedDataArrayPaths(includePaths); extVertGeomFilter->preflight(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) // The preflight should be passing at this point so execute the filter dca = createDataContainerArray(); extVertGeomFilter->setDataContainerArray(dca); extVertGeomFilter->execute(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) dap.update(k_ImageGeomDataContainerName, k_CellAttrMatName, k_FloatArrayName); @@ -227,7 +226,7 @@ class ExtractVertexGeometryTest extVertGeomFilter->setDataContainerArray(dca); extVertGeomFilter->setArrayHandling(k_CopyArrays); extVertGeomFilter->execute(); - err = extVertGeomFilter->getErrorCondition(); + err = extVertGeomFilter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) dap.update(k_ImageGeomDataContainerName, k_CellAttrMatName, k_FloatArrayName); @@ -253,12 +252,14 @@ class ExtractVertexGeometryTest } private: + const DataArrayPath k_ImageGeomDataContainerPath = DataArrayPath("ImageGeomDataContainer", "", ""); const QString k_ImageGeomDataContainerName = QString("ImageGeomDataContainer"); const QString k_CellAttrMatName = QString("CellData"); const QString k_FloatArrayName = QString("FloatArray"); const QString k_VertexDataContainerName = QString("VertexDataContainer"); - const QString k_BadDataContainerName = QString("BadDataContainer"); - const QString k_WrongGeomDataContainerName = QString("WrongGeomDataContainer"); + const DataArrayPath k_VertexDataContainerPath = DataArrayPath("VertexDataContainer", "", ""); + const DataArrayPath k_BadDataContainerName = DataArrayPath("BadDataContainer", "", ""); + const DataArrayPath k_WrongGeomDataContainerName = DataArrayPath("WrongGeomDataContainer", "", ""); const QString k_FeatureAttrMatName = QString("Feature Attr Mat"); const QString k_FeatureArrayName = QString("featureData"); }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/FeatureDataCSVWriterTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/FeatureDataCSVWriterTest.cpp index f8cc2bbc0c..21d5148f73 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/FeatureDataCSVWriterTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/FeatureDataCSVWriterTest.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,25 +35,23 @@ #pragma once -#include #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Geometry/ImageGeom.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" - -#include "SIMPLib/Filtering/QMetaObjectUtilities.h" - #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/Common/Constants.h" - class FeatureDataCSVWriterTest { @@ -96,7 +94,8 @@ class FeatureDataCSVWriterTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template T convertQByteArray(const QByteArray& value) + template + T convertQByteArray(const QByteArray& value) { if(typeid(T) == typeid(float)) { @@ -132,7 +131,8 @@ class FeatureDataCSVWriterTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void checkDataList(AttributeMatrix::Pointer am, const QString& daName, const QList& tokens, int featureID, int column) + template + void checkDataList(AttributeMatrix::Pointer am, const QString& daName, const QList& tokens, int featureID, int column) { typename DataArray::Pointer dataPtr = am->getAttributeArrayAs>(daName); @@ -181,7 +181,7 @@ class FeatureDataCSVWriterTest std::vector nlList; int originalNumColumns = 0; - NeighborList::Pointer neighborlistPtr = NeighborList::CreateArray(0, "_INTERNAL_USE_ONLY_JunkNeighborList", false); + NeighborList::Pointer neighborlistPtr = NeighborList::CreateArray(0, std::string("_INTERNAL_USE_ONLY_JunkNeighborList"), false); for(int i = 0; i < daNames.size(); i++) { @@ -275,8 +275,8 @@ class FeatureDataCSVWriterTest // The data array added last in code will be the first printed and first in daList - checkDataList(am, daList[0]->getName(), tokens, i, 1); - checkDataList(am, daList[1]->getName(), tokens, i, 1 + daList[0]->getNumberOfComponents()); + checkDataList(am, daList[0]->getName(), tokens, i, 1); + checkDataList(am, daList[1]->getName(), tokens, i, 1 + daList[0]->getNumberOfComponents()); } if(writeNeighborListData) @@ -352,10 +352,10 @@ class FeatureDataCSVWriterTest // Run filter featureDataCSVWriter->preflight(); - DREAM3D_REQUIRED(featureDataCSVWriter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(featureDataCSVWriter->getErrorCode(), >=, 0); featureDataCSVWriter->execute(); - DREAM3D_REQUIRED(featureDataCSVWriter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(featureDataCSVWriter->getErrorCode(), >=, 0); checkFilter(am, delimiterChoice, writeNumFeaturesLine, writeNeighborListData); } @@ -379,10 +379,10 @@ class FeatureDataCSVWriterTest static const size_t yDim(2); static const size_t zDim(3); - QVector tupleDims = {xDim, yDim, zDim}; - QVector cDims = {2}; - QVector cDimsFloat = {3}; - QVector cDimsNeighbor = {1}; + std::vector tupleDims = {xDim, yDim, zDim}; + std::vector cDims = {2}; + std::vector cDimsFloat = {3}; + std::vector cDimsNeighbor = {1}; // Create DataContainerArray @@ -391,31 +391,31 @@ class FeatureDataCSVWriterTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); // Create Image Geometry ImageGeom::Pointer ig = ImageGeom::New(); - ig->setDimensions(xDim, yDim, zDim); + ig->setDimensions(SizeVec3Type(xDim, yDim, zDim)); dc->setGeometry(ig); // Create AttributeMatrix AttributeMatrix::Pointer am = AttributeMatrix::New(tupleDims, k_AttributeMatrixName, AttributeMatrix::Type::CellFeature); - dc->addAttributeMatrix(k_AttributeMatrixName, am); + dc->addOrReplaceAttributeMatrix(am); // Create DataArrayInt (add in under checkFilter) - DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, k_DataArrayIntName); + DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, k_DataArrayIntName, true); for(size_t i = 0; i < da->getSize(); i++) { da->setValue(i, i); } - am->addAttributeArray(k_DataArrayIntName, da); + am->insertOrAssign(da); // Create DataArrayFloat - DataArray::Pointer daFloat = DataArray::CreateArray(tupleDims, cDimsFloat, k_DataArrayFloatName); + DataArray::Pointer daFloat = DataArray::CreateArray(tupleDims, cDimsFloat, k_DataArrayFloatName, true); for(size_t i = 0; i < daFloat->getSize(); i++) { if(i % 2 == 0) @@ -427,26 +427,26 @@ class FeatureDataCSVWriterTest daFloat->setValue(i, static_cast(i) * -0.1); } } - am->addAttributeArray(k_DataArrayFloatName, daFloat); + am->insertOrAssign(daFloat); // Create NeighborLists (must be int32_t) - NeighborList::Pointer nl = NeighborList::CreateArray(tupleDims, cDimsNeighbor, k_NeighborListName); + NeighborList::Pointer nl = NeighborList::CreateArray(tupleDims, cDimsNeighbor, k_NeighborListName, true); for(size_t i = 0; i < nl->getNumberOfTuples(); i++) { nl->addEntry(i, i); nl->addEntry(i, i * 2); } - am->addAttributeArray(k_NeighborListName, nl); + am->insertOrAssign(nl); - NeighborList::Pointer nl2 = NeighborList::CreateArray(tupleDims, cDimsNeighbor, k_NeighborListName2); + NeighborList::Pointer nl2 = NeighborList::CreateArray(tupleDims, cDimsNeighbor, k_NeighborListName2, true); for(size_t i = 0; i < nl2->getNumberOfTuples(); i++) { nl2->addEntry(i, i * 3); nl2->addEntry(i, i); nl2->addEntry(i, i + 1); } - am->addAttributeArray(k_NeighborListName2, nl2); + am->insertOrAssign(nl2); // Create Filter diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/FindDerivativesFilterTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/FindDerivativesFilterTest.cpp index d37a5c5073..68d7118efa 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/FindDerivativesFilterTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/FindDerivativesFilterTest.cpp @@ -1,47 +1,47 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include #include -#include #include -#include +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" - +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" @@ -55,15 +55,13 @@ #include "SIMPLib/Geometry/VertexGeom.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" #define FDTEST_CREATE_DATA_CONTAINER(name, geom, dca) \ DataContainer::Pointer _##geom##Container = DataContainer::New(#name); \ _##geom##Container->setGeometry(geom); \ - dca->addDataContainer(_##geom##Container); + dca->addOrReplaceDataContainer(_##geom##Container); #define FDTEST_SET_PROPERTIES_AND_CHECK_EQ(filter, dc, path, derivsName, data) \ var.setValue(path); \ @@ -79,7 +77,7 @@ qDebug() << "Unable to set property DerivativesArrayPath for" << #dc; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, 0); \ data = dc->getAttributeMatrix(derivsName.getAttributeMatrixName())->getAttributeArray(derivsName.getDataArrayName()); \ if(nullptr == std::dynamic_pointer_cast(data)) \ @@ -108,7 +106,7 @@ qDebug() << "Unable to set property DerivativesArrayPath for" << #dc; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_NE(err, 0); class FindDerivativesFilterTest @@ -116,71 +114,86 @@ class FindDerivativesFilterTest public: FindDerivativesFilterTest() = default; virtual ~FindDerivativesFilterTest() = default; - SIMPL_TYPE_MACRO(FindDerivativesFilterTest) + /** + * @brief Returns the name of the class for FindDerivativesFilterTest + */ + /** + * @brief Returns the name of the class for FindDerivativesFilterTest + */ + QString getNameOfClass() const + { + return QString("FindDerivativesFilterTest"); + } + + /** + * @brief Returns the name of the class for FindDerivativesFilterTest + */ + QString ClassName() + { + return QString("FindDerivativesFilterTest"); + } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void initializeDataArrays(DataContainer::Pointer m, QVector cDims) + void initializeDataArrays(DataContainer::Pointer m, std::vector cDims) { - QMap attrMats = m->getAttributeMatrices(); - QMap::Iterator it; - for(it = attrMats.begin(); it != attrMats.end(); ++it) + for(auto& am : m->getChildren()) { - DoubleArrayType::Pointer dblArray = DoubleArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_D"); + DoubleArrayType::Pointer dblArray = DoubleArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_D", true); dblArray->initializeWithValue(5); - (*it)->addAttributeArray("TEST_D", dblArray); - FloatArrayType::Pointer fltArray = FloatArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_F"); + am->insertOrAssign(dblArray); + FloatArrayType::Pointer fltArray = FloatArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_F", true); fltArray->initializeWithValue(5); - (*it)->addAttributeArray("TEST_F", fltArray); - Int8ArrayType::Pointer int8Array = Int8ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_I8"); + am->insertOrAssign(fltArray); + Int8ArrayType::Pointer int8Array = Int8ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_I8", true); int8Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_I8", int8Array); - UInt8ArrayType::Pointer uint8Array = UInt8ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_UI8"); + am->insertOrAssign(int8Array); + UInt8ArrayType::Pointer uint8Array = UInt8ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_UI8", true); uint8Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_UI8", uint8Array); - Int16ArrayType::Pointer int16Array = Int16ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_I16"); + am->insertOrAssign(uint8Array); + Int16ArrayType::Pointer int16Array = Int16ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_I16", true); int16Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_I16", int16Array); - UInt16ArrayType::Pointer uint16Array = UInt16ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_UI16"); + am->insertOrAssign(int16Array); + UInt16ArrayType::Pointer uint16Array = UInt16ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_UI16", true); uint16Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_UI16", uint16Array); - Int32ArrayType::Pointer int32Array = Int32ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_I32"); + am->insertOrAssign(uint16Array); + Int32ArrayType::Pointer int32Array = Int32ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_I32", true); int32Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_I32", int32Array); - UInt32ArrayType::Pointer uint32Array = UInt32ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_UI32"); + am->insertOrAssign(int32Array); + UInt32ArrayType::Pointer uint32Array = UInt32ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_UI32", true); uint32Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_UI32", uint32Array); - Int64ArrayType::Pointer int64Array = Int64ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_I64"); + am->insertOrAssign(uint32Array); + Int64ArrayType::Pointer int64Array = Int64ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_I64", true); int64Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_I64", int64Array); - UInt64ArrayType::Pointer uint64Array = UInt64ArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_UI64"); + am->insertOrAssign(int64Array); + UInt64ArrayType::Pointer uint64Array = UInt64ArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_UI64", true); uint64Array->initializeWithValue(5); - (*it)->addAttributeArray("TEST_UI64", uint64Array); - BoolArrayType::Pointer boolArray = BoolArrayType::CreateArray((*it)->getTupleDimensions(), cDims, "TEST_BOOL"); + am->insertOrAssign(uint64Array); + BoolArrayType::Pointer boolArray = BoolArrayType::CreateArray(am->getTupleDimensions(), cDims, "TEST_BOOL", true); boolArray->initializeWithZeros(); - (*it)->addAttributeArray("TEST_BOOL", boolArray); + am->insertOrAssign(boolArray); } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void initializeAttributeMatrices(DataContainer::Pointer m, QVector tDimsVert, QVector tDimsCell) + void initializeAttributeMatrices(DataContainer::Pointer m, std::vector tDimsVert, std::vector tDimsCell) { AttributeMatrix::Pointer attrMat; QString ss = QObject::tr("AttrMatType%1").arg(0); attrMat = AttributeMatrix::New(tDimsVert, ss, AttributeMatrix::Type::Vertex); - m->addAttributeMatrix(ss, attrMat); + m->addOrReplaceAttributeMatrix(attrMat); ss = QObject::tr("AttrMatType%1").arg(1); attrMat = AttributeMatrix::New(tDimsVert, ss, AttributeMatrix::Type::Edge); - m->addAttributeMatrix(ss, attrMat); + m->addOrReplaceAttributeMatrix(attrMat); ss = QObject::tr("AttrMatType%1").arg(2); attrMat = AttributeMatrix::New(tDimsVert, ss, AttributeMatrix::Type::Face); - m->addAttributeMatrix(ss, attrMat); + m->addOrReplaceAttributeMatrix(attrMat); ss = QObject::tr("AttrMatType%1").arg(3); attrMat = AttributeMatrix::New(tDimsCell, ss, AttributeMatrix::Type::Cell); - m->addAttributeMatrix(ss, attrMat); + m->addOrReplaceAttributeMatrix(attrMat); } // ----------------------------------------------------------------------------- @@ -205,13 +218,13 @@ class FindDerivativesFilterTest QuadGeom::Pointer quads = QuadGeom::CreateGeometry(1, vertices4, "QuadGeom"); TetrahedralGeom::Pointer tets = TetrahedralGeom::CreateGeometry(1, vertices5, "TetrahedralGeom"); - image->setDimensions(std::make_tuple(10, 10, 10)); - image->setOrigin(std::make_tuple(0.0f, 0.0f, 0.0f)); - image->setResolution(std::make_tuple(1.0f, 1.0f, 1.0f)); - rectGrid->setDimensions(std::make_tuple(10, 10, 10)); - FloatArrayType::Pointer xBounds = FloatArrayType::CreateArray(11, SIMPL::Geometry::xBoundsList); - FloatArrayType::Pointer yBounds = FloatArrayType::CreateArray(11, SIMPL::Geometry::yBoundsList); - FloatArrayType::Pointer zBounds = FloatArrayType::CreateArray(11, SIMPL::Geometry::zBoundsList); + image->setDimensions(10, 10, 10); + image->setOrigin(0.0f, 0.0f, 0.0f); + image->setSpacing(1.0f, 1.0f, 1.0f); + rectGrid->setDimensions(SizeVec3Type(10, 10, 10)); + FloatArrayType::Pointer xBounds = FloatArrayType::CreateArray(11, SIMPL::Geometry::xBoundsList, true); + FloatArrayType::Pointer yBounds = FloatArrayType::CreateArray(11, SIMPL::Geometry::yBoundsList, true); + FloatArrayType::Pointer zBounds = FloatArrayType::CreateArray(11, SIMPL::Geometry::zBoundsList, true); float* xBoundsPtr = xBounds->getPointer(0); float* yBoundsPtr = yBounds->getPointer(0); float* zBoundsPtr = zBounds->getPointer(0); @@ -230,10 +243,10 @@ class FindDerivativesFilterTest float* verts3 = vertices3->getPointer(0); float* verts4 = vertices4->getPointer(0); float* verts5 = vertices5->getPointer(0); - int64_t* edge = edges->getEdgePointer(0); - int64_t* tri = tris->getTriPointer(0); - int64_t* quad = quads->getQuadPointer(0); - int64_t* tet = tets->getTetPointer(0); + MeshIndexType* edge = edges->getEdgePointer(0); + MeshIndexType* tri = tris->getTriPointer(0); + MeshIndexType* quad = quads->getQuadPointer(0); + MeshIndexType* tet = tets->getTetPointer(0); for(size_t i = 0; i < 3; i++) // first vertex at (0,0,0) { @@ -287,8 +300,8 @@ class FindDerivativesFilterTest FDTEST_CREATE_DATA_CONTAINER(QuadDC, quads, dca); FDTEST_CREATE_DATA_CONTAINER(TetDC, tets, dca); - QVector tDims(1, 100); - QVector tDims2(1, 1); + std::vector tDims(1, 100); + std::vector tDims2(1, 1); initializeAttributeMatrices(_nullGeomContainer, tDims, tDims); tDims[0] = 1000; initializeAttributeMatrices(_imageContainer, tDims, tDims); @@ -303,7 +316,7 @@ class FindDerivativesFilterTest initializeAttributeMatrices(_quadsContainer, tDims, tDims2); initializeAttributeMatrices(_tetsContainer, tDims, tDims2); - QVector cDims(1, 3); + std::vector cDims(1, 3); initializeDataArrays(_nullGeomContainer, cDims); initializeDataArrays(_imageContainer, cDims); @@ -354,8 +367,8 @@ class FindDerivativesFilterTest QVariant var; bool propWasSet; int err = 0; - QVector checkDims; - QVector cDims(1, 3); + std::vector checkDims; + std::vector cDims(1, 3); QString derivativeName = "Derivatives"; DataArrayPath derivs; IDataArray::Pointer data; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/GenerateColorTableTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/GenerateColorTableTest.cpp index 0c136ef658..c9ebc2a2c2 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/GenerateColorTableTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/GenerateColorTableTest.cpp @@ -1,61 +1,123 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + #include #include #include #include #include -#include #include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" - +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/CoreFilters/GenerateColorTable.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/GenerateColorTable.h" +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString createErrorMessageFromJsonParseError(const QJsonParseError& parseError) +{ + QString msg; + QTextStream ss(&msg); + + switch(parseError.error) + { + case QJsonParseError::NoError: + ss << "No Error"; + break; + case QJsonParseError::UnterminatedObject: + ss << "Json Parsing Error: " << parseError.error << " of type UnterminatedObject. An object is not correctly terminated with a closing curly bracket"; + break; + case QJsonParseError::MissingNameSeparator: + ss << "Json Parsing Error: " << parseError.error << " of type MissingNameSeparator. A comma separating different items is missing"; + break; + case QJsonParseError::UnterminatedArray: + ss << "Json Parsing Error: " << parseError.error << " of type UnterminatedArray. The array is not correctly terminated with a closing square bracket"; + break; + case QJsonParseError::MissingValueSeparator: + ss << "Json Parsing Error: " << parseError.error << " of type MissingValueSeparator. A colon separating keys from values inside objects is missing"; + break; + case QJsonParseError::IllegalValue: + ss << "Json Parsing Error: " << parseError.error << " of type IllegalValue. The value is illegal"; + break; + case QJsonParseError::TerminationByNumber: + ss << "Json Parsing Error: " << parseError.error << " of type TerminationByNumber. The input stream ended while parsing a number"; + break; + case QJsonParseError::IllegalNumber: + ss << "Json Parsing Error: " << parseError.error << " of type IllegalNumber. The number is not well formed"; + break; + case QJsonParseError::IllegalEscapeSequence: + ss << "Json Parsing Error: " << parseError.error << " of type IllegalEscapeSequence. An illegal escape sequence occurred in the input"; + break; + case QJsonParseError::IllegalUTF8String: + ss << "Json Parsing Error: " << parseError.error << " of type IllegalUTF8String. An illegal UTF8 sequence occurred in the input"; + break; + case QJsonParseError::UnterminatedString: + ss << "Json Parsing Error: " << parseError.error << " of type UnterminatedString. A string wasn't terminated with a quote"; + break; + case QJsonParseError::MissingObject: + ss << "Json Parsing Error: " << parseError.error << " of type MissingObject. An object was expected but couldn't be found"; + break; + case QJsonParseError::DeepNesting: + ss << "Json Parsing Error: " << parseError.error << " of type DeepNesting. The JSON document is too deeply nested for the parser to parse it"; + break; + case QJsonParseError::DocumentTooLarge: + ss << "Json Parsing Error: " << parseError.error << " of type DocumentTooLarge. The JSON document is too large for the parser to parse it"; + break; + case QJsonParseError::GarbageAtEnd: + ss << "Json Parsing Error: " << parseError.error << " of type GarbageAtEnd. The parsed document contains additional garbage characters at the end"; + break; + default: + ss << "Json Parsing Error: " << parseError.error << " is of an unknown type."; + break; + } + ss << "\nThe error occurred at offset " << parseError.offset << ".\nReported error message is: " << parseError.errorString(); + + return msg; +} class GenerateColorTableTest { @@ -111,6 +173,7 @@ class GenerateColorTableTest QJsonDocument doc = QJsonDocument::fromJson(byteArray, &parseError); if(parseError.error != QJsonParseError::NoError) { + std::cout << createErrorMessageFromJsonParseError(parseError).toStdString() << std::endl; // "Failed to parse presets file" error DREAM3D_REQUIRE_EQUAL(0, -1); } @@ -161,13 +224,13 @@ class GenerateColorTableTest filter->setDataContainerArray(dca); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0) } // Validate Results { DataArrayPath daPath(SIMPL::Defaults::ImageDataContainerName, SIMPL::Defaults::CellAttributeMatrixName, "CI_RGB"); - UInt8ArrayType::Pointer da = dca->getPrereqArrayFromPath(nullptr, daPath, QVector(1, 3)); + UInt8ArrayType::Pointer da = dca->getPrereqArrayFromPath(nullptr, daPath, std::vector(1, 3)); if(da.get() != nullptr) { QFile file(presetFilePath); @@ -194,7 +257,7 @@ class GenerateColorTableTest } DataArrayPath amPath(SIMPL::Defaults::ImageDataContainerName, SIMPL::Defaults::CellAttributeMatrixName, ""); - AttributeMatrix::Pointer am = dca->getPrereqAttributeMatrixFromPath(nullptr, amPath, -300); + AttributeMatrix::Pointer am = dca->getPrereqAttributeMatrixFromPath(nullptr, amPath, -300); am->removeAttributeArray("CI_RGB"); } @@ -207,9 +270,9 @@ class GenerateColorTableTest DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc = DataContainer::New(SIMPL::Defaults::ImageDataContainerName); - AttributeMatrix::Pointer am = AttributeMatrix::New(QVector(1, 37989), SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(SIMPL::Defaults::CellAttributeMatrixName, am); - dca->addDataContainer(dc); + AttributeMatrix::Pointer am = AttributeMatrix::New(std::vector(1, 37989), SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Generic); + dc->addOrReplaceAttributeMatrix(am); + dca->addOrReplaceDataContainer(dc); // Read Image File { @@ -242,7 +305,7 @@ class GenerateColorTableTest filter->setDataContainerArray(dca); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0) + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0) } CheckPreset("Black, Blue and White", UnitTest::GenerateColorTableTest::BlackBlueWhiteFile, dca); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/GenerateTiltSeriesTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/GenerateTiltSeriesTest.cpp new file mode 100644 index 0000000000..c5f853dd2a --- /dev/null +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/GenerateTiltSeriesTest.cpp @@ -0,0 +1,181 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * United States Air Force Prime Contract FA8650-10-D-5210 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/CoreFilters/GenerateTiltSeries.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/CoreFilters/DataContainerReader.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainerArray.h" +#include "SIMPLib/Filtering/FilterFactory.hpp" +#include "SIMPLib/Filtering/FilterManager.h" +#include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Plugin/ISIMPLibPlugin.h" +#include "SIMPLib/Plugin/SIMPLibPluginLoader.h" + +// These Headers are generated into the build directory +#include "SIMPLib/Testing/SIMPLTestFileLocations.h" +#include "SIMPLib/Testing/UnitTestSupport.hpp" + +template +bool dataArrayEqual(const T& a, const T& b) +{ + std::vector aDims = a.getComponentDimensions(); + size_t aSize = a.getNumberOfTuples(); + + std::vector bDims = b.getComponentDimensions(); + size_t bSize = b.getNumberOfTuples(); + + if(aDims != bDims) + { + return false; + } + + if(aSize != bSize) + { + return false; + } + + return std::equal(a.begin(), a.end(), b.begin(), b.end()); +} + +// ----------------------------------------------------------------------------- +class GenerateTiltSeriesTest +{ + const DataArrayPath k_CellDataArray = DataArrayPath("SyntheticVolumeDataContainer", "CellData", "FeatureIds"); + const QString k_RotationBaseString = QString("Rotation_%1_%2"); + const QString k_FeatureIdsName = QString("FeatureIds"); + const QString k_SliceDataName = QString("Slice Data"); + const int k_NumRotations = 12; + const float k_Increment = 15.0f; + +public: + GenerateTiltSeriesTest() = default; + ~GenerateTiltSeriesTest() = default; + GenerateTiltSeriesTest(const GenerateTiltSeriesTest&) = delete; // Copy Constructor + GenerateTiltSeriesTest(GenerateTiltSeriesTest&&) = delete; // Move Constructor + GenerateTiltSeriesTest& operator=(const GenerateTiltSeriesTest&) = delete; // Copy Assignment + GenerateTiltSeriesTest& operator=(GenerateTiltSeriesTest&&) = delete; // Move Assignment + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void RemoveTestFiles() + { +#if REMOVE_TEST_FILES + // QFile::remove(UnitTest::GenerateTiltSeriesTest::TestFile1); +#endif + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + int TestGenerateTiltSeriesTest() + { + DataContainerArray::Pointer dca = DataContainerArray::New(); + + DataContainerReader::Pointer dataContainerReader = DataContainerReader::New(); + dataContainerReader->setDataContainerArray(dca); + dataContainerReader->setInputFile(UnitTest::GenerateTiltSeriesTest::TestFile1); + DataContainerArrayProxy proxy = dataContainerReader->readDataContainerArrayStructure(UnitTest::GenerateTiltSeriesTest::TestFile1); + dataContainerReader->setInputFileDataContainerArrayProxy(proxy); + + dataContainerReader->execute(); + int err = dataContainerReader->getErrorCode(); + DREAM3D_REQUIRED(err, >=, 0) + + DataArrayPath featureIdsPath("", k_SliceDataName, k_FeatureIdsName); + + const std::map rotations = {{"X", 0}, {"Y", 1}, {"Z", 2}}; + + GenerateTiltSeries::Pointer generateTiltSeries = GenerateTiltSeries::New(); + generateTiltSeries->setDataContainerArray(dca); + FloatVec3Type rotationLimits = {0.0f, 180.0f, k_Increment}; + generateTiltSeries->setRotationLimits(rotationLimits); + generateTiltSeries->setInputDataArrayPath(k_CellDataArray); + + for(const auto& rotation : rotations) + { + QString rotationString = rotation.first; + int rotationValue = rotation.second; + QString outputDc = QString("Rotation_Test_%1_").arg(rotationString); + + generateTiltSeries->setOutputPrefix(outputDc); + generateTiltSeries->setRotationAxis(rotationValue); + + for(int i = 0; i < k_NumRotations; i++) + { + DataArrayPath outputFeatureIdsPath(outputDc + QString::number(i), k_SliceDataName, k_FeatureIdsName); + + QString rotationDc = QString(k_RotationBaseString).arg(rotationString).arg(i); + featureIdsPath.setDataContainerName(rotationDc); + Int8ArrayType::Pointer dataArray = dca->getPrereqArrayFromPath(nullptr, featureIdsPath); + DREAM3D_REQUIRE_VALID_POINTER(dataArray) + + ImageGeom::Pointer imageGeom = dca->getPrereqGeometryFromDataContainer(nullptr, featureIdsPath); + DREAM3D_REQUIRE_VALID_POINTER(imageGeom) + + FloatVec3Type spacing = imageGeom->getSpacing(); + generateTiltSeries->setSpacing(spacing); + + generateTiltSeries->preflight(); + err = generateTiltSeries->getErrorCode(); + DREAM3D_REQUIRED(err, >=, 0) + + generateTiltSeries->execute(); + err = generateTiltSeries->getErrorCode(); + DREAM3D_REQUIRED(err, >=, 0) + + Int8ArrayType::Pointer testArray = dca->getPrereqArrayFromPath(nullptr, outputFeatureIdsPath); + DREAM3D_REQUIRE_VALID_POINTER(testArray) + + DREAM3D_REQUIRE(dataArrayEqual(*testArray, *dataArray)) + } + } + + return EXIT_SUCCESS; + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void operator()() + { + int err = EXIT_SUCCESS; + + DREAM3D_REGISTER_TEST(TestGenerateTiltSeriesTest()) + + DREAM3D_REGISTER_TEST(RemoveTestFiles()) + } +}; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/GenerateVertexCoordinatesTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/GenerateVertexCoordinatesTest.cpp new file mode 100644 index 0000000000..852ab0dcec --- /dev/null +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/GenerateVertexCoordinatesTest.cpp @@ -0,0 +1,143 @@ +// ----------------------------------------------------------------------------- +// Insert your license & copyright information here +// ----------------------------------------------------------------------------- +#pragma once + +#include +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/CoreFilters/GenerateVertexCoordinates.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" +#include "SIMPLib/Geometry/ImageGeom.h" +#include "SIMPLib/Geometry/VertexGeom.h" +#include "SIMPLib/Plugin/ISIMPLibPlugin.h" +#include "SIMPLib/Testing/SIMPLTestFileLocations.h" +#include "SIMPLib/Testing/UnitTestSupport.hpp" + +class GenerateVertexCoordinatesTest +{ + +public: + GenerateVertexCoordinatesTest() = default; + ~GenerateVertexCoordinatesTest() = default; + GenerateVertexCoordinatesTest(const GenerateVertexCoordinatesTest&) = delete; // Copy Constructor + GenerateVertexCoordinatesTest(GenerateVertexCoordinatesTest&&) = delete; // Move Constructor + GenerateVertexCoordinatesTest& operator=(const GenerateVertexCoordinatesTest&) = delete; // Copy Assignment + GenerateVertexCoordinatesTest& operator=(GenerateVertexCoordinatesTest&&) = delete; // Move Assignment + + // ----------------------------------------------------------------------------- + void RemoveTestFiles() + { +#if REMOVE_TEST_FILES + +#endif + } + + const std::vector k_Dims = {10ULL, 20ULL, 30ULL}; + + // ----------------------------------------------------------------------------- + DataContainerArray::Pointer createDataContainerArray() + { + // Create the DataContainer Array + DataContainerArray::Pointer dca = DataContainerArray::New(); + + // Create the DataContainer for the ImageGeometry + DataContainer::Pointer imageGeomDC = DataContainer::New(k_ImageGeomDataContainerPath); + dca->addOrReplaceDataContainer(imageGeomDC); + + // Create an ImageGeometry + + ImageGeom::Pointer imageGeom = ImageGeom::CreateGeometry("ImageGeometry"); + imageGeom->setDimensions(k_Dims.data()); + imageGeomDC->setGeometry(imageGeom); + + // Create the Cell AttributeMatrix + AttributeMatrix::Pointer cellAttrMat = AttributeMatrix::New(k_Dims, k_CellAttrMatName, AttributeMatrix::Type::Cell); + imageGeomDC->addOrReplaceAttributeMatrix(cellAttrMat); + + return dca; + } + + // ----------------------------------------------------------------------------- + int RunTest() + { + int32_t err = 0; + GenerateVertexCoordinates::Pointer filter = GenerateVertexCoordinates::New(); + + DataContainerArray::Pointer dca = createDataContainerArray(); + filter->setDataContainerArray(dca); + filter->setSelectedDataContainerName({"", "", ""}); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, -2004) + + DataContainer::Pointer dc = dca->getDataContainer(k_ImageGeomDataContainerPath); + dc->setGeometry(IGeometry::NullPointer()); + filter->setSelectedDataContainerName(k_ImageGeomDataContainerPath); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, -2008) + + dca = createDataContainerArray(); + filter->setDataContainerArray(dca); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, -80010) + + filter->setCoordinateArrayPath(k_CreatedCoordinatePath); + filter->preflight(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0) + + // Reset the Data Container Array to run the filter + dca = createDataContainerArray(); + filter->setDataContainerArray(dca); + filter->execute(); + err = filter->getErrorCode(); + DREAM3D_REQUIRE_EQUAL(err, 0) + + FloatArrayType::Pointer coords = + std::dynamic_pointer_cast(dca->getDataContainer(k_ImageGeomDataContainerPath)->getAttributeMatrix(k_CellAttrMatName)->getAttributeArray(k_CreatedCoordinatePath)); + std::array origin = {0.0F, 0.0F, 0.0F}; + std::array spacing = {1.0F, 1.0F, 1.0F}; + for(size_t z = 0; z < k_Dims[2]; z++) + { + for(size_t y = 0; y < k_Dims[1]; y++) + { + for(size_t x = 0; x < k_Dims[0]; x++) + { + size_t idx = (z * k_Dims[1] * k_Dims[0]) + (y * k_Dims[0]) + x; + float crds[3] = { + x * spacing[0] + origin[0] + (0.5f * spacing[0]), + y * spacing[1] + origin[1] + (0.5f * spacing[1]), + z * spacing[2] + origin[2] + (0.5f * spacing[2]), + }; + + float* ptr = coords->getTuplePointer(idx); + + DREAM3D_REQUIRE_EQUAL(ptr[0], crds[0]) + DREAM3D_REQUIRE_EQUAL(ptr[1], crds[1]) + DREAM3D_REQUIRE_EQUAL(ptr[2], crds[2]) + } + } + } + + return EXIT_SUCCESS; + } + + // ----------------------------------------------------------------------------- + void operator()() + { + std::cout << "#### GenerateVertexCoordinatesTest Starting ####" << std::endl; + int32_t err; // needed inside the next macro. + DREAM3D_REGISTER_TEST(RunTest()) + } + +private: + const DataArrayPath k_ImageGeomDataContainerPath = DataArrayPath("ImageGeomDataContainer", "", ""); + const QString k_CellAttrMatName = QString("CellData"); + const DataArrayPath k_CreatedCoordinatePath = DataArrayPath("ImageGeomDataContainer", "CellData", "Cell Centers"); +}; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportAsciDataArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportAsciDataArrayTest.cpp index 7ac14f387f..9b9b101bcf 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportAsciDataArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportAsciDataArrayTest.cpp @@ -52,7 +52,8 @@ class ImportAsciDataArrayTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template int RunTest(char sep, int delimiter, int scalarType) + template + int RunTest(char sep, int delimiter, int scalarType) { writeFile(sep); @@ -61,15 +62,15 @@ class ImportAsciDataArrayTest DataContainer::Pointer dc = DataContainer::New("ImageDataContainer"); ImageGeom::Pointer imageGeom = ImageGeom::New(); - imageGeom->setDimensions(m_XDim, m_YDim, m_ZDim); + imageGeom->setDimensions(SizeVec3Type(m_XDim, m_YDim, m_ZDim)); dc->setGeometry(imageGeom); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); - QVector tDims = {m_XDim, m_YDim, m_ZDim}; + std::vector tDims = {m_XDim, m_YDim, m_ZDim}; AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tDims, "AttributeMatrix", AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(attrMat->getName(), attrMat); + dc->addOrReplaceAttributeMatrix(attrMat); FilterManager* fm = FilterManager::Instance(); @@ -112,17 +113,17 @@ class ImportAsciDataArrayTest #if 0 Observer obs; - filter->connect(filter.get(), SIGNAL(filterGeneratedMessage(const PipelineMessage&)), - &obs, SLOT(processPipelineMessage(const PipelineMessage&))); + filter->connect(filter.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), + &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); #endif filter->preflight(); - DREAM3D_REQUIRED(filter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(filter->getErrorCode(), >=, 0); attrMat->removeAttributeArray("ImportedData"); filter->execute(); - DREAM3D_REQUIRED(filter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(filter->getErrorCode(), >=, 0); typename DataArray::Pointer dataPtr = attrMat->getAttributeArrayAs>("ImportedData"); T* ptr = dataPtr->getPointer(0); @@ -140,7 +141,7 @@ class ImportAsciDataArrayTest else // Bool type { bool value = (index != 0); - //DREAM3D_REQUIRE_EQUAL(value, (ptr[index])) + // DREAM3D_REQUIRE_EQUAL(value, (ptr[index])) DREAM3D_REQUIRE_EQUAL(value, static_cast(ptr[index])) index++; } diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportHDF5DatasetTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportHDF5DatasetTest.cpp index aecf6c5f07..a3686d7e3f 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportHDF5DatasetTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ImportHDF5DatasetTest.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include @@ -19,11 +18,9 @@ #include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/DataContainers/DataContainer.h" #include "SIMPLib/DataContainers/DataContainerArray.h" - #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Geometry/ImageGeom.h" - #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -55,10 +52,9 @@ class ImportHDF5DatasetTest // ----------------------------------------------------------------------------- // Uses Raw Pointers to save data to the data file // ----------------------------------------------------------------------------- - template herr_t writePointer1DArrayDataset(hid_t loc_id) + template + herr_t writePointer1DArrayDataset(hid_t loc_id) { - - T value = 0x0; herr_t err = 1; int32_t rank = 1; // Create the Dimensions @@ -74,7 +70,7 @@ class ImportHDF5DatasetTest data[i] = static_cast(i * 5); } - QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(value); + QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(); dsetName = "Pointer1DArrayDataset<" + dsetName + ">"; err = QH5Lite::writePointerDataset(loc_id, dsetName, rank, dims, &(data.front())); DREAM3D_REQUIRE(err >= 0); @@ -85,10 +81,9 @@ class ImportHDF5DatasetTest // ----------------------------------------------------------------------------- // Uses Raw Pointers to save data to the data file // ----------------------------------------------------------------------------- - template herr_t writePointer2DArrayDataset(hid_t loc_id) + template + herr_t writePointer2DArrayDataset(hid_t loc_id) { - - T value = 0x0; herr_t err = 1; int32_t rank = 2; // Create the Dimensions @@ -105,7 +100,7 @@ class ImportHDF5DatasetTest data[i] = static_cast(i * 5); } - QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(value); + QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(); dsetName = "Pointer2DArrayDataset<" + dsetName + ">"; err = QH5Lite::writePointerDataset(loc_id, dsetName, rank, dims, &(data.front())); DREAM3D_REQUIRE(err >= 0); @@ -116,10 +111,9 @@ class ImportHDF5DatasetTest // ----------------------------------------------------------------------------- // Uses Raw Pointers to save data to the data file // ----------------------------------------------------------------------------- - template herr_t writePointer3DArrayDataset(hid_t loc_id) + template + herr_t writePointer3DArrayDataset(hid_t loc_id) { - - T value = 0x0; herr_t err = 1; int32_t rank = 3; // Create the Dimensions @@ -137,7 +131,7 @@ class ImportHDF5DatasetTest data[i] = static_cast(i * 5); } - QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(value); + QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(); dsetName = "Pointer3DArrayDataset<" + dsetName + ">"; err = QH5Lite::writePointerDataset(loc_id, dsetName, rank, dims, &(data.front())); DREAM3D_REQUIRE(err >= 0); @@ -148,10 +142,9 @@ class ImportHDF5DatasetTest // ----------------------------------------------------------------------------- // Uses Raw Pointers to save data to the data file // ----------------------------------------------------------------------------- - template herr_t writePointer4DArrayDataset(hid_t loc_id) + template + herr_t writePointer4DArrayDataset(hid_t loc_id) { - - T value = 0x0; herr_t err = 1; int32_t rank = 4; // Create the Dimensions @@ -170,7 +163,7 @@ class ImportHDF5DatasetTest data[i] = static_cast(i * 5); } - QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(value); + QString dsetName = QH5Lite::HDFTypeForPrimitiveAsStr(); dsetName = "Pointer4DArrayDataset<" + dsetName + ">"; err = QH5Lite::writePointerDataset(loc_id, dsetName, rank, dims, &(data.front())); DREAM3D_REQUIRE(err >= 0); @@ -194,11 +187,11 @@ class ImportHDF5DatasetTest hid_t file_id = QH5Utilities::createFile(m_FilePath); DREAM3D_REQUIRE(file_id > 0); - H5ScopedFileSentinel sentinel(&file_id, false); + H5ScopedFileSentinel sentinel(file_id, false); // Create the Pointer group hid_t ptrId = QH5Utilities::createGroup(file_id, "Pointer"); - sentinel.addGroupId(&ptrId); + sentinel.addGroupId(ptrId); DREAM3D_REQUIRED(ptrId, >, 0); DREAM3D_REQUIRE(writePointer1DArrayDataset(ptrId) >= 0); @@ -254,36 +247,36 @@ class ImportHDF5DatasetTest ImportHDF5Dataset::Pointer filter = ImportHDF5Dataset::New(); // Set a dummy data container array for error testing purposes - DataContainerArray::Pointer dca = createDataContainerArray(QVector(1, 1)); + DataContainerArray::Pointer dca = createDataContainerArray(std::vector(1, 1)); filter->setDataContainerArray(dca); filter->setSelectedAttributeMatrix(DataArrayPath("DataContainer", "AttributeMatrix", "")); // Check empty file path error filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -20001); - filter->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -20001); + filter->clearErrorCode(); // Check incorrect extension error filter->setHDF5FilePath("foo.txt"); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -20002); - filter->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -20002); + filter->clearErrorCode(); // Check non-existent file error filter->setHDF5FilePath("foo.h5"); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -20003); - filter->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -20003); + filter->clearErrorCode(); // Put in the correct file path filter->setHDF5FilePath(m_FilePath); // Check empty dataset path error filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -20004); - filter->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -20004); + filter->clearErrorCode(); // Check incorrect dataset path error QList importInfoList; @@ -293,21 +286,20 @@ class ImportHDF5DatasetTest filter->setDatasetImportInfoList(importInfoList); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -20005); - filter->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -20005); + filter->clearErrorCode(); // Fill in Dataset Path with a valid path so that we can continue our error checks importInfoList.clear(); - int8_t dummyVal = 0x0; - QString typeStr = QH5Lite::HDFTypeForPrimitiveAsStr(dummyVal); + QString typeStr = QH5Lite::HDFTypeForPrimitiveAsStr(); importInfo.dataSetPath = "Pointer/Pointer1DArrayDataset<" + typeStr + ">"; importInfoList.push_back(importInfo); filter->setDatasetImportInfoList(importInfoList); // Check empty component dimensions filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -20006); - filter->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -20006); + filter->clearErrorCode(); // Check incorrect component dimensions importInfoList.clear(); @@ -316,8 +308,8 @@ class ImportHDF5DatasetTest filter->setDatasetImportInfoList(importInfoList); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -20007); - filter->setErrorCondition(0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -20007); + filter->clearErrorCode(); return filter; } @@ -325,16 +317,16 @@ class ImportHDF5DatasetTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - DataContainerArray::Pointer createDataContainerArray(QVector tDims) + DataContainerArray::Pointer createDataContainerArray(std::vector tDims) { DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tDims, "AttributeMatrix", AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(attrMat->getName(), attrMat); + dc->addOrReplaceAttributeMatrix(attrMat); return dca; } @@ -342,7 +334,7 @@ class ImportHDF5DatasetTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - QString createVectorString(QVector vec) + QString createVectorString(std::vector vec) { QString str = "("; for(int i = 0; i < vec.size(); i++) @@ -361,15 +353,15 @@ class ImportHDF5DatasetTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void DatasetTest(ImportHDF5Dataset::Pointer filter, QList importInfoList, QVector amDims, int errCode) + template + void DatasetTest(ImportHDF5Dataset::Pointer filter, QList importInfoList, std::vector amDims, int errCode) { if(importInfoList.empty()) { return; } - T value = 0x0; - QString typeStr = QH5Lite::HDFTypeForPrimitiveAsStr(value); + QString typeStr = QH5Lite::HDFTypeForPrimitiveAsStr(); DataContainerArray::Pointer dca = createDataContainerArray(amDims); filter->setDataContainerArray(dca); @@ -402,17 +394,18 @@ class ImportHDF5DatasetTest statusMessage.append("tDims = " + tDimsStr + "\n"); statusMessage.append("cDims = \n" + cDimsVectorStr); - //std::cout << statusMessage.toStdString() << std::endl; + // std::cout << statusMessage.toStdString() << std::endl; } else { ImportHDF5Dataset::DatasetImportInfo info = dsetInfoList[0]; -// std::cout << QObject::tr("Starting %1 Dataset Test: Dataset Path = %2, tDims = %3, cDims = %4").arg(typeStr).arg(info.dataSetPath).arg(tDimsStr).arg(info.componentDimensions).toStdString() -// << std::endl; + // std::cout << QObject::tr("Starting %1 Dataset Test: Dataset Path = %2, tDims = %3, cDims = + // %4").arg(typeStr).arg(info.dataSetPath).arg(tDimsStr).arg(info.componentDimensions).toStdString() + // << std::endl; } filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), errCode); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), errCode); // If we got through without errors, validate the results if(errCode == 0) @@ -428,7 +421,7 @@ class ImportHDF5DatasetTest QString cDimsStr = dsetInfoList[i].componentDimensions; QStringList tokens = cDimsStr.split(", "); - QVector cDims; + std::vector cDims; for(int i = 0; i < tokens.size(); i++) { cDims.push_back(tokens[i].toInt()); @@ -443,7 +436,7 @@ class ImportHDF5DatasetTest QString dsetPath = dsetInfoList[i].dataSetPath; QString dsetName = dsetPath.remove("/Pointer/"); - typename DataArray::Pointer da = dca->getPrereqIDataArrayFromPath, AbstractFilter>(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", dsetName)); + typename DataArray::Pointer da = dca->getPrereqArrayFromPath>(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", dsetName)); size_t totalArrayValues = da->getNumberOfTuples() * da->getNumberOfComponents(); DREAM3D_REQUIRE_EQUAL(totalArrayValues, tDimsProduct * cDimsProduct); @@ -473,7 +466,8 @@ class ImportHDF5DatasetTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template QString joinVector(QVector vector, const QString& separator) + template + QString joinVector(std::vector vector, const QString& separator) { QString cDimsStr = ""; for(int i = 0; i < vector.size(); i++) @@ -498,8 +492,8 @@ class ImportHDF5DatasetTest // // ******************* Test Reading Data ************************************* // Create tuple and component dimensions for all tests - QVector> tDimsVector; - QVector> cDimsVector; + QVector> tDimsVector; + QVector> cDimsVector; // Add 1D, 2D, 3D, and 4D tuple and component dimensions that test all 4 possibilities: // 1. Tuple dimensions and component dimensions are both valid @@ -507,37 +501,37 @@ class ImportHDF5DatasetTest // 3. Tuple dimensions are invalid, but component dimensions are valid // 4. Neither tuple dimensions or component dimensions are valid - tDimsVector.push_back(QVector(1) = {TUPLEDIMPROD}); - cDimsVector.push_back(QVector(1) = {COMPDIMPROD}); + tDimsVector.push_back(std::vector(1) = {TUPLEDIMPROD}); + cDimsVector.push_back(std::vector(1) = {COMPDIMPROD}); - tDimsVector.push_back(QVector(2) = {10, 4}); - cDimsVector.push_back(QVector(2) = {12, 6}); + tDimsVector.push_back(std::vector(2) = {10, 4}); + cDimsVector.push_back(std::vector(2) = {12, 6}); - tDimsVector.push_back(QVector(3) = {2, 2, 10}); - cDimsVector.push_back(QVector(3) = {4, 3, 6}); + tDimsVector.push_back(std::vector(3) = {2, 2, 10}); + cDimsVector.push_back(std::vector(3) = {4, 3, 6}); - tDimsVector.push_back(QVector(4) = {2, 2, 5, 2}); - cDimsVector.push_back(QVector(4) = {4, 3, 3, 2}); + tDimsVector.push_back(std::vector(4) = {2, 2, 5, 2}); + cDimsVector.push_back(std::vector(4) = {4, 3, 3, 2}); - tDimsVector.push_back(QVector(1) = {TUPLEDIMPROD - 1}); - cDimsVector.push_back(QVector(1) = {COMPDIMPROD - 1}); + tDimsVector.push_back(std::vector(1) = {TUPLEDIMPROD - 1}); + cDimsVector.push_back(std::vector(1) = {COMPDIMPROD - 1}); - tDimsVector.push_back(QVector(2) = {TUPLEDIMPROD - 1, 34}); - cDimsVector.push_back(QVector(2) = {COMPDIMPROD - 1, 56}); + tDimsVector.push_back(std::vector(2) = {TUPLEDIMPROD - 1, 34}); + cDimsVector.push_back(std::vector(2) = {COMPDIMPROD - 1, 56}); - tDimsVector.push_back(QVector(3) = {TUPLEDIMPROD - 1, 23, 654}); - cDimsVector.push_back(QVector(3) = {COMPDIMPROD - 1, 56, 12}); + tDimsVector.push_back(std::vector(3) = {TUPLEDIMPROD - 1, 23, 654}); + cDimsVector.push_back(std::vector(3) = {COMPDIMPROD - 1, 56, 12}); - tDimsVector.push_back(QVector(4) = {TUPLEDIMPROD - 1, 98, 12, 45}); - cDimsVector.push_back(QVector(4) = {COMPDIMPROD - 1, 43, 12, 53}); + tDimsVector.push_back(std::vector(4) = {TUPLEDIMPROD - 1, 98, 12, 45}); + cDimsVector.push_back(std::vector(4) = {COMPDIMPROD - 1, 43, 12, 53}); // Execute all combinations of tests for(int i = 0; i < tDimsVector.size(); i++) { for(int j = 0; j < cDimsVector.size(); j++) { - QVector tDims = tDimsVector[i]; - QVector cDims = cDimsVector[j]; + std::vector tDims = tDimsVector[i]; + std::vector cDims = cDimsVector[j]; size_t amTupleCount = 1; for(int t = 0; t < tDims.size(); t++) diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveDataTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveDataTest.cpp index 3ef6e55676..0acda84cbd 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveDataTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveDataTest.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,25 +35,23 @@ #pragma once -#include -#include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" - -#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/Common/Constants.h" - class MoveDataTest { @@ -85,9 +83,10 @@ class MoveDataTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template std::shared_ptr> createDataArray(const QString& daName, const QVector& tupleDims, const QVector& cDims) + template + std::shared_ptr> createDataArray(const QString& daName, const std::vector& tupleDims, const std::vector& cDims) { - typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName); + typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName, true); for(size_t i = 0; i < da->getNumberOfTuples(); i++) { for(int j = 0; j < da->getNumberOfComponents(); j++) @@ -101,7 +100,8 @@ class MoveDataTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void checkDataArray(IDataArray::Pointer originalData, IDataArray::Pointer newData, bool isRenamed) + template + void checkDataArray(IDataArray::Pointer originalData, IDataArray::Pointer newData, bool isRenamed) { if(originalData == IDataArray::NullPointer() || newData == IDataArray::NullPointer()) { @@ -240,7 +240,7 @@ class MoveDataTest if(whatToMove == 0) // Move AttributeMatrix { - var.setValue(dapDst.getDataContainerName()); + var.setValue(dapDst); propWasSet = moveData->setProperty("DataContainerDestination", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -269,11 +269,11 @@ class MoveDataTest if(err >= 0) { - DREAM3D_REQUIRED(moveData->getErrorCondition(), >=, err) + DREAM3D_REQUIRED(moveData->getErrorCode(), >=, err) } else { - DREAM3D_REQUIRED(moveData->getErrorCondition(), ==, err) + DREAM3D_REQUIRED(moveData->getErrorCode(), ==, err) } // Check filter results if filter successfully executed @@ -376,9 +376,9 @@ class MoveDataTest static const QString k_AttributeMatrixBadDstName("AttributeMatrixBadDst"); static const QString k_DataArraySrcName("DataArraySrc"); - QVector tupleDims = {12}; - QVector badTupleDims = {14}; - QVector cDims = {3}; + std::vector tupleDims = {12}; + std::vector badTupleDims = {14}; + std::vector cDims = {3}; // Create DataContainerArray @@ -387,26 +387,26 @@ class MoveDataTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); DataContainer::Pointer dcDst = DataContainer::New(k_DataContainerDstName); - dca->addDataContainer(dcDst); + dca->addOrReplaceDataContainer(dcDst); // Create AttributeMatrix AttributeMatrix::Pointer amSrc = AttributeMatrix::New(tupleDims, k_AttributeMatrixSrcName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixSrcName, amSrc); + dc->addOrReplaceAttributeMatrix(amSrc); AttributeMatrix::Pointer amDst = AttributeMatrix::New(tupleDims, k_AttributeMatrixDstName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixDstName, amDst); + dc->addOrReplaceAttributeMatrix(amDst); AttributeMatrix::Pointer amBadDst = AttributeMatrix::New(badTupleDims, k_AttributeMatrixBadDstName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixBadDstName, amBadDst); + dc->addOrReplaceAttributeMatrix(amBadDst); // Create DataArray IDataArray::Pointer daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - amSrc->addAttributeArray(k_DataArraySrcName, daSrc); + amSrc->insertOrAssign(daSrc); // Run test cases @@ -425,7 +425,7 @@ class MoveDataTest dcaTest = dca->deepCopy(); - dcaTest->getDataContainer(k_DataContainerDstName)->addAttributeMatrix(k_AttributeMatrixDstName, dcaTest->getDataContainer(k_DataContainerName)->removeAttributeMatrix(k_AttributeMatrixDstName)); + dcaTest->getDataContainer(k_DataContainerDstName)->addOrReplaceAttributeMatrix(dcaTest->getDataContainer(k_DataContainerName)->removeAttributeMatrix(k_AttributeMatrixDstName)); src = DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_DataArraySrcName); dst = DataArrayPath(k_DataContainerDstName, k_AttributeMatrixDstName, ""); @@ -454,7 +454,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -464,7 +464,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -474,7 +474,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -484,7 +484,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -494,7 +494,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -504,7 +504,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -514,7 +514,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -524,7 +524,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); @@ -534,7 +534,7 @@ class MoveDataTest dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->removeAttributeArray(k_DataArraySrcName); daSrc = createDataArray(k_DataArraySrcName, tupleDims, cDims); - dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->addAttributeArray(k_DataArraySrcName, daSrc); + dcaTest->getDataContainer(k_DataContainerName)->getAttributeMatrix(k_AttributeMatrixSrcName)->insertOrAssign(daSrc); TestCase(dcaTest, src, dst, 1, 0); } diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveMultiDataTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveMultiDataTest.cpp index 7e5b76aacb..c0213257cf 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveMultiDataTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/MoveMultiDataTest.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,25 +35,23 @@ #pragma once -#include -#include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" - -#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/Common/Constants.h" - class MoveMultiDataTest { @@ -85,9 +83,10 @@ class MoveMultiDataTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template std::shared_ptr> createDataArray(const QString& daName, const QVector& tupleDims, const QVector& cDims) + template + std::shared_ptr> createDataArray(const QString& daName, const std::vector& tupleDims, const std::vector& cDims) { - typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName); + typename DataArray::Pointer da = DataArray::CreateArray(tupleDims, cDims, daName, true); for(size_t i = 0; i < da->getNumberOfTuples(); i++) { for(int j = 0; j < da->getNumberOfComponents(); j++) @@ -101,7 +100,8 @@ class MoveMultiDataTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void checkDataArray(IDataArray::Pointer originalData, IDataArray::Pointer newData, bool isRenamed) + template + void checkDataArray(IDataArray::Pointer originalData, IDataArray::Pointer newData, bool isRenamed) { if(originalData == IDataArray::NullPointer() || newData == IDataArray::NullPointer()) { @@ -217,7 +217,7 @@ class MoveMultiDataTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - void TestCase(DataContainerArray::Pointer dca, QVector sources, DataArrayPath dapDst, int whatToMove, int err) + void TestCase(DataContainerArray::Pointer dca, const std::vector& sources, DataArrayPath dapDst, int whatToMove, int err) { QVector amSourcesCopy; @@ -241,7 +241,7 @@ class MoveMultiDataTest if(whatToMove == 0) // Move AttributeMatrix { - var.setValue(dapDst.getDataContainerName()); + var.setValue(dapDst); propWasSet = moveMultiData->setProperty("DataContainerDestination", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -277,11 +277,11 @@ class MoveMultiDataTest if(err >= 0) { - DREAM3D_REQUIRED(moveMultiData->getErrorCondition(), >=, err) + DREAM3D_REQUIRED(moveMultiData->getErrorCode(), >=, err) } else { - DREAM3D_REQUIRED(moveMultiData->getErrorCondition(), ==, err) + DREAM3D_REQUIRED(moveMultiData->getErrorCode(), ==, err) } // Check filter results if filter successfully executed @@ -400,9 +400,9 @@ class MoveMultiDataTest static const QString k_floatArrayName("floatDataArray"); static const QString k_doubleArrayName("doubleDataArray"); - QVector tupleDims = {12}; - QVector badTupleDims = {14}; - QVector cDims = {3}; + std::vector tupleDims = {12}; + std::vector badTupleDims = {14}; + std::vector cDims = {3}; // Create DataContainerArray @@ -411,53 +411,53 @@ class MoveMultiDataTest // Create DataContainer DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); DataContainer::Pointer dcDst = DataContainer::New(k_DataContainerDstName); - dca->addDataContainer(dcDst); + dca->addOrReplaceDataContainer(dcDst); // Create AttributeMatrix AttributeMatrix::Pointer amSrc = AttributeMatrix::New(tupleDims, k_AttributeMatrixSrcName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixSrcName, amSrc); + dc->addOrReplaceAttributeMatrix(amSrc); AttributeMatrix::Pointer amDst = AttributeMatrix::New(tupleDims, k_AttributeMatrixDstName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixDstName, amDst); + dc->addOrReplaceAttributeMatrix(amDst); AttributeMatrix::Pointer amBadDst = AttributeMatrix::New(badTupleDims, k_AttributeMatrixBadDstName, AttributeMatrix::Type::Generic); - dc->addAttributeMatrix(k_AttributeMatrixBadDstName, amBadDst); + dc->addOrReplaceAttributeMatrix(amBadDst); // Create DataArray IDataArray::Pointer daSrc = createDataArray(k_uint8ArrayName, tupleDims, cDims); - amSrc->addAttributeArray(k_uint8ArrayName, daSrc); + amSrc->insertOrAssign(daSrc); daSrc = createDataArray(k_int8ArrayName, tupleDims, cDims); - amSrc->addAttributeArray(k_int8ArrayName, daSrc); + amSrc->insertOrAssign(daSrc); daSrc = createDataArray(k_uint16ArrayName, tupleDims, cDims); - amSrc->addAttributeArray(k_uint16ArrayName, daSrc); + amSrc->insertOrAssign(daSrc); daSrc = createDataArray(k_int16ArrayName, tupleDims, cDims); - amSrc->addAttributeArray(k_int16ArrayName, daSrc); + amSrc->insertOrAssign(daSrc); daSrc = createDataArray(k_uint32ArrayName, tupleDims, cDims); - amSrc->addAttributeArray(k_uint32ArrayName, daSrc); + amSrc->insertOrAssign(daSrc); daSrc = createDataArray(k_int32ArrayName, tupleDims, cDims); - amDst->addAttributeArray(k_int32ArrayName, daSrc); + amDst->insertOrAssign(daSrc); daSrc = createDataArray(k_uint64ArrayName, tupleDims, cDims); - amDst->addAttributeArray(k_uint64ArrayName, daSrc); + amDst->insertOrAssign(daSrc); daSrc = createDataArray(k_int64ArrayName, tupleDims, cDims); - amDst->addAttributeArray(k_int64ArrayName, daSrc); + amDst->insertOrAssign(daSrc); daSrc = createDataArray(k_floatArrayName, tupleDims, cDims); - amDst->addAttributeArray(k_floatArrayName, daSrc); + amDst->insertOrAssign(daSrc); daSrc = createDataArray(k_doubleArrayName, tupleDims, cDims); - amDst->addAttributeArray(k_doubleArrayName, daSrc); + amDst->insertOrAssign(daSrc); // Run test cases @@ -465,7 +465,7 @@ class MoveMultiDataTest DataContainerArray::Pointer dcaTest = dca->deepCopy(); - QVector sources = {DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, ""), DataArrayPath(k_DataContainerName, k_AttributeMatrixDstName, "")}; + std::vector sources = {DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, ""), DataArrayPath(k_DataContainerName, k_AttributeMatrixDstName, "")}; DataArrayPath dst(k_DataContainerDstName); @@ -485,9 +485,9 @@ class MoveMultiDataTest TestCase(dcaTest, sources, dst, 1, 0); - sources = { DataArrayPath(k_DataContainerName, k_AttributeMatrixDstName, k_int32ArrayName), DataArrayPath(k_DataContainerName, k_AttributeMatrixDstName, k_uint64ArrayName), - DataArrayPath(k_DataContainerName, k_AttributeMatrixDstName, k_int64ArrayName), DataArrayPath(k_DataContainerName, k_AttributeMatrixDstName, k_floatArrayName), - DataArrayPath(k_DataContainerName, k_AttributeMatrixDstName, k_doubleArrayName) }; + sources = {DataArrayPath(k_DataContainerName, k_AttributeMatrixDstName, k_int32ArrayName), DataArrayPath(k_DataContainerName, k_AttributeMatrixDstName, k_uint64ArrayName), + DataArrayPath(k_DataContainerName, k_AttributeMatrixDstName, k_int64ArrayName), DataArrayPath(k_DataContainerName, k_AttributeMatrixDstName, k_floatArrayName), + DataArrayPath(k_DataContainerName, k_AttributeMatrixDstName, k_doubleArrayName)}; dst = DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, ""); @@ -505,11 +505,11 @@ class MoveMultiDataTest dcaTest = dca->deepCopy(); - dcaTest->getDataContainer(k_DataContainerDstName)->addAttributeMatrix(k_AttributeMatrixDstName, dcaTest->getDataContainer(k_DataContainerName)->removeAttributeMatrix(k_AttributeMatrixDstName)); + dcaTest->getDataContainer(k_DataContainerDstName)->addOrReplaceAttributeMatrix(dcaTest->getDataContainer(k_DataContainerName)->removeAttributeMatrix(k_AttributeMatrixDstName)); - sources = { DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_uint8ArrayName), DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_int8ArrayName), - DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_uint16ArrayName), DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_int16ArrayName), - DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_uint32ArrayName) }; + sources = {DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_uint8ArrayName), DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_int8ArrayName), + DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_uint16ArrayName), DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_int16ArrayName), + DataArrayPath(k_DataContainerName, k_AttributeMatrixSrcName, k_uint32ArrayName)}; dst = DataArrayPath(k_DataContainerDstName, k_AttributeMatrixDstName, ""); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjects2Test.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjects2Test.cpp index f2f07db745..393be364df 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjects2Test.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjects2Test.cpp @@ -1,43 +1,46 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include + #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/ComparisonInputsAdvanced.h" #include "SIMPLib/Filtering/ComparisonSet.h" #include "SIMPLib/Filtering/ComparisonValue.h" @@ -48,7 +51,6 @@ #include "SIMPLib/Geometry/ImageGeom.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" class MultiThresholdObjects2Test @@ -56,7 +58,22 @@ class MultiThresholdObjects2Test public: MultiThresholdObjects2Test() = default; virtual ~MultiThresholdObjects2Test() = default; - SIMPL_TYPE_MACRO(MultiThresholdObjects2Test) + + /** + * @brief Returns the name of the class for MultiThresholdObjects2Test + */ + QString getNameOfClass() const + { + return QString("MultiThresholdObjects2Test"); + } + + /** + * @brief Returns the name of the class for MultiThresholdObjects2Test + */ + QString ClassName() + { + return QString("MultiThresholdObjects2Test"); + } // ----------------------------------------------------------------------------- // @@ -87,18 +104,18 @@ class MultiThresholdObjects2Test // Set up geometry for tuples, a cuboid with dimensions 20, 10, 1 ImageGeom::Pointer image = ImageGeom::CreateGeometry(SIMPL::Geometry::ImageGeometry); vdc->setGeometry(image); - size_t dims[1] = {20}; + std::array dims = {20, 1, 1}; image->setDimensions(dims); - QVector tDims(1, 0); + std::vector tDims(1, 0); tDims[0] = 20; - QVector cDims(1); + std::vector cDims(1); cDims[0] = 1; float fnum = 0.0f; int inum = 0; AttributeMatrix::Pointer am = AttributeMatrix::New(tDims, SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Cell); - DataArray::Pointer dataf = DataArray::CreateArray(tDims, cDims, "TestArrayFloat"); - DataArray::Pointer datai = DataArray::CreateArray(tDims, cDims, "TestArrayInt"); + DataArray::Pointer dataf = DataArray::CreateArray(tDims, cDims, "TestArrayFloat", true); + DataArray::Pointer datai = DataArray::CreateArray(tDims, cDims, "TestArrayInt", true); // Fill the float array with {.01,.02,.03,.04,.05,.06,.07,.08,.09,.10,.11,.12,.13,.14,.15.,16,.17,.18,.19,.20} // Fill the int array with { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 } @@ -109,10 +126,10 @@ class MultiThresholdObjects2Test datai->setValue(i, inum); // int array inum += 1; } - am->addAttributeArray(dataf->getName(), dataf); // float array - am->addAttributeArray(datai->getName(), datai); // int array - vdc->addAttributeMatrix(am->getName(), am); - dca->addDataContainer(vdc); + am->insertOrAssign(dataf); // float array + am->insertOrAssign(datai); // int array + vdc->addOrReplaceAttributeMatrix(am); + dca->addOrReplaceDataContainer(vdc); // Now instantiate the MultiThresholdObjects2Test Filter from the FilterManager QString filtName = "MultiThresholdObjects2"; @@ -138,7 +155,8 @@ class MultiThresholdObjects2Test // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void ComparisonValueTest(AbstractFilter::Pointer filter, DataArray* dataArray, SIMPL::Comparison::Enumeration comparisonOperator, T value, QString outputName) + template + void ComparisonValueTest(AbstractFilter::Pointer filter, DataArray* dataArray, SIMPL::Comparison::Enumeration comparisonOperator, T value, QString outputName) { QString dataContainerName = filter->getDataContainerArray()->getDataContainerNames().at(0); @@ -165,7 +183,7 @@ class MultiThresholdObjects2Test DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - DREAM3D_REQUIRED(filter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(filter->getErrorCode(), >=, 0); DataArrayPath path = DataArrayPath(dataContainerName, SIMPL::Defaults::CellAttributeMatrixName, outputName); IDataArray::Pointer thresholdArray = @@ -203,7 +221,7 @@ class MultiThresholdObjects2Test // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template + template void ComparisonValueTestAll(AbstractFilter::Pointer filter, DataArray* dataArray, T comparisonValue, QString outputName) { ComparisonValueTest(filter, dataArray, SIMPL::Comparison::Operator_GreaterThan, comparisonValue, outputName + QString::number(0)); @@ -240,7 +258,7 @@ class MultiThresholdObjects2Test DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - DREAM3D_REQUIRED(filter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(filter->getErrorCode(), >=, 0); DataArrayPath path = DataArrayPath(dataContainerName, SIMPL::Defaults::CellAttributeMatrixName, outputName); IDataArray::Pointer thresholdArray = @@ -338,8 +356,8 @@ class MultiThresholdObjects2Test } /** -* @brief -*/ + * @brief + */ void operator()() { int err = EXIT_SUCCESS; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjectsTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjectsTest.cpp index 116cf43a5f..d9e86453fa 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjectsTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/MultiThresholdObjectsTest.cpp @@ -1,43 +1,44 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/ComparisonInputs.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" @@ -46,7 +47,6 @@ #include "SIMPLib/Geometry/ImageGeom.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" class MultiThresholdObjectsTest @@ -54,7 +54,22 @@ class MultiThresholdObjectsTest public: MultiThresholdObjectsTest() = default; virtual ~MultiThresholdObjectsTest() = default; - SIMPL_TYPE_MACRO(MultiThresholdObjectsTest) + + /** + * @brief Returns the name of the class for MultiThresholdObjectsTest + */ + QString getNameOfClass() const + { + return QString("MultiThresholdObjectsTest"); + } + + /** + * @brief Returns the name of the class for MultiThresholdObjectsTest + */ + QString ClassName() + { + return QString("MultiThresholdObjectsTest"); + } // ----------------------------------------------------------------------------- // @@ -85,18 +100,18 @@ class MultiThresholdObjectsTest // Set up geometry for tuples, a cuboid with dimensions 20, 10, 1 ImageGeom::Pointer image = ImageGeom::CreateGeometry(SIMPL::Geometry::ImageGeometry); vdc->setGeometry(image); - size_t dims[1] = {20}; + std::array dims = {20, 1, 1}; image->setDimensions(dims); - QVector tDims(1, 0); + std::vector tDims(1, 0); tDims[0] = 20; - QVector cDims(1); + std::vector cDims(1); cDims[0] = 1; float fnum = 0.0f; int inum = 0; AttributeMatrix::Pointer am = AttributeMatrix::New(tDims, SIMPL::Defaults::CellAttributeMatrixName, AttributeMatrix::Type::Cell); - DataArray::Pointer data = DataArray::CreateArray(tDims, cDims, "TestArrayFloat"); - DataArray::Pointer data1 = DataArray::CreateArray(tDims, cDims, "TestArrayInt"); + DataArray::Pointer data = DataArray::CreateArray(tDims, cDims, "TestArrayFloat", true); + DataArray::Pointer data1 = DataArray::CreateArray(tDims, cDims, "TestArrayInt", true); // Fill the float array with {.01,.02,.03,.04,.05,.06,.07,.08,.09,.10,.11,.12,.13,.14,.15.,16,.17,.18,.19,.20} // Fill the int array with { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 } @@ -107,10 +122,10 @@ class MultiThresholdObjectsTest data1->setValue(i, inum); // int array inum += 1; } - am->addAttributeArray(data->getName(), data); // float array - am->addAttributeArray(data1->getName(), data1); // int array - vdc->addAttributeMatrix(am->getName(), am); - dca->addDataContainer(vdc); + am->insertOrAssign(data); // float array + am->insertOrAssign(data1); // int array + vdc->addOrReplaceAttributeMatrix(am); + dca->addOrReplaceDataContainer(vdc); // Now instantiate the MultiThresholdObjectsTest Filter from the FilterManager QString filtName = "MultiThresholdObjects"; @@ -144,7 +159,7 @@ class MultiThresholdObjectsTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - DREAM3D_REQUIRED(filter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(filter->getErrorCode(), >=, 0); DataArrayPath path = DataArrayPath("dc1", SIMPL::Defaults::CellAttributeMatrixName, SIMPL::GeneralData::ThresholdArray); IDataArray::Pointer thresholdArray = vdc->getAttributeMatrix(path.getAttributeMatrixName())->getAttributeArray(path.getDataArrayName()); @@ -179,7 +194,7 @@ class MultiThresholdObjectsTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - DREAM3D_REQUIRED(filter->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(filter->getErrorCode(), >=, 0); DataArrayPath path1 = DataArrayPath("dc1", SIMPL::Defaults::CellAttributeMatrixName, "ThresholdArray1"); IDataArray::Pointer thresholdArray1 = vdc->getAttributeMatrix(path1.getAttributeMatrixName())->getAttributeArray(path1.getDataArrayName()); @@ -204,8 +219,8 @@ class MultiThresholdObjectsTest } /** -* @brief -*/ + * @brief + */ void operator()() { int err = EXIT_SUCCESS; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/PipelinePauseTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/PipelinePauseTest.cpp index 9ccb4dc7b9..48a8c5d2c2 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/PipelinePauseTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/PipelinePauseTest.cpp @@ -1,46 +1,48 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include #include #include #include +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.hpp" - +#include "SIMPLib/CoreFilters/Breakpoint.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" @@ -48,14 +50,10 @@ #include "SIMPLib/Math/SIMPLibMath.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/TestFilters/ChangeGlobalValue.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/Breakpoint.h" -#include "SIMPLib/TestFilters/ChangeGlobalValue.h" - int GlobalVariable = 0; class PipelinePauseTest : public QObject @@ -71,7 +69,24 @@ class PipelinePauseTest : public QObject virtual ~PipelinePauseTest() { } - SIMPL_TYPE_MACRO(PipelinePauseTest) + /** + * @brief Returns the name of the class for PipelinePauseTest + */ + /** + * @brief Returns the name of the class for PipelinePauseTest + */ + QString getNameOfClass() const + { + return QString("PipelinePauseTest"); + } + + /** + * @brief Returns the name of the class for PipelinePauseTest + */ + QString ClassName() + { + return QString("PipelinePauseTest"); + } // ----------------------------------------------------------------------------- // @@ -140,7 +155,7 @@ class PipelinePauseTest : public QObject m_WorkerThread->start(); } -public slots: +public Q_SLOTS: // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -160,7 +175,7 @@ public slots: DREAM3D_REQUIRE_EQUAL(GlobalVariable, 3); std::cout << "GlobalVariable = 3" << std::endl; - emit pipelineIsResuming(); + Q_EMIT pipelineIsResuming(); } // ----------------------------------------------------------------------------- @@ -173,7 +188,7 @@ public slots: std::cout << "GlobalVariable = 7" << std::endl; } -signals: +Q_SIGNALS: void pipelineIsResuming(); void testFinished(); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/PostSlackMessageTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/PostSlackMessageTest.cpp index eced49ef27..fb29f904a9 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/PostSlackMessageTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/PostSlackMessageTest.cpp @@ -2,11 +2,10 @@ // Insert your license & copyright information here // ----------------------------------------------------------------------------- -#include #include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/SIMPLibSetGetMacros.h" - #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" @@ -14,7 +13,6 @@ #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RawBinaryReaderTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RawBinaryReaderTest.cpp index 637a91216a..08197f685d 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RawBinaryReaderTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RawBinaryReaderTest.cpp @@ -1,51 +1,52 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include #include +#include #include #include -#include #include #include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/ScopedFileMonitor.hpp" #include "SIMPLib/CoreFilters/RawBinaryReader.h" -#include "SIMPLib/SIMPLib.h" - +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -89,7 +90,7 @@ enum JunkPlacement End, Both }; -} +} // namespace Detail class RawBinaryReaderTest { @@ -116,7 +117,8 @@ class RawBinaryReaderTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template bool createAndWriteToFile(T* dataArray, size_t dataSize, T* junkArray, size_t junkSize, Detail::JunkPlacement junkPlacement) + template + bool createAndWriteToFile(T* dataArray, size_t dataSize, T* junkArray, size_t junkSize, Detail::JunkPlacement junkPlacement) { /* Any of these combinations will return failure: * If the junkArray has values and junkPlacement is set to NONE @@ -207,7 +209,7 @@ class RawBinaryReaderTest // filt->setOrigin(origin); // FloatVec3Widget_t spacing; // spacing.x = spacing.y = spacing.z = 0.55f; - // filt->setResolution(spacing); + // filt->setSpacing(spacing); filt->setCreatedAttributeArrayPath(DataArrayPath("DataContainer", "AttributeMatrix", "Test_Array")); return filt; @@ -217,16 +219,16 @@ class RawBinaryReaderTest // // ----------------------------------------------------------------------------- // testCase1: This tests when the file size is equal to the allocated size, and checks to see if the data read is the same as the data written. - template int testCase1_Execute(const QString& name, SIMPL::NumericTypes::Type scalarType) + template + int testCase1_Execute(SIMPL::NumericTypes::Type scalarType) { + size_t dataArraySize = k_ArraySize * N; + size_t junkArraySize = 0; + size_t skipHeaderBytes = 0; int err = 0; - int dataArraySize = k_ArraySize * N; - int junkArraySize = 0; - int skipHeaderBytes = 0; - //// qDebug() << "Testing case 1: " << name << " with num comps " << N; // Allocate an array, and get the dataArray from that array - typename DataArray::Pointer array = DataArray::CreateArray(dataArraySize, "_Temp_"); // This makes sure our allocated array is deleted when we leave + typename DataArray::Pointer array = DataArray::CreateArray(dataArraySize, std::string("_Temp_"), true); T* dataArray = array->getPointer(0); // Write some data into the data array @@ -245,14 +247,14 @@ class RawBinaryReaderTest DREAM3D_REQUIRED(result, ==, true) // Create the attribute matrix - QVector dims(1, k_ArraySize); + std::vector dims(1, k_ArraySize); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - m->addAttributeMatrix("AttributeMatrix", am); + m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); @@ -260,14 +262,14 @@ class RawBinaryReaderTest // Preflight, get the error condition, and check that there are no errors filt->preflight(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) am->clearAttributeArrays(); // Execute the filter, check that there are no errors, and compare the data filt->execute(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) IDataArray::Pointer iData = am->getAttributeArray("Test_Array"); @@ -285,11 +287,12 @@ class RawBinaryReaderTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void testCase1_TestPrimitives(const QString& name, SIMPL::NumericTypes::Type scalarType) + template + void testCase1_TestPrimitives(SIMPL::NumericTypes::Type scalarType) { - testCase1_Execute(name, scalarType); - testCase1_Execute(name, scalarType); - testCase1_Execute(name, scalarType); + testCase1_Execute(scalarType); + testCase1_Execute(scalarType); + testCase1_Execute(scalarType); } // ----------------------------------------------------------------------------- @@ -306,32 +309,34 @@ class RawBinaryReaderTest return; } - testCase1_TestPrimitives("int8_t", SIMPL::NumericTypes::Type::Int8); - testCase1_TestPrimitives("uint8_t", SIMPL::NumericTypes::Type::UInt8); - testCase1_TestPrimitives("int16_t", SIMPL::NumericTypes::Type::Int16); - testCase1_TestPrimitives("uint16_t", SIMPL::NumericTypes::Type::UInt16); - testCase1_TestPrimitives("int32_t", SIMPL::NumericTypes::Type::Int32); - testCase1_TestPrimitives("uint32_t", SIMPL::NumericTypes::Type::UInt32); - testCase1_TestPrimitives("int64_t", SIMPL::NumericTypes::Type::Int64); - testCase1_TestPrimitives("uint64_t", SIMPL::NumericTypes::Type::UInt64); - testCase1_TestPrimitives("float", SIMPL::NumericTypes::Type::Float); - testCase1_TestPrimitives("double", SIMPL::NumericTypes::Type::Double); + testCase1_TestPrimitives(SIMPL::NumericTypes::Type::Int8); + testCase1_TestPrimitives(SIMPL::NumericTypes::Type::UInt8); + testCase1_TestPrimitives(SIMPL::NumericTypes::Type::Int16); + testCase1_TestPrimitives(SIMPL::NumericTypes::Type::UInt16); + testCase1_TestPrimitives(SIMPL::NumericTypes::Type::Int32); + testCase1_TestPrimitives(SIMPL::NumericTypes::Type::UInt32); + testCase1_TestPrimitives(SIMPL::NumericTypes::Type::Int64); + testCase1_TestPrimitives(SIMPL::NumericTypes::Type::UInt64); + testCase1_TestPrimitives(SIMPL::NumericTypes::Type::Float); + testCase1_TestPrimitives(SIMPL::NumericTypes::Type::Double); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // testCase2: This tests when the file size is smaller than the allocated size. (Reading past the end of the file) - template void testCase2_Execute(const QString& name, SIMPL::NumericTypes::Type scalarType) + template + void testCase2_Execute(SIMPL::NumericTypes::Type scalarType) { + size_t dataArraySize = k_ArraySize * N / 2; // We don't care what is written...we just need the data array size to be less than the file size + size_t junkArraySize = 0; + size_t skipHeaderBytes = junkArraySize * sizeof(T); int err = 0; - int dataArraySize = k_ArraySize * N / 2; // We don't care what is written...we just need the data array size to be less than the file size - int junkArraySize = 0; - int skipHeaderBytes = junkArraySize * sizeof(T); // qDebug() << "Testing case 2: " << name << " with num comps " << N; // Allocate an array, and get the dataArray from that array - typename DataArray::Pointer array = DataArray::CreateArray(dataArraySize, "_Temp_"); // This makes sure our allocated array is deleted when we leave + typename DataArray::Pointer array = DataArray::CreateArray(dataArraySize, std::string("_Temp_"), + true); // This makes sure our allocated array is deleted when we leave T* dataArray = array->getPointer(0); // Write some data into the data array @@ -350,14 +355,14 @@ class RawBinaryReaderTest DREAM3D_REQUIRED(result, ==, true) // Create the attribute matrix - QVector dims(1, k_ArraySize); + std::vector dims(1, k_ArraySize); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - m->addAttributeMatrix("AttributeMatrix", am); + m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); @@ -365,25 +370,26 @@ class RawBinaryReaderTest // Preflight, get error condition, and check that the "file is too small" error is returned filt->preflight(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, ==, RBRT_FILE_TOO_SMALL) am->clearAttributeArrays(); // Execute, get error condition, and check that the "file is too small" error is returned filt->execute(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, ==, RBRT_FILE_TOO_SMALL) } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void testCase2_TestPrimitives(const QString& name, SIMPL::NumericTypes::Type scalarType) + template + void testCase2_TestPrimitives(SIMPL::NumericTypes::Type scalarType) { - testCase2_Execute(name, scalarType); - testCase2_Execute(name, scalarType); - testCase2_Execute(name, scalarType); + testCase2_Execute(scalarType); + testCase2_Execute(scalarType); + testCase2_Execute(scalarType); } // ----------------------------------------------------------------------------- @@ -400,32 +406,34 @@ class RawBinaryReaderTest return; } - testCase2_TestPrimitives("int8_t", SIMPL::NumericTypes::Type::Int8); - testCase2_TestPrimitives("uint8_t", SIMPL::NumericTypes::Type::UInt8); - testCase2_TestPrimitives("int16_t", SIMPL::NumericTypes::Type::Int16); - testCase2_TestPrimitives("uint16_t", SIMPL::NumericTypes::Type::UInt16); - testCase2_TestPrimitives("int32_t", SIMPL::NumericTypes::Type::Int32); - testCase2_TestPrimitives("uint32_t", SIMPL::NumericTypes::Type::UInt32); - testCase2_TestPrimitives("int64_t", SIMPL::NumericTypes::Type::Int64); - testCase2_TestPrimitives("uint64_t", SIMPL::NumericTypes::Type::UInt64); - testCase2_TestPrimitives("float", SIMPL::NumericTypes::Type::Float); - testCase2_TestPrimitives("double", SIMPL::NumericTypes::Type::Double); + testCase2_TestPrimitives(SIMPL::NumericTypes::Type::Int8); + testCase2_TestPrimitives(SIMPL::NumericTypes::Type::UInt8); + testCase2_TestPrimitives(SIMPL::NumericTypes::Type::Int16); + testCase2_TestPrimitives(SIMPL::NumericTypes::Type::UInt16); + testCase2_TestPrimitives(SIMPL::NumericTypes::Type::Int32); + testCase2_TestPrimitives(SIMPL::NumericTypes::Type::UInt32); + testCase2_TestPrimitives(SIMPL::NumericTypes::Type::Int64); + testCase2_TestPrimitives(SIMPL::NumericTypes::Type::UInt64); + testCase2_TestPrimitives(SIMPL::NumericTypes::Type::Float); + testCase2_TestPrimitives(SIMPL::NumericTypes::Type::Double); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // testCase3: This tests when the file size is larger than the allocated size and there is junk at the end of the file. - template void testCase3_Execute(const QString& name, SIMPL::NumericTypes::Type scalarType) + template + void testCase3_Execute(SIMPL::NumericTypes::Type scalarType) { - int dataArraySize = k_ArraySize * N; - int junkArraySize = 10; - int skipHeaderBytes = 0; + size_t dataArraySize = k_ArraySize * N; + size_t junkArraySize = 10; + size_t skipHeaderBytes = 0; int err = 0; // qDebug() << "Testing case 3: " << name << " with num comps " << N; // Allocate an array, and get the dataArray from that array - typename DataArray::Pointer array = DataArray::CreateArray(dataArraySize, "_Temp__"); // This makes sure our allocated array is deleted when we leave + typename DataArray::Pointer array = DataArray::CreateArray(dataArraySize, std::string("_Temp__"), + true); // This makes sure our allocated array is deleted when we leave T* dataArray = array->getPointer(0); // Write some data into the data array @@ -435,29 +443,26 @@ class RawBinaryReaderTest } // Create junkArray - T* junkArray = new T[junkArraySize]; + std::vector junkArray(junkArraySize); // Write a pattern into junkArray - for(size_t i = 0; i < junkArraySize; ++i) - { - junkArray[i] = (unsigned)0xAB; - } + std::memset(junkArray.data(), 0xAB, junkArray.size() * sizeof(T)); // Create the file and write to it. If any of the information is wrong, the result will be false - bool result = createAndWriteToFile(dataArray, dataArraySize, junkArray, junkArraySize, Detail::End); + bool result = createAndWriteToFile(dataArray, dataArraySize, junkArray.data(), junkArraySize, Detail::End); // Test to make sure that the file was created and written to successfully DREAM3D_REQUIRED(result, ==, true) // Create the attribute matrix - QVector dims(1, k_ArraySize); + std::vector dims(1, k_ArraySize); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - m->addAttributeMatrix("AttributeMatrix", am); + m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); @@ -465,14 +470,14 @@ class RawBinaryReaderTest // Preflight, get the error condition, and check that there are no errors filt->preflight(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) am->clearAttributeArrays(); // Execute, get the error condition, check that there are no errors, and compare the data filt->execute(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) IDataArray::Pointer iData = am->getAttributeArray("Test_Array"); @@ -489,11 +494,12 @@ class RawBinaryReaderTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void testCase3_TestPrimitives(const QString& name, SIMPL::NumericTypes::Type scalarType) + template + void testCase3_TestPrimitives(SIMPL::NumericTypes::Type scalarType) { - testCase3_Execute(name, scalarType); - testCase3_Execute(name, scalarType); - testCase3_Execute(name, scalarType); + testCase3_Execute(scalarType); + testCase3_Execute(scalarType); + testCase3_Execute(scalarType); } // ----------------------------------------------------------------------------- @@ -510,32 +516,33 @@ class RawBinaryReaderTest return; } - testCase3_TestPrimitives("int8_t", SIMPL::NumericTypes::Type::Int8); - testCase3_TestPrimitives("uint8_t", SIMPL::NumericTypes::Type::UInt8); - testCase3_TestPrimitives("int16_t", SIMPL::NumericTypes::Type::Int16); - testCase3_TestPrimitives("uint16_t", SIMPL::NumericTypes::Type::UInt16); - testCase3_TestPrimitives("int32_t", SIMPL::NumericTypes::Type::Int32); - testCase3_TestPrimitives("uint32_t", SIMPL::NumericTypes::Type::UInt32); - testCase3_TestPrimitives("int64_t", SIMPL::NumericTypes::Type::Int64); - testCase3_TestPrimitives("uint64_t", SIMPL::NumericTypes::Type::UInt64); - testCase3_TestPrimitives("float", SIMPL::NumericTypes::Type::Float); - testCase3_TestPrimitives("double", SIMPL::NumericTypes::Type::Double); + testCase3_TestPrimitives(SIMPL::NumericTypes::Type::Int8); + testCase3_TestPrimitives(SIMPL::NumericTypes::Type::UInt8); + testCase3_TestPrimitives(SIMPL::NumericTypes::Type::Int16); + testCase3_TestPrimitives(SIMPL::NumericTypes::Type::UInt16); + testCase3_TestPrimitives(SIMPL::NumericTypes::Type::Int32); + testCase3_TestPrimitives(SIMPL::NumericTypes::Type::UInt32); + testCase3_TestPrimitives(SIMPL::NumericTypes::Type::Int64); + testCase3_TestPrimitives(SIMPL::NumericTypes::Type::UInt64); + testCase3_TestPrimitives(SIMPL::NumericTypes::Type::Float); + testCase3_TestPrimitives(SIMPL::NumericTypes::Type::Double); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // testCase4: This tests when the file size is larger than the allocated size and there is junk at the beginning of the file. - template void testCase4_Execute(const QString& name, SIMPL::NumericTypes::Type scalarType) + template + void testCase4_Execute(SIMPL::NumericTypes::Type scalarType) { - int dataArraySize = k_ArraySize * N; - int junkArraySize = 5; - int skipHeaderBytes = junkArraySize * sizeof(T); + size_t dataArraySize = k_ArraySize * N; + size_t junkArraySize = 5; + size_t skipHeaderBytes = junkArraySize * sizeof(T); int err = 0; // qDebug() << "Testing case 4: " << name << " with num comps " << N; // Allocate an array, and get the dataArray from that array - typename DataArray::Pointer array = DataArray::CreateArray(dataArraySize, "_Temp_"); // This makes sure our allocated array is deleted when we leave + typename DataArray::Pointer array = DataArray::CreateArray(dataArraySize, std::string("_Temp_"), true); T* dataArray = array->getPointer(0); // Write some data into the data array @@ -545,29 +552,26 @@ class RawBinaryReaderTest } // Create junkArray - T* junkArray = new T[junkArraySize]; + std::vector junkArray(junkArraySize, 0xAB); // Write a pattern into junkArray - for(size_t i = 0; i < junkArraySize; ++i) - { - junkArray[i] = (unsigned)0xAB; - } + std::memset(junkArray.data(), 0xAB, junkArray.size() * sizeof(T)); // Create the file and write to it. If any of the information is wrong, the result will be false - bool result = createAndWriteToFile(dataArray, dataArraySize, junkArray, junkArraySize, Detail::Start); + bool result = createAndWriteToFile(dataArray, dataArraySize, junkArray.data(), junkArray.size(), Detail::Start); // Test to make sure that the file was created and written to successfully DREAM3D_REQUIRED(result, ==, true) // Create the attribute matrix - QVector dims(1, k_ArraySize); + std::vector dims(1, k_ArraySize); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - m->addAttributeMatrix("AttributeMatrix", am); + m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); @@ -575,14 +579,14 @@ class RawBinaryReaderTest // Preflight, get error condition, and check that there are no errors filt->preflight(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) am->clearAttributeArrays(); // Execute, get error condition, check that there are no errors, and compare the data filt->execute(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) IDataArray::Pointer iData = m->getAttributeMatrix(SIMPL::Defaults::AttributeMatrixName)->getAttributeArray("Test_Array"); @@ -601,9 +605,9 @@ class RawBinaryReaderTest // Create another data container DataContainer::Pointer m2 = DataContainer::New(SIMPL::Defaults::DataContainerName); - m2->addAttributeMatrix("AttributeMatrix", am); + m2->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca2 = DataContainerArray::New(); - dca2->addDataContainer(m2); + dca2->addOrReplaceDataContainer(m2); // Create another filter, passing in the skipHeaderBytes + 1 RawBinaryReader::Pointer filt2 = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes + 1); @@ -613,25 +617,26 @@ class RawBinaryReaderTest // Preflight, get error condition, and check that there are errors filt2->preflight(); - err = filt2->getErrorCondition(); + err = filt2->getErrorCode(); DREAM3D_REQUIRED(err, <, 0) am->clearAttributeArrays(); // Execute, get error condition, and check that the "file too small" error occurred filt2->execute(); - err = filt2->getErrorCondition(); + err = filt2->getErrorCode(); DREAM3D_REQUIRED(err, ==, RBRT_FILE_TOO_SMALL) } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void testCase4_TestPrimitives(const QString& name, SIMPL::NumericTypes::Type scalarType) + template + void testCase4_TestPrimitives(SIMPL::NumericTypes::Type scalarType) { - testCase4_Execute(name, scalarType); - testCase4_Execute(name, scalarType); - testCase4_Execute(name, scalarType); + testCase4_Execute(scalarType); + testCase4_Execute(scalarType); + testCase4_Execute(scalarType); } // ----------------------------------------------------------------------------- @@ -648,32 +653,34 @@ class RawBinaryReaderTest return; } - testCase4_TestPrimitives("int8_t", SIMPL::NumericTypes::Type::Int8); - testCase4_TestPrimitives("uint8_t", SIMPL::NumericTypes::Type::UInt8); - testCase4_TestPrimitives("int16_t", SIMPL::NumericTypes::Type::Int16); - testCase4_TestPrimitives("uint16_t", SIMPL::NumericTypes::Type::UInt16); - testCase4_TestPrimitives("int32_t", SIMPL::NumericTypes::Type::Int32); - testCase4_TestPrimitives("uint32_t", SIMPL::NumericTypes::Type::UInt32); - testCase4_TestPrimitives("int64_t", SIMPL::NumericTypes::Type::Int64); - testCase4_TestPrimitives("uint64_t", SIMPL::NumericTypes::Type::UInt64); - testCase4_TestPrimitives("float", SIMPL::NumericTypes::Type::Float); - testCase4_TestPrimitives("double", SIMPL::NumericTypes::Type::Double); + testCase4_TestPrimitives(SIMPL::NumericTypes::Type::Int8); + testCase4_TestPrimitives(SIMPL::NumericTypes::Type::UInt8); + testCase4_TestPrimitives(SIMPL::NumericTypes::Type::Int16); + testCase4_TestPrimitives(SIMPL::NumericTypes::Type::UInt16); + testCase4_TestPrimitives(SIMPL::NumericTypes::Type::Int32); + testCase4_TestPrimitives(SIMPL::NumericTypes::Type::UInt32); + testCase4_TestPrimitives(SIMPL::NumericTypes::Type::Int64); + testCase4_TestPrimitives(SIMPL::NumericTypes::Type::UInt64); + testCase4_TestPrimitives(SIMPL::NumericTypes::Type::Float); + testCase4_TestPrimitives(SIMPL::NumericTypes::Type::Double); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // testCase5: This tests when the file size is larger than the allocated size and there is junk both at the beginning and end of the file. - template void testCase5_Execute(const QString& name, SIMPL::NumericTypes::Type scalarType) + template + void testCase5_Execute(SIMPL::NumericTypes::Type scalarType) { - int dataArraySize = k_ArraySize * N; - int junkArraySize = 10; - int skipHeaderBytes = junkArraySize * sizeof(T); + size_t dataArraySize = k_ArraySize * N; + size_t junkArraySize = 10; + size_t skipHeaderBytes = junkArraySize * sizeof(T); int err = 0; // qDebug() << "Testing case 5: " << name << " with num comps " << N; // Allocate an array, and get the dataArray from that array - typename DataArray::Pointer array = DataArray::CreateArray(dataArraySize, "_Temp_"); // This makes sure our allocated array is deleted when we leave + typename DataArray::Pointer array = DataArray::CreateArray(dataArraySize, std::string("_Temp_"), + true); // This makes sure our allocated array is deleted when we leave T* dataArray = array->getPointer(0); // Write some data into the data array @@ -683,29 +690,26 @@ class RawBinaryReaderTest } // Create junkArray - T* junkArray = new T[junkArraySize]; + std::vector junkArray(junkArraySize, 0xAB); // Write a pattern into junkArray - for(size_t i = 0; i < junkArraySize; ++i) - { - junkArray[i] = (unsigned)0xAB; - } + std::memset(junkArray.data(), 0xAB, junkArray.size() * sizeof(T)); // Create the file and write to it. If any of the information is wrong, the result will be false - bool result = createAndWriteToFile(dataArray, dataArraySize, junkArray, junkArraySize, Detail::Both); + bool result = createAndWriteToFile(dataArray, dataArraySize, junkArray.data(), junkArray.size(), Detail::Both); // Test to make sure that the file was created and written to successfully DREAM3D_REQUIRED(result, ==, true) // Create the attribute matrix - QVector dims(1, k_ArraySize); + std::vector dims(1, k_ArraySize); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - m->addAttributeMatrix("AttributeMatrix", am); + m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); @@ -713,14 +717,14 @@ class RawBinaryReaderTest // Preflight, get error condition, and check that there are no errors filt->preflight(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) am->clearAttributeArrays(); // Execute, get error condition, check that there are no errors, and compare the data filt->execute(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) IDataArray::Pointer iData = m->getAttributeMatrix(SIMPL::Defaults::AttributeMatrixName)->getAttributeArray("Test_Array"); @@ -737,11 +741,12 @@ class RawBinaryReaderTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void testCase5_TestPrimitives(const QString& name, SIMPL::NumericTypes::Type scalarType) + template + void testCase5_TestPrimitives(SIMPL::NumericTypes::Type scalarType) { - testCase5_Execute(name, scalarType); - testCase5_Execute(name, scalarType); - testCase5_Execute(name, scalarType); + testCase5_Execute(scalarType); + testCase5_Execute(scalarType); + testCase5_Execute(scalarType); } // ----------------------------------------------------------------------------- @@ -758,32 +763,34 @@ class RawBinaryReaderTest return; } - testCase5_TestPrimitives("int8_t", SIMPL::NumericTypes::Type::Int8); - testCase5_TestPrimitives("uint8_t", SIMPL::NumericTypes::Type::UInt8); - testCase5_TestPrimitives("int16_t", SIMPL::NumericTypes::Type::Int16); - testCase5_TestPrimitives("uint16_t", SIMPL::NumericTypes::Type::UInt16); - testCase5_TestPrimitives("int32_t", SIMPL::NumericTypes::Type::Int32); - testCase5_TestPrimitives("uint32_t", SIMPL::NumericTypes::Type::UInt32); - testCase5_TestPrimitives("int64_t", SIMPL::NumericTypes::Type::Int64); - testCase5_TestPrimitives("uint64_t", SIMPL::NumericTypes::Type::UInt64); - testCase5_TestPrimitives("float", SIMPL::NumericTypes::Type::Float); - testCase5_TestPrimitives("double", SIMPL::NumericTypes::Type::Double); + testCase5_TestPrimitives(SIMPL::NumericTypes::Type::Int8); + testCase5_TestPrimitives(SIMPL::NumericTypes::Type::UInt8); + testCase5_TestPrimitives(SIMPL::NumericTypes::Type::Int16); + testCase5_TestPrimitives(SIMPL::NumericTypes::Type::UInt16); + testCase5_TestPrimitives(SIMPL::NumericTypes::Type::Int32); + testCase5_TestPrimitives(SIMPL::NumericTypes::Type::UInt32); + testCase5_TestPrimitives(SIMPL::NumericTypes::Type::Int64); + testCase5_TestPrimitives(SIMPL::NumericTypes::Type::UInt64); + testCase5_TestPrimitives(SIMPL::NumericTypes::Type::Float); + testCase5_TestPrimitives(SIMPL::NumericTypes::Type::Double); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // testCase6: This tests when skipHeaderBytes equals the file size - template void testCase6_Execute(const QString& name, SIMPL::NumericTypes::Type scalarType) + template + void testCase6_Execute(SIMPL::NumericTypes::Type scalarType) { - int dataArraySize = 1000; - int junkArraySize = k_ArraySize * N; + size_t dataArraySize = 1000; + size_t junkArraySize = k_ArraySize * N; int skipHeaderBytes = junkArraySize * sizeof(T); int err = 0; // qDebug() << "Testing case 6: " << name << " with num comps " << N; // Allocate an array, and get the dataArray from that array - typename DataArray::Pointer array = DataArray::CreateArray(dataArraySize, "_Temp_"); // This makes sure our allocated array is deleted when we leave + typename DataArray::Pointer array = DataArray::CreateArray(dataArraySize, std::string("_Temp_"), + true); // This makes sure our allocated array is deleted when we leave T* dataArray = array->getPointer(0); // Write some data into the data array @@ -793,29 +800,26 @@ class RawBinaryReaderTest } // Create junkArray - T* junkArray = new T[junkArraySize]; + std::vector junkArray(junkArraySize, 0xAB); // Write a pattern into junkArray - for(size_t i = 0; i < junkArraySize; ++i) - { - junkArray[i] = (unsigned)0xAB; - } + std::memset(junkArray.data(), 0xAB, junkArray.size() * sizeof(T)); // Create the file and write to it. If any of the information is wrong, the result will be false - bool result = createAndWriteToFile(dataArray, dataArraySize, junkArray, junkArraySize, Detail::Start); + bool result = createAndWriteToFile(dataArray, dataArraySize, junkArray.data(), junkArraySize, Detail::Start); // Test to make sure that the file was created and written to successfully DREAM3D_REQUIRED(result, ==, true) // Create the attribute matrix - QVector dims(1, k_ArraySize); + std::vector dims(1, k_ArraySize); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - m->addAttributeMatrix("AttributeMatrix", am); + m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); @@ -823,23 +827,24 @@ class RawBinaryReaderTest // Preflight, get error condition, and check that the "file too small" error has occurred filt->preflight(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, ==, RBRT_FILE_TOO_SMALL) // Execute, get error condition, and check that there are errors filt->execute(); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); DREAM3D_REQUIRED(err, <, 0) } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void testCase6_TestPrimitives(const QString& name, SIMPL::NumericTypes::Type scalarType) + template + void testCase6_TestPrimitives(SIMPL::NumericTypes::Type scalarType) { - testCase6_Execute(name, scalarType); - testCase6_Execute(name, scalarType); - testCase6_Execute(name, scalarType); + testCase6_Execute(scalarType); + testCase6_Execute(scalarType); + testCase6_Execute(scalarType); } // ----------------------------------------------------------------------------- @@ -856,16 +861,16 @@ class RawBinaryReaderTest return; } - testCase6_TestPrimitives("int8_t", SIMPL::NumericTypes::Type::Int8); - testCase6_TestPrimitives("uint8_t", SIMPL::NumericTypes::Type::UInt8); - testCase6_TestPrimitives("int16_t", SIMPL::NumericTypes::Type::Int16); - testCase6_TestPrimitives("uint16_t", SIMPL::NumericTypes::Type::UInt16); - testCase6_TestPrimitives("int32_t", SIMPL::NumericTypes::Type::Int32); - testCase6_TestPrimitives("uint32_t", SIMPL::NumericTypes::Type::UInt32); - testCase6_TestPrimitives("int64_t", SIMPL::NumericTypes::Type::Int64); - testCase6_TestPrimitives("uint64_t", SIMPL::NumericTypes::Type::UInt64); - testCase6_TestPrimitives("float", SIMPL::NumericTypes::Type::Float); - testCase6_TestPrimitives("double", SIMPL::NumericTypes::Type::Double); + testCase6_TestPrimitives(SIMPL::NumericTypes::Type::Int8); + testCase6_TestPrimitives(SIMPL::NumericTypes::Type::UInt8); + testCase6_TestPrimitives(SIMPL::NumericTypes::Type::Int16); + testCase6_TestPrimitives(SIMPL::NumericTypes::Type::UInt16); + testCase6_TestPrimitives(SIMPL::NumericTypes::Type::Int32); + testCase6_TestPrimitives(SIMPL::NumericTypes::Type::UInt32); + testCase6_TestPrimitives(SIMPL::NumericTypes::Type::Int64); + testCase6_TestPrimitives(SIMPL::NumericTypes::Type::UInt64); + testCase6_TestPrimitives(SIMPL::NumericTypes::Type::Float); + testCase6_TestPrimitives(SIMPL::NumericTypes::Type::Double); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ReadASCIIDataTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ReadASCIIDataTest.cpp index 540ca7483f..203bdc1c95 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ReadASCIIDataTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ReadASCIIDataTest.cpp @@ -1,46 +1,48 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include -#include #include #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" - +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/CoreFilters/ReadASCIIData.h" +#include "SIMPLib/CoreFilters/util/ASCIIWizardData.hpp" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" @@ -48,13 +50,9 @@ #include "SIMPLib/Math/SIMPLibMath.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/ReadASCIIData.h" -#include "SIMPLib/CoreFilters/util/ASCIIWizardData.hpp" - const QString DataContainerName = "DataContainer"; const QString AttributeMatrixName = "AttributeMatrix"; const QString DataArrayName = "Array1"; @@ -74,7 +72,24 @@ class ReadASCIIDataTest public: ReadASCIIDataTest() = default; virtual ~ReadASCIIDataTest() = default; - SIMPL_TYPE_MACRO(ReadASCIIDataTest) + /** + * @brief Returns the name of the class for ReadASCIIDataTest + */ + /** + * @brief Returns the name of the class for ReadASCIIDataTest + */ + QString getNameOfClass() const + { + return QString("ReadASCIIDataTest"); + } + + /** + * @brief Returns the name of the class for ReadASCIIDataTest + */ + QString ClassName() + { + return QString("ReadASCIIDataTest"); + } // ----------------------------------------------------------------------------- // @@ -108,7 +123,8 @@ class ReadASCIIDataTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void CreateFile(const QString& filePath, std::vector values, char /* delimiter */) + template + void CreateFile(const QString& filePath, std::vector values, char /* delimiter */) { QFile data(filePath); if(data.open(QFile::WriteOnly)) @@ -134,9 +150,9 @@ class ReadASCIIDataTest { DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc = DataContainer::New(DataContainerName); - AttributeMatrix::Pointer am = AttributeMatrix::New(QVector(1, data.numberOfLines), AttributeMatrixName, AttributeMatrix::Type::Cell); - dc->addAttributeMatrix(AttributeMatrixName, am); - dca->addDataContainer(dc); + AttributeMatrix::Pointer am = AttributeMatrix::New(std::vector(1, data.numberOfLines), AttributeMatrixName, AttributeMatrix::Type::Cell); + dc->addOrReplaceAttributeMatrix(am); + dca->addOrReplaceDataContainer(dc); // Now instantiate the DxWriter Filter from the FilterManager QString filtName = "ReadASCIIData"; @@ -149,7 +165,7 @@ class ReadASCIIDataTest AbstractFilter::Pointer importASCIIData = filterFactory->create(); importASCIIData->preflight(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, ReadASCIIData::EMPTY_FILE) QVariant var; @@ -158,7 +174,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) importASCIIData->preflight(); - err = importASCIIData->getErrorCondition(); + err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, ReadASCIIData::EMPTY_ATTR_MATRIX) importASCIIData->setDataContainerArray(dca); @@ -172,11 +188,12 @@ class ReadASCIIDataTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void ConvertType() + template + void ConvertType() { char delimiter = '\t'; using DataArrayType = DataArray; - typename DataArrayType::Pointer output = DataArrayType::CreateArray(1, "OutputArray", false); + typename DataArrayType::Pointer output = DataArrayType::CreateArray(1, std::string("OutputArray"), false); QString outputType = output->getTypeAsString(); ASCIIWizardData data; @@ -189,7 +206,7 @@ class ReadASCIIDataTest data.inputFilePath = UnitTest::ReadASCIIDataTest::TestFile1; data.numberOfLines = 10; data.selectedPath = DataArrayPath(DataContainerName, AttributeMatrixName, ""); - data.tupleDims = QVector(1, 10); + data.tupleDims = std::vector(1, 10); // Test Using Expected Input - Double/Float { @@ -199,7 +216,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) AttributeMatrix::Pointer am = importASCIIData->getDataContainerArray()->getAttributeMatrix(DataArrayPath(DataContainerName, AttributeMatrixName, "")); @@ -232,7 +249,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) AttributeMatrix::Pointer am = importASCIIData->getDataContainerArray()->getAttributeMatrix(DataArrayPath(DataContainerName, AttributeMatrixName, "")); @@ -264,7 +281,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, ReadASCIIData::CONVERSION_FAILURE) } @@ -279,7 +296,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) AttributeMatrix::Pointer am = importASCIIData->getDataContainerArray()->getAttributeMatrix(DataArrayPath(DataContainerName, AttributeMatrixName, "")); @@ -313,7 +330,7 @@ class ReadASCIIDataTest DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) AttributeMatrix::Pointer am = importASCIIData->getDataContainerArray()->getAttributeMatrix(DataArrayPath(DataContainerName, AttributeMatrixName, "")); @@ -336,12 +353,12 @@ class ReadASCIIDataTest CreateFile(UnitTest::ReadASCIIDataTest::TestFile1, inputOctVector, delimiter); data.numberOfLines = 7; - data.tupleDims = QVector(1, 7); + data.tupleDims = std::vector(1, 7); AbstractFilter::Pointer importASCIIData = PrepFilter(data); DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, 0) AttributeMatrix::Pointer am = importASCIIData->getDataContainerArray()->getAttributeMatrix(DataArrayPath(DataContainerName, AttributeMatrixName, "")); @@ -364,12 +381,12 @@ class ReadASCIIDataTest CreateFile(UnitTest::ReadASCIIDataTest::TestFile1, inputMaxVector, delimiter); data.numberOfLines = 1; - data.tupleDims = QVector(1, 1); + data.tupleDims = std::vector(1, 1); AbstractFilter::Pointer importASCIIData = PrepFilter(data); DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, ReadASCIIData::CONVERSION_FAILURE) } @@ -400,12 +417,12 @@ class ReadASCIIDataTest CreateFile(UnitTest::ReadASCIIDataTest::TestFile1, inputMinVector, delimiter); data.numberOfLines = 1; - data.tupleDims = QVector(1, 1); + data.tupleDims = std::vector(1, 1); AbstractFilter::Pointer importASCIIData = PrepFilter(data); DREAM3D_REQUIRE_VALID_POINTER(importASCIIData.get()) importASCIIData->execute(); - int err = importASCIIData->getErrorCondition(); + int err = importASCIIData->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, ReadASCIIData::CONVERSION_FAILURE) } } diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveArraysObserver.h b/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveArraysObserver.h index 2ce5451606..a9b801f308 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveArraysObserver.h +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveArraysObserver.h @@ -1,24 +1,48 @@ #pragma once +#include + #include #include -#include "SIMPLib/Common/PipelineMessage.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/SIMPLib.h" #include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Common/PipelineMessage.h" class RemoveArraysObserver : public QObject { Q_OBJECT - SIMPL_INSTANCE_PROPERTY(QList, ErrorList) + /** + * @brief Setter property for ErrorList + */ + void setErrorList(const QList& value); + /** + * @brief Getter property for ErrorList + * @return Value of ErrorList + */ + QList getErrorList() const; + Q_PROPERTY(QList ErrorList READ getErrorList WRITE setErrorList) public: - SIMPL_SHARED_POINTERS(RemoveArraysObserver) - SIMPL_TYPE_MACRO(RemoveArraysObserver) - SIMPL_STATIC_NEW_MACRO(RemoveArraysObserver) + using Self = RemoveArraysObserver; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for RemoveArraysObserver + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for RemoveArraysObserver + */ + static QString ClassName(); + + static Pointer New(); RemoveArraysObserver() { @@ -27,16 +51,18 @@ class RemoveArraysObserver : public QObject { } -public slots: +public Q_SLOTS: void processPipelineMessage(const PipelineMessage& msg) { m_ErrorList.push_back(msg); } public: - RemoveArraysObserver(const RemoveArraysObserver&) = delete; // Copy Constructor Not Implemented - RemoveArraysObserver(RemoveArraysObserver&&) = delete; // Move Constructor Not Implemented + RemoveArraysObserver(const RemoveArraysObserver&) = delete; // Copy Constructor Not Implemented + RemoveArraysObserver(RemoveArraysObserver&&) = delete; // Move Constructor Not Implemented RemoveArraysObserver& operator=(const RemoveArraysObserver&) = delete; // Copy Assignment Not Implemented RemoveArraysObserver& operator=(RemoveArraysObserver&&) = delete; // Move Assignment Not Implemented -}; +private: + QList m_ErrorList = {}; +}; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveArraysTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveArraysTest.cpp index 3ba1de82ea..b5a8ca15f4 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveArraysTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveArraysTest.cpp @@ -1,62 +1,54 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include -#include -#include -#include -#include -#include -#include + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/CoreFilters/RemoveArrays.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/RemoveArrays.h" - class RemoveArraysTest { @@ -69,26 +61,26 @@ class RemoveArraysTest // ----------------------------------------------------------------------------- AbstractFilter::Pointer createFilter() { - QVector vec; + std::vector vec; vec.push_back(1); const QString arrayName = "DataArray"; - DataArray::Pointer da = DataArray::CreateArray(1, vec, arrayName); + DataArray::Pointer da = DataArray::CreateArray(1, vec, arrayName, true); - QVector sizeList; + std::vector sizeList; sizeList.push_back(1); sizeList.push_back(1); sizeList.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(sizeList, "AttributeMatrix", AttributeMatrix::Type::Any); - am->addAttributeArray("DataArray", da); + am->insertOrAssign(da); DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); FilterManager* fm = FilterManager::Instance(); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveComponentFromArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveComponentFromArrayTest.cpp index 93537fa767..fe2456e9f6 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveComponentFromArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RemoveComponentFromArrayTest.cpp @@ -1,56 +1,51 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" - class RemoveComponentFromArrayTest { public: @@ -134,7 +129,7 @@ class RemoveComponentFromArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) } @@ -157,7 +152,7 @@ class RemoveComponentFromArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) } @@ -171,9 +166,9 @@ class RemoveComponentFromArrayTest { DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); - dca->addDataContainer(m); - AttributeMatrix::Pointer attrMatrix = AttributeMatrix::New(QVector(1, numTuples), SIMPL::Defaults::AttributeMatrixName, AttributeMatrix::Type::Generic); - m->addAttributeMatrix(SIMPL::Defaults::AttributeMatrixName, attrMatrix); + dca->addOrReplaceDataContainer(m); + AttributeMatrix::Pointer attrMatrix = AttributeMatrix::New(std::vector(1, numTuples), SIMPL::Defaults::AttributeMatrixName, AttributeMatrix::Type::Generic); + m->addOrReplaceAttributeMatrix(attrMatrix); return dca; } // ----------------------------------------------------------------------------- @@ -214,7 +209,7 @@ class RemoveComponentFromArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); IDataArray::Pointer ReducedArrayPtr = dca->getDataContainer(SIMPL::Defaults::DataContainerName)->getAttributeMatrix(path.getAttributeMatrixName())->getAttributeArray(ReducedArrayArrayName); @@ -258,7 +253,7 @@ class RemoveComponentFromArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -11004); // Test to make sure sending in a single component array fails. @@ -283,7 +278,7 @@ class RemoveComponentFromArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, -11003); } @@ -315,7 +310,8 @@ class RemoveComponentFromArrayTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void TestScalarType(AbstractFilter::Pointer filter, DataArrayPath path, int scalarType) + template + void TestScalarType(AbstractFilter::Pointer filter, DataArrayPath path, int scalarType) { DataContainerArray::Pointer dca = CreateDataContainerArray(); @@ -344,13 +340,13 @@ class RemoveComponentFromArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); dca = CreateDataContainerArray(); filter->setDataContainerArray(dca); filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); { @@ -370,14 +366,14 @@ class RemoveComponentFromArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); dca = CreateDataContainerArray(); filter->setDataContainerArray(dca); filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRE_EQUAL(err, k_NoError); IDataArray::Pointer testArrayPtr = dca->getDataContainer(SIMPL::Defaults::DataContainerName)->getAttributeMatrix(path.getAttributeMatrixName())->getAttributeArray(path.getDataArrayName()); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeArrayTest.cpp index cc8ec233ba..015690ef1d 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeArrayTest.cpp @@ -1,56 +1,52 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "SIMPLib/CoreFilters/RenameAttributeArray.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/RenameAttributeArray.h" - class RenameAttributeArrayTest { public: @@ -91,12 +87,12 @@ class RenameAttributeArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); - QVector dims = QVector(); + std::vector dims = std::vector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); filter->setDataContainerArray(dca); @@ -111,7 +107,7 @@ class RenameAttributeArrayTest filter->setProperty("NewArrayName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11016); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11016); } // ----------------------------------------------------------------------------- @@ -126,15 +122,15 @@ class RenameAttributeArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); - QVector dims = QVector(); + std::vector dims = std::vector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); - DataArray::Pointer da = DataArray::CreateArray(1, "DataArray"); - am->addAttributeArray("DataArray", da); + DataArray::Pointer da = DataArray::CreateArray(1, std::string("DataArray"), true); + am->insertOrAssign(da); filter->setDataContainerArray(dca); @@ -149,7 +145,7 @@ class RenameAttributeArrayTest filter->setProperty("NewArrayName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11016); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11016); } // ----------------------------------------------------------------------------- @@ -164,15 +160,15 @@ class RenameAttributeArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); - QVector dims = QVector(); + std::vector dims = std::vector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); - DataArray::Pointer da = DataArray::CreateArray(1, "DataArray"); - am->addAttributeArray("DataArray", da); + DataArray::Pointer da = DataArray::CreateArray(1, std::string("DataArray"), true); + am->insertOrAssign(da); filter->setDataContainerArray(dca); @@ -187,7 +183,7 @@ class RenameAttributeArrayTest filter->setProperty("NewArrayName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); DREAM3D_REQUIRE_EQUAL(da->getName(), newAttributeArrayName); } @@ -204,15 +200,15 @@ class RenameAttributeArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); - QVector dims = QVector(); + std::vector dims = std::vector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); - DataArray::Pointer da = DataArray::CreateArray(1, "DataArray"); - am->addAttributeArray("DataArray", da); + DataArray::Pointer da = DataArray::CreateArray(1, std::string("DataArray"), true); + am->insertOrAssign(da); filter->setDataContainerArray(dca); @@ -227,7 +223,7 @@ class RenameAttributeArrayTest filter->setProperty("NewArrayName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11009); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11009); } // ----------------------------------------------------------------------------- @@ -242,15 +238,15 @@ class RenameAttributeArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); - QVector dims = QVector(); + std::vector dims = std::vector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); - DataArray::Pointer da = DataArray::CreateArray(1, "DataArray"); - am->addAttributeArray("DataArray", da); + DataArray::Pointer da = DataArray::CreateArray(1, std::string("DataArray"), true); + am->insertOrAssign(da); filter->setDataContainerArray(dca); @@ -264,7 +260,7 @@ class RenameAttributeArrayTest value.setValue(newAttributeArrayName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11009); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11009); } // ----------------------------------------------------------------------------- @@ -279,17 +275,17 @@ class RenameAttributeArrayTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); - QVector dims = QVector(); + std::vector dims = std::vector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); - DataArray::Pointer da = DataArray::CreateArray(1, "DataArray"); - am->addAttributeArray("DataArray", da); - DataArray::Pointer da2 = DataArray::CreateArray(1, "DataArray_2"); - am->addAttributeArray("DataArray_2", da2); + DataArray::Pointer da = DataArray::CreateArray(1, std::string("DataArray"), true); + am->insertOrAssign(da); + DataArray::Pointer da2 = DataArray::CreateArray(1, std::string("DataArray_2"), true); + am->insertOrAssign(da2); filter->setDataContainerArray(dca); @@ -304,7 +300,7 @@ class RenameAttributeArrayTest filter->setProperty("NewArrayName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11017); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11017); } // ----------------------------------------------------------------------------- @@ -327,4 +323,4 @@ class RenameAttributeArrayTest private: RenameAttributeArrayTest(const RenameAttributeArrayTest&); // Copy Constructor Not Implemented void operator=(const RenameAttributeArrayTest&); // Move assignment Not Implemented -}; \ No newline at end of file +}; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeMatrixTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeMatrixTest.cpp index 43195c0a70..34d4f541af 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeMatrixTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameAttributeMatrixTest.cpp @@ -1,56 +1,52 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "SIMPLib/CoreFilters/RenameAttributeMatrix.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/RenameAttributeMatrix.h" - class RenameAttributeMatrixTest { public: @@ -91,7 +87,7 @@ class RenameAttributeMatrixTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); filter->setDataContainerArray(dca); @@ -106,7 +102,7 @@ class RenameAttributeMatrixTest filter->setProperty("NewAttributeMatrix", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -307020); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -307020); } // ----------------------------------------------------------------------------- @@ -121,12 +117,12 @@ class RenameAttributeMatrixTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); - QVector dims = QVector(); + std::vector dims = std::vector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); filter->setDataContainerArray(dca); @@ -141,7 +137,7 @@ class RenameAttributeMatrixTest filter->setProperty("NewAttributeMatrix", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -301000); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -301000); } // ----------------------------------------------------------------------------- @@ -156,12 +152,12 @@ class RenameAttributeMatrixTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); - QVector dims = QVector(); + std::vector dims = std::vector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); filter->setDataContainerArray(dca); @@ -176,7 +172,7 @@ class RenameAttributeMatrixTest filter->setProperty("NewAttributeMatrix", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); DREAM3D_REQUIRE_EQUAL(am->getName(), newAttributeMatrixName); } @@ -193,12 +189,12 @@ class RenameAttributeMatrixTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); - QVector dims = QVector(); + std::vector dims = std::vector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); filter->setDataContainerArray(dca); @@ -213,7 +209,7 @@ class RenameAttributeMatrixTest filter->setProperty("NewAttributeMatrix", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11004); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11004); } // ----------------------------------------------------------------------------- @@ -228,12 +224,12 @@ class RenameAttributeMatrixTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); - QVector dims = QVector(); + std::vector dims = std::vector(); dims.push_back(1); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); - dc->addAttributeMatrix("AttributeMatrix", am); + dc->addOrReplaceAttributeMatrix(am); filter->setDataContainerArray(dca); @@ -247,7 +243,7 @@ class RenameAttributeMatrixTest value.setValue(newAttributeMatrixName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11004); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11004); } // ----------------------------------------------------------------------------- @@ -269,4 +265,4 @@ class RenameAttributeMatrixTest private: RenameAttributeMatrixTest(const RenameAttributeMatrixTest&); // Copy Constructor Not Implemented void operator=(const RenameAttributeMatrixTest&); // Move assignment Not Implemented -}; \ No newline at end of file +}; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameDataContainerTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameDataContainerTest.cpp index 56528a46e7..f44175c29c 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameDataContainerTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameDataContainerTest.cpp @@ -1,56 +1,52 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "SIMPLib/CoreFilters/RenameDataContainer.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/RenameDataContainer.h" - class RenameDataContainerTest { public: @@ -93,16 +89,16 @@ class RenameDataContainerTest QVariant value; - QString dataContainerName = "DataContainer"; + DataArrayPath dataContainerName("DataContainer"); value.setValue(dataContainerName); filter->setProperty("SelectedDataContainerName", value); - QString newDataContainerName = "DataContainer_"; + DataArrayPath newDataContainerName("DataContainer_"); value.setValue(dataContainerName); filter->setProperty("NewDataContainerName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -999); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -999); } // ----------------------------------------------------------------------------- @@ -117,22 +113,22 @@ class RenameDataContainerTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); filter->setDataContainerArray(dca); QVariant value; - QString dataContainerName = ""; + DataArrayPath dataContainerName; value.setValue(dataContainerName); filter->setProperty("SelectedDataContainerName", value); - QString newDataContainerName = "DataContainer_"; + DataArrayPath newDataContainerName("DataContainer_"); value.setValue(dataContainerName); filter->setProperty("NewDataContainerName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11001); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11001); } // ----------------------------------------------------------------------------- @@ -147,24 +143,26 @@ class RenameDataContainerTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); filter->setDataContainerArray(dca); QVariant value; - QString dataContainerName = "DataContainer"; + DataArrayPath dataContainerName("DataContainer"); value.setValue(dataContainerName); filter->setProperty("SelectedDataContainerName", value); - QString newDataContainerName = "Container_2"; + DataArrayPath newDataContainerName("Container_2"); value.setValue(newDataContainerName); filter->setProperty("NewDataContainerName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); + + DataArrayPath dap(dc->getName()); - DREAM3D_REQUIRE_EQUAL(dc->getName(), newDataContainerName); + DREAM3D_REQUIRE_EQUAL(dap, newDataContainerName); } // ----------------------------------------------------------------------------- @@ -179,22 +177,22 @@ class RenameDataContainerTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); filter->setDataContainerArray(dca); QVariant value; - QString dataContainerName = "DataContainer"; + DataArrayPath dataContainerName("DataContainer"); value.setValue(dataContainerName); filter->setProperty("SelectedDataContainerName", value); - QString newDataContainerName = ""; + DataArrayPath newDataContainerName; value.setValue(newDataContainerName); filter->setProperty("NewDataContainerName", value); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11001); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11001); } // ----------------------------------------------------------------------------- @@ -209,21 +207,21 @@ class RenameDataContainerTest DataContainer::Pointer dc = DataContainer::New("DataContainer"); - dca->addDataContainer(dc); + dca->addOrReplaceDataContainer(dc); filter->setDataContainerArray(dca); QVariant value; - QString dataContainerName = "DataContainer"; + DataArrayPath dataContainerName("DataContainer"); value.setValue(dataContainerName); filter->setProperty("SelectedDataContainerName", value); - QString newDataContainerName = ""; + DataArrayPath newDataContainerName; value.setValue(newDataContainerName); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -11001); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -11001); } // ----------------------------------------------------------------------------- @@ -245,4 +243,4 @@ class RenameDataContainerTest private: RenameDataContainerTest(const RenameDataContainerTest&); // Copy Constructor Not Implemented void operator=(const RenameDataContainerTest&); // Move assignment Not Implemented -}; \ No newline at end of file +}; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameTimingTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameTimingTest.cpp new file mode 100644 index 0000000000..526d58c3bf --- /dev/null +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RenameTimingTest.cpp @@ -0,0 +1,150 @@ +/* ============================================================================ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include +#include +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/CoreFilters/RenameDataContainer.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/Filtering/FilterFactory.hpp" +#include "SIMPLib/Filtering/FilterManager.h" +#include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Plugin/ISIMPLibPlugin.h" +#include "SIMPLib/Plugin/SIMPLibPluginLoader.h" +#include "SIMPLib/Testing/SIMPLTestFileLocations.h" +#include "SIMPLib/Testing/UnitTestSupport.hpp" + +class RenameTimingTest +{ +public: + RenameTimingTest() = default; + virtual ~RenameTimingTest() = default; + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + AbstractFilter::Pointer createFilter() + { + // Now instantiate the RenameAttributeArray Filter from the FilterManager + QString filtName = "MassCreateData"; + FilterManager* fm = FilterManager::Instance(); + IFilterFactory::Pointer filterFactory = fm->getFactoryFromClassName(filtName); + if(nullptr == filterFactory.get()) + { + std::stringstream ss; + ss << "The RenameTimingTest Requires the use of the " << filtName.toStdString() << " filter which is found in Core Filters"; + DREAM3D_TEST_THROW_EXCEPTION(ss.str()) + } + + AbstractFilter::Pointer filter = filterFactory->create(); + DREAM3D_REQUIRE(nullptr != filter.get()); + + return filter; + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + FilterPipeline::Pointer createPipeline() + { + const int iterations = 2; + FilterPipeline::Pointer pipeline = FilterPipeline::New(); + for(int i = 0; i < iterations; i++) + { + AbstractFilter::Pointer filter = createFilter(); + + QVariant value; + QString dataContainerName = "DataContainer_" + QString::number(i); + value.setValue(dataContainerName); + filter->setProperty("DataContainerName", value); + pipeline->pushBack(filter); + } + return pipeline; + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void TestPreflightTimes() + { + // const int iterations = 1; + FilterPipeline::Pointer pipeline = createPipeline(); + + { + auto start = std::chrono::steady_clock::now(); + pipeline->preflightPipeline(); + auto end = std::chrono::steady_clock::now(); + + auto elapsed = std::chrono::duration_cast(end - start); + std::cout << "\tFirst Preflight Duration: " << elapsed.count() << " milliseconds" << std::endl; + } + + QVariant value; + value.setValue(QString("NewName")); + AbstractFilter::Pointer filter = pipeline->getFilterContainer().front(); + filter->setProperty("DataContainerName", value); + + { + auto start = std::chrono::steady_clock::now(); + // for(int i = 0; i < iterations; i++) + { + pipeline->preflightPipeline(); + } + auto end = std::chrono::steady_clock::now(); + + auto elapsed = std::chrono::duration_cast(end - start); + std::cout << "\tSecond Preflight Duration: " << elapsed.count() << " milliseconds" << std::endl; + } + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void operator()() + { + std::cout << "#### RenameTimingTest Starting ####" << std::endl; + + int err = EXIT_SUCCESS; + + DREAM3D_REGISTER_TEST(TestPreflightTimes()); + } + +private: + RenameTimingTest(const RenameTimingTest&); // Copy Constructor Not Implemented + void operator=(const RenameTimingTest&); // Move assignment Not Implemented diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ReplaceValueTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ReplaceValueTest.cpp index 353d70988f..9b2c85da30 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ReplaceValueTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ReplaceValueTest.cpp @@ -1,50 +1,50 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include + +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -54,7 +54,7 @@ #define CREATE_DATA_ARRAY(type, attrMat, tDims, cDims, initVal, comps, err) \ DataArray::Pointer _##type##_##comps##_##attrMat##Array = DataArray::CreateArray(tDims, cDims, #type #comps, true); \ - err = attrMat->addAttributeArray(#type #comps, _##type##_##comps##_##attrMat##Array); \ + err = attrMat->insertOrAssign(_##type##_##comps##_##attrMat##Array); \ _##type##_##comps##_##attrMat##Array->initializeWithValue(initVal); \ DREAM3D_REQUIRE(err >= 0); @@ -82,7 +82,7 @@ qDebug() << "Unable to set property ReplaceValue"; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, errVal); #ifdef SET_PROPERTIES_AND_CHECK_EQ @@ -109,7 +109,7 @@ qDebug() << "Unable to set property ReplaceValue"; \ } \ filter->execute(); \ - err = filter->getErrorCondition(); \ + err = filter->getErrorCode(); \ DREAM3D_REQUIRE_EQUAL(err, 0); \ dataArray = dc->getAttributeMatrix(selectedArray.getAttributeMatrixName())->getAttributeArray(selectedArray.getDataArrayName()); \ DREAM3D_REQUIRE_EQUAL(err, 0); \ @@ -151,14 +151,14 @@ class ReplaceValueTest DataContainer::Pointer m = DataContainer::New("ReplaceValueTest"); // Create Attribute Matrices with different tDims to test validation of tuple compatibility - QVector tDims(1, 100); + std::vector tDims(1, 100); AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tDims, "ReplaceValueAttrMat", AttributeMatrix::Type::Cell); - m->addAttributeMatrix("ReplaceValueAttrMat", attrMat); + m->addOrReplaceAttributeMatrix(attrMat); - dca->addDataContainer(m); + dca->addOrReplaceDataContainer(m); - QVector cDims(1, 3); + std::vector cDims(1, 3); int32_t initVal = 10; tDims[0] = 100; @@ -194,7 +194,8 @@ class ReplaceValueTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void validateReplacedValues(IDataArray::Pointer iArray) + template + void validateReplacedValues(IDataArray::Pointer iArray) { typename DataArray::Pointer dataArrayPtr = std::dynamic_pointer_cast>(iArray); T* dataArray = dataArrayPtr->getPointer(0); diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RequiredZThicknessTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RequiredZThicknessTest.cpp index 9bfd6668ac..8fe94c3fc4 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/RequiredZThicknessTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RequiredZThicknessTest.cpp @@ -1,58 +1,54 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "SIMPLib/CoreFilters/RequiredZThickness.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Geometry/ImageGeom.h" +#include "SIMPLib/Geometry/TriangleGeom.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/RequiredZThickness.h" -#include "SIMPLib/Geometry/ImageGeom.h" -#include "SIMPLib/Geometry/TriangleGeom.h" - class RequiredZThicknessTest { public: @@ -67,10 +63,10 @@ class RequiredZThicknessTest DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc1 = DataContainer::New("DataContainer1"); - dca->addDataContainer(dc1); + dca->addOrReplaceDataContainer(dc1); DataContainer::Pointer dc2 = DataContainer::New("DataContainer2"); - dca->addDataContainer(dc2); + dca->addOrReplaceDataContainer(dc2); ImageGeom::Pointer imgGeom = ImageGeom::New(); imgGeom->setDimensions(2, 2, 2); @@ -79,9 +75,9 @@ class RequiredZThicknessTest // incorrect geometry TriangleGeom::Pointer triGeom = TriangleGeom::New(); - QVector dims; + std::vector dims; dims.push_back(3); - DataArray::Pointer verts = DataArray::CreateArray(3, dims, "Vertices"); + DataArray::Pointer verts = DataArray::CreateArray(3, dims, "Vertices", true); verts->setComponent(0, 0, -1); verts->setComponent(0, 1, 0); verts->setComponent(0, 2, 0); @@ -94,9 +90,9 @@ class RequiredZThicknessTest verts->setComponent(2, 1, 1); verts->setComponent(2, 2, 0); - QVector dims2; + std::vector dims2; dims2.push_back(3); - DataArray::Pointer tris = DataArray::CreateArray(1, dims2, "Triangles"); + SharedTriList::Pointer tris = SharedTriList::CreateArray(1, dims2, "Triangles", true); tris->setComponent(0, 0, 0); tris->setComponent(0, 1, 1); @@ -143,7 +139,7 @@ class RequiredZThicknessTest QVariant value; - value.setValue(QString("DataContainer1")); + value.setValue(DataArrayPath("DataContainer1")); filter->setProperty("DataContainerSelection", value); value.setValue(numZVoxels); @@ -162,7 +158,7 @@ class RequiredZThicknessTest QVariant value; - value.setValue(QString("DataContainer2")); + value.setValue(DataArrayPath("DataContainer2")); filter->setProperty("DataContainerSelection", value); value.setValue(numZVoxels); @@ -181,7 +177,7 @@ class RequiredZThicknessTest QVariant value; - value.setValue(QString("DataContainer3")); + value.setValue(DataArrayPath("DataContainer3")); filter->setProperty("DataContainerSelection", value); value.setValue(0); @@ -198,12 +194,12 @@ class RequiredZThicknessTest setGeometryTest(filter, 1); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); // test Z equal to minimum Z setGeometryTest(filter, 2); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); } // ----------------------------------------------------------------------------- @@ -216,7 +212,7 @@ class RequiredZThicknessTest setGeometryTest(filter, 3); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -7788); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -7788); } // ----------------------------------------------------------------------------- @@ -229,7 +225,7 @@ class RequiredZThicknessTest setInvalidGeometry(filter, 3); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -7789); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -7789); } // ----------------------------------------------------------------------------- @@ -243,7 +239,7 @@ class RequiredZThicknessTest setNullDataContainer(filter); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -999); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -999); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/RotateSampleRefFrameTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/RotateSampleRefFrameTest.cpp new file mode 100644 index 0000000000..729fe7fd21 --- /dev/null +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/RotateSampleRefFrameTest.cpp @@ -0,0 +1,478 @@ +/* ============================================================================ + * Copyright (c) 2019-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/CoreFilters/DataContainerReader.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainerArray.h" +#include "SIMPLib/FilterParameters/DynamicTableData.h" +#include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" +#include "SIMPLib/Filtering/FilterFactory.hpp" +#include "SIMPLib/Filtering/FilterManager.h" +#include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Geometry/ImageGeom.h" +#include "SIMPLib/Math/SIMPLibMath.h" +#include "SIMPLib/Plugin/ISIMPLibPlugin.h" +#include "SIMPLib/Plugin/SIMPLibPluginLoader.h" +#include "SIMPLib/Testing/SIMPLTestFileLocations.h" +#include "SIMPLib/Testing/UnitTestSupport.hpp" + +class RotateSampleRefFrameTest +{ +private: + const QString k_FilterName = "RotateSampleRefFrame"; + const QString k_RotationAngleName = "RotationAngle"; + const QString k_RotationAxisName = "RotationAxis"; + const QString k_RotationTableName = "RotationTable"; + const QString k_RotationRepresentationChoiceName = "RotationRepresentationChoice"; + const QString k_CellAttributeMatrixPathName = "CellAttributeMatrixPath"; + const int k_AxisAngle = 0; + const int k_RotationMatrix = 1; + + template + static bool dataArrayEqual(const DataArray& a, const DataArray& b) + { + if(a.getNumberOfComponents() != b.getNumberOfComponents()) + { + return false; + } + + if(a.getNumberOfTuples() != b.getNumberOfTuples()) + { + return false; + } + + return std::equal(a.begin(), a.end(), b.begin(), b.end()); + } + + static bool imageGeomEqual(const ImageGeom& a, const ImageGeom& b) + { + SizeVec3Type dimsA = a.getDimensions(); + FloatVec3Type originA = a.getOrigin(); + FloatVec3Type spacingA = a.getSpacing(); + + SizeVec3Type dimsB = b.getDimensions(); + FloatVec3Type originB = b.getOrigin(); + FloatVec3Type spacingB = b.getSpacing(); + + return (dimsA == dimsB) && (originA == originB) && (spacingA == spacingB); + } + + static bool matrixEqual(const AttributeMatrix& a, const AttributeMatrix& b) + { + return a.getTupleDimensions() == b.getTupleDimensions(); + } + + static void dataContainerEqual(const DataContainerArray& dca, const DataArrayPath& testPath, const DataArrayPath& expectedPath) + { + // Get test + + DataContainer::Pointer testContainer = dca.getDataContainer(testPath); + DREAM3D_REQUIRE_VALID_POINTER(testContainer) + + ImageGeom::Pointer testGeom = testContainer->getGeometryAs(); + DREAM3D_REQUIRE_VALID_POINTER(testGeom) + + AttributeMatrix::Pointer testMatrix = testContainer->getAttributeMatrix(testPath); + DREAM3D_REQUIRE_VALID_POINTER(testMatrix) + + UInt8ArrayType::Pointer testArray = testMatrix->getAttributeArrayAs(testPath.getDataArrayName()); + DREAM3D_REQUIRE_VALID_POINTER(testArray) + + // Get expected + + DataContainer::Pointer expectedContainer = dca.getDataContainer(expectedPath); + DREAM3D_REQUIRE_VALID_POINTER(expectedContainer) + + ImageGeom::Pointer expectedGeom = expectedContainer->getGeometryAs(); + DREAM3D_REQUIRE_VALID_POINTER(expectedGeom) + + AttributeMatrix::Pointer expectedMatrix = expectedContainer->getAttributeMatrix(expectedPath); + DREAM3D_REQUIRE_VALID_POINTER(expectedMatrix) + + UInt8ArrayType::Pointer expectedArray = testMatrix->getAttributeArrayAs(expectedPath.getDataArrayName()); + DREAM3D_REQUIRE_VALID_POINTER(expectedArray) + + // Compare + + bool geometryEqual = imageGeomEqual(*testGeom, *expectedGeom); + DREAM3D_REQUIRE(geometryEqual) + + bool attributeMatrixEqual = matrixEqual(*testMatrix, *expectedMatrix); + DREAM3D_REQUIRE(attributeMatrixEqual) + + bool arraysEqual = dataArrayEqual(*testArray, *expectedArray); + DREAM3D_REQUIRE(arraysEqual) + } + + static void resetGeometry(AttributeMatrix::Pointer matrix, ImageGeom::Pointer imageGeom, const std::vector& tDims) + { + matrix->resizeAttributeArrays(tDims); + imageGeom->setDimensions(tDims); + imageGeom->setOrigin(0.0f, 0.0f, 0.0f); + imageGeom->setSpacing(1.0f, 1.0f, 1.0f); + } + + AbstractFilter::Pointer createFilter() const + { + FilterManager* fm = FilterManager::Instance(); + IFilterFactory::Pointer filterFactory = fm->getFactoryFromClassName(k_FilterName); + DREAM3D_REQUIRE_VALID_POINTER(filterFactory) + + AbstractFilter::Pointer rotateFilter = filterFactory->create(); + DREAM3D_REQUIRE_VALID_POINTER(rotateFilter) + + return rotateFilter; + } + + template + static void setProperty(AbstractFilter::Pointer filter, const QString& property, const T& value) + { + QVariant variant; + variant.setValue(value); + bool propWasSet = filter->setProperty(property.toStdString().c_str(), variant); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) + } + +public: + RotateSampleRefFrameTest() = default; + ~RotateSampleRefFrameTest() = default; + RotateSampleRefFrameTest(const RotateSampleRefFrameTest&) = delete; // Copy Constructor Not Implemented + RotateSampleRefFrameTest(RotateSampleRefFrameTest&&) = delete; // Move Constructor Not Implemented + RotateSampleRefFrameTest& operator=(const RotateSampleRefFrameTest&) = delete; // Copy Assignment Not Implemented + RotateSampleRefFrameTest& operator=(RotateSampleRefFrameTest&&) = delete; // Move Assignment Not Implemented + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void RemoveTestFiles() + { +#if REMOVE_TEST_FILES +#endif + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + int TestFilterAvailability() + { + // Now instantiate the SampleSurfaceMeshSpecifiedPointsTest Filter from the FilterManager + FilterManager* filterManager = FilterManager::Instance(); + IFilterFactory::Pointer filterFactory = filterManager->getFactoryFromClassName(k_FilterName); + if(filterFactory == nullptr) + { + std::stringstream ss; + ss << "The RotateSampleRefFrameTest Requires the use of the " << k_FilterName.toStdString() << " filter which is found in the Sampling Plugin"; + DREAM3D_TEST_THROW_EXCEPTION(ss.str()) + } + return 0; + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void TestFilterParameters() + { + const std::vector tDims{10, 20, 30}; + const DataArrayPath path("DataContainer", "AttributeMatrix", "DataArray"); + + DataContainerArray::Pointer dca = DataContainerArray::New(); + + DataContainer::Pointer dc = DataContainer::New(path.getDataContainerName()); + + ImageGeom::Pointer imageGeom = ImageGeom::New(); + + imageGeom->setDimensions(tDims); + + dc->setGeometry(imageGeom); + + dca->addOrReplaceDataContainer(dc); + + AttributeMatrix::Pointer matrix = dc->createNonPrereqAttributeMatrix(nullptr, path.getAttributeMatrixName(), tDims, AttributeMatrix::Type::Cell); + + AbstractFilter::Pointer rotateFilter = createFilter(); + rotateFilter->setDataContainerArray(dca); + + setProperty(rotateFilter, k_CellAttributeMatrixPathName, path); + setProperty(rotateFilter, k_RotationRepresentationChoiceName, k_AxisAngle); + + // Correct axis angle inputs + + setProperty(rotateFilter, k_RotationAxisName, FloatVec3Type(0.0f, 1.0f, 0.0f)); + setProperty(rotateFilter, k_RotationAngleName, 90.0f); + + rotateFilter->preflight(); + int error = rotateFilter->getErrorCode(); + DREAM3D_REQUIRED(error, >=, 0) + + resetGeometry(matrix, imageGeom, tDims); + + // Non-normalized rotation axis should generate a warning + + setProperty(rotateFilter, k_RotationAxisName, FloatVec3Type(1.0f, 1.0f, 0.0f)); + + rotateFilter->preflight(); + int warning = rotateFilter->getWarningCode(); + DREAM3D_REQUIRED(warning, <, 0) + + resetGeometry(matrix, imageGeom, tDims); + + // Correct rotation matrix inputs + + setProperty(rotateFilter, k_RotationRepresentationChoiceName, k_RotationMatrix); + + // 0 0 1 + // 0 1 0 + // -1 0 0 + + std::vector> table = {{0.0, 0.0, 1.0}, {0.0, 1.0, 0.0}, {-1.0, 0.0, 0.0}}; + + DynamicTableData tableData(table); + + setProperty(rotateFilter, k_RotationTableName, tableData); + + rotateFilter->preflight(); + error = rotateFilter->getErrorCode(); + DREAM3D_REQUIRED(error, >=, 0) + + resetGeometry(matrix, imageGeom, tDims); + + // Inverse != Transpose error + + // 1 0 1 + // 0 1 0 + // 0 0 1 + + table = {{1.0, 0.0, 1.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}; + + tableData.setTableData(table); + + setProperty(rotateFilter, k_RotationTableName, tableData); + + rotateFilter->preflight(); + error = rotateFilter->getErrorCode(); + DREAM3D_REQUIRED(error, <, 0) + + resetGeometry(matrix, imageGeom, tDims); + + // Determinant != 1 error + + // 1 0 1 + // 0 1 0 + // 1 0 1 + + table = {{1.0, 0.0, 1.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 1.0}}; + + tableData.setTableData(table); + + setProperty(rotateFilter, k_RotationTableName, tableData); + + rotateFilter->preflight(); + error = rotateFilter->getErrorCode(); + DREAM3D_REQUIRED(error, <, 0) + + resetGeometry(matrix, imageGeom, tDims); + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void TestRotateSampleRefFrameTest() + { + const DataArrayPath basePath("", "CellData", "Data"); + + // Read test file + + DataContainerArray::Pointer dca = DataContainerArray::New(); + + DataContainerReader::Pointer dataContainerReader = DataContainerReader::New(); + dataContainerReader->setDataContainerArray(dca); + dataContainerReader->setInputFile(UnitTest::RotateSampleRefFrameTest::TestFile1); + DataContainerArrayProxy proxy = dataContainerReader->readDataContainerArrayStructure(UnitTest::RotateSampleRefFrameTest::TestFile1); + dataContainerReader->setInputFileDataContainerArrayProxy(proxy); + + dataContainerReader->execute(); + int error = dataContainerReader->getErrorCode(); + DREAM3D_REQUIRED(error, >=, 0) + + QList dcNames = dca->getDataContainerNames(); + + bool hasOriginal = dcNames.contains("Original"); + + DREAM3D_REQUIRE(hasOriginal) + + AbstractFilter::Pointer rotateFilter = createFilter(); + rotateFilter->setDataContainerArray(dca); + + DataArrayPath originalPath = basePath; + originalPath.setDataContainerName("Original"); + DataContainer::Pointer dcOriginal = dca->getDataContainer(originalPath); + DREAM3D_REQUIRE_VALID_POINTER(dcOriginal) + + bool foundRotated = false; + + for(const auto& name : dcNames) + { + bool isRotated = name.startsWith("Rotate"); + foundRotated = isRotated ? true : foundRotated; + if(!isRotated) + { + continue; + } + + DataArrayPath expectedPath = basePath; + expectedPath.setDataContainerName(name); + + QStringList parts = name.split("_"); + int size = parts.size(); + DREAM3D_REQUIRED(size, ==, 5) + + bool conversionSuccess = false; + + float x = parts[1].toFloat(&conversionSuccess); + DREAM3D_REQUIRE(conversionSuccess) + float y = parts[2].toFloat(&conversionSuccess); + DREAM3D_REQUIRE(conversionSuccess) + float z = parts[3].toFloat(&conversionSuccess); + DREAM3D_REQUIRE(conversionSuccess) + float angle = parts[4].toFloat(&conversionSuccess); + DREAM3D_REQUIRE(conversionSuccess) + + { + // Set to axis angle representation + setProperty(rotateFilter, k_RotationRepresentationChoiceName, k_AxisAngle); + + // Copy original data for rotation + + DataContainer::Pointer dcCopy = dcOriginal->deepCopy(); + dcCopy->setName(name + "_Copy"); + dca->addOrReplaceDataContainer(dcCopy); + + DataArrayPath testPath = basePath; + testPath.setDataContainerName(dcCopy->getName()); + + setProperty(rotateFilter, k_CellAttributeMatrixPathName, testPath); + + // Set properties + + setProperty(rotateFilter, k_RotationAngleName, angle); + setProperty(rotateFilter, k_RotationAxisName, FloatVec3Type(x, y, z)); + + // Execute + + rotateFilter->execute(); + int error = rotateFilter->getErrorCode(); + DREAM3D_REQUIRED(error, >=, 0) + + // Compare + + dataContainerEqual(*dca, testPath, expectedPath); + } + + { + // Set to rotation matrix representation + setProperty(rotateFilter, k_RotationRepresentationChoiceName, k_RotationMatrix); + + // Copy original data for rotation + + DataContainer::Pointer dcCopy = dcOriginal->deepCopy(); + dcCopy->setName(name + "_Copy_Matrix"); + dca->addOrReplaceDataContainer(dcCopy); + + DataArrayPath testPath = basePath; + testPath.setDataContainerName(dcCopy->getName()); + + setProperty(rotateFilter, k_CellAttributeMatrixPathName, testPath); + + // Set properties + + Eigen::Vector3f axis(x, y, z); + float angleRadians = angle * SIMPLib::Constants::k_DegToRadF; + Eigen::AngleAxisf axisAngle(angleRadians, axis); + + Eigen::Matrix3f rotationMatrix = axisAngle.toRotationMatrix(); + + std::vector> data; + + for(int i = 0; i < rotationMatrix.rows(); i++) + { + std::vector row; + for(int j = 0; j < rotationMatrix.cols(); j++) + { + row.push_back(static_cast(rotationMatrix(i, j))); + } + data.push_back(row); + } + + DynamicTableData tableData(data); + + setProperty(rotateFilter, k_RotationTableName, tableData); + + // Execute + + rotateFilter->execute(); + int error = rotateFilter->getErrorCode(); + DREAM3D_REQUIRED(error, >=, 0) + + // Compare + + dataContainerEqual(*dca, testPath, expectedPath); + } + } + + DREAM3D_REQUIRE(foundRotated) + } + + // ----------------------------------------------------------------------------- + // + // ----------------------------------------------------------------------------- + void operator()() + { + std::cout << "----Start RotateSampleRefFrameTest----\n"; + + int err = EXIT_SUCCESS; + DREAM3D_REGISTER_TEST(TestFilterAvailability()) + + DREAM3D_REGISTER_TEST(TestFilterParameters()) + DREAM3D_REGISTER_TEST(TestRotateSampleRefFrameTest()) + + DREAM3D_REGISTER_TEST(RemoveTestFiles()) + + std::cout << "----End RotateSampleRefFrameTest----\n"; + } +}; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/ScaleVolumeTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/ScaleVolumeTest.cpp index 4c9be1f05a..2849d3249d 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/ScaleVolumeTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/ScaleVolumeTest.cpp @@ -1,61 +1,57 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "SIMPLib/CoreFilters/ScaleVolume.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Geometry/ImageGeom.h" +#include "SIMPLib/Geometry/TriangleGeom.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/ScaleVolume.h" -#include "SIMPLib/Geometry/ImageGeom.h" -#include "SIMPLib/Geometry/TriangleGeom.h" - namespace ScaleVolumeTestConsts { -const FloatVec3_t SCALE = FloatVec3_t{3, 3, 3}; +const FloatVec3Type SCALE = FloatVec3Type{3, 3, 3}; } class ScaleVolumeTest @@ -72,16 +68,16 @@ class ScaleVolumeTest DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc1 = DataContainer::New("DataContainer1"); - dca->addDataContainer(dc1); + dca->addOrReplaceDataContainer(dc1); DataContainer::Pointer dc2 = DataContainer::New("DataContainer2"); - dca->addDataContainer(dc2); + dca->addOrReplaceDataContainer(dc2); DataContainer::Pointer dc3 = DataContainer::New("DataContainer3"); - dca->addDataContainer(dc3); + dca->addOrReplaceDataContainer(dc3); DataContainer::Pointer dc4 = DataContainer::New("DataContainer4"); - dca->addDataContainer(dc4); + dca->addOrReplaceDataContainer(dc4); ImageGeom::Pointer imgGeom = ImageGeom::New(); imgGeom->setDimensions(2, 2, 2); @@ -89,9 +85,9 @@ class ScaleVolumeTest TriangleGeom::Pointer triGeom = TriangleGeom::New(); - QVector dims; + std::vector dims; dims.push_back(3); - DataArray::Pointer verts = DataArray::CreateArray(3, dims, "Vertices"); + DataArray::Pointer verts = DataArray::CreateArray(3, dims, "Vertices", true); verts->setComponent(0, 0, -1); verts->setComponent(0, 1, 0); verts->setComponent(0, 2, 0); @@ -104,9 +100,9 @@ class ScaleVolumeTest verts->setComponent(2, 1, 1); verts->setComponent(2, 2, 0); - QVector dims2; + std::vector dims2; dims2.push_back(3); - DataArray::Pointer tris = DataArray::CreateArray(1, dims2, "Triangles"); + SharedTriList::Pointer tris = SharedTriList::CreateArray(1, dims2, "Triangles", true); tris->setComponent(0, 0, 0); tris->setComponent(0, 1, 1); @@ -154,19 +150,24 @@ class ScaleVolumeTest QVariant value; value.setValue(imageGeometry); - filter->setProperty("ApplyToVoxelVolume", value); + bool propWasSet = filter->setProperty("ApplyToVoxelVolume", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(surfaceGeometry); - filter->setProperty("ApplyToSurfaceMesh", value); + propWasSet = filter->setProperty("ApplyToSurfaceMesh", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(ScaleVolumeTestConsts::SCALE); - filter->setProperty("ScaleFactor", value); + propWasSet = filter->setProperty("ScaleFactor", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) - value.setValue(QString("DataContainer1")); - filter->setProperty("DataContainerName", value); + value.setValue(DataArrayPath("DataContainer1")); + propWasSet = filter->setProperty("DataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) - value.setValue(QString("DataContainer2")); - filter->setProperty("SurfaceDataContainerName", value); + value.setValue(DataArrayPath("DataContainer2")); + propWasSet = filter->setProperty("SurfaceDataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -182,19 +183,24 @@ class ScaleVolumeTest QVariant value; value.setValue(imageGeometry); - filter->setProperty("ApplyToVoxelVolume", value); + bool propWasSet = filter->setProperty("ApplyToVoxelVolume", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(surfaceGeometry); - filter->setProperty("ApplyToSurfaceMesh", value); + propWasSet = filter->setProperty("ApplyToSurfaceMesh", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(ScaleVolumeTestConsts::SCALE); - filter->setProperty("ScaleFactor", value); + propWasSet = filter->setProperty("ScaleFactor", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) - value.setValue(QString("DataContainer2")); - filter->setProperty("DataContainerName", value); + value.setValue(DataArrayPath("DataContainer2")); + propWasSet = filter->setProperty("DataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) - value.setValue(QString("DataContainer1")); - filter->setProperty("SurfaceDataContainerName", value); + value.setValue(DataArrayPath("DataContainer1")); + propWasSet = filter->setProperty("SurfaceDataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -210,19 +216,24 @@ class ScaleVolumeTest QVariant value; value.setValue(imageGeometry); - filter->setProperty("ApplyToVoxelVolume", value); + bool propWasSet = filter->setProperty("ApplyToVoxelVolume", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(surfaceGeometry); - filter->setProperty("ApplyToSurfaceMesh", value); + propWasSet = filter->setProperty("ApplyToSurfaceMesh", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(ScaleVolumeTestConsts::SCALE); - filter->setProperty("ScaleFactor", value); + propWasSet = filter->setProperty("ScaleFactor", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) - value.setValue(QString("DataContainer3")); - filter->setProperty("DataContainerName", value); + value.setValue(DataArrayPath("DataContainer3")); + propWasSet = filter->setProperty("DataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) - value.setValue(QString("DataContainer4")); - filter->setProperty("SurfaceDataContainerName", value); + value.setValue(DataArrayPath("DataContainer4")); + propWasSet = filter->setProperty("SurfaceDataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -236,21 +247,18 @@ class ScaleVolumeTest setGeometryTest(filter, true, false); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer("DataContainer1"); ImageGeom::Pointer imgGeom = std::dynamic_pointer_cast(dc->getGeometry()); DREAM3D_REQUIRE(imgGeom != nullptr); - float xRes = 0.0f; - float yRes = 0.0f; - float zRes = 0.0f; - std::tie(xRes, yRes, zRes) = imgGeom->getResolution(); + FloatVec3Type spacing = imgGeom->getSpacing(); - DREAM3D_REQUIRE_EQUAL(xRes, ScaleVolumeTestConsts::SCALE.x); - DREAM3D_REQUIRE_EQUAL(yRes, ScaleVolumeTestConsts::SCALE.y); - DREAM3D_REQUIRE_EQUAL(zRes, ScaleVolumeTestConsts::SCALE.z); + DREAM3D_REQUIRE_EQUAL(spacing[0], ScaleVolumeTestConsts::SCALE[0]); + DREAM3D_REQUIRE_EQUAL(spacing[1], ScaleVolumeTestConsts::SCALE[1]); + DREAM3D_REQUIRE_EQUAL(spacing[2], ScaleVolumeTestConsts::SCALE[2]); } // ----------------------------------------------------------------------------- @@ -264,7 +272,7 @@ class ScaleVolumeTest setGeometryTest(filter, false, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer("DataContainer2"); TriangleGeom::Pointer triGeom = std::dynamic_pointer_cast(dc->getGeometry()); @@ -297,7 +305,7 @@ class ScaleVolumeTest setIncorrectGeometry(filter, true, false); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -384); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -384); } // ----------------------------------------------------------------------------- @@ -311,7 +319,7 @@ class ScaleVolumeTest setIncorrectGeometry(filter, false, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -384); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -384); } // ----------------------------------------------------------------------------- @@ -325,7 +333,7 @@ class ScaleVolumeTest setNullGeometry(filter, true, false); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -385); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -385); } // ----------------------------------------------------------------------------- @@ -339,7 +347,7 @@ class ScaleVolumeTest setNullGeometry(filter, false, true); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -385); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -385); } // ----------------------------------------------------------------------------- diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/SetOriginResolutionImageGeomTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/SetOriginResolutionImageGeomTest.cpp index 54fa25797c..e623e93058 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/SetOriginResolutionImageGeomTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/SetOriginResolutionImageGeomTest.cpp @@ -1,63 +1,59 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "SIMPLib/CoreFilters/SetOriginResolutionImageGeom.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Geometry/ImageGeom.h" +#include "SIMPLib/Geometry/TriangleGeom.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/CoreFilters/SetOriginResolutionImageGeom.h" -#include "SIMPLib/Geometry/ImageGeom.h" -#include "SIMPLib/Geometry/TriangleGeom.h" - namespace SetOriginResolutionImageGeometryTest { -const FloatVec3_t ORIGIN = FloatVec3_t{1, 2, 3}; -const FloatVec3_t RESOLUTION = FloatVec3_t{4, 5, 6}; -} +const FloatVec3Type ORIGIN = FloatVec3Type{1, 2, 3}; +const FloatVec3Type RESOLUTION = FloatVec3Type{4, 5, 6}; +} // namespace SetOriginResolutionImageGeometryTest class SetOriginResolutionImageGeomTest { @@ -73,13 +69,13 @@ class SetOriginResolutionImageGeomTest DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc1 = DataContainer::New("DataContainer1"); - dca->addDataContainer(dc1); + dca->addOrReplaceDataContainer(dc1); DataContainer::Pointer dc2 = DataContainer::New("DataContainer2"); - dca->addDataContainer(dc2); + dca->addOrReplaceDataContainer(dc2); DataContainer::Pointer dc3 = DataContainer::New("DataContainer3"); - dca->addDataContainer(dc3); + dca->addOrReplaceDataContainer(dc3); ImageGeom::Pointer imgGeom = ImageGeom::New(); imgGeom->setDimensions(2, 2, 2); @@ -88,9 +84,9 @@ class SetOriginResolutionImageGeomTest // incorrect geometry TriangleGeom::Pointer triGeom = TriangleGeom::New(); - QVector dims; + std::vector dims; dims.push_back(3); - DataArray::Pointer verts = DataArray::CreateArray(3, dims, "Vertices"); + DataArray::Pointer verts = DataArray::CreateArray(3, dims, "Vertices", true); verts->setComponent(0, 0, -1); verts->setComponent(0, 1, 0); verts->setComponent(0, 2, 0); @@ -103,9 +99,9 @@ class SetOriginResolutionImageGeomTest verts->setComponent(2, 1, 1); verts->setComponent(2, 2, 0); - QVector dims2; + std::vector dims2; dims2.push_back(3); - DataArray::Pointer tris = DataArray::CreateArray(1, dims2, "Triangles"); + SharedTriList::Pointer tris = SharedTriList::CreateArray(1, dims2, "Triangles", true); tris->setComponent(0, 0, 0); tris->setComponent(0, 1, 1); @@ -152,8 +148,9 @@ class SetOriginResolutionImageGeomTest QVariant value; - value.setValue(QString("DataContainer1")); - filter->setProperty("DataContainerName", value); + value.setValue(DataArrayPath("DataContainer1")); + bool propWasSet = filter->setProperty("DataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -168,8 +165,9 @@ class SetOriginResolutionImageGeomTest QVariant value; - value.setValue(QString("DataContainer2")); - filter->setProperty("DataContainerName", value); + value.setValue(DataArrayPath("DataContainer2")); + bool propWasSet = filter->setProperty("DataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -184,8 +182,9 @@ class SetOriginResolutionImageGeomTest QVariant value; - value.setValue(QString("DataContainer3")); - filter->setProperty("DataContainerName", value); + value.setValue(DataArrayPath("DataContainer3")); + bool propWasSet = filter->setProperty("DataContainerName", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -201,10 +200,12 @@ class SetOriginResolutionImageGeomTest QVariant value; value.setValue(true); - filter->setProperty("ChangeOrigin", value); + bool propWasSet = filter->setProperty("ChangeOrigin", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(SetOriginResolutionImageGeometryTest::ORIGIN); - filter->setProperty("Origin", value); + propWasSet = filter->setProperty("Origin", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -220,10 +221,12 @@ class SetOriginResolutionImageGeomTest QVariant value; value.setValue(true); - filter->setProperty("ChangeResolution", value); + bool propWasSet = filter->setProperty("ChangeResolution", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) value.setValue(SetOriginResolutionImageGeometryTest::RESOLUTION); - filter->setProperty("Resolution", value); + propWasSet = filter->setProperty("Spacing", value); + DREAM3D_REQUIRE_EQUAL(propWasSet, true) } // ----------------------------------------------------------------------------- @@ -238,18 +241,17 @@ class SetOriginResolutionImageGeomTest changeOrigin(filter); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer("DataContainer1"); ImageGeom::Pointer imgGeom = std::dynamic_pointer_cast(dc->getGeometry()); DREAM3D_REQUIRE(imgGeom != nullptr); - float origin[3]; - imgGeom->getOrigin(origin); - DREAM3D_REQUIRE_EQUAL(origin[0], SetOriginResolutionImageGeometryTest::ORIGIN.x); - DREAM3D_REQUIRE_EQUAL(origin[1], SetOriginResolutionImageGeometryTest::ORIGIN.y); - DREAM3D_REQUIRE_EQUAL(origin[2], SetOriginResolutionImageGeometryTest::ORIGIN.z); + FloatVec3Type origin = imgGeom->getOrigin(); + DREAM3D_REQUIRE_EQUAL(origin[0], SetOriginResolutionImageGeometryTest::ORIGIN[0]); + DREAM3D_REQUIRE_EQUAL(origin[1], SetOriginResolutionImageGeometryTest::ORIGIN[1]); + DREAM3D_REQUIRE_EQUAL(origin[2], SetOriginResolutionImageGeometryTest::ORIGIN[2]); } // ----------------------------------------------------------------------------- @@ -264,21 +266,18 @@ class SetOriginResolutionImageGeomTest changeResolution(filter); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), 0); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), 0); DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer("DataContainer1"); ImageGeom::Pointer imgGeom = std::dynamic_pointer_cast(dc->getGeometry()); DREAM3D_REQUIRE(imgGeom != nullptr); - float xRes = 0.0f; - float yRes = 0.0f; - float zRes = 0.0f; - std::tie(xRes, yRes, zRes) = imgGeom->getResolution(); + FloatVec3Type spacing = imgGeom->getSpacing(); - DREAM3D_REQUIRE_EQUAL(xRes, SetOriginResolutionImageGeometryTest::RESOLUTION.x); - DREAM3D_REQUIRE_EQUAL(yRes, SetOriginResolutionImageGeometryTest::RESOLUTION.y); - DREAM3D_REQUIRE_EQUAL(zRes, SetOriginResolutionImageGeometryTest::RESOLUTION.z); + DREAM3D_REQUIRE_EQUAL(spacing[0], SetOriginResolutionImageGeometryTest::RESOLUTION[0]); + DREAM3D_REQUIRE_EQUAL(spacing[1], SetOriginResolutionImageGeometryTest::RESOLUTION[1]); + DREAM3D_REQUIRE_EQUAL(spacing[2], SetOriginResolutionImageGeometryTest::RESOLUTION[2]); } // ----------------------------------------------------------------------------- @@ -292,7 +291,7 @@ class SetOriginResolutionImageGeomTest setInvalidGeometry(filter); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -384); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -384); } // ----------------------------------------------------------------------------- @@ -306,7 +305,7 @@ class SetOriginResolutionImageGeomTest setNullGeometry(filter); filter->execute(); - DREAM3D_REQUIRE_EQUAL(filter->getErrorCondition(), -385); + DREAM3D_REQUIRE_EQUAL(filter->getErrorCode(), -385); } // ----------------------------------------------------------------------------- @@ -325,7 +324,9 @@ class SetOriginResolutionImageGeomTest DREAM3D_REGISTER_TEST(TestNullGeometry()); } -private: - SetOriginResolutionImageGeomTest(const SetOriginResolutionImageGeomTest&); // Copy Constructor Not Implemented - void operator=(const SetOriginResolutionImageGeomTest&); // Move assignment Not Implemented +public: + SetOriginResolutionImageGeomTest(const SetOriginResolutionImageGeomTest&) = delete; // Copy Constructor Not Implemented + SetOriginResolutionImageGeomTest(SetOriginResolutionImageGeomTest&&) = delete; // Move Constructor Not Implemented + SetOriginResolutionImageGeomTest& operator=(const SetOriginResolutionImageGeomTest&) = delete; // Copy Assignment Not Implemented + SetOriginResolutionImageGeomTest& operator=(SetOriginResolutionImageGeomTest&&) = delete; // Move Assignment Not Implemented }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/SourceList.cmake b/Source/SIMPLib/CoreFilters/Testing/Cxx/SourceList.cmake index ff3ff7fc0b..352cfafeb0 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/SourceList.cmake +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/SourceList.cmake @@ -2,6 +2,8 @@ set(TEST_TESTFILES_DIR ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Testing/Cxx/TestFiles) set(TEST_${SUBDIR_NAME}_NAMES + WriteASCIIDataTest + ApplyImageTransformsTest ArrayCalculatorTest CombineAttributeArraysTest CombineAttributeMatricesTest @@ -21,12 +23,14 @@ set(TEST_${SUBDIR_NAME}_NAMES DataContainerTest ErrorMessageTest ExecuteProcessTest + ExportDataTest ExtractAttributeArraysFromGeometryTest ExtractComponentAsArrayTest ExtractVertexGeometryTest FindDerivativesFilterTest FeatureDataCSVWriterTest GenerateColorTableTest + GenerateTiltSeriesTest ImportAsciDataArrayTest ImportHDF5DatasetTest MoveDataTest @@ -40,15 +44,25 @@ set(TEST_${SUBDIR_NAME}_NAMES RenameAttributeArrayTest RenameAttributeMatrixTest RenameDataContainerTest + # RenameTimingTest ReplaceValueTest RequiredZThicknessTest + RotateSampleRefFrameTest ScaleVolumeTest SetOriginResolutionImageGeomTest SplitAttributeArrayTest - WriteASCIIDataTest WriteTriangleGeometryTest + GenerateVertexCoordinatesTest ) + +if( SIMPL_USE_ITK ) + set(TEST_${SUBDIR_NAME}_NAMES ${TEST_${SUBDIR_NAME}_NAMES} + ) +endif() + + + SIMPL_ADD_UNIT_TEST("${TEST_${SUBDIR_NAME}_NAMES}" "${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Testing/Cxx") SIMPL_ADD_UNIT_TEST_MOC_FILE(ExecuteProcessTest "${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Testing/Cxx") diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/SplitAttributeArrayTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/SplitAttributeArrayTest.cpp index f3f8638d87..f82ceefe20 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/SplitAttributeArrayTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/SplitAttributeArrayTest.cpp @@ -26,25 +26,25 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include -#include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -52,14 +52,13 @@ class SplitAttributeArrayTest { public: - SplitAttributeArrayTest()= default; + SplitAttributeArrayTest() = default; virtual ~SplitAttributeArrayTest() = default; - SplitAttributeArrayTest(const SplitAttributeArrayTest&) = delete; // Copy Constructor Not Implemented - SplitAttributeArrayTest(SplitAttributeArrayTest&&) = delete; // Move Constructor Not Implemented + SplitAttributeArrayTest(const SplitAttributeArrayTest&) = delete; // Copy Constructor Not Implemented + SplitAttributeArrayTest(SplitAttributeArrayTest&&) = delete; // Move Constructor Not Implemented SplitAttributeArrayTest& operator=(const SplitAttributeArrayTest&) = delete; // Copy Assignment Not Implemented SplitAttributeArrayTest& operator=(SplitAttributeArrayTest&&) = delete; // Move Assignment Not Implemented - - + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -67,62 +66,62 @@ class SplitAttributeArrayTest { DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc = DataContainer::New("DataContainer"); - AttributeMatrix::Pointer am1 = AttributeMatrix::New(QVector(1, 10), "AttributeMatrix", AttributeMatrix::Type::Any); + AttributeMatrix::Pointer am1 = AttributeMatrix::New(std::vector(1, 10), "AttributeMatrix", AttributeMatrix::Type::Any); - UInt32ArrayType::Pointer mcArray1 = UInt32ArrayType::CreateArray(QVector(1, 10), QVector(1, 5), "MultiComponent Array uint32_t"); + UInt32ArrayType::Pointer mcArray1 = UInt32ArrayType::CreateArray(std::vector(1, 10), std::vector(1, 5), "MultiComponent Array uint32_t", true); fillDataArray(mcArray1); - BoolArrayType::Pointer mcArray2 = BoolArrayType::CreateArray(QVector(1, 10), QVector(1, 5), "MultiComponent Array bool"); + BoolArrayType::Pointer mcArray2 = BoolArrayType::CreateArray(std::vector(1, 10), std::vector(1, 5), "MultiComponent Array bool", true); fillDataArray(mcArray2); - UCharArrayType::Pointer mcArray3 = UCharArrayType::CreateArray(QVector(1, 10), QVector(1, 5), "MultiComponent Array unsigned char"); + UCharArrayType::Pointer mcArray3 = UCharArrayType::CreateArray(std::vector(1, 10), std::vector(1, 5), "MultiComponent Array unsigned char", true); fillDataArray(mcArray3); - Int8ArrayType::Pointer mcArray4 = Int8ArrayType::CreateArray(QVector(1, 10), QVector(1, 5), "MultiComponent Array int8_t"); + Int8ArrayType::Pointer mcArray4 = Int8ArrayType::CreateArray(std::vector(1, 10), std::vector(1, 5), "MultiComponent Array int8_t", true); fillDataArray(mcArray4); - UInt8ArrayType::Pointer mcArray5 = UInt8ArrayType::CreateArray(QVector(1, 10), QVector(1, 5), "MultiComponent Array uint8_t"); + UInt8ArrayType::Pointer mcArray5 = UInt8ArrayType::CreateArray(std::vector(1, 10), std::vector(1, 5), "MultiComponent Array uint8_t", true); fillDataArray(mcArray5); - Int16ArrayType::Pointer mcArray6 = Int16ArrayType::CreateArray(QVector(1, 10), QVector(1, 5), "MultiComponent Array int16_t"); + Int16ArrayType::Pointer mcArray6 = Int16ArrayType::CreateArray(std::vector(1, 10), std::vector(1, 5), "MultiComponent Array int16_t", true); fillDataArray(mcArray6); - UInt16ArrayType::Pointer mcArray7 = UInt16ArrayType::CreateArray(QVector(1, 10), QVector(1, 5), "MultiComponent Array uint16_t"); + UInt16ArrayType::Pointer mcArray7 = UInt16ArrayType::CreateArray(std::vector(1, 10), std::vector(1, 5), "MultiComponent Array uint16_t", true); fillDataArray(mcArray7); - Int32ArrayType::Pointer mcArray8 = Int32ArrayType::CreateArray(QVector(1, 10), QVector(1, 5), "MultiComponent Array int32_t"); + Int32ArrayType::Pointer mcArray8 = Int32ArrayType::CreateArray(std::vector(1, 10), std::vector(1, 5), "MultiComponent Array int32_t", true); fillDataArray(mcArray8); - Int64ArrayType::Pointer mcArray9 = Int64ArrayType::CreateArray(QVector(1, 10), QVector(1, 5), "MultiComponent Array int64_t"); + Int64ArrayType::Pointer mcArray9 = Int64ArrayType::CreateArray(std::vector(1, 10), std::vector(1, 5), "MultiComponent Array int64_t", true); fillDataArray(mcArray9); - UInt64ArrayType::Pointer mcArray10 = UInt64ArrayType::CreateArray(QVector(1, 10), QVector(1, 5), "MultiComponent Array uint64_t"); + UInt64ArrayType::Pointer mcArray10 = UInt64ArrayType::CreateArray(std::vector(1, 10), std::vector(1, 5), "MultiComponent Array uint64_t", true); fillDataArray(mcArray10); - FloatArrayType::Pointer mcArray11 = FloatArrayType::CreateArray(QVector(1, 10), QVector(1, 5), "MultiComponent Array float"); + FloatArrayType::Pointer mcArray11 = FloatArrayType::CreateArray(std::vector(1, 10), std::vector(1, 5), "MultiComponent Array float", true); fillDataArray(mcArray11); - DoubleArrayType::Pointer mcArray12 = DoubleArrayType::CreateArray(QVector(1, 10), QVector(1, 5), "MultiComponent Array double"); + DoubleArrayType::Pointer mcArray12 = DoubleArrayType::CreateArray(std::vector(1, 10), std::vector(1, 5), "MultiComponent Array double", true); fillDataArray(mcArray12); - SizeTArrayType::Pointer mcArray13 = SizeTArrayType::CreateArray(QVector(1, 10), QVector(1, 5), "MultiComponent Array size_t"); + SizeTArrayType::Pointer mcArray13 = SizeTArrayType::CreateArray(std::vector(1, 10), std::vector(1, 5), "MultiComponent Array size_t", true); fillDataArray(mcArray13); - am1->addAttributeArray("MultiComponent Array uint32_t", mcArray1); - am1->addAttributeArray("MultiComponent Array bool", mcArray2); - am1->addAttributeArray("MultiComponent Array unsigned char", mcArray3); - am1->addAttributeArray("MultiComponent Array int8_t", mcArray4); - am1->addAttributeArray("MultiComponent Array uint8_t", mcArray5); - am1->addAttributeArray("MultiComponent Array int16_t", mcArray6); - am1->addAttributeArray("MultiComponent Array uint16_t", mcArray7); - am1->addAttributeArray("MultiComponent Array int32_t", mcArray8); - am1->addAttributeArray("MultiComponent Array int64_t", mcArray9); - am1->addAttributeArray("MultiComponent Array uint64_t", mcArray10); - am1->addAttributeArray("MultiComponent Array float", mcArray11); - am1->addAttributeArray("MultiComponent Array double", mcArray12); - am1->addAttributeArray("MultiComponent Array size_t", mcArray13); - dc->addAttributeMatrix("AttributeMatrix", am1); - dca->addDataContainer(dc); + am1->insertOrAssign(mcArray1); + am1->insertOrAssign(mcArray2); + am1->insertOrAssign(mcArray3); + am1->insertOrAssign(mcArray4); + am1->insertOrAssign(mcArray5); + am1->insertOrAssign(mcArray6); + am1->insertOrAssign(mcArray7); + am1->insertOrAssign(mcArray8); + am1->insertOrAssign(mcArray9); + am1->insertOrAssign(mcArray10); + am1->insertOrAssign(mcArray11); + am1->insertOrAssign(mcArray12); + am1->insertOrAssign(mcArray13); + dc->addOrReplaceAttributeMatrix(am1); + dca->addOrReplaceDataContainer(dc); return dca; } @@ -144,7 +143,8 @@ class SplitAttributeArrayTest } } - template void fillDataArray(IDataArray::Pointer inputArray) + template + void fillDataArray(IDataArray::Pointer inputArray) { typename DataArray::Pointer daPtr = std::dynamic_pointer_cast>(inputArray); T num = 0; @@ -220,11 +220,12 @@ class SplitAttributeArrayTest return EXIT_SUCCESS; } - template void TestSplitByType(AbstractFilter::Pointer filter, DataContainerArray::Pointer dca, QString dataType) + template + void TestSplitByType(AbstractFilter::Pointer filter, DataContainerArray::Pointer dca, QString dataType) { // Observer obs; // QObject::connect( - // filter.get(), &AbstractFilter::filterGeneratedMessage, + // filter.get(), &AbstractFilter::messageGenerated, // &obs, &Observer::processPipelineMessage // ); @@ -240,33 +241,33 @@ class SplitAttributeArrayTest DREAM3D_REQUIRE_EQUAL(propWasSet, true) filter->preflight(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) dca = createDataContainerArray(); filter->setDataContainerArray(dca); filter->execute(); - err = filter->getErrorCondition(); + err = filter->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) using DataArrayPtrType = std::shared_ptr>; DataArrayPtrType mcArray_original = - filter->getDataContainerArray()->getPrereqIDataArrayFromPath, AbstractFilter>(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array " + dataType)); + filter->getDataContainerArray()->getPrereqArrayFromPath>(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array " + dataType)); std::vector mcArraysAfterSplit; - DataArrayPtrType mcArray0 = filter->getDataContainerArray()->getPrereqIDataArrayFromPath, AbstractFilter>( - filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array " + dataType + "Component0")); + DataArrayPtrType mcArray0 = + filter->getDataContainerArray()->getPrereqArrayFromPath>(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array " + dataType + "Component0")); mcArraysAfterSplit.push_back(mcArray0); - DataArrayPtrType mcArray1 = filter->getDataContainerArray()->getPrereqIDataArrayFromPath, AbstractFilter>( - filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array " + dataType + "Component1")); + DataArrayPtrType mcArray1 = + filter->getDataContainerArray()->getPrereqArrayFromPath>(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array " + dataType + "Component1")); mcArraysAfterSplit.push_back(mcArray1); - DataArrayPtrType mcArray2 = filter->getDataContainerArray()->getPrereqIDataArrayFromPath, AbstractFilter>( - filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array " + dataType + "Component2")); + DataArrayPtrType mcArray2 = + filter->getDataContainerArray()->getPrereqArrayFromPath>(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array " + dataType + "Component2")); mcArraysAfterSplit.push_back(mcArray2); - DataArrayPtrType mcArray3 = filter->getDataContainerArray()->getPrereqIDataArrayFromPath, AbstractFilter>( - filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array " + dataType + "Component3")); + DataArrayPtrType mcArray3 = + filter->getDataContainerArray()->getPrereqArrayFromPath>(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array " + dataType + "Component3")); mcArraysAfterSplit.push_back(mcArray3); - DataArrayPtrType mcArray4 = filter->getDataContainerArray()->getPrereqIDataArrayFromPath, AbstractFilter>( - filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array " + dataType + "Component4")); + DataArrayPtrType mcArray4 = + filter->getDataContainerArray()->getPrereqArrayFromPath>(filter.get(), DataArrayPath("DataContainer", "AttributeMatrix", "MultiComponent Array " + dataType + "Component4")); mcArraysAfterSplit.push_back(mcArray4); size_t numTuples = mcArray_original->getNumberOfTuples(); @@ -295,5 +296,4 @@ class SplitAttributeArrayTest DREAM3D_REGISTER_TEST(RemoveTestFiles()) } - }; diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/Unused/RecursivePipelineTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/Unused/RecursivePipelineTest.cpp index 6dcc0b25a3..9ef7982e82 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/Unused/RecursivePipelineTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/Unused/RecursivePipelineTest.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -36,7 +36,6 @@ #include #include -#include #include "SIMPLib/CoreFilters/DataContainerReader.h" #include "SIMPLib/CoreFilters/DataContainerWriter.h" diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteASCIIDataTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteASCIIDataTest.cpp index e8f0b98c19..17dad6f164 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteASCIIDataTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteASCIIDataTest.cpp @@ -1,57 +1,58 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include #include #include -#include #include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Common/TemplateHelpers.h" #include "SIMPLib/CoreFilters/WriteASCIIData.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataArrays/NeighborList.hpp" #include "SIMPLib/DataArrays/StatsDataArray.h" #include "SIMPLib/DataArrays/StringDataArray.h" #include "SIMPLib/DataArrays/StructArray.hpp" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Geometry/MeshStructs.h" -#include "SIMPLib/SIMPLib.h" - #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -90,7 +91,7 @@ class WriteASCIIDataTest DataContainerArray::Pointer dca = DataContainerArray::New(); DataContainer::Pointer dc = DataContainer::New("DataContainer"); - AttributeMatrix::Pointer am = AttributeMatrix::New(QVector(1, k_ArraySize), "TestAttributeMatrix", AttributeMatrix::Type::Any); + AttributeMatrix::Pointer am = AttributeMatrix::New(std::vector(1, k_ArraySize), "TestAttributeMatrix", AttributeMatrix::Type::Any); StringDataArray::Pointer strArray = StringDataArray::CreateArray(k_ArraySize, k_ArrayName, true); strArray->setValue(0, QString("Foo")); @@ -104,11 +105,11 @@ class WriteASCIIDataTest strArray->setValue(8, QString("Weird words")); strArray->setValue(9, QString("Sierra")); - am->addAttributeArray(strArray->getName(), strArray); - dc->addAttributeMatrix(am->getName(), am); - dca->addDataContainer(dc); + am->insertOrAssign(strArray); + dc->addOrReplaceAttributeMatrix(am); + dca->addOrReplaceDataContainer(dc); - QVector paths = {DataArrayPath("DataContainer", "TestAttributeMatrix", "ASCII_Data")}; + std::vector paths = {DataArrayPath("DataContainer", "TestAttributeMatrix", "ASCII_Data")}; WriteASCIIData::Pointer writer = WriteASCIIData::New(); writer->setDataContainerArray(dca); writer->setSelectedDataArrayPaths(paths); @@ -119,62 +120,62 @@ class WriteASCIIDataTest writer->setOutputStyle(WriteASCIIData::MultiFile); writer->preflight(); - int err = writer->getErrorCondition(); + int err = writer->getErrorCode(); DREAM3D_REQUIRE(err >= 0) writer->execute(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err >= 0) // Test Single File mode writer->setOutputStyle(WriteASCIIData::SingleFile); writer->setOutputFilePath(UnitTest::TestTempDir + "/" + "SingleFileMode.csv"); writer->preflight(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err >= 0) writer->execute(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err >= 0) // Back to MultiFile mode writer->setOutputStyle(WriteASCIIData::MultiFile); - NeighborList::Pointer neighborList = NeighborList::CreateArray(k_ArraySize, "NeighborList", true); - am->addAttributeArray(neighborList->getName(), neighborList); + NeighborList::Pointer neighborList = NeighborList::CreateArray(k_ArraySize, std::string("NeighborList"), true); + am->insertOrAssign(neighborList); paths = {DataArrayPath("DataContainer", "TestAttributeMatrix", "NeighborList")}; writer->setSelectedDataArrayPaths(paths); writer->preflight(); - err = writer->getErrorCondition(); - DREAM3D_REQUIRE(err < 0) + err = writer->getErrorCode(); + DREAM3D_REQUIRED(err, ==, TemplateHelpers::Errors::UnsupportedDataType) writer->execute(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err < 0) - StructArray::Pointer structArray = StructArray::CreateArray(k_ArraySize, "StructArray", true); - am->addAttributeArray(structArray->getName(), structArray); + StructArray::Pointer structArray = StructArray::CreateArray(k_ArraySize, std::string("StructArray"), true); + am->insertOrAssign(structArray); paths = {DataArrayPath("DataContainer", "TestAttributeMatrix", "StructArray")}; writer->setSelectedDataArrayPaths(paths); writer->preflight(); - err = writer->getErrorCondition(); - DREAM3D_REQUIRE(err < 0) + err = writer->getErrorCode(); + DREAM3D_REQUIRED(err, ==, TemplateHelpers::Errors::UnsupportedDataType) writer->execute(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err < 0) - StatsDataArray::Pointer statsDataArray = StatsDataArray::CreateArray(k_ArraySize, "StatsDataArray", true); - am->addAttributeArray(statsDataArray->getName(), statsDataArray); + StatsDataArray::Pointer statsDataArray = StatsDataArray::CreateArray(k_ArraySize, std::string("StatsDataArray"), true); + am->insertOrAssign(statsDataArray); paths = {DataArrayPath("DataContainer", "TestAttributeMatrix", "StatsDataArray")}; writer->setSelectedDataArrayPaths(paths); writer->preflight(); - err = writer->getErrorCondition(); - DREAM3D_REQUIRE(err < 0) + err = writer->getErrorCode(); + DREAM3D_REQUIRED(err, ==, TemplateHelpers::Errors::UnsupportedDataType) writer->execute(); - err = writer->getErrorCondition(); + err = writer->getErrorCode(); DREAM3D_REQUIRE(err < 0) } diff --git a/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteTriangleGeometryTest.cpp b/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteTriangleGeometryTest.cpp index 50ce965479..8ec9e509cc 100644 --- a/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteTriangleGeometryTest.cpp +++ b/Source/SIMPLib/CoreFilters/Testing/Cxx/WriteTriangleGeometryTest.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,26 +35,25 @@ #pragma once -#include #include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/QtBackwardCompatibilityMacro.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Filtering/QMetaObjectUtilities.h" +#include "SIMPLib/Geometry/TriangleGeom.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" - -#include "SIMPLib/Filtering/QMetaObjectUtilities.h" - #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" -#include "SIMPLib/Geometry/TriangleGeom.h" - #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" class WriteTriangleGeometryTest { @@ -102,13 +101,13 @@ class WriteTriangleGeometryTest { // Names and Constants - static const QString k_DataContainerName("DataContainer"); + static const DataArrayPath k_DataContainerPath("DataContainer", "", ""); static const QString k_TriVertexListDAName("TriVertexList"); static const QString k_TriListDAName("TriangleList"); - QVector k_Dims3(1, 3); - QVector k_NumNodes(1, 99); - QVector k_NumTriangles(1, 33); + std::vector k_Dims3(1, 3); + std::vector k_NumNodes(1, 99); + std::vector k_NumTriangles(1, 33); // Create DataContainerArray @@ -116,22 +115,22 @@ class WriteTriangleGeometryTest // Create DataContainer - DataContainer::Pointer dc = DataContainer::New(k_DataContainerName); - dca->addDataContainer(dc); + DataContainer::Pointer dc = DataContainer::New(k_DataContainerPath); + dca->addOrReplaceDataContainer(dc); // Create Triangle Data Arrays - FloatArrayType::Pointer daTriVert = FloatArrayType::CreateArray(k_NumNodes, k_Dims3, k_TriVertexListDAName); - for (size_t i = 0; i < daTriVert->getNumberOfTuples(); i++) + FloatArrayType::Pointer daTriVert = FloatArrayType::CreateArray(k_NumNodes, k_Dims3, k_TriVertexListDAName, true); + for(size_t i = 0; i < daTriVert->getNumberOfTuples(); i++) { - for (int j = 0; j < daTriVert->getNumberOfComponents(); j++) + for(int j = 0; j < daTriVert->getNumberOfComponents(); j++) { float value(static_cast(i + j)); - if (i % 2 != 0) + if(i % 2 != 0) { value *= -1.0f; } - if (j > 0) + if(j > 0) { value += (j + 1) * 0.111f; } @@ -139,10 +138,10 @@ class WriteTriangleGeometryTest } } - Int64ArrayType::Pointer daTriList = Int64ArrayType::CreateArray(k_NumTriangles, k_Dims3, k_TriListDAName); - for (size_t i = 0; i < daTriList->getNumberOfTuples(); i++) + SharedTriList::Pointer daTriList = SharedTriList::CreateArray(k_NumTriangles, k_Dims3, k_TriListDAName, true); + for(size_t i = 0; i < daTriList->getNumberOfTuples(); i++) { - for (int j = 0; j < daTriList->getNumberOfComponents(); j++) + for(int j = 0; j < daTriList->getNumberOfComponents(); j++) { daTriList->setComponent(i, j, i + j); } @@ -164,7 +163,7 @@ class WriteTriangleGeometryTest QVariant var; - var.setValue(k_DataContainerName); + var.setValue(k_DataContainerPath); bool propWasSet = writeTriangleGeometry->setProperty("DataContainerSelection", var); DREAM3D_REQUIRE_EQUAL(propWasSet, true) @@ -179,7 +178,7 @@ class WriteTriangleGeometryTest // Run filter writeTriangleGeometry->execute(); - DREAM3D_REQUIRED(writeTriangleGeometry->getErrorCondition(), >=, 0); + DREAM3D_REQUIRED(writeTriangleGeometry->getErrorCode(), >=, 0); // Test filter @@ -210,16 +209,16 @@ class WriteTriangleGeometryTest QStringList list = line.split(':'); DREAM3D_REQUIRE(list[0].trimmed() == "Node Count") - qlonglong nodeCount = list[1].trimmed().toLongLong(); + MeshIndexType nodeCount = list[1].trimmed().toULongLong(); DREAM3D_REQUIRE(nodeCount == triGeom->getNumberOfVertices()) // Check vertices - for(int64_t i = 0; i < triGeom->getNumberOfVertices(); i++) + for(MeshIndexType i = 0; i < triGeom->getNumberOfVertices(); i++) { line = inFileNodes.readLine(); - list = line.split(QRegExp("\\s+"), QString::SkipEmptyParts); - for(int j = 0; j < daTriVert->getNumberOfComponents(); j++) + list = line.split(QRegExp("\\s+"), QSTRING_SKIP_EMPTY_PARTS); + for(MeshIndexType j = 0; j < daTriVert->getNumberOfComponents(); j++) { DREAM3D_REQUIRE(list[j] == QString::number(daTriVert->getComponent(i, j), 'f', 5)) } @@ -282,13 +281,13 @@ class WriteTriangleGeometryTest // Check triangles - for(int64_t i = 0; i < triGeom->getNumberOfTris(); i++) + for(MeshIndexType i = 0; i < triGeom->getNumberOfTris(); i++) { line = inFileTriangles.readLine(); - list = line.split(QRegExp("\\s+"), QString::SkipEmptyParts); - for(int j = 0; j < daTriList->getNumberOfComponents(); j++) + list = line.split(QRegExp("\\s+"), QSTRING_SKIP_EMPTY_PARTS); + for(MeshIndexType j = 0; j < daTriList->getNumberOfComponents(); j++) { - DREAM3D_REQUIRE(list[j].toLongLong() == daTriList->getComponent(i, j)) + DREAM3D_REQUIRE(list[j].toULongLong() == daTriList->getComponent(i, j)) } } diff --git a/Source/SIMPLib/CoreFilters/WriteASCIIData.cpp b/Source/SIMPLib/CoreFilters/WriteASCIIData.cpp index d10bc582bd..b26c183478 100644 --- a/Source/SIMPLib/CoreFilters/WriteASCIIData.cpp +++ b/Source/SIMPLib/CoreFilters/WriteASCIIData.cpp @@ -1,46 +1,49 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "WriteASCIIData.h" #include +#include +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/TemplateHelpers.h" +#include "SIMPLib/DataArrays/IDataArray.h" #include "SIMPLib/DataArrays/NeighborList.hpp" #include "SIMPLib/DataArrays/StringDataArray.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/ChoiceFilterParameter.h" #include "SIMPLib/FilterParameters/IntFilterParameter.h" @@ -49,14 +52,13 @@ #include "SIMPLib/FilterParameters/OutputFileFilterParameter.h" #include "SIMPLib/FilterParameters/OutputPathFilterParameter.h" #include "SIMPLib/FilterParameters/StringFilterParameter.h" -#include "SIMPLib/SIMPLibVersion.h" - /** * @brief The ExportDataPrivate class is a templated class that implements a method to generically * export data to an ASCII file */ -template class WriteASCIIDataPrivate +template +class WriteASCIIDataPrivate { public: using DataArrayType = DataArray; @@ -83,8 +85,7 @@ template class WriteASCIIDataPrivate if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QString ss = QObject::tr("The output file could not be opened: '%1'").arg(outputFile); - filter->setErrorCondition(-11012); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-11012, ss); return; } @@ -124,14 +125,7 @@ template class WriteASCIIDataPrivate // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -WriteASCIIData::WriteASCIIData() -: m_SelectedDataArrayPaths(QVector()) -, m_OutputPath("") -, m_Delimiter(0) -, m_FileExtension(".txt") -, m_MaxValPerLine(-1) -{ -} +WriteASCIIData::WriteASCIIData() = default; // ----------------------------------------------------------------------------- // @@ -143,7 +137,7 @@ WriteASCIIData::~WriteASCIIData() = default; // ----------------------------------------------------------------------------- void WriteASCIIData::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; { LinkedChoicesFilterParameter::Pointer parameter = LinkedChoicesFilterParameter::New(); @@ -151,26 +145,26 @@ void WriteASCIIData::setupFilterParameters() parameter->setPropertyName("OutputStyle"); parameter->setSetterCallback(SIMPL_BIND_SETTER(WriteASCIIData, this, OutputStyle)); parameter->setGetterCallback(SIMPL_BIND_GETTER(WriteASCIIData, this, OutputStyle)); - QVector choices; + std::vector choices; choices.push_back("Multiple Files"); choices.push_back("Single File"); parameter->setChoices(choices); - QStringList linkedProps = {"OutputPath", "FileExtension", "MaxValPerLine", "OutputFilePath"}; + std::vector linkedProps = {"OutputPath", "FileExtension", "MaxValPerLine", "OutputFilePath"}; parameter->setLinkedProperties(linkedProps); parameter->setEditable(false); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameters.push_back(parameter); linkedProps.clear(); } // Multiple File Output - parameters.push_back(SIMPL_NEW_OUTPUT_PATH_FP("Output Path", OutputPath, FilterParameter::Parameter, WriteASCIIData, "*", "*", 0)); - parameters.push_back(SIMPL_NEW_STRING_FP("File Extension", FileExtension, FilterParameter::Parameter, WriteASCIIData, 0)); - parameters.push_back(SIMPL_NEW_INTEGER_FP("Maximum Tuples Per Line", MaxValPerLine, FilterParameter::Parameter, WriteASCIIData, 0)); + parameters.push_back(SIMPL_NEW_OUTPUT_PATH_FP("Output Path", OutputPath, FilterParameter::Category::Parameter, WriteASCIIData, 0)); + parameters.push_back(SIMPL_NEW_STRING_FP("File Extension", FileExtension, FilterParameter::Category::Parameter, WriteASCIIData, 0)); + parameters.push_back(SIMPL_NEW_INTEGER_FP("Maximum Tuples Per Line", MaxValPerLine, FilterParameter::Category::Parameter, WriteASCIIData, 0)); // Single File Output - parameters.push_back(SIMPL_NEW_OUTPUT_FILE_FP("Output File Path", OutputFilePath, FilterParameter::Parameter, WriteASCIIData, "*", "*", 1)); + parameters.push_back(SIMPL_NEW_OUTPUT_FILE_FP("Output File Path", OutputFilePath, FilterParameter::Category::Parameter, WriteASCIIData, "*", "*", 1)); { ChoiceFilterParameter::Pointer parameter = ChoiceFilterParameter::New(); // Delimiter choice @@ -179,37 +173,23 @@ void WriteASCIIData::setupFilterParameters() parameter->setSetterCallback(SIMPL_BIND_SETTER(WriteASCIIData, this, Delimiter)); parameter->setGetterCallback(SIMPL_BIND_GETTER(WriteASCIIData, this, Delimiter)); - QVector choices; + std::vector choices; choices.push_back(", (comma)"); choices.push_back("; (semicolon)"); choices.push_back(" (space)"); choices.push_back(": (colon)"); choices.push_back("\\t (Tab)"); parameter->setChoices(choices); - parameter->setCategory(FilterParameter::Parameter); + parameter->setCategory(FilterParameter::Category::Parameter); parameters.push_back(parameter); } { MultiDataArraySelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_MDA_SELECTION_FP("Attribute Arrays to Export", SelectedDataArrayPaths, FilterParameter::RequiredArray, WriteASCIIData, req)); + parameters.push_back(SIMPL_NEW_MDA_SELECTION_FP("Attribute Arrays to Export", SelectedDataArrayPaths, FilterParameter::Category::RequiredArray, WriteASCIIData, req)); } setFilterParameters(parameters); } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void WriteASCIIData::readFilterParameters(AbstractFilterParametersReader* reader, int index) -{ - reader->openFilterGroup(this, index); - setSelectedDataArrayPaths(reader->readDataArrayPathVector("SelectedDataArrayPaths", getSelectedDataArrayPaths())); - setOutputPath(reader->readString("OutputPath", getOutputPath())); - setDelimiter(reader->readValue("Delimiter", getDelimiter())); - setFileExtension(reader->readString("FileExtension", getFileExtension())); - setMaxValPerLine(reader->readValue("MaxValPerLine", getMaxValPerLine())); - reader->closeFilterGroup(); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -223,36 +203,33 @@ void WriteASCIIData::initialize() // ----------------------------------------------------------------------------- void WriteASCIIData::dataCheck() { + clearErrorCode(); + clearWarningCode(); + // Make sure the weak pointer vector is cleared before we begin... m_SelectedWeakPtrVector.clear(); - setErrorCondition(0); - setWarningCondition(0); - //**************** MultiFile Checks ****************** if(m_OutputStyle == MultiFile) { if(m_OutputPath.isEmpty()) { - setErrorCondition(-11002); QString ss = QObject::tr("The output path must be set"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11002, ss); return; } if(m_MaxValPerLine <= 0) { - setErrorCondition(-11003); QString ss = QObject::tr("The Maximum Tuples Per Line (%1) must be positive").arg(m_MaxValPerLine); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11003, ss); return; } if(m_FileExtension.isEmpty()) { - setErrorCondition(-11004); QString ss = QObject::tr("The file extension must be set."); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11004, ss); return; } } @@ -261,110 +238,87 @@ void WriteASCIIData::dataCheck() { if(m_OutputFilePath.isEmpty()) { - setErrorCondition(-11005); QString ss = QObject::tr("The output file path must be set"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11005, ss); } QFileInfo fi(m_OutputPath); QDir parentPath = fi.path(); if(!parentPath.exists()) { - setWarningCondition(-11006); QString ss = QObject::tr("The directory path for the output file does not exist. DREAM.3D will attempt to create this path during execution of the filter"); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); + setWarningCondition(-11006, ss); } } else { QString ss = QObject::tr("The type of output did not match either 0 (Multi-File) or 1 (Single File)"); - setErrorCondition(-11009); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11009, ss); return; } - if(m_SelectedDataArrayPaths.isEmpty()) + if(m_SelectedDataArrayPaths.empty()) { - setErrorCondition(-11007); QString ss = QObject::tr("At least one Attribute Array must be selected"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11007, ss); return; } - QVector paths = getSelectedDataArrayPaths(); + std::vector paths = getSelectedDataArrayPaths(); if(!DataArrayPath::ValidateVector(paths)) { - setErrorCondition(-11008); QString ss = QObject::tr("There are Attribute Arrays selected that are not contained in the same Attribute Matrix. All selected Attribute Arrays must belong to the same Attribute Matrix"); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11008, ss); return; } for(auto const& path : paths) { - IDataArray::WeakPointer ptr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, path); + IDataArray::WeakPointer ptr = getDataContainerArray()->getPrereqIDataArrayFromPath(this, path); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - if( ptr.lock()->getTypeAsString().compare("NeighborList") == 0) + if(ptr.lock()->getNameOfClass() == "NeighborList") { - setErrorCondition(TemplateHelpers::Errors::UnsupportedType); - notifyErrorMessage(getHumanLabel(), "NeighborList is unsupported when writing ASCII Data.", getErrorCondition()); + setErrorCondition(TemplateHelpers::Errors::UnsupportedDataType, "NeighborList is unsupported when writing ASCII Data."); } - else if( ptr.lock()->getTypeAsString().compare("struct") == 0) + else if(ptr.lock()->getTypeAsString() == "struct") { - setErrorCondition(TemplateHelpers::Errors::UnsupportedType); - notifyErrorMessage(getHumanLabel(), "StructArray is unsupported when writing ASCII Data.", getErrorCondition()); + setErrorCondition(TemplateHelpers::Errors::UnsupportedDataType, "StructArray is unsupported when writing ASCII Data."); } - else if( ptr.lock()->getTypeAsString().compare("StatsDataArray") == 0) + else if(ptr.lock()->getTypeAsString() == "StatsDataArray") { - setErrorCondition(TemplateHelpers::Errors::UnsupportedType); - notifyErrorMessage(getHumanLabel(), "StatsDataArray is unsupported when writing ASCII Data.", getErrorCondition()); + setErrorCondition(TemplateHelpers::Errors::UnsupportedDataType, "StatsDataArray is unsupported when writing ASCII Data."); } else { m_SelectedWeakPtrVector.push_back(ptr); } - } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void WriteASCIIData::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void WriteASCIIData::execute() { - setErrorCondition(0); - setWarningCondition(0); + clearErrorCode(); + clearWarningCode(); initialize(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - if(m_SelectedDataArrayPaths.count() != m_SelectedWeakPtrVector.count()) + if(m_SelectedDataArrayPaths.size() != m_SelectedWeakPtrVector.count()) { QString ss = QObject::tr("The number of selected Attribute Arrays does not equal the number of internal weak pointers"); - setErrorCondition(-11010); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11010, ss); return; } @@ -379,8 +333,7 @@ void WriteASCIIData::execute() else { QString ss = QObject::tr("The type of output did not match either 0 (Multi-File) or 1 (Single File)"); - setErrorCondition(-11009); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11009, ss); return; } } @@ -393,8 +346,7 @@ void WriteASCIIData::writeMultiFileOutput() if(!dir.mkpath(m_OutputPath)) { ss = QObject::tr("Error creating output path '%1'").arg(m_OutputPath); - setErrorCondition(-11004); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11004, ss); return; } @@ -408,37 +360,32 @@ void WriteASCIIData::writeMultiFileOutput() IDataArray::Pointer selectedArrayPtr = m_SelectedWeakPtrVector.at(i).lock(); QString message = QObject::tr("|| Exporting Dataset '%1'").arg(selectedArrayPtr->getName()); - notifyStatusMessage(getMessagePrefix(), getHumanLabel(), message); + notifyStatusMessage(message); QString exportArrayFile = m_OutputPath + QDir::separator() + selectedArrayPtr->getName() + m_FileExtension; // the complete output file path, name and extension char delimiter = lookupDelimiter(); - - if( std::dynamic_pointer_cast(selectedArrayPtr).get() != nullptr) + if(std::dynamic_pointer_cast(selectedArrayPtr).get() != nullptr) { - writeStringArray(selectedArrayPtr, exportArrayFile, delimiter); + writeStringArray(selectedArrayPtr, exportArrayFile, delimiter); } - else if( selectedArrayPtr->getTypeAsString().compare("NeighborList") == 0) + else if(selectedArrayPtr->getTypeAsString().compare("NeighborList") == 0) { - setErrorCondition(TemplateHelpers::Errors::UnsupportedType); - notifyErrorMessage(getHumanLabel(), "NeighborList is unsupported when writing ASCII Data.", getErrorCondition()); + setErrorCondition(TemplateHelpers::Errors::UnsupportedDataType, "NeighborList is unsupported when writing ASCII Data."); } - else if( selectedArrayPtr->getTypeAsString().compare("struct") == 0) + else if(selectedArrayPtr->getTypeAsString().compare("struct") == 0) { - setErrorCondition(TemplateHelpers::Errors::UnsupportedType); - notifyErrorMessage(getHumanLabel(), "StructArray is unsupported when writing ASCII Data.", getErrorCondition()); + setErrorCondition(TemplateHelpers::Errors::UnsupportedDataType, "StructArray is unsupported when writing ASCII Data."); } - else if( selectedArrayPtr->getTypeAsString().compare("StatsDataArray") == 0) + else if(selectedArrayPtr->getTypeAsString().compare("StatsDataArray") == 0) { - setErrorCondition(TemplateHelpers::Errors::UnsupportedType); - notifyErrorMessage(getHumanLabel(), "StatsDataArray is unsupported when writing ASCII Data.", getErrorCondition()); + setErrorCondition(TemplateHelpers::Errors::UnsupportedDataType, "StatsDataArray is unsupported when writing ASCII Data."); } else EXECUTE_TEMPLATE(this, WriteASCIIDataPrivate, selectedArrayPtr, this, selectedArrayPtr, delimiter, exportArrayFile, m_MaxValPerLine) - - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { break; } @@ -456,8 +403,7 @@ void WriteASCIIData::writeSingleFileOutput() if(!parentPath.mkpath(".")) { QString ss = QObject::tr("Error creating parent path '%1'").arg(parentPath.absolutePath()); - setErrorCondition(-11020); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11020, ss); return; } @@ -465,8 +411,7 @@ void WriteASCIIData::writeSingleFileOutput() if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QString ss = QObject::tr("Output file could not be opened: %1").arg(getOutputFilePath()); - setErrorCondition(-11021); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11021, ss); return; } @@ -519,7 +464,7 @@ void WriteASCIIData::writeSingleFileOutput() if(percentIncrement > threshold) { QString ss = QObject::tr("Writing Output: %1%").arg(static_cast(percentIncrement)); - notifyStatusMessage(getMessagePrefix(), getHumanLabel(), ss); + notifyStatusMessage(ss); threshold = threshold + 5.0f; if(threshold < percentIncrement) { @@ -555,8 +500,7 @@ void WriteASCIIData::writeStringArray(const IDataArray::Pointer& inputData, cons if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QString ss = QObject::tr("The output file could not be opened: '%1'").arg(outputFile); - setErrorCondition(-11011); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-11011, ss); return; } @@ -628,7 +572,7 @@ AbstractFilter::Pointer WriteASCIIData::newFilterInstance(bool copyFilterParamet // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString WriteASCIIData::getCompiledLibraryName() const +QString WriteASCIIData::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -636,7 +580,7 @@ const QString WriteASCIIData::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString WriteASCIIData::getBrandingString() const +QString WriteASCIIData::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -644,7 +588,7 @@ const QString WriteASCIIData::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString WriteASCIIData::getFilterVersion() const +QString WriteASCIIData::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -655,7 +599,7 @@ const QString WriteASCIIData::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString WriteASCIIData::getGroupName() const +QString WriteASCIIData::getGroupName() const { return SIMPL::FilterGroups::IOFilters; } @@ -663,7 +607,7 @@ const QString WriteASCIIData::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid WriteASCIIData::getUuid() +QUuid WriteASCIIData::getUuid() const { return QUuid("{5fbf9204-2c6c-597b-856a-f4612adbac38}"); } @@ -671,7 +615,7 @@ const QUuid WriteASCIIData::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString WriteASCIIData::getSubGroupName() const +QString WriteASCIIData::getSubGroupName() const { return SIMPL::FilterSubGroups::OutputFilters; } @@ -679,7 +623,120 @@ const QString WriteASCIIData::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString WriteASCIIData::getHumanLabel() const +QString WriteASCIIData::getHumanLabel() const { return "Export ASCII Data"; } + +// ----------------------------------------------------------------------------- +WriteASCIIData::Pointer WriteASCIIData::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr WriteASCIIData::New() +{ + struct make_shared_enabler : public WriteASCIIData + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString WriteASCIIData::getNameOfClass() const +{ + return QString("WriteASCIIData"); +} + +// ----------------------------------------------------------------------------- +QString WriteASCIIData::ClassName() +{ + return QString("WriteASCIIData"); +} + +// ----------------------------------------------------------------------------- +void WriteASCIIData::setSelectedDataArrayPaths(const std::vector& value) +{ + m_SelectedDataArrayPaths = value; +} + +// ----------------------------------------------------------------------------- +std::vector WriteASCIIData::getSelectedDataArrayPaths() const +{ + return m_SelectedDataArrayPaths; +} + +// ----------------------------------------------------------------------------- +void WriteASCIIData::setOutputPath(const QString& value) +{ + m_OutputPath = value; +} + +// ----------------------------------------------------------------------------- +QString WriteASCIIData::getOutputPath() const +{ + return m_OutputPath; +} + +// ----------------------------------------------------------------------------- +void WriteASCIIData::setOutputFilePath(const QString& value) +{ + m_OutputFilePath = value; +} + +// ----------------------------------------------------------------------------- +QString WriteASCIIData::getOutputFilePath() const +{ + return m_OutputFilePath; +} + +// ----------------------------------------------------------------------------- +void WriteASCIIData::setDelimiter(int value) +{ + m_Delimiter = value; +} + +// ----------------------------------------------------------------------------- +int WriteASCIIData::getDelimiter() const +{ + return m_Delimiter; +} + +// ----------------------------------------------------------------------------- +void WriteASCIIData::setFileExtension(const QString& value) +{ + m_FileExtension = value; +} + +// ----------------------------------------------------------------------------- +QString WriteASCIIData::getFileExtension() const +{ + return m_FileExtension; +} + +// ----------------------------------------------------------------------------- +void WriteASCIIData::setMaxValPerLine(int value) +{ + m_MaxValPerLine = value; +} + +// ----------------------------------------------------------------------------- +int WriteASCIIData::getMaxValPerLine() const +{ + return m_MaxValPerLine; +} + +// ----------------------------------------------------------------------------- +void WriteASCIIData::setOutputStyle(int value) +{ + m_OutputStyle = value; +} + +// ----------------------------------------------------------------------------- +int WriteASCIIData::getOutputStyle() const +{ + return m_OutputStyle; +} diff --git a/Source/SIMPLib/CoreFilters/WriteASCIIData.h b/Source/SIMPLib/CoreFilters/WriteASCIIData.h index 61100e6400..099779ebb3 100644 --- a/Source/SIMPLib/CoreFilters/WriteASCIIData.h +++ b/Source/SIMPLib/CoreFilters/WriteASCIIData.h @@ -1,237 +1,298 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +class IDataArray; +using IDataArrayShPtrType = std::shared_ptr; +using IDataArrayWkPtrType = std::weak_ptr; /** * @brief The WriteASCIIData class. See [Filter documentation](@ref writeasciidata) for details. */ class SIMPLib_EXPORT WriteASCIIData : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(WriteASCIIData SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QVector SelectedDataArrayPaths READ getSelectedDataArrayPaths WRITE setSelectedDataArrayPaths) - PYB11_PROPERTY(QString OutputPath READ getOutputPath WRITE setOutputPath) - PYB11_PROPERTY(QString OutputFilePath READ getOutputFilePath WRITE setOutputFilePath) - PYB11_PROPERTY(int Delimiter READ getDelimiter WRITE setDelimiter) - PYB11_PROPERTY(QString FileExtension READ getFileExtension WRITE setFileExtension) - PYB11_PROPERTY(int MaxValPerLine READ getMaxValPerLine WRITE setMaxValPerLine) - PYB11_PROPERTY(int OutputStyle READ getOutputStyle WRITE setOutputStyle) - - public: - SIMPL_SHARED_POINTERS(WriteASCIIData) - SIMPL_FILTER_NEW_MACRO(WriteASCIIData) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(WriteASCIIData, AbstractFilter) - - ~WriteASCIIData() override; - - SIMPL_FILTER_PARAMETER(QVector, SelectedDataArrayPaths) - Q_PROPERTY(QVector SelectedDataArrayPaths READ getSelectedDataArrayPaths WRITE setSelectedDataArrayPaths) - - SIMPL_FILTER_PARAMETER(QString, OutputPath) - Q_PROPERTY(QString OutputPath READ getOutputPath WRITE setOutputPath) - - SIMPL_FILTER_PARAMETER(QString, OutputFilePath) - Q_PROPERTY(QString OutputFilePath READ getOutputFilePath WRITE setOutputFilePath) - - SIMPL_FILTER_PARAMETER(int, Delimiter) - Q_PROPERTY(int Delimiter READ getDelimiter WRITE setDelimiter) - - SIMPL_FILTER_PARAMETER(QString, FileExtension) - Q_PROPERTY(QString FileExtension READ getFileExtension WRITE setFileExtension) - - SIMPL_FILTER_PARAMETER(int, MaxValPerLine) - Q_PROPERTY(int MaxValPerLine READ getMaxValPerLine WRITE setMaxValPerLine) - - SIMPL_FILTER_PARAMETER(int, OutputStyle) - Q_PROPERTY(int OutputStyle READ getOutputStyle WRITE setOutputStyle) - - enum DelimiterType - { - Comma = 0, - Semicolon = 1, - Space = 2, - Colon = 3, - Tab = 4 - }; - - enum OutputType - { - MultiFile = 0, - SingleFile = 1 - }; - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - WriteASCIIData(); - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - - private: - /** - * @brief lookupDelimiter Returns the char representation for the - * selected delimiter - * @return Char for delimiter - */ - char lookupDelimiter(); - - /** - * @brief Specific function to write string arrays to a text file - * @param inputData - */ - void writeStringArray(const IDataArray::Pointer& inputData, const QString& outputFile, char delimiter); - - /** - * @brief m_SelectedWeakPtrVector - */ - QVector m_SelectedWeakPtrVector; - - /** - * @brief writeMultifileOutput - */ - void writeMultiFileOutput(); - - /** - * @brief writeSingleFileOutput - */ - void writeSingleFileOutput(); - - public: - WriteASCIIData(const WriteASCIIData&) = delete; // Copy Constructor Not Implemented - WriteASCIIData(WriteASCIIData&&) = delete; // Move Constructor Not Implemented - WriteASCIIData& operator=(const WriteASCIIData&) = delete; // Copy Assignment Not Implemented - WriteASCIIData& operator=(WriteASCIIData&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(WriteASCIIData SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(WriteASCIIData) + PYB11_FILTER_NEW_MACRO(WriteASCIIData) + PYB11_PROPERTY(std::vector SelectedDataArrayPaths READ getSelectedDataArrayPaths WRITE setSelectedDataArrayPaths) + PYB11_PROPERTY(QString OutputPath READ getOutputPath WRITE setOutputPath) + PYB11_PROPERTY(QString OutputFilePath READ getOutputFilePath WRITE setOutputFilePath) + PYB11_PROPERTY(int Delimiter READ getDelimiter WRITE setDelimiter) + PYB11_PROPERTY(QString FileExtension READ getFileExtension WRITE setFileExtension) + PYB11_PROPERTY(int MaxValPerLine READ getMaxValPerLine WRITE setMaxValPerLine) + PYB11_PROPERTY(int OutputStyle READ getOutputStyle WRITE setOutputStyle) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = WriteASCIIData; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for WriteASCIIData + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for WriteASCIIData + */ + static QString ClassName(); + + ~WriteASCIIData() override; + + /** + * @brief Setter property for SelectedDataArrayPaths + */ + void setSelectedDataArrayPaths(const std::vector& value); + /** + * @brief Getter property for SelectedDataArrayPaths + * @return Value of SelectedDataArrayPaths + */ + std::vector getSelectedDataArrayPaths() const; + + Q_PROPERTY(DataArrayPathVec SelectedDataArrayPaths READ getSelectedDataArrayPaths WRITE setSelectedDataArrayPaths) + + /** + * @brief Setter property for OutputPath + */ + void setOutputPath(const QString& value); + /** + * @brief Getter property for OutputPath + * @return Value of OutputPath + */ + QString getOutputPath() const; + + Q_PROPERTY(QString OutputPath READ getOutputPath WRITE setOutputPath) + + /** + * @brief Setter property for OutputFilePath + */ + void setOutputFilePath(const QString& value); + /** + * @brief Getter property for OutputFilePath + * @return Value of OutputFilePath + */ + QString getOutputFilePath() const; + + Q_PROPERTY(QString OutputFilePath READ getOutputFilePath WRITE setOutputFilePath) + + /** + * @brief Setter property for Delimiter + */ + void setDelimiter(int value); + /** + * @brief Getter property for Delimiter + * @return Value of Delimiter + */ + int getDelimiter() const; + + Q_PROPERTY(int Delimiter READ getDelimiter WRITE setDelimiter) + + /** + * @brief Setter property for FileExtension + */ + void setFileExtension(const QString& value); + /** + * @brief Getter property for FileExtension + * @return Value of FileExtension + */ + QString getFileExtension() const; + + Q_PROPERTY(QString FileExtension READ getFileExtension WRITE setFileExtension) + + /** + * @brief Setter property for MaxValPerLine + */ + void setMaxValPerLine(int value); + /** + * @brief Getter property for MaxValPerLine + * @return Value of MaxValPerLine + */ + int getMaxValPerLine() const; + + Q_PROPERTY(int MaxValPerLine READ getMaxValPerLine WRITE setMaxValPerLine) + + /** + * @brief Setter property for OutputStyle + */ + void setOutputStyle(int value); + /** + * @brief Getter property for OutputStyle + * @return Value of OutputStyle + */ + int getOutputStyle() const; + + Q_PROPERTY(int OutputStyle READ getOutputStyle WRITE setOutputStyle) + + enum DelimiterType + { + Comma = 0, + Semicolon = 1, + Space = 2, + Colon = 3, + Tab = 4 + }; + + enum OutputType + { + MultiFile = 0, + SingleFile = 1 + }; + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + WriteASCIIData(); + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +private: + std::vector m_SelectedDataArrayPaths = {}; + QString m_OutputPath = {""}; + QString m_OutputFilePath = {}; + int m_Delimiter = {0}; + QString m_FileExtension = {".txt"}; + int m_MaxValPerLine = {-1}; + int m_OutputStyle = {}; + + /** + * @brief lookupDelimiter Returns the char representation for the + * selected delimiter + * @return Char for delimiter + */ + char lookupDelimiter(); + + /** + * @brief Specific function to write string arrays to a text file + * @param inputData + */ + void writeStringArray(const IDataArrayShPtrType& inputData, const QString& outputFile, char delimiter); + + /** + * @brief m_SelectedWeakPtrVector + */ + QVector m_SelectedWeakPtrVector; + + /** + * @brief writeMultifileOutput + */ + void writeMultiFileOutput(); + + /** + * @brief writeSingleFileOutput + */ + void writeSingleFileOutput(); + +public: + WriteASCIIData(const WriteASCIIData&) = delete; // Copy Constructor Not Implemented + WriteASCIIData(WriteASCIIData&&) = delete; // Move Constructor Not Implemented + WriteASCIIData& operator=(const WriteASCIIData&) = delete; // Copy Assignment Not Implemented + WriteASCIIData& operator=(WriteASCIIData&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.cpp b/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.cpp index 40308ae403..ae778a8890 100644 --- a/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.cpp +++ b/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.cpp @@ -1,51 +1,53 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "WriteTriangleGeometry.h" #include #include #include +#include +#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h" #include "SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h" #include "SIMPLib/FilterParameters/OutputFileFilterParameter.h" #include "SIMPLib/FilterParameters/SeparatorFilterParameter.h" #include "SIMPLib/Geometry/TriangleGeom.h" -#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Utilities/FileSystemPathHelper.h" #define WRITE_EDGES_FILE 0 @@ -53,12 +55,7 @@ // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -WriteTriangleGeometry::WriteTriangleGeometry() -: m_DataContainerSelection("") -, m_OutputNodesFile("") -, m_OutputTrianglesFile("") -{ -} +WriteTriangleGeometry::WriteTriangleGeometry() = default; // ----------------------------------------------------------------------------- // @@ -70,14 +67,14 @@ WriteTriangleGeometry::~WriteTriangleGeometry() = default; // ----------------------------------------------------------------------------- void WriteTriangleGeometry::setupFilterParameters() { - FilterParameterVector parameters; + FilterParameterVectorType parameters; - parameters.push_back(SIMPL_NEW_OUTPUT_FILE_FP("Output Nodes File", OutputNodesFile, FilterParameter::Parameter, WriteTriangleGeometry)); - parameters.push_back(SIMPL_NEW_OUTPUT_FILE_FP("Output Triangles File", OutputTrianglesFile, FilterParameter::Parameter, WriteTriangleGeometry)); + parameters.push_back(SIMPL_NEW_OUTPUT_FILE_FP("Output Nodes File", OutputNodesFile, FilterParameter::Category::Parameter, WriteTriangleGeometry)); + parameters.push_back(SIMPL_NEW_OUTPUT_FILE_FP("Output Triangles File", OutputTrianglesFile, FilterParameter::Category::Parameter, WriteTriangleGeometry)); { DataContainerSelectionFilterParameter::RequirementType req; - parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("DataContainer", DataContainerSelection, FilterParameter::RequiredArray, WriteTriangleGeometry, req)); + parameters.push_back(SIMPL_NEW_DC_SELECTION_FP("DataContainer", DataContainerSelection, FilterParameter::Category::RequiredArray, WriteTriangleGeometry, req)); } setFilterParameters(parameters); @@ -89,7 +86,7 @@ void WriteTriangleGeometry::setupFilterParameters() void WriteTriangleGeometry::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); - setDataContainerSelection(reader->readString("DataContainerSelection", getDataContainerSelection())); + setDataContainerSelection(reader->readDataArrayPath("DataContainerSelection", getDataContainerSelection())); setOutputNodesFile(reader->readString("OutputNodesFile", getOutputNodesFile())); setOutputTrianglesFile(reader->readString("OutputTrianglesFile", getOutputTrianglesFile())); reader->closeFilterGroup(); @@ -107,9 +104,8 @@ void WriteTriangleGeometry::initialize() // ----------------------------------------------------------------------------- void WriteTriangleGeometry::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); - + clearErrorCode(); + clearWarningCode(); QFileInfo fi(getOutputNodesFile()); if(fi.suffix().compare("") == 0) @@ -118,7 +114,7 @@ void WriteTriangleGeometry::dataCheck() } FileSystemPathHelper::CheckOutputFile(this, "Output Nodes File", getOutputNodesFile(), true); - fi= QFileInfo(getOutputTrianglesFile()); + fi = QFileInfo(getOutputTrianglesFile()); if(fi.suffix().compare("") == 0) { m_OutputTrianglesFile.append(".bin"); @@ -126,13 +122,13 @@ void WriteTriangleGeometry::dataCheck() FileSystemPathHelper::CheckOutputFile(this, "Output Triangles File", getOutputTrianglesFile(), true); DataContainer::Pointer dataContainer = getDataContainerArray()->getPrereqDataContainer(this, getDataContainerSelection()); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } - TriangleGeom::Pointer triangles = dataContainer->getPrereqGeometry(this); - if(getErrorCondition() < 0) + TriangleGeom::Pointer triangles = dataContainer->getPrereqGeometry(this); + if(getErrorCode() < 0) { return; } @@ -140,40 +136,25 @@ void WriteTriangleGeometry::dataCheck() // We MUST have Nodes if(nullptr == triangles->getVertices().get()) { - setErrorCondition(-386); - notifyErrorMessage(getHumanLabel(), "DataContainer Geometry missing Vertices", getErrorCondition()); + setErrorCondition(-386, "DataContainer Geometry missing Vertices"); } // We MUST have Triangles defined also. if(nullptr == triangles->getTriangles().get()) { - setErrorCondition(-387); - notifyErrorMessage(getHumanLabel(), "DataContainer Geometry missing Triangles", getErrorCondition()); + setErrorCondition(-387, "DataContainer Geometry missing Triangles"); } } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void WriteTriangleGeometry::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void WriteTriangleGeometry::execute() { - int err = 0; - setErrorCondition(err); + clearErrorCode(); + clearWarningCode(); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -182,35 +163,33 @@ void WriteTriangleGeometry::execute() TriangleGeom::Pointer triangleGeom = dataContainer->getGeometryAs(); QString geometryType = triangleGeom->getGeometryTypeAsString(); float* nodes = triangleGeom->getVertexPointer(0); - int64_t* triangles = triangleGeom->getTriPointer(0); + size_t* triangles = triangleGeom->getTriPointer(0); - int64_t numNodes = triangleGeom->getNumberOfVertices(); - int64_t maxNodeId = numNodes - 1; - int64_t numTriangles = triangleGeom->getNumberOfTris(); + size_t numNodes = triangleGeom->getNumberOfVertices(); + size_t maxNodeId = numNodes - 1; + size_t numTriangles = triangleGeom->getNumberOfTris(); // ++++++++++++++ Write the Nodes File +++++++++++++++++++++++++++++++++++++++++++ // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path - notifyStatusMessage(getHumanLabel(), "Writing Nodes Text File"); + notifyStatusMessage("Writing Nodes Text File"); QFileInfo fi(getOutputNodesFile()); QDir parentPath = fi.path(); if(!parentPath.mkpath(".")) { QString ss = QObject::tr("Error creating parent path '%1'").arg(parentPath.absolutePath()); - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); return; } - + QFile fileNodes(getOutputNodesFile()); - - if (!fileNodes.open(QIODevice::WriteOnly | QIODevice::Text)) + + if(!fileNodes.open(QIODevice::WriteOnly | QIODevice::Text)) { QString ss = QObject::tr("Output file could not be opened: %1").arg(getOutputNodesFile()); - setErrorCondition(-100); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-100, ss); return; } @@ -226,7 +205,7 @@ void WriteTriangleGeometry::execute() outFileNodes.setRealNumberPrecision(5); outFileNodes.setRealNumberNotation(QTextStream::FixedNotation); - for(int64_t i = 0; i < numNodes; i++) + for(size_t i = 0; i < numNodes; i++) { outFileNodes.setFieldWidth(8); outFileNodes << nodes[i * 3] << qSetFieldWidth(0); @@ -241,25 +220,23 @@ void WriteTriangleGeometry::execute() // ++++++++++++++ Write the Triangles File +++++++++++++++++++++++++++++++++++++++++++ - notifyStatusMessage(getHumanLabel(), "Writing Triangles Text File"); + notifyStatusMessage("Writing Triangles Text File"); QFileInfo triFI(getOutputTrianglesFile()); - parentPath = triFI.path(); + parentPath.setPath(triFI.path()); if(!parentPath.mkpath(".")) { QString ss = QObject::tr("Error creating parent path '%1'").arg(parentPath.absolutePath()); - setErrorCondition(-1); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-1, ss); return; } QFile fileTri(getOutputTrianglesFile()); - if (!fileTri.open(QIODevice::WriteOnly | QIODevice::Text)) + if(!fileTri.open(QIODevice::WriteOnly | QIODevice::Text)) { QString ss = QObject::tr("Output file could not be opened: %1").arg(getOutputTrianglesFile()); - setErrorCondition(-100); - notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); + setErrorCondition(-100, ss); return; } @@ -276,7 +253,7 @@ void WriteTriangleGeometry::execute() outFileTri << "Triangle Count: " << numTriangles << "\n"; int n1, n2, n3; - for(int64_t j = 0; j < numTriangles; ++j) + for(size_t j = 0; j < numTriangles; ++j) { n1 = triangles[j * 3]; n2 = triangles[j * 3 + 1]; @@ -304,7 +281,7 @@ AbstractFilter::Pointer WriteTriangleGeometry::newFilterInstance(bool copyFilter // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString WriteTriangleGeometry::getCompiledLibraryName() const +QString WriteTriangleGeometry::getCompiledLibraryName() const { return Core::CoreBaseName; } @@ -312,7 +289,7 @@ const QString WriteTriangleGeometry::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString WriteTriangleGeometry::getBrandingString() const +QString WriteTriangleGeometry::getBrandingString() const { return "SIMPLib Core Filter"; } @@ -320,7 +297,7 @@ const QString WriteTriangleGeometry::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString WriteTriangleGeometry::getFilterVersion() const +QString WriteTriangleGeometry::getFilterVersion() const { QString version; QTextStream vStream(&version); @@ -331,7 +308,7 @@ const QString WriteTriangleGeometry::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString WriteTriangleGeometry::getGroupName() const +QString WriteTriangleGeometry::getGroupName() const { return SIMPL::FilterGroups::CoreFilters; } @@ -339,7 +316,7 @@ const QString WriteTriangleGeometry::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid WriteTriangleGeometry::getUuid() +QUuid WriteTriangleGeometry::getUuid() const { return QUuid("{5e523ec1-49ac-541e-a4ba-6fa725798b91}"); } @@ -347,7 +324,7 @@ const QUuid WriteTriangleGeometry::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString WriteTriangleGeometry::getSubGroupName() const +QString WriteTriangleGeometry::getSubGroupName() const { return SIMPL::FilterSubGroups::OutputFilters; } @@ -355,7 +332,72 @@ const QString WriteTriangleGeometry::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString WriteTriangleGeometry::getHumanLabel() const +QString WriteTriangleGeometry::getHumanLabel() const { return "Export Triangle Geometry"; } + +// ----------------------------------------------------------------------------- +WriteTriangleGeometry::Pointer WriteTriangleGeometry::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr WriteTriangleGeometry::New() +{ + struct make_shared_enabler : public WriteTriangleGeometry + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString WriteTriangleGeometry::getNameOfClass() const +{ + return QString("WriteTriangleGeometry"); +} + +// ----------------------------------------------------------------------------- +QString WriteTriangleGeometry::ClassName() +{ + return QString("WriteTriangleGeometry"); +} + +// ----------------------------------------------------------------------------- +void WriteTriangleGeometry::setDataContainerSelection(const DataArrayPath& value) +{ + m_DataContainerSelection = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath WriteTriangleGeometry::getDataContainerSelection() const +{ + return m_DataContainerSelection; +} + +// ----------------------------------------------------------------------------- +void WriteTriangleGeometry::setOutputNodesFile(const QString& value) +{ + m_OutputNodesFile = value; +} + +// ----------------------------------------------------------------------------- +QString WriteTriangleGeometry::getOutputNodesFile() const +{ + return m_OutputNodesFile; +} + +// ----------------------------------------------------------------------------- +void WriteTriangleGeometry::setOutputTrianglesFile(const QString& value) +{ + m_OutputTrianglesFile = value; +} + +// ----------------------------------------------------------------------------- +QString WriteTriangleGeometry::getOutputTrianglesFile() const +{ + return m_OutputTrianglesFile; +} diff --git a/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.h b/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.h index d32ba83352..a61d6ddd21 100644 --- a/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.h +++ b/Source/SIMPLib/CoreFilters/WriteTriangleGeometry.h @@ -1,51 +1,49 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Constants.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataArrays/IDataArray.h" #include "SIMPLib/DataContainers/DataContainer.h" #include "SIMPLib/Filtering/AbstractFilter.h" - /** * @class WriteTriangleGeometry WriteTriangleGeometry.h FilterCategory/Code/FilterCategoryFilters/WriteTriangleGeometry.h * @brief This filter writes a Nodes, Triangles and Edges file from a Surface Mesh. @@ -55,133 +53,157 @@ */ class SIMPLib_EXPORT WriteTriangleGeometry : public AbstractFilter { - Q_OBJECT - PYB11_CREATE_BINDINGS(WriteTriangleGeometry SUPERCLASS AbstractFilter) - PYB11_PROPERTY(QString DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) - PYB11_PROPERTY(QString OutputNodesFile READ getOutputNodesFile WRITE setOutputNodesFile) - PYB11_PROPERTY(QString OutputTrianglesFile READ getOutputTrianglesFile WRITE setOutputTrianglesFile) - - public: - SIMPL_SHARED_POINTERS(WriteTriangleGeometry) - SIMPL_FILTER_NEW_MACRO(WriteTriangleGeometry) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(WriteTriangleGeometry, AbstractFilter) - - ~WriteTriangleGeometry() override; - - SIMPL_FILTER_PARAMETER(QString, DataContainerSelection) - Q_PROPERTY(QString DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) - - SIMPL_FILTER_PARAMETER(QString, OutputNodesFile) - Q_PROPERTY(QString OutputNodesFile READ getOutputNodesFile WRITE setOutputNodesFile) - - SIMPL_FILTER_PARAMETER(QString, OutputTrianglesFile) - Q_PROPERTY(QString OutputTrianglesFile READ getOutputTrianglesFile WRITE setOutputTrianglesFile) - - /** - * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class - */ - const QString getCompiledLibraryName() const override; - - /** - * @brief getBrandingString Returns the branding string for the filter, which is a tag - * used to denote the filter's association with specific plugins - * @return Branding string - */ - const QString getBrandingString() const override; - - /** - * @brief getFilterVersion Returns a version string for this filter. Default - * value is an empty string. - * @return - */ - const QString getFilterVersion() const override; - - /** - * @brief newFilterInstance Reimplemented from @see AbstractFilter class - */ - AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; - - /** - * @brief getGroupName Reimplemented from @see AbstractFilter class - */ - const QString getGroupName() const override; - - /** - * @brief getSubGroupName Reimplemented from @see AbstractFilter class - */ - const QString getSubGroupName() const override; - - /** - * @brief getUuid Return the unique identifier for this filter. - * @return A QUuid object. - */ - const QUuid getUuid() override; - - /** - * @brief getHumanLabel Reimplemented from @see AbstractFilter class - */ - const QString getHumanLabel() const override; - - /** - * @brief setupFilterParameters Reimplemented from @see AbstractFilter class - */ - void setupFilterParameters() override; - - /** - * @brief readFilterParameters Reimplemented from @see AbstractFilter class - */ - void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; - - /** - * @brief execute Reimplemented from @see AbstractFilter class - */ - void execute() override; - - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - - signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - - protected: - WriteTriangleGeometry(); - - /** - * @brief dataCheck Checks for the appropriate parameter values and availability of arrays - */ - void dataCheck(); - - /** - * @brief Initializes all the private instance variables. - */ - void initialize(); - - public: - WriteTriangleGeometry(const WriteTriangleGeometry&) = delete; // Copy Constructor Not Implemented - WriteTriangleGeometry(WriteTriangleGeometry&&) = delete; // Move Constructor Not Implemented - WriteTriangleGeometry& operator=(const WriteTriangleGeometry&) = delete; // Copy Assignment Not Implemented - WriteTriangleGeometry& operator=(WriteTriangleGeometry&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(WriteTriangleGeometry SUPERCLASS AbstractFilter) + PYB11_FILTER() + PYB11_SHARED_POINTERS(WriteTriangleGeometry) + PYB11_FILTER_NEW_MACRO(WriteTriangleGeometry) + PYB11_PROPERTY(DataArrayPath DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) + PYB11_PROPERTY(QString OutputNodesFile READ getOutputNodesFile WRITE setOutputNodesFile) + PYB11_PROPERTY(QString OutputTrianglesFile READ getOutputTrianglesFile WRITE setOutputTrianglesFile) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = WriteTriangleGeometry; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static std::shared_ptr New(); + + /** + * @brief Returns the name of the class for WriteTriangleGeometry + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for WriteTriangleGeometry + */ + static QString ClassName(); + + ~WriteTriangleGeometry() override; + + /** + * @brief Setter property for DataContainerSelection + */ + void setDataContainerSelection(const DataArrayPath& value); + /** + * @brief Getter property for DataContainerSelection + * @return Value of DataContainerSelection + */ + DataArrayPath getDataContainerSelection() const; + + Q_PROPERTY(DataArrayPath DataContainerSelection READ getDataContainerSelection WRITE setDataContainerSelection) + + /** + * @brief Setter property for OutputNodesFile + */ + void setOutputNodesFile(const QString& value); + /** + * @brief Getter property for OutputNodesFile + * @return Value of OutputNodesFile + */ + QString getOutputNodesFile() const; + + Q_PROPERTY(QString OutputNodesFile READ getOutputNodesFile WRITE setOutputNodesFile) + + /** + * @brief Setter property for OutputTrianglesFile + */ + void setOutputTrianglesFile(const QString& value); + /** + * @brief Getter property for OutputTrianglesFile + * @return Value of OutputTrianglesFile + */ + QString getOutputTrianglesFile() const; + + Q_PROPERTY(QString OutputTrianglesFile READ getOutputTrianglesFile WRITE setOutputTrianglesFile) + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief readFilterParameters Reimplemented from @see AbstractFilter class + */ + void readFilterParameters(AbstractFilterParametersReader* reader, int index) override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + WriteTriangleGeometry(); + + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + + /** + * @brief Initializes all the private instance variables. + */ + void initialize(); + +public: + WriteTriangleGeometry(const WriteTriangleGeometry&) = delete; // Copy Constructor Not Implemented + WriteTriangleGeometry(WriteTriangleGeometry&&) = delete; // Move Constructor Not Implemented + WriteTriangleGeometry& operator=(const WriteTriangleGeometry&) = delete; // Copy Assignment Not Implemented + WriteTriangleGeometry& operator=(WriteTriangleGeometry&&) = delete; // Move Assignment Not Implemented + +private: + DataArrayPath m_DataContainerSelection = {"", "", ""}; + QString m_OutputNodesFile = {""}; + QString m_OutputTrianglesFile = {""}; }; - diff --git a/Source/SIMPLib/CoreFilters/util/ABSOperator.cpp b/Source/SIMPLib/CoreFilters/util/ABSOperator.cpp index a4bfc97ec4..c46fa9215f 100644 --- a/Source/SIMPLib/CoreFilters/util/ABSOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/ABSOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ABSOperator.h" @@ -60,5 +60,11 @@ ABSOperator::~ABSOperator() = default; // ----------------------------------------------------------------------------- void ABSOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) { - CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, fabs) + CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, fabs); +} + +// ----------------------------------------------------------------------------- +ABSOperator::Pointer ABSOperator::NullPointer() +{ + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/ABSOperator.h b/Source/SIMPLib/CoreFilters/util/ABSOperator.h index 48be1bf213..8a33c59d5b 100644 --- a/Source/SIMPLib/CoreFilters/util/ABSOperator.h +++ b/Source/SIMPLib/CoreFilters/util/ABSOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT ABSOperator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(ABSOperator) +public: + using Self = ABSOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new ABSOperator()); - } + static Pointer New() + { + return Pointer(new ABSOperator()); + } - ~ABSOperator() override; + ~ABSOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - ABSOperator(); +protected: + ABSOperator(); - public: - ABSOperator(const ABSOperator&) = delete; // Copy Constructor Not Implemented - ABSOperator(ABSOperator&&) = delete; // Move Constructor Not Implemented - ABSOperator& operator=(const ABSOperator&) = delete; // Copy Assignment Not Implemented - ABSOperator& operator=(ABSOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + ABSOperator(const ABSOperator&) = delete; // Copy Constructor Not Implemented + ABSOperator(ABSOperator&&) = delete; // Move Constructor Not Implemented + ABSOperator& operator=(const ABSOperator&) = delete; // Copy Assignment Not Implemented + ABSOperator& operator=(ABSOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/ACosOperator.cpp b/Source/SIMPLib/CoreFilters/util/ACosOperator.cpp index 295192c0bf..5da8d32a34 100644 --- a/Source/SIMPLib/CoreFilters/util/ACosOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/ACosOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ACosOperator.h" @@ -58,7 +58,11 @@ ACosOperator::~ACosOperator() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ACosOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) +void ACosOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, + QStack& executionStack){CREATE_NEW_ARRAY_ARCTRIG(filter, calculatedArrayPath, executionStack, acos)} + +// ----------------------------------------------------------------------------- +ACosOperator::Pointer ACosOperator::NullPointer() { - CREATE_NEW_ARRAY_ARCTRIG(filter, calculatedArrayPath, executionStack, acos) + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/ACosOperator.h b/Source/SIMPLib/CoreFilters/util/ACosOperator.h index 2bba0e11cc..1bd204c7b0 100644 --- a/Source/SIMPLib/CoreFilters/util/ACosOperator.h +++ b/Source/SIMPLib/CoreFilters/util/ACosOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT ACosOperator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(ACosOperator) +public: + using Self = ACosOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new ACosOperator()); - } + static Pointer New() + { + return Pointer(new ACosOperator()); + } - ~ACosOperator() override; + ~ACosOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - ACosOperator(); +protected: + ACosOperator(); - public: - ACosOperator(const ACosOperator&) = delete; // Copy Constructor Not Implemented - ACosOperator(ACosOperator&&) = delete; // Move Constructor Not Implemented - ACosOperator& operator=(const ACosOperator&) = delete; // Copy Assignment Not Implemented - ACosOperator& operator=(ACosOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + ACosOperator(const ACosOperator&) = delete; // Copy Constructor Not Implemented + ACosOperator(ACosOperator&&) = delete; // Move Constructor Not Implemented + ACosOperator& operator=(const ACosOperator&) = delete; // Copy Assignment Not Implemented + ACosOperator& operator=(ACosOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/ASCIIWizardData.hpp b/Source/SIMPLib/CoreFilters/util/ASCIIWizardData.hpp index 28056ed2e2..ebdf3c60b1 100644 --- a/Source/SIMPLib/CoreFilters/util/ASCIIWizardData.hpp +++ b/Source/SIMPLib/CoreFilters/util/ASCIIWizardData.hpp @@ -1,46 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once #include #include -#include -#include #include +#include +#include #include "SIMPLib/DataContainers/DataArrayPath.h" @@ -49,35 +48,28 @@ class ASCIIWizardData { // clang-format off - PYB11_CREATE_BINDINGS(ASCIIWizardData) - - PYB11_CREATION(ASCIIWizardData ARGS QString int int) - + PYB11_BEGIN_BINDINGS(ASCIIWizardData) + PYB11_CREATION() PYB11_METHOD(void updateDataArrayPath ARGS DataArrayPath::RenameType,renamePath) PYB11_METHOD(bool isEmpty) + PYB11_END_BINDINGS() // clang-format on public: - ASCIIWizardData() : - inputFilePath(""), - beginIndex(-1), - numberOfLines(-1) - { + ASCIIWizardData() = default; - } - - QString inputFilePath; + QString inputFilePath = ""; QStringList dataHeaders; int beginIndex = -1; int numberOfLines = -1; QStringList dataTypes; QList delimiters; - QVector tupleDims; + std::vector tupleDims; int attrMatType = 999; DataArrayPath selectedPath; - int headerLine = 0; // -1 means this selection is not used - bool headerIsCustom = false; // The user has set their own header names + int headerLine = 0; // -1 means this selection is not used + bool headerIsCustom = false; // The user has set their own header names bool headerUsesDefaults = false; // The user just wants to use the automatically generated headers bool consecutiveDelimiters = false; bool automaticAM = false; @@ -109,7 +101,7 @@ class ASCIIWizardData bool isEmpty() { - if (inputFilePath.isEmpty() && dataHeaders.isEmpty() && dataTypes.isEmpty() && tupleDims.isEmpty() && beginIndex < 0 && numberOfLines < 0 && selectedPath.isEmpty()) + if(inputFilePath.isEmpty() && dataHeaders.isEmpty() && dataTypes.isEmpty() && tupleDims.empty() && beginIndex < 0 && numberOfLines < 0 && selectedPath.isEmpty()) { return true; } @@ -135,4 +127,3 @@ class ASCIIWizardData }; Q_DECLARE_METATYPE(ASCIIWizardData) - diff --git a/Source/SIMPLib/CoreFilters/util/ASinOperator.cpp b/Source/SIMPLib/CoreFilters/util/ASinOperator.cpp index d97a80bd0e..9d014c1de6 100644 --- a/Source/SIMPLib/CoreFilters/util/ASinOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/ASinOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ASinOperator.h" @@ -58,7 +58,11 @@ ASinOperator::~ASinOperator() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ASinOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) +void ASinOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, + QStack& executionStack){CREATE_NEW_ARRAY_ARCTRIG(filter, calculatedArrayPath, executionStack, asin)} + +// ----------------------------------------------------------------------------- +ASinOperator::Pointer ASinOperator::NullPointer() { - CREATE_NEW_ARRAY_ARCTRIG(filter, calculatedArrayPath, executionStack, asin) + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/ASinOperator.h b/Source/SIMPLib/CoreFilters/util/ASinOperator.h index e303a9fc0a..c1d0f637cb 100644 --- a/Source/SIMPLib/CoreFilters/util/ASinOperator.h +++ b/Source/SIMPLib/CoreFilters/util/ASinOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT ASinOperator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(ASinOperator) +public: + using Self = ASinOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new ASinOperator()); - } + static Pointer New() + { + return Pointer(new ASinOperator()); + } - ~ASinOperator() override; + ~ASinOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - ASinOperator(); +protected: + ASinOperator(); - public: - ASinOperator(const ASinOperator&) = delete; // Copy Constructor Not Implemented - ASinOperator(ASinOperator&&) = delete; // Move Constructor Not Implemented - ASinOperator& operator=(const ASinOperator&) = delete; // Copy Assignment Not Implemented - ASinOperator& operator=(ASinOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + ASinOperator(const ASinOperator&) = delete; // Copy Constructor Not Implemented + ASinOperator(ASinOperator&&) = delete; // Move Constructor Not Implemented + ASinOperator& operator=(const ASinOperator&) = delete; // Copy Assignment Not Implemented + ASinOperator& operator=(ASinOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/ATanOperator.cpp b/Source/SIMPLib/CoreFilters/util/ATanOperator.cpp index 759e672555..3a50c752da 100644 --- a/Source/SIMPLib/CoreFilters/util/ATanOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/ATanOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ATanOperator.h" @@ -58,7 +58,11 @@ ATanOperator::~ATanOperator() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ATanOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) +void ATanOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, + QStack& executionStack){CREATE_NEW_ARRAY_ARCTRIG(filter, calculatedArrayPath, executionStack, atan)} + +// ----------------------------------------------------------------------------- +ATanOperator::Pointer ATanOperator::NullPointer() { - CREATE_NEW_ARRAY_ARCTRIG(filter, calculatedArrayPath, executionStack, atan) + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/ATanOperator.h b/Source/SIMPLib/CoreFilters/util/ATanOperator.h index 97aeac5894..3326f1664c 100644 --- a/Source/SIMPLib/CoreFilters/util/ATanOperator.h +++ b/Source/SIMPLib/CoreFilters/util/ATanOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT ATanOperator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(ATanOperator) +public: + using Self = ATanOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new ATanOperator()); - } + static Pointer New() + { + return Pointer(new ATanOperator()); + } - ~ATanOperator() override; + ~ATanOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - ATanOperator(); +protected: + ATanOperator(); - public: - ATanOperator(const ATanOperator&) = delete; // Copy Constructor Not Implemented - ATanOperator(ATanOperator&&) = delete; // Move Constructor Not Implemented - ATanOperator& operator=(const ATanOperator&) = delete; // Copy Assignment Not Implemented - ATanOperator& operator=(ATanOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + ATanOperator(const ATanOperator&) = delete; // Copy Constructor Not Implemented + ATanOperator(ATanOperator&&) = delete; // Move Constructor Not Implemented + ATanOperator& operator=(const ATanOperator&) = delete; // Copy Assignment Not Implemented + ATanOperator& operator=(ATanOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/AbstractDataParser.hpp b/Source/SIMPLib/CoreFilters/util/AbstractDataParser.hpp index a9ceac92fd..8572a5be44 100644 --- a/Source/SIMPLib/CoreFilters/util/AbstractDataParser.hpp +++ b/Source/SIMPLib/CoreFilters/util/AbstractDataParser.hpp @@ -31,29 +31,63 @@ #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/DataArrays/DataArray.hpp" -#include "SIMPLib/DataArrays/StringDataArray.h" #include "SIMPLib/SIMPLib.h" - #include "SIMPLib/CoreFilters/util/ParserFunctors.hpp" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataArrays/StringDataArray.h" class AbstractDataParser { public: - SIMPL_SHARED_POINTERS(AbstractDataParser) - SIMPL_TYPE_MACRO(AbstractDataParser) + using Self = AbstractDataParser; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer() + { + return Pointer(static_cast(nullptr)); + } + /** + * @brief Returns the name of the class for AbstractMessage + */ + virtual QString getNameOfClass() const + { + return QString("AbstractDataParser"); + } + /** + * @brief Returns the name of the class for AbstractMessage + */ + static QString ClassName() + { + return QString("AbstractDataParser"); + } virtual ~AbstractDataParser() = default; - SIMPL_INSTANCE_STRING_PROPERTY(ColumnName) - SIMPL_INSTANCE_PROPERTY(int, ColumnIndex) - + void setColumnName(const QString& value) + { + m_ColumnName = value; + } + QString getColumnName() + { + return m_ColumnName; + } + + void setColumnIndex(int32_t value) + { + m_ColumnIndex = value; + } + int32_t getColumnIndex() + { + return m_ColumnIndex; + } + virtual void setDataArray(IDataArray::Pointer value) { m_DataArray = value; } - + IDataArray::Pointer getDataArray() { return m_DataArray; @@ -67,14 +101,13 @@ class AbstractDataParser virtual ParserFunctor::ErrorObject parse(const QString& token, size_t index) = 0; protected: - AbstractDataParser() : - m_ColumnIndex(0) - { - } + AbstractDataParser() = default; private: IDataArray::Pointer m_DataArray; - + int32_t m_ColumnIndex = 0; + QString m_ColumnName = QString(""); + AbstractDataParser(const AbstractDataParser&); // Copy Constructor Not Implemented void operator=(const AbstractDataParser&); // Move assignment Not Implemented }; @@ -82,13 +115,35 @@ class AbstractDataParser // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template class Parser : public AbstractDataParser +template +class Parser : public AbstractDataParser { public: - typedef Parser SelfType; - - SIMPL_SHARED_POINTERS(SelfType) - SIMPL_TYPE_MACRO(SelfType) + using SelfType = Parser; + + using Self = SelfType; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer() + { + return Pointer(static_cast(nullptr)); + } + /** + * @brief Returns the name of the class for AbstractMessage + */ + QString getNameOfClass() const override + { + return QString("Parser"); + } + /** + * @brief Returns the name of the class for AbstractMessage + */ + static QString ClassName() + { + return QString("Parser"); + } static Pointer New(typename ArrayType::Pointer ptr, const QString& name, int colIndex) { @@ -134,28 +189,26 @@ template class Parser : public AbstractDataParser private: typename ArrayType::Pointer m_Ptr; - public: - Parser(const Parser&) = delete; // Copy Constructor Not Implemented - Parser(Parser&&) = delete; // Move Constructor Not Implemented +public: + Parser(const Parser&) = delete; // Copy Constructor Not Implemented + Parser(Parser&&) = delete; // Move Constructor Not Implemented Parser& operator=(const Parser&) = delete; // Copy Assignment Not Implemented Parser& operator=(Parser&&) = delete; // Move Assignment - }; -typedef Parser Int8ParserType; -typedef Parser UInt8ParserType; - -typedef Parser Int16ParserType; -typedef Parser UInt16ParserType; +using Int8ParserType = Parser; +using UInt8ParserType = Parser; -typedef Parser Int32ParserType; -typedef Parser UInt32ParserType; +using Int16ParserType = Parser; +using UInt16ParserType = Parser; -typedef Parser Int64ParserType; -typedef Parser UInt64ParserType; +using Int32ParserType = Parser; +using UInt32ParserType = Parser; -typedef Parser FloatParserType; -typedef Parser DoubleParserType; +using Int64ParserType = Parser; +using UInt64ParserType = Parser; -typedef Parser StringParserType; +using FloatParserType = Parser; +using DoubleParserType = Parser; +using StringParserType = Parser; diff --git a/Source/SIMPLib/CoreFilters/util/AdditionOperator.cpp b/Source/SIMPLib/CoreFilters/util/AdditionOperator.cpp index f12b0ee959..c8347cc207 100644 --- a/Source/SIMPLib/CoreFilters/util/AdditionOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/AdditionOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "AdditionOperator.h" @@ -58,7 +58,11 @@ AdditionOperator::~AdditionOperator() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AdditionOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) +void AdditionOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, + QStack& executionStack){CREATE_NEW_ARRAY_STANDARD_BINARY(filter, calculatedArrayPath, executionStack, +)} + +// ----------------------------------------------------------------------------- +AdditionOperator::Pointer AdditionOperator::NullPointer() { - CREATE_NEW_ARRAY_STANDARD_BINARY(filter, calculatedArrayPath, executionStack, +) + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/AdditionOperator.h b/Source/SIMPLib/CoreFilters/util/AdditionOperator.h index 26f8e3121e..c40199a7d9 100644 --- a/Source/SIMPLib/CoreFilters/util/AdditionOperator.h +++ b/Source/SIMPLib/CoreFilters/util/AdditionOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT AdditionOperator : public BinaryOperator { - public: - SIMPL_SHARED_POINTERS(AdditionOperator) +public: + using Self = AdditionOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new AdditionOperator()); - } + static Pointer New() + { + return Pointer(new AdditionOperator()); + } - ~AdditionOperator() override; + ~AdditionOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - AdditionOperator(); +protected: + AdditionOperator(); - public: - AdditionOperator(const AdditionOperator&) = delete; // Copy Constructor Not Implemented - AdditionOperator(AdditionOperator&&) = delete; // Move Constructor Not Implemented - AdditionOperator& operator=(const AdditionOperator&) = delete; // Copy Assignment Not Implemented - AdditionOperator& operator=(AdditionOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + AdditionOperator(const AdditionOperator&) = delete; // Copy Constructor Not Implemented + AdditionOperator(AdditionOperator&&) = delete; // Move Constructor Not Implemented + AdditionOperator& operator=(const AdditionOperator&) = delete; // Copy Assignment Not Implemented + AdditionOperator& operator=(AdditionOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/BinaryOperator.cpp b/Source/SIMPLib/CoreFilters/util/BinaryOperator.cpp index e6f6362878..30b6fa73be 100644 --- a/Source/SIMPLib/CoreFilters/util/BinaryOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/BinaryOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "BinaryOperator.h" @@ -88,3 +88,9 @@ CalculatorItem::ErrorCode BinaryOperator::checkValidity(QVector(nullptr)); +} diff --git a/Source/SIMPLib/CoreFilters/util/BinaryOperator.h b/Source/SIMPLib/CoreFilters/util/BinaryOperator.h index 28b71c79c5..ea73c84fba 100644 --- a/Source/SIMPLib/CoreFilters/util/BinaryOperator.h +++ b/Source/SIMPLib/CoreFilters/util/BinaryOperator.h @@ -1,66 +1,77 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include "CalculatorOperator.h" +#include "SIMPLib/DataArrays/DataArray.hpp" + class SIMPLib_EXPORT BinaryOperator : public CalculatorOperator { - public: - SIMPL_SHARED_POINTERS(BinaryOperator) +public: + using Self = BinaryOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new BinaryOperator()); - } + static Pointer New() + { + return Pointer(new BinaryOperator()); + } - ~BinaryOperator() override; + ~BinaryOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& msg) final; + CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& msg) final; - protected: - BinaryOperator(); +protected: + BinaryOperator(); - public: - BinaryOperator(const BinaryOperator&) = delete; // Copy Constructor Not Implemented - BinaryOperator(BinaryOperator&&) = delete; // Move Constructor Not Implemented - BinaryOperator& operator=(const BinaryOperator&) = delete; // Copy Assignment Not Implemented - BinaryOperator& operator=(BinaryOperator&&) = delete; // Move Assignment Not Implemented +public: + BinaryOperator(const BinaryOperator&) = delete; // Copy Constructor Not Implemented + BinaryOperator(BinaryOperator&&) = delete; // Move Constructor Not Implemented + BinaryOperator& operator=(const BinaryOperator&) = delete; // Copy Assignment Not Implemented + BinaryOperator& operator=(BinaryOperator&&) = delete; // Move Assignment Not Implemented + +private: }; #define CREATE_NEW_ARRAY_STANDARD_BINARY(filter, calculatedArrayPath, executionStack, op) \ @@ -74,11 +85,11 @@ class SIMPLib_EXPORT BinaryOperator : public CalculatorOperator DoubleArrayType::Pointer newArray; \ if(array1->getType() == ICalculatorArray::Array) \ { \ - newArray = DoubleArrayType::CreateArray(array1->getArray()->getNumberOfTuples(), array1->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName()); \ + newArray = DoubleArrayType::CreateArray(array1->getArray()->getNumberOfTuples(), array1->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName(), true); \ } \ else \ { \ - newArray = DoubleArrayType::CreateArray(array2->getArray()->getNumberOfTuples(), array2->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName()); \ + newArray = DoubleArrayType::CreateArray(array2->getArray()->getNumberOfTuples(), array2->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName(), true); \ } \ \ int numComps = newArray->getNumberOfComponents(); \ @@ -103,4 +114,3 @@ class SIMPLib_EXPORT BinaryOperator : public CalculatorOperator } \ return; \ } - diff --git a/Source/SIMPLib/CoreFilters/util/CalculatorArray.hpp b/Source/SIMPLib/CoreFilters/util/CalculatorArray.hpp index a968b6d2eb..c0cba7938a 100644 --- a/Source/SIMPLib/CoreFilters/util/CalculatorArray.hpp +++ b/Source/SIMPLib/CoreFilters/util/CalculatorArray.hpp @@ -1,141 +1,165 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once #include -#include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" #include "ICalculatorArray.h" template class SIMPLib_EXPORT CalculatorArray : public ICalculatorArray { - public: - SIMPL_SHARED_POINTERS(CalculatorArray) - - static Pointer New(typename DataArray::Pointer dataArray, ValueType type, bool allocate) - { - return Pointer(new CalculatorArray(dataArray, type, allocate)); - } - - ~CalculatorArray() override = default; - - IDataArray::Pointer getArray() override { return m_Array; } - - void setValue(int i, double val) override - { - m_Array->setValue(i, val); - } - - double getValue(int i) override +public: + using Self = CalculatorArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer() + { + return Pointer(static_cast(nullptr)); + } + /** + * @brief Returns the name of the class for AbstractMessage + */ + virtual QString getNameOfClass() const + { + return QString("CalculatorArray"); + } + /** + * @brief Returns the name of the class for AbstractMessage + */ + static QString ClassName() + { + return QString("CalculatorArray"); + } + + static Pointer New(typename DataArray::Pointer dataArray, ValueType type, bool allocate) + { + return Pointer(new CalculatorArray(dataArray, type, allocate)); + } + + ~CalculatorArray() override = default; + + IDataArray::Pointer getArray() override + { + return m_Array; + } + + void setValue(int i, double val) override + { + m_Array->setValue(i, val); + } + + double getValue(int i) override + { + if(m_Array->getNumberOfTuples() > 1) { - if (m_Array->getNumberOfTuples() > 1) - { - return static_cast(m_Array->getValue(i)); - } - else if (m_Array->getNumberOfTuples() == 1) - { - return static_cast(m_Array->getValue(0)); - } - else - { - // ERROR: The array is empty! - return 0.0; - } + return static_cast(m_Array->getValue(i)); } - - ICalculatorArray::ValueType getType() override + if(m_Array->getNumberOfTuples() == 1) { - return m_Type; + return static_cast(m_Array->getValue(0)); } - - DoubleArrayType::Pointer reduceToOneComponent(int c, bool allocate = true) override + // ERROR: The array is empty! + return 0.0; + } + + ICalculatorArray::ValueType getType() override + { + return m_Type; + } + + DoubleArrayType::Pointer reduceToOneComponent(int c, bool allocate = true) override + { + if(c >= 0 && c <= m_Array->getNumberOfComponents()) { - if(c >= 0 && c <= m_Array->getNumberOfComponents()) + if(m_Array->getNumberOfComponents() > 1) { - if(m_Array->getNumberOfComponents() > 1) + DoubleArrayType::Pointer newArray = DoubleArrayType::CreateArray(m_Array->getNumberOfTuples(), {1}, m_Array->getName(), allocate); + if(allocate) { - DoubleArrayType::Pointer newArray = DoubleArrayType::CreateArray(m_Array->getNumberOfTuples(), QVector(1, 1), m_Array->getName(), allocate); - if(allocate) + for(int i = 0; i < m_Array->getNumberOfTuples(); i++) { - for(int i = 0; i < m_Array->getNumberOfTuples(); i++) - { - newArray->setComponent(i, 0, m_Array->getComponent(i, c)); - } + newArray->setComponent(i, 0, m_Array->getComponent(i, c)); } - - return newArray; } - } - return DoubleArrayType::NullPointer(); + return newArray; + } } - CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& msg) override - { - Q_UNUSED(infixVector) - Q_UNUSED(currentIndex) + return DoubleArrayType::NullPointer(); + } - return CalculatorItem::ErrorCode::SUCCESS; - } + CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& msg) override + { + Q_UNUSED(infixVector) + Q_UNUSED(currentIndex) + + return CalculatorItem::ErrorCode::SUCCESS; + } - protected: - CalculatorArray() = default; +protected: + CalculatorArray() = default; - CalculatorArray(typename DataArray::Pointer dataArray, ValueType type, bool allocate) : - ICalculatorArray(), - m_Type(type) + CalculatorArray(typename DataArray::Pointer dataArray, ValueType type, bool allocate) + : ICalculatorArray() + , m_Type(type) + { + m_Array = DoubleArrayType::CreateArray(dataArray->getNumberOfTuples(), dataArray->getComponentDimensions(), dataArray->getName(), allocate); + if(allocate) { - m_Array = DoubleArrayType::CreateArray(dataArray->getNumberOfTuples(), dataArray->getComponentDimensions(), dataArray->getName(), allocate); - if (allocate == true) + for(int i = 0; i < dataArray->getSize(); i++) { - for (int i = 0; i < dataArray->getSize(); i++) - { - m_Array->setValue(i, static_cast(dataArray->getValue(i))); - } + m_Array->setValue(i, static_cast(dataArray->getValue(i))); } } + } - private: - DoubleArrayType::Pointer m_Array; - ValueType m_Type; +private: + DoubleArrayType::Pointer m_Array; + ValueType m_Type; - CalculatorArray(const CalculatorArray&); // Copy Constructor Not Implemented - void operator=(const CalculatorArray&); // Move assignment Not Implemented +public: + CalculatorArray(const CalculatorArray&) = delete; // Copy Constructor Not Implemented + CalculatorArray(CalculatorArray&&) = delete; // Move Constructor Not Implemented + CalculatorArray& operator=(const CalculatorArray&) = delete; // Copy Assignment Not Implemented + CalculatorArray& operator=(CalculatorArray&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/util/CalculatorItem.cpp b/Source/SIMPLib/CoreFilters/util/CalculatorItem.cpp index 6db25dbbd9..81a8bf3cc5 100644 --- a/Source/SIMPLib/CoreFilters/util/CalculatorItem.cpp +++ b/Source/SIMPLib/CoreFilters/util/CalculatorItem.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CalculatorItem.h" @@ -98,3 +98,9 @@ bool CalculatorItem::isNumber() return false; } + +// ----------------------------------------------------------------------------- +CalculatorItem::Pointer CalculatorItem::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} diff --git a/Source/SIMPLib/CoreFilters/util/CalculatorItem.h b/Source/SIMPLib/CoreFilters/util/CalculatorItem.h index 8c1b5b8d52..9c0745d7a4 100644 --- a/Source/SIMPLib/CoreFilters/util/CalculatorItem.h +++ b/Source/SIMPLib/CoreFilters/util/CalculatorItem.h @@ -1,116 +1,125 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + +#include #include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +/** + * @brief The CalculatorItem class + */ class SIMPLib_EXPORT CalculatorItem { - public: - SIMPL_SHARED_POINTERS(CalculatorItem) - - virtual ~CalculatorItem(); - - using EnumType = int; - - enum class ErrorCode : EnumType - { - SUCCESS = 0, - INVALID_EQUATION = -4009, - INVALID_COMPONENT = -4010, - EMPTY_EQUATION = -4011, - EMPTY_CAL_ARRAY = -4012, - EMPTY_SEL_MATRIX = -4013, - LOST_ATTR_MATRIX = -4014, - INCORRECT_TUPLE_COUNT = -4015, - INCONSISTENT_TUPLES = -4016, - UNRECOGNIZED_ITEM = -4017, - MISMATCHED_PARENTHESES = -4018, - UNEXPECTED_OUTPUT = -4019, - COMPONENT_OUT_OF_RANGE = -4020, - INVALID_ARRAY_NAME = -4022, - INCONSISTENT_INDEXING = -4023, - INCONSISTENT_COMP_DIMS = -4024, - ATTRARRAY_ZEROTUPLES_WARNING = -4025, - ORPHANED_COMPONENT = -4026, - OPERATOR_NO_LEFT_VALUE = -4027, - OPERATOR_NO_RIGHT_VALUE = -4028, - OPERATOR_NO_OPENING_PAREN = -4029, - OPERATOR_NO_CLOSING_PAREN = -4030, - NO_NUMERIC_ARGUMENTS = -4031, - MISSING_ARGUMENTS = -4032, - NOT_ENOUGH_ARGUMENTS = -4033, - TOO_MANY_ARGUMENTS = -4034, - INVALID_SYMBOL = -4035, - NO_PRECEDING_UNARY_OPERATOR = -4036, - InvalidOutputArrayType = -4037 - }; - - enum class WarningCode : EnumType - { - NONE = 0, - NUMERIC_VALUE_WARNING = -5010, - AMBIGUOUS_NAME_WARNING = -5011 - }; - - QString getInfixToken(); - - virtual CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& msg) = 0; - - bool isICalculatorArray(); - - bool isArray(); - - bool isNumber(); - - protected: - CalculatorItem(); - - void setInfixToken(const QString& token); - - private: - QString m_InfixToken = ""; - - public: - CalculatorItem(const CalculatorItem&) = delete; // Copy Constructor Not Implemented - CalculatorItem(CalculatorItem&&) = delete; // Move Constructor Not Implemented - CalculatorItem& operator=(const CalculatorItem&) = delete; // Copy Assignment Not Implemented - CalculatorItem& operator=(CalculatorItem&&) = delete; // Move Assignment Not Implemented +public: + using Self = CalculatorItem; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + virtual ~CalculatorItem(); + + using EnumType = int; + + enum class ErrorCode : EnumType + { + SUCCESS = 0, + INVALID_EQUATION = -4009, + INVALID_COMPONENT = -4010, + EMPTY_EQUATION = -4011, + EMPTY_CAL_ARRAY = -4012, + EMPTY_SEL_MATRIX = -4013, + LOST_ATTR_MATRIX = -4014, + INCORRECT_TUPLE_COUNT = -4015, + INCONSISTENT_TUPLES = -4016, + UNRECOGNIZED_ITEM = -4017, + MISMATCHED_PARENTHESES = -4018, + UNEXPECTED_OUTPUT = -4019, + COMPONENT_OUT_OF_RANGE = -4020, + INVALID_ARRAY_NAME = -4022, + INCONSISTENT_INDEXING = -4023, + INCONSISTENT_COMP_DIMS = -4024, + ATTRARRAY_ZEROTUPLES_WARNING = -4025, + ORPHANED_COMPONENT = -4026, + OPERATOR_NO_LEFT_VALUE = -4027, + OPERATOR_NO_RIGHT_VALUE = -4028, + OPERATOR_NO_OPENING_PAREN = -4029, + OPERATOR_NO_CLOSING_PAREN = -4030, + NO_NUMERIC_ARGUMENTS = -4031, + MISSING_ARGUMENTS = -4032, + NOT_ENOUGH_ARGUMENTS = -4033, + TOO_MANY_ARGUMENTS = -4034, + INVALID_SYMBOL = -4035, + NO_PRECEDING_UNARY_OPERATOR = -4036, + InvalidOutputArrayType = -4037, + AttributeMatrixInsertionError = -4038 + }; + + enum class WarningCode : EnumType + { + NONE = 0, + NUMERIC_VALUE_WARNING = -5010, + AMBIGUOUS_NAME_WARNING = -5011 + }; + + QString getInfixToken(); + + virtual CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& msg) = 0; + + bool isICalculatorArray(); + + bool isArray(); + + bool isNumber(); + +protected: + CalculatorItem(); + + void setInfixToken(const QString& token); + +private: + QString m_InfixToken = ""; + +public: + CalculatorItem(const CalculatorItem&) = delete; // Copy Constructor Not Implemented + CalculatorItem(CalculatorItem&&) = delete; // Move Constructor Not Implemented + CalculatorItem& operator=(const CalculatorItem&) = delete; // Copy Assignment Not Implemented + CalculatorItem& operator=(CalculatorItem&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/util/CalculatorOperator.cpp b/Source/SIMPLib/CoreFilters/util/CalculatorOperator.cpp index 84696a0706..aabddb7087 100644 --- a/Source/SIMPLib/CoreFilters/util/CalculatorOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/CalculatorOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CalculatorOperator.h" @@ -40,10 +40,7 @@ // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -CalculatorOperator::CalculatorOperator() -: m_Precedence(Unknown_Precedence) -{ -} +CalculatorOperator::CalculatorOperator() = default; // ----------------------------------------------------------------------------- // @@ -118,3 +115,9 @@ double CalculatorOperator::root(double base, double root) return pow(base, 1 / root); } + +// ----------------------------------------------------------------------------- +CalculatorOperator::Pointer CalculatorOperator::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} diff --git a/Source/SIMPLib/CoreFilters/util/CalculatorOperator.h b/Source/SIMPLib/CoreFilters/util/CalculatorOperator.h index 9758f4df37..71bb20d486 100644 --- a/Source/SIMPLib/CoreFilters/util/CalculatorOperator.h +++ b/Source/SIMPLib/CoreFilters/util/CalculatorOperator.h @@ -1,102 +1,108 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include -#include +#include + #include #include "SIMPLib/SIMPLib.h" #include "CalculatorArray.hpp" +#include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataArrays/IDataArray.h" #include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/Filtering/AbstractFilter.h" class SIMPLib_EXPORT CalculatorOperator : public CalculatorItem { - public: - enum OperatorType - { - Unary, - Binary - }; +public: + enum OperatorType + { + Unary, + Binary + }; - SIMPL_SHARED_POINTERS(CalculatorOperator) + using Self = CalculatorOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static double toDegrees(double radians); - static double toRadians(double degrees); + static double toDegrees(double radians); + static double toRadians(double degrees); - ~CalculatorOperator() override; + ~CalculatorOperator() override; - bool hasHigherPrecedence(CalculatorOperator::Pointer other); + bool hasHigherPrecedence(CalculatorOperator::Pointer other); - virtual void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) = 0; + virtual void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) = 0; - OperatorType getOperatorType(); + OperatorType getOperatorType(); - protected: - CalculatorOperator(); +protected: + CalculatorOperator(); - enum Precedence - { - Unknown_Precedence, - A_Precedence, - B_Precedence, - C_Precedence, - D_Precedence, - E_Precedence - }; + enum Precedence + { + Unknown_Precedence, + A_Precedence, + B_Precedence, + C_Precedence, + D_Precedence, + E_Precedence + }; - double root(double base, double root); + double root(double base, double root); - Precedence getPrecedence(); - void setPrecedence(Precedence precedence); + Precedence getPrecedence(); + void setPrecedence(Precedence precedence); - void setOperatorType(OperatorType type); + void setOperatorType(OperatorType type); - private: - Precedence m_Precedence; - OperatorType m_OperatorType; +private: + Precedence m_Precedence = {Unknown_Precedence}; + OperatorType m_OperatorType; - public: - CalculatorOperator(const CalculatorOperator&) = delete; // Copy Constructor Not Implemented - CalculatorOperator(CalculatorOperator&&) = delete; // Move Constructor Not Implemented - CalculatorOperator& operator=(const CalculatorOperator&) = delete; // Copy Assignment Not Implemented - CalculatorOperator& operator=(CalculatorOperator&&) = delete; // Move Assignment Not Implemented +public: + CalculatorOperator(const CalculatorOperator&) = delete; // Copy Constructor Not Implemented + CalculatorOperator(CalculatorOperator&&) = delete; // Move Constructor Not Implemented + CalculatorOperator& operator=(const CalculatorOperator&) = delete; // Copy Assignment Not Implemented + CalculatorOperator& operator=(CalculatorOperator&&) = delete; // Move Assignment Not Implemented }; #define CREATE_NEW_ARRAY_TWO_ARGUMENTS(filter, calculatedArrayPath, executionStack, func) \ @@ -110,11 +116,11 @@ class SIMPLib_EXPORT CalculatorOperator : public CalculatorItem DoubleArrayType::Pointer newArray; \ if(array1->getType() == ICalculatorArray::Array) \ { \ - newArray = DoubleArrayType::CreateArray(array1->getArray()->getNumberOfTuples(), array1->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName()); \ + newArray = DoubleArrayType::CreateArray(array1->getArray()->getNumberOfTuples(), array1->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName(), true); \ } \ else \ { \ - newArray = DoubleArrayType::CreateArray(array2->getArray()->getNumberOfTuples(), array2->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName()); \ + newArray = DoubleArrayType::CreateArray(array2->getArray()->getNumberOfTuples(), array2->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName(), true); \ } \ \ int numComps = newArray->getNumberOfComponents(); \ @@ -139,4 +145,3 @@ class SIMPLib_EXPORT CalculatorOperator : public CalculatorItem } \ return; \ } - diff --git a/Source/SIMPLib/CoreFilters/util/CalculatorSeparator.cpp b/Source/SIMPLib/CoreFilters/util/CalculatorSeparator.cpp index 80819db97e..f955aaa10c 100644 --- a/Source/SIMPLib/CoreFilters/util/CalculatorSeparator.cpp +++ b/Source/SIMPLib/CoreFilters/util/CalculatorSeparator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CalculatorSeparator.h" @@ -44,3 +44,9 @@ CalculatorSeparator::CalculatorSeparator() = default; // // ----------------------------------------------------------------------------- CalculatorSeparator::~CalculatorSeparator() = default; + +// ----------------------------------------------------------------------------- +CalculatorSeparator::Pointer CalculatorSeparator::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} diff --git a/Source/SIMPLib/CoreFilters/util/CalculatorSeparator.h b/Source/SIMPLib/CoreFilters/util/CalculatorSeparator.h index e115cc734c..cd944d3642 100644 --- a/Source/SIMPLib/CoreFilters/util/CalculatorSeparator.h +++ b/Source/SIMPLib/CoreFilters/util/CalculatorSeparator.h @@ -1,58 +1,66 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include "SIMPLib/SIMPLib.h" #include "CalculatorItem.h" class SIMPLib_EXPORT CalculatorSeparator : public CalculatorItem { - public: - SIMPL_SHARED_POINTERS(CalculatorSeparator) +public: + using Self = CalculatorSeparator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - ~CalculatorSeparator() override; + ~CalculatorSeparator() override; - protected: - CalculatorSeparator(); +protected: + CalculatorSeparator(); - public: - CalculatorSeparator(const CalculatorSeparator&) = delete; // Copy Constructor Not Implemented - CalculatorSeparator(CalculatorSeparator&&) = delete; // Move Constructor Not Implemented - CalculatorSeparator& operator=(const CalculatorSeparator&) = delete; // Copy Assignment Not Implemented - CalculatorSeparator& operator=(CalculatorSeparator&&) = delete; // Move Assignment Not Implemented -}; +public: + CalculatorSeparator(const CalculatorSeparator&) = delete; // Copy Constructor Not Implemented + CalculatorSeparator(CalculatorSeparator&&) = delete; // Move Constructor Not Implemented + CalculatorSeparator& operator=(const CalculatorSeparator&) = delete; // Copy Assignment Not Implemented + CalculatorSeparator& operator=(CalculatorSeparator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/CeilOperator.cpp b/Source/SIMPLib/CoreFilters/util/CeilOperator.cpp index 165ce5a51f..641033b4c6 100644 --- a/Source/SIMPLib/CoreFilters/util/CeilOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/CeilOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CeilOperator.h" @@ -60,5 +60,11 @@ CeilOperator::~CeilOperator() = default; // ----------------------------------------------------------------------------- void CeilOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) { - CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, ceil) + CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, ceil); +} + +// ----------------------------------------------------------------------------- +CeilOperator::Pointer CeilOperator::NullPointer() +{ + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/CeilOperator.h b/Source/SIMPLib/CoreFilters/util/CeilOperator.h index 676075478a..ee92608ca4 100644 --- a/Source/SIMPLib/CoreFilters/util/CeilOperator.h +++ b/Source/SIMPLib/CoreFilters/util/CeilOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT CeilOperator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(CeilOperator) +public: + using Self = CeilOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new CeilOperator()); - } + static Pointer New() + { + return Pointer(new CeilOperator()); + } - ~CeilOperator() override; + ~CeilOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - CeilOperator(); +protected: + CeilOperator(); - public: - CeilOperator(const CeilOperator&) = delete; // Copy Constructor Not Implemented - CeilOperator(CeilOperator&&) = delete; // Move Constructor Not Implemented - CeilOperator& operator=(const CeilOperator&) = delete; // Copy Assignment Not Implemented - CeilOperator& operator=(CeilOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + CeilOperator(const CeilOperator&) = delete; // Copy Constructor Not Implemented + CeilOperator(CeilOperator&&) = delete; // Move Constructor Not Implemented + CeilOperator& operator=(const CeilOperator&) = delete; // Copy Assignment Not Implemented + CeilOperator& operator=(CeilOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/CommaSeparator.cpp b/Source/SIMPLib/CoreFilters/util/CommaSeparator.cpp index 2218772060..1e2817bb27 100644 --- a/Source/SIMPLib/CoreFilters/util/CommaSeparator.cpp +++ b/Source/SIMPLib/CoreFilters/util/CommaSeparator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CommaSeparator.h" @@ -76,3 +76,9 @@ CalculatorItem::ErrorCode CommaSeparator::checkValidity(QVector(nullptr)); +} diff --git a/Source/SIMPLib/CoreFilters/util/CommaSeparator.h b/Source/SIMPLib/CoreFilters/util/CommaSeparator.h index 718196716c..010a52726e 100644 --- a/Source/SIMPLib/CoreFilters/util/CommaSeparator.h +++ b/Source/SIMPLib/CoreFilters/util/CommaSeparator.h @@ -1,65 +1,73 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include "SIMPLib/SIMPLib.h" #include "CalculatorSeparator.h" class SIMPLib_EXPORT CommaSeparator : public CalculatorSeparator { - public: - SIMPL_SHARED_POINTERS(CommaSeparator) +public: + using Self = CommaSeparator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new CommaSeparator()); - } + static Pointer New() + { + return Pointer(new CommaSeparator()); + } - ~CommaSeparator() override; + ~CommaSeparator() override; - CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& msg) override; + CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& msg) override; - protected: - CommaSeparator(); +protected: + CommaSeparator(); - public: - CommaSeparator(const CommaSeparator&) = delete; // Copy Constructor Not Implemented - CommaSeparator(CommaSeparator&&) = delete; // Move Constructor Not Implemented - CommaSeparator& operator=(const CommaSeparator&) = delete; // Copy Assignment Not Implemented - CommaSeparator& operator=(CommaSeparator&&) = delete; // Move Assignment Not Implemented -}; +public: + CommaSeparator(const CommaSeparator&) = delete; // Copy Constructor Not Implemented + CommaSeparator(CommaSeparator&&) = delete; // Move Constructor Not Implemented + CommaSeparator& operator=(const CommaSeparator&) = delete; // Copy Assignment Not Implemented + CommaSeparator& operator=(CommaSeparator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/CosOperator.cpp b/Source/SIMPLib/CoreFilters/util/CosOperator.cpp index 3ee233c24d..8aaf5063b5 100644 --- a/Source/SIMPLib/CoreFilters/util/CosOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/CosOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CosOperator.h" @@ -58,7 +58,11 @@ CosOperator::~CosOperator() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void CosOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) +void CosOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, + QStack& executionStack){CREATE_NEW_ARRAY_TRIG(filter, calculatedArrayPath, executionStack, cos)} + +// ----------------------------------------------------------------------------- +CosOperator::Pointer CosOperator::NullPointer() { - CREATE_NEW_ARRAY_TRIG(filter, calculatedArrayPath, executionStack, cos) + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/CosOperator.h b/Source/SIMPLib/CoreFilters/util/CosOperator.h index f06bfd5e15..cfbbad63ac 100644 --- a/Source/SIMPLib/CoreFilters/util/CosOperator.h +++ b/Source/SIMPLib/CoreFilters/util/CosOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT CosOperator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(CosOperator) +public: + using Self = CosOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new CosOperator()); - } + static Pointer New() + { + return Pointer(new CosOperator()); + } - ~CosOperator() override; + ~CosOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - CosOperator(); +protected: + CosOperator(); - public: - CosOperator(const CosOperator&) = delete; // Copy Constructor Not Implemented - CosOperator(CosOperator&&) = delete; // Move Constructor Not Implemented - CosOperator& operator=(const CosOperator&) = delete; // Copy Assignment Not Implemented - CosOperator& operator=(CosOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + CosOperator(const CosOperator&) = delete; // Copy Constructor Not Implemented + CosOperator(CosOperator&&) = delete; // Move Constructor Not Implemented + CosOperator& operator=(const CosOperator&) = delete; // Copy Assignment Not Implemented + CosOperator& operator=(CosOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/DivisionOperator.cpp b/Source/SIMPLib/CoreFilters/util/DivisionOperator.cpp index 15af2a8bca..24eba8690e 100644 --- a/Source/SIMPLib/CoreFilters/util/DivisionOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/DivisionOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DivisionOperator.h" @@ -61,7 +61,11 @@ DivisionOperator::~DivisionOperator() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DivisionOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) +void DivisionOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, + QStack& executionStack){CREATE_NEW_ARRAY_STANDARD_BINARY(filter, calculatedArrayPath, executionStack, /)} + +// ----------------------------------------------------------------------------- +DivisionOperator::Pointer DivisionOperator::NullPointer() { - CREATE_NEW_ARRAY_STANDARD_BINARY(filter, calculatedArrayPath, executionStack, /) + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/DivisionOperator.h b/Source/SIMPLib/CoreFilters/util/DivisionOperator.h index 105be7898d..21d5d28daa 100644 --- a/Source/SIMPLib/CoreFilters/util/DivisionOperator.h +++ b/Source/SIMPLib/CoreFilters/util/DivisionOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -44,25 +45,31 @@ class SIMPLib_EXPORT DivisionOperator : public BinaryOperator { - public: - SIMPL_SHARED_POINTERS(DivisionOperator) +public: + using Self = DivisionOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new DivisionOperator()); - } + static Pointer New() + { + return Pointer(new DivisionOperator()); + } - ~DivisionOperator() override; + ~DivisionOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - DivisionOperator(); +protected: + DivisionOperator(); - public: - DivisionOperator(const DivisionOperator&) = delete; // Copy Constructor Not Implemented - DivisionOperator(DivisionOperator&&) = delete; // Move Constructor Not Implemented - DivisionOperator& operator=(const DivisionOperator&) = delete; // Copy Assignment Not Implemented - DivisionOperator& operator=(DivisionOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + DivisionOperator(const DivisionOperator&) = delete; // Copy Constructor Not Implemented + DivisionOperator(DivisionOperator&&) = delete; // Move Constructor Not Implemented + DivisionOperator& operator=(const DivisionOperator&) = delete; // Copy Assignment Not Implemented + DivisionOperator& operator=(DivisionOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/ExpOperator.cpp b/Source/SIMPLib/CoreFilters/util/ExpOperator.cpp index ab774cdb0e..1b1c6c0bac 100644 --- a/Source/SIMPLib/CoreFilters/util/ExpOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/ExpOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ExpOperator.h" @@ -60,5 +60,11 @@ ExpOperator::~ExpOperator() = default; // ----------------------------------------------------------------------------- void ExpOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) { - CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, exp) + CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, exp); +} + +// ----------------------------------------------------------------------------- +ExpOperator::Pointer ExpOperator::NullPointer() +{ + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/ExpOperator.h b/Source/SIMPLib/CoreFilters/util/ExpOperator.h index a30e60671a..1bcaade7d8 100644 --- a/Source/SIMPLib/CoreFilters/util/ExpOperator.h +++ b/Source/SIMPLib/CoreFilters/util/ExpOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT ExpOperator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(ExpOperator) +public: + using Self = ExpOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new ExpOperator()); - } + static Pointer New() + { + return Pointer(new ExpOperator()); + } - ~ExpOperator() override; + ~ExpOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - ExpOperator(); +protected: + ExpOperator(); - public: - ExpOperator(const ExpOperator&) = delete; // Copy Constructor Not Implemented - ExpOperator(ExpOperator&&) = delete; // Move Constructor Not Implemented - ExpOperator& operator=(const ExpOperator&) = delete; // Copy Assignment Not Implemented - ExpOperator& operator=(ExpOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + ExpOperator(const ExpOperator&) = delete; // Copy Constructor Not Implemented + ExpOperator(ExpOperator&&) = delete; // Move Constructor Not Implemented + ExpOperator& operator=(const ExpOperator&) = delete; // Copy Assignment Not Implemented + ExpOperator& operator=(ExpOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/FloorOperator.cpp b/Source/SIMPLib/CoreFilters/util/FloorOperator.cpp index e5f153d277..d90d73d439 100644 --- a/Source/SIMPLib/CoreFilters/util/FloorOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/FloorOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "FloorOperator.h" @@ -58,7 +58,11 @@ FloorOperator::~FloorOperator() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FloorOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) +void FloorOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, + QStack& executionStack){CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, floor)} + +// ----------------------------------------------------------------------------- +FloorOperator::Pointer FloorOperator::NullPointer() { - CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, floor) + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/FloorOperator.h b/Source/SIMPLib/CoreFilters/util/FloorOperator.h index baeea72311..56c320baa5 100644 --- a/Source/SIMPLib/CoreFilters/util/FloorOperator.h +++ b/Source/SIMPLib/CoreFilters/util/FloorOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT FloorOperator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(FloorOperator) +public: + using Self = FloorOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new FloorOperator()); - } + static Pointer New() + { + return Pointer(new FloorOperator()); + } - ~FloorOperator() override; + ~FloorOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - FloorOperator(); +protected: + FloorOperator(); - public: - FloorOperator(const FloorOperator&) = delete; // Copy Constructor Not Implemented - FloorOperator(FloorOperator&&) = delete; // Move Constructor Not Implemented - FloorOperator& operator=(const FloorOperator&) = delete; // Copy Assignment Not Implemented - FloorOperator& operator=(FloorOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + FloorOperator(const FloorOperator&) = delete; // Copy Constructor Not Implemented + FloorOperator(FloorOperator&&) = delete; // Move Constructor Not Implemented + FloorOperator& operator=(const FloorOperator&) = delete; // Copy Assignment Not Implemented + FloorOperator& operator=(FloorOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/ICalculatorArray.cpp b/Source/SIMPLib/CoreFilters/util/ICalculatorArray.cpp index d20b759f98..76253b2113 100644 --- a/Source/SIMPLib/CoreFilters/util/ICalculatorArray.cpp +++ b/Source/SIMPLib/CoreFilters/util/ICalculatorArray.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ICalculatorArray.h" @@ -44,3 +44,9 @@ ICalculatorArray::ICalculatorArray() = default; // // ----------------------------------------------------------------------------- ICalculatorArray::~ICalculatorArray() = default; + +// ----------------------------------------------------------------------------- +ICalculatorArray::Pointer ICalculatorArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} diff --git a/Source/SIMPLib/CoreFilters/util/ICalculatorArray.h b/Source/SIMPLib/CoreFilters/util/ICalculatorArray.h index e01e52e95f..f2f1480f11 100644 --- a/Source/SIMPLib/CoreFilters/util/ICalculatorArray.h +++ b/Source/SIMPLib/CoreFilters/util/ICalculatorArray.h @@ -1,75 +1,84 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include -#include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" + +class IDataArray; +using IDataArrayShPtrType = std::shared_ptr; #include "CalculatorItem.h" class SIMPLib_EXPORT ICalculatorArray : public CalculatorItem { - public: - enum ValueType - { - Number, - Array, - Unknown - }; +public: + enum ValueType + { + Number, + Array, + Unknown + }; - SIMPL_SHARED_POINTERS(ICalculatorArray) + using Self = ICalculatorArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - ~ICalculatorArray() override; + ~ICalculatorArray() override; - virtual IDataArray::Pointer getArray() = 0; - virtual double getValue(int i) = 0; - virtual void setValue(int i, double value) = 0; - virtual ValueType getType() = 0; + virtual IDataArrayShPtrType getArray() = 0; + virtual double getValue(int i) = 0; + virtual void setValue(int i, double value) = 0; + virtual ValueType getType() = 0; - virtual DoubleArrayType::Pointer reduceToOneComponent(int c, bool allocate = true) = 0; + virtual DoubleArrayType::Pointer reduceToOneComponent(int c, bool allocate = true) = 0; - protected: - ICalculatorArray(); +protected: + ICalculatorArray(); - public: - ICalculatorArray(const ICalculatorArray&) = delete; // Copy Constructor Not Implemented - ICalculatorArray(ICalculatorArray&&) = delete; // Move Constructor Not Implemented - ICalculatorArray& operator=(const ICalculatorArray&) = delete; // Copy Assignment Not Implemented - ICalculatorArray& operator=(ICalculatorArray&&) = delete; // Move Assignment Not Implemented -}; +public: + ICalculatorArray(const ICalculatorArray&) = delete; // Copy Constructor Not Implemented + ICalculatorArray(ICalculatorArray&&) = delete; // Move Constructor Not Implemented + ICalculatorArray& operator=(const ICalculatorArray&) = delete; // Copy Assignment Not Implemented + ICalculatorArray& operator=(ICalculatorArray&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/LeftParenthesisItem.cpp b/Source/SIMPLib/CoreFilters/util/LeftParenthesisItem.cpp index 6e41eba8f8..f29f32bdb8 100644 --- a/Source/SIMPLib/CoreFilters/util/LeftParenthesisItem.cpp +++ b/Source/SIMPLib/CoreFilters/util/LeftParenthesisItem.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "LeftParenthesisItem.h" @@ -79,3 +79,9 @@ CalculatorItem::ErrorCode LeftParenthesisItem::checkValidity(QVector(nullptr)); +} diff --git a/Source/SIMPLib/CoreFilters/util/LeftParenthesisItem.h b/Source/SIMPLib/CoreFilters/util/LeftParenthesisItem.h index e68b6726ab..b151f46c58 100644 --- a/Source/SIMPLib/CoreFilters/util/LeftParenthesisItem.h +++ b/Source/SIMPLib/CoreFilters/util/LeftParenthesisItem.h @@ -1,65 +1,82 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + +#include + #include "SIMPLib/SIMPLib.h" #include "CalculatorItem.h" class SIMPLib_EXPORT LeftParenthesisItem : public CalculatorItem { - public: - SIMPL_SHARED_POINTERS(LeftParenthesisItem) +public: + using Self = LeftParenthesisItem; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new LeftParenthesisItem()); - } + static Pointer New() + { + return Pointer(new LeftParenthesisItem()); + } - ~LeftParenthesisItem() override; + ~LeftParenthesisItem() override; - CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& msg) override; + /** + * @brief checkValidity + * @param infixVector + * @param currentIndex + * @param msg + * @return + */ + CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& msg) override; - protected: - LeftParenthesisItem(); +protected: + LeftParenthesisItem(); - public: - LeftParenthesisItem(const LeftParenthesisItem&) = delete; // Copy Constructor Not Implemented - LeftParenthesisItem(LeftParenthesisItem&&) = delete; // Move Constructor Not Implemented - LeftParenthesisItem& operator=(const LeftParenthesisItem&) = delete; // Copy Assignment Not Implemented - LeftParenthesisItem& operator=(LeftParenthesisItem&&) = delete; // Move Assignment Not Implemented -}; +public: + LeftParenthesisItem(const LeftParenthesisItem&) = delete; // Copy Constructor Not Implemented + LeftParenthesisItem(LeftParenthesisItem&&) = delete; // Move Constructor Not Implemented + LeftParenthesisItem& operator=(const LeftParenthesisItem&) = delete; // Copy Assignment Not Implemented + LeftParenthesisItem& operator=(LeftParenthesisItem&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/LnOperator.cpp b/Source/SIMPLib/CoreFilters/util/LnOperator.cpp index 05b19ab172..c5b91e2dc1 100644 --- a/Source/SIMPLib/CoreFilters/util/LnOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/LnOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "LnOperator.h" @@ -60,5 +60,11 @@ LnOperator::~LnOperator() = default; // ----------------------------------------------------------------------------- void LnOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) { - CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, log) + CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, log); +} + +// ----------------------------------------------------------------------------- +LnOperator::Pointer LnOperator::NullPointer() +{ + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/LnOperator.h b/Source/SIMPLib/CoreFilters/util/LnOperator.h index 2de98a2dd5..288b75936e 100644 --- a/Source/SIMPLib/CoreFilters/util/LnOperator.h +++ b/Source/SIMPLib/CoreFilters/util/LnOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT LnOperator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(LnOperator) +public: + using Self = LnOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new LnOperator()); - } + static Pointer New() + { + return Pointer(new LnOperator()); + } - ~LnOperator() override; + ~LnOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - LnOperator(); +protected: + LnOperator(); - public: - LnOperator(const LnOperator&) = delete; // Copy Constructor Not Implemented - LnOperator(LnOperator&&) = delete; // Move Constructor Not Implemented - LnOperator& operator=(const LnOperator&) = delete; // Copy Assignment Not Implemented - LnOperator& operator=(LnOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + LnOperator(const LnOperator&) = delete; // Copy Constructor Not Implemented + LnOperator(LnOperator&&) = delete; // Move Constructor Not Implemented + LnOperator& operator=(const LnOperator&) = delete; // Copy Assignment Not Implemented + LnOperator& operator=(LnOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/Log10Operator.cpp b/Source/SIMPLib/CoreFilters/util/Log10Operator.cpp index ad5eca0f00..2585b7392c 100644 --- a/Source/SIMPLib/CoreFilters/util/Log10Operator.cpp +++ b/Source/SIMPLib/CoreFilters/util/Log10Operator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "Log10Operator.h" @@ -60,5 +60,11 @@ Log10Operator::~Log10Operator() = default; // ----------------------------------------------------------------------------- void Log10Operator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) { - CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, log10) + CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, log10); +} + +// ----------------------------------------------------------------------------- +Log10Operator::Pointer Log10Operator::NullPointer() +{ + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/Log10Operator.h b/Source/SIMPLib/CoreFilters/util/Log10Operator.h index ecbf864672..6cd7ed00a9 100644 --- a/Source/SIMPLib/CoreFilters/util/Log10Operator.h +++ b/Source/SIMPLib/CoreFilters/util/Log10Operator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT Log10Operator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(Log10Operator) +public: + using Self = Log10Operator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new Log10Operator()); - } + static Pointer New() + { + return Pointer(new Log10Operator()); + } - ~Log10Operator() override; + ~Log10Operator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - Log10Operator(); +protected: + Log10Operator(); - public: - Log10Operator(const Log10Operator&) = delete; // Copy Constructor Not Implemented - Log10Operator(Log10Operator&&) = delete; // Move Constructor Not Implemented - Log10Operator& operator=(const Log10Operator&) = delete; // Copy Assignment Not Implemented - Log10Operator& operator=(Log10Operator&&) = delete; // Move Assignment Not Implemented -}; +public: + Log10Operator(const Log10Operator&) = delete; // Copy Constructor Not Implemented + Log10Operator(Log10Operator&&) = delete; // Move Constructor Not Implemented + Log10Operator& operator=(const Log10Operator&) = delete; // Copy Assignment Not Implemented + Log10Operator& operator=(Log10Operator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/LogOperator.cpp b/Source/SIMPLib/CoreFilters/util/LogOperator.cpp index fe81fa42c3..52c3d7afe7 100644 --- a/Source/SIMPLib/CoreFilters/util/LogOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/LogOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "LogOperator.h" @@ -70,3 +70,9 @@ double LogOperator::log_arbitrary_base(double base, double value) { return log(value) / log(base); } + +// ----------------------------------------------------------------------------- +LogOperator::Pointer LogOperator::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} diff --git a/Source/SIMPLib/CoreFilters/util/LogOperator.h b/Source/SIMPLib/CoreFilters/util/LogOperator.h index 5ff42c72e2..678835e060 100644 --- a/Source/SIMPLib/CoreFilters/util/LogOperator.h +++ b/Source/SIMPLib/CoreFilters/util/LogOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,28 +47,32 @@ class CalculatorNumber; class SIMPLib_EXPORT LogOperator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(LogOperator) +public: + using Self = LogOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new LogOperator()); - } + static Pointer New() + { + return Pointer(new LogOperator()); + } - ~LogOperator() override; + ~LogOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - LogOperator(); +protected: + LogOperator(); - private: - double log_arbitrary_base(double base, double value); +private: + double log_arbitrary_base(double base, double value); - public: - LogOperator(const LogOperator&) = delete; // Copy Constructor Not Implemented - LogOperator(LogOperator&&) = delete; // Move Constructor Not Implemented - LogOperator& operator=(const LogOperator&) = delete; // Copy Assignment Not Implemented - LogOperator& operator=(LogOperator&&) = delete; // Move Assignment Not Implemented +public: + LogOperator(const LogOperator&) = delete; // Copy Constructor Not Implemented + LogOperator(LogOperator&&) = delete; // Move Constructor Not Implemented + LogOperator& operator=(const LogOperator&) = delete; // Copy Assignment Not Implemented + LogOperator& operator=(LogOperator&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/CoreFilters/util/MultiplicationOperator.cpp b/Source/SIMPLib/CoreFilters/util/MultiplicationOperator.cpp index 261efcb4cc..6fbe70c7a6 100644 --- a/Source/SIMPLib/CoreFilters/util/MultiplicationOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/MultiplicationOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "MultiplicationOperator.h" @@ -58,7 +58,11 @@ MultiplicationOperator::~MultiplicationOperator() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void MultiplicationOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) +void MultiplicationOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, + QStack& executionStack){CREATE_NEW_ARRAY_STANDARD_BINARY(filter, calculatedArrayPath, executionStack, *)} + +// ----------------------------------------------------------------------------- +MultiplicationOperator::Pointer MultiplicationOperator::NullPointer() { - CREATE_NEW_ARRAY_STANDARD_BINARY(filter, calculatedArrayPath, executionStack, *) + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/MultiplicationOperator.h b/Source/SIMPLib/CoreFilters/util/MultiplicationOperator.h index 05d6082c07..455fab3a5e 100644 --- a/Source/SIMPLib/CoreFilters/util/MultiplicationOperator.h +++ b/Source/SIMPLib/CoreFilters/util/MultiplicationOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -44,25 +45,31 @@ class SIMPLib_EXPORT MultiplicationOperator : public BinaryOperator { - public: - SIMPL_SHARED_POINTERS(MultiplicationOperator) +public: + using Self = MultiplicationOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new MultiplicationOperator()); - } + static Pointer New() + { + return Pointer(new MultiplicationOperator()); + } - ~MultiplicationOperator() override; + ~MultiplicationOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - MultiplicationOperator(); +protected: + MultiplicationOperator(); - public: - MultiplicationOperator(const MultiplicationOperator&) = delete; // Copy Constructor Not Implemented - MultiplicationOperator(MultiplicationOperator&&) = delete; // Move Constructor Not Implemented - MultiplicationOperator& operator=(const MultiplicationOperator&) = delete; // Copy Assignment Not Implemented - MultiplicationOperator& operator=(MultiplicationOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + MultiplicationOperator(const MultiplicationOperator&) = delete; // Copy Constructor Not Implemented + MultiplicationOperator(MultiplicationOperator&&) = delete; // Move Constructor Not Implemented + MultiplicationOperator& operator=(const MultiplicationOperator&) = delete; // Copy Assignment Not Implemented + MultiplicationOperator& operator=(MultiplicationOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/NegativeOperator.cpp b/Source/SIMPLib/CoreFilters/util/NegativeOperator.cpp index 575ae79a8f..99fc71cc7a 100644 --- a/Source/SIMPLib/CoreFilters/util/NegativeOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/NegativeOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "NegativeOperator.h" @@ -66,7 +66,8 @@ void NegativeOperator::calculate(AbstractFilter* filter, DataArrayPath calculate { ICalculatorArray::Pointer arrayPtr = executionStack.pop(); - DoubleArrayType::Pointer newArray = DoubleArrayType::CreateArray(arrayPtr->getArray()->getNumberOfTuples(), arrayPtr->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName()); + DoubleArrayType::Pointer newArray = + DoubleArrayType::CreateArray(arrayPtr->getArray()->getNumberOfTuples(), arrayPtr->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName(), true); int numComps = newArray->getNumberOfComponents(); for(int i = 0; i < newArray->getNumberOfTuples(); i++) @@ -107,3 +108,9 @@ CalculatorItem::ErrorCode NegativeOperator::checkValidity(QVector(nullptr)); +} diff --git a/Source/SIMPLib/CoreFilters/util/NegativeOperator.h b/Source/SIMPLib/CoreFilters/util/NegativeOperator.h index 515e7b6ed4..ef49a69522 100644 --- a/Source/SIMPLib/CoreFilters/util/NegativeOperator.h +++ b/Source/SIMPLib/CoreFilters/util/NegativeOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -44,27 +45,33 @@ class SIMPLib_EXPORT NegativeOperator : public CalculatorOperator { - public: - SIMPL_SHARED_POINTERS(NegativeOperator) +public: + using Self = NegativeOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new NegativeOperator()); - } + static Pointer New() + { + return Pointer(new NegativeOperator()); + } - ~NegativeOperator() override; + ~NegativeOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& errMsg) final; + CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& errMsg) final; - protected: - NegativeOperator(); +protected: + NegativeOperator(); - public: - NegativeOperator(const NegativeOperator&) = delete; // Copy Constructor Not Implemented - NegativeOperator(NegativeOperator&&) = delete; // Move Constructor Not Implemented - NegativeOperator& operator=(const NegativeOperator&) = delete; // Copy Assignment Not Implemented - NegativeOperator& operator=(NegativeOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + NegativeOperator(const NegativeOperator&) = delete; // Copy Constructor Not Implemented + NegativeOperator(NegativeOperator&&) = delete; // Move Constructor Not Implemented + NegativeOperator& operator=(const NegativeOperator&) = delete; // Copy Assignment Not Implemented + NegativeOperator& operator=(NegativeOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/ParserFunctors.hpp b/Source/SIMPLib/CoreFilters/util/ParserFunctors.hpp index b4fab9972b..696ebc4489 100644 --- a/Source/SIMPLib/CoreFilters/util/ParserFunctors.hpp +++ b/Source/SIMPLib/CoreFilters/util/ParserFunctors.hpp @@ -39,7 +39,7 @@ namespace ParserErrorMessages { const QString ValueOutOfRange = "Value is out of range for the specified data type."; const QString CouldNotConvert = "Value could not be converted to the specified data type."; -} +} // namespace ParserErrorMessages // ----------------------------------------------------------------------------- // @@ -51,7 +51,7 @@ class ParserFunctor struct ErrorObject { - bool ok; + bool ok = false; QString errorMessage; }; }; @@ -429,4 +429,3 @@ class StringFunctor : public ParserFunctor return token; } }; - diff --git a/Source/SIMPLib/CoreFilters/util/PowOperator.cpp b/Source/SIMPLib/CoreFilters/util/PowOperator.cpp index 7f8c71d0bc..1c99f870a2 100644 --- a/Source/SIMPLib/CoreFilters/util/PowOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/PowOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "PowOperator.h" @@ -58,7 +58,11 @@ PowOperator::~PowOperator() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void PowOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) +void PowOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, + QStack& executionStack){CREATE_NEW_ARRAY_TWO_ARGUMENTS(filter, calculatedArrayPath, executionStack, pow)} + +// ----------------------------------------------------------------------------- +PowOperator::Pointer PowOperator::NullPointer() { - CREATE_NEW_ARRAY_TWO_ARGUMENTS(filter, calculatedArrayPath, executionStack, pow) + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/PowOperator.h b/Source/SIMPLib/CoreFilters/util/PowOperator.h index 5b0731b4b9..c2885472cb 100644 --- a/Source/SIMPLib/CoreFilters/util/PowOperator.h +++ b/Source/SIMPLib/CoreFilters/util/PowOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT PowOperator : public BinaryOperator { - public: - SIMPL_SHARED_POINTERS(PowOperator) +public: + using Self = PowOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new PowOperator()); - } + static Pointer New() + { + return Pointer(new PowOperator()); + } - ~PowOperator() override; + ~PowOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - PowOperator(); +protected: + PowOperator(); - public: - PowOperator(const PowOperator&) = delete; // Copy Constructor Not Implemented - PowOperator(PowOperator&&) = delete; // Move Constructor Not Implemented - PowOperator& operator=(const PowOperator&) = delete; // Copy Assignment Not Implemented - PowOperator& operator=(PowOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + PowOperator(const PowOperator&) = delete; // Copy Constructor Not Implemented + PowOperator(PowOperator&&) = delete; // Move Constructor Not Implemented + PowOperator& operator=(const PowOperator&) = delete; // Copy Assignment Not Implemented + PowOperator& operator=(PowOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/RightParenthesisItem.cpp b/Source/SIMPLib/CoreFilters/util/RightParenthesisItem.cpp index 9382f662ed..a9b0195441 100644 --- a/Source/SIMPLib/CoreFilters/util/RightParenthesisItem.cpp +++ b/Source/SIMPLib/CoreFilters/util/RightParenthesisItem.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "RightParenthesisItem.h" @@ -79,3 +79,9 @@ CalculatorItem::ErrorCode RightParenthesisItem::checkValidity(QVector(nullptr)); +} diff --git a/Source/SIMPLib/CoreFilters/util/RightParenthesisItem.h b/Source/SIMPLib/CoreFilters/util/RightParenthesisItem.h index 596c9fce6d..303e9e49cf 100644 --- a/Source/SIMPLib/CoreFilters/util/RightParenthesisItem.h +++ b/Source/SIMPLib/CoreFilters/util/RightParenthesisItem.h @@ -1,65 +1,82 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + +#include + #include "SIMPLib/SIMPLib.h" #include "CalculatorItem.h" class SIMPLib_EXPORT RightParenthesisItem : public CalculatorItem { - public: - SIMPL_SHARED_POINTERS(RightParenthesisItem) +public: + using Self = RightParenthesisItem; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new RightParenthesisItem()); - } + static Pointer New() + { + return Pointer(new RightParenthesisItem()); + } - ~RightParenthesisItem() override; + ~RightParenthesisItem() override; - CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& msg) override; + /** + * @brief checkValidity + * @param infixVector + * @param currentIndex + * @param msg + * @return + */ + CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& msg) override; - protected: - RightParenthesisItem(); +protected: + RightParenthesisItem(); - public: - RightParenthesisItem(const RightParenthesisItem&) = delete; // Copy Constructor Not Implemented - RightParenthesisItem(RightParenthesisItem&&) = delete; // Move Constructor Not Implemented - RightParenthesisItem& operator=(const RightParenthesisItem&) = delete; // Copy Assignment Not Implemented - RightParenthesisItem& operator=(RightParenthesisItem&&) = delete; // Move Assignment Not Implemented -}; +public: + RightParenthesisItem(const RightParenthesisItem&) = delete; // Copy Constructor Not Implemented + RightParenthesisItem(RightParenthesisItem&&) = delete; // Move Constructor Not Implemented + RightParenthesisItem& operator=(const RightParenthesisItem&) = delete; // Copy Assignment Not Implemented + RightParenthesisItem& operator=(RightParenthesisItem&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/RootOperator.cpp b/Source/SIMPLib/CoreFilters/util/RootOperator.cpp index a3fa906541..9c1b84dd0c 100644 --- a/Source/SIMPLib/CoreFilters/util/RootOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/RootOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "RootOperator.h" @@ -58,7 +58,11 @@ RootOperator::~RootOperator() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void RootOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) +void RootOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, + QStack& executionStack){CREATE_NEW_ARRAY_TWO_ARGUMENTS(filter, calculatedArrayPath, executionStack, root)} + +// ----------------------------------------------------------------------------- +RootOperator::Pointer RootOperator::NullPointer() { - CREATE_NEW_ARRAY_TWO_ARGUMENTS(filter, calculatedArrayPath, executionStack, root) + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/RootOperator.h b/Source/SIMPLib/CoreFilters/util/RootOperator.h index 8cc350a9b8..7c28a75016 100644 --- a/Source/SIMPLib/CoreFilters/util/RootOperator.h +++ b/Source/SIMPLib/CoreFilters/util/RootOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT RootOperator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(RootOperator) +public: + using Self = RootOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new RootOperator()); - } + static Pointer New() + { + return Pointer(new RootOperator()); + } - ~RootOperator() override; + ~RootOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - RootOperator(); +protected: + RootOperator(); - public: - RootOperator(const RootOperator&) = delete; // Copy Constructor Not Implemented - RootOperator(RootOperator&&) = delete; // Move Constructor Not Implemented - RootOperator& operator=(const RootOperator&) = delete; // Copy Assignment Not Implemented - RootOperator& operator=(RootOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + RootOperator(const RootOperator&) = delete; // Copy Constructor Not Implemented + RootOperator(RootOperator&&) = delete; // Move Constructor Not Implemented + RootOperator& operator=(const RootOperator&) = delete; // Copy Assignment Not Implemented + RootOperator& operator=(RootOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/SinOperator.cpp b/Source/SIMPLib/CoreFilters/util/SinOperator.cpp index 9880a5be68..dba5da2264 100644 --- a/Source/SIMPLib/CoreFilters/util/SinOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/SinOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "SinOperator.h" @@ -58,7 +58,11 @@ SinOperator::~SinOperator() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void SinOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) +void SinOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, + QStack& executionStack){CREATE_NEW_ARRAY_TRIG(filter, calculatedArrayPath, executionStack, sin)} + +// ----------------------------------------------------------------------------- +SinOperator::Pointer SinOperator::NullPointer() { - CREATE_NEW_ARRAY_TRIG(filter, calculatedArrayPath, executionStack, sin) + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/SinOperator.h b/Source/SIMPLib/CoreFilters/util/SinOperator.h index 438a646d2f..76e71351d4 100644 --- a/Source/SIMPLib/CoreFilters/util/SinOperator.h +++ b/Source/SIMPLib/CoreFilters/util/SinOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT SinOperator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(SinOperator) +public: + using Self = SinOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new SinOperator()); - } + static Pointer New() + { + return Pointer(new SinOperator()); + } - ~SinOperator() override; + ~SinOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - SinOperator(); +protected: + SinOperator(); - public: - SinOperator(const SinOperator&) = delete; // Copy Constructor Not Implemented - SinOperator(SinOperator&&) = delete; // Move Constructor Not Implemented - SinOperator& operator=(const SinOperator&) = delete; // Copy Assignment Not Implemented - SinOperator& operator=(SinOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + SinOperator(const SinOperator&) = delete; // Copy Constructor Not Implemented + SinOperator(SinOperator&&) = delete; // Move Constructor Not Implemented + SinOperator& operator=(const SinOperator&) = delete; // Copy Assignment Not Implemented + SinOperator& operator=(SinOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/SqrtOperator.cpp b/Source/SIMPLib/CoreFilters/util/SqrtOperator.cpp index d4c06db11e..7e129ca36f 100644 --- a/Source/SIMPLib/CoreFilters/util/SqrtOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/SqrtOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "SqrtOperator.h" @@ -60,5 +60,11 @@ SqrtOperator::~SqrtOperator() = default; // ----------------------------------------------------------------------------- void SqrtOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) { - CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, sqrt) + CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, sqrt); +} + +// ----------------------------------------------------------------------------- +SqrtOperator::Pointer SqrtOperator::NullPointer() +{ + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/SqrtOperator.h b/Source/SIMPLib/CoreFilters/util/SqrtOperator.h index a026787d05..5da78a1a1b 100644 --- a/Source/SIMPLib/CoreFilters/util/SqrtOperator.h +++ b/Source/SIMPLib/CoreFilters/util/SqrtOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT SqrtOperator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(SqrtOperator) +public: + using Self = SqrtOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new SqrtOperator()); - } + static Pointer New() + { + return Pointer(new SqrtOperator()); + } - ~SqrtOperator() override; + ~SqrtOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - SqrtOperator(); +protected: + SqrtOperator(); - public: - SqrtOperator(const SqrtOperator&) = delete; // Copy Constructor Not Implemented - SqrtOperator(SqrtOperator&&) = delete; // Move Constructor Not Implemented - SqrtOperator& operator=(const SqrtOperator&) = delete; // Copy Assignment Not Implemented - SqrtOperator& operator=(SqrtOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + SqrtOperator(const SqrtOperator&) = delete; // Copy Constructor Not Implemented + SqrtOperator(SqrtOperator&&) = delete; // Move Constructor Not Implemented + SqrtOperator& operator=(const SqrtOperator&) = delete; // Copy Assignment Not Implemented + SqrtOperator& operator=(SqrtOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/SubtractionOperator.cpp b/Source/SIMPLib/CoreFilters/util/SubtractionOperator.cpp index 54b13f8d37..b7890510c8 100644 --- a/Source/SIMPLib/CoreFilters/util/SubtractionOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/SubtractionOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "SubtractionOperator.h" @@ -58,7 +58,11 @@ SubtractionOperator::~SubtractionOperator() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void SubtractionOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) +void SubtractionOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, + QStack& executionStack){CREATE_NEW_ARRAY_STANDARD_BINARY(filter, calculatedArrayPath, executionStack, -)} + +// ----------------------------------------------------------------------------- +SubtractionOperator::Pointer SubtractionOperator::NullPointer() { - CREATE_NEW_ARRAY_STANDARD_BINARY(filter, calculatedArrayPath, executionStack, -) + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/SubtractionOperator.h b/Source/SIMPLib/CoreFilters/util/SubtractionOperator.h index 207104fd23..a2b6c49084 100644 --- a/Source/SIMPLib/CoreFilters/util/SubtractionOperator.h +++ b/Source/SIMPLib/CoreFilters/util/SubtractionOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -44,25 +45,31 @@ class SIMPLib_EXPORT SubtractionOperator : public BinaryOperator { - public: - SIMPL_SHARED_POINTERS(SubtractionOperator) +public: + using Self = SubtractionOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new SubtractionOperator()); - } + static Pointer New() + { + return Pointer(new SubtractionOperator()); + } - ~SubtractionOperator() override; + ~SubtractionOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - SubtractionOperator(); +protected: + SubtractionOperator(); - public: - SubtractionOperator(const SubtractionOperator&) = delete; // Copy Constructor Not Implemented - SubtractionOperator(SubtractionOperator&&) = delete; // Move Constructor Not Implemented - SubtractionOperator& operator=(const SubtractionOperator&) = delete; // Copy Assignment Not Implemented - SubtractionOperator& operator=(SubtractionOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + SubtractionOperator(const SubtractionOperator&) = delete; // Copy Constructor Not Implemented + SubtractionOperator(SubtractionOperator&&) = delete; // Move Constructor Not Implemented + SubtractionOperator& operator=(const SubtractionOperator&) = delete; // Copy Assignment Not Implemented + SubtractionOperator& operator=(SubtractionOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/TanOperator.cpp b/Source/SIMPLib/CoreFilters/util/TanOperator.cpp index c4324480aa..cccae1bacf 100644 --- a/Source/SIMPLib/CoreFilters/util/TanOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/TanOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "TanOperator.h" @@ -58,7 +58,11 @@ TanOperator::~TanOperator() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void TanOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) +void TanOperator::calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, + QStack& executionStack){CREATE_NEW_ARRAY_TRIG(filter, calculatedArrayPath, executionStack, tan)} + +// ----------------------------------------------------------------------------- +TanOperator::Pointer TanOperator::NullPointer() { - CREATE_NEW_ARRAY_TRIG(filter, calculatedArrayPath, executionStack, tan) + return Pointer(static_cast(nullptr)); } diff --git a/Source/SIMPLib/CoreFilters/util/TanOperator.h b/Source/SIMPLib/CoreFilters/util/TanOperator.h index 18773ac96a..a5004d08f2 100644 --- a/Source/SIMPLib/CoreFilters/util/TanOperator.h +++ b/Source/SIMPLib/CoreFilters/util/TanOperator.h @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include #include "SIMPLib/SIMPLib.h" @@ -46,25 +47,31 @@ class CalculatorNumber; class SIMPLib_EXPORT TanOperator : public UnaryOperator { - public: - SIMPL_SHARED_POINTERS(TanOperator) +public: + using Self = TanOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New() - { - return Pointer(new TanOperator()); - } + static Pointer New() + { + return Pointer(new TanOperator()); + } - ~TanOperator() override; + ~TanOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - protected: - TanOperator(); +protected: + TanOperator(); - public: - TanOperator(const TanOperator&) = delete; // Copy Constructor Not Implemented - TanOperator(TanOperator&&) = delete; // Move Constructor Not Implemented - TanOperator& operator=(const TanOperator&) = delete; // Copy Assignment Not Implemented - TanOperator& operator=(TanOperator&&) = delete; // Move Assignment Not Implemented -}; +public: + TanOperator(const TanOperator&) = delete; // Copy Constructor Not Implemented + TanOperator(TanOperator&&) = delete; // Move Constructor Not Implemented + TanOperator& operator=(const TanOperator&) = delete; // Copy Assignment Not Implemented + TanOperator& operator=(TanOperator&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/CoreFilters/util/UnaryOperator.cpp b/Source/SIMPLib/CoreFilters/util/UnaryOperator.cpp index 9df9402fcd..4455cce5d5 100644 --- a/Source/SIMPLib/CoreFilters/util/UnaryOperator.cpp +++ b/Source/SIMPLib/CoreFilters/util/UnaryOperator.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "UnaryOperator.h" @@ -181,3 +181,9 @@ void UnaryOperator::setNumberOfArguments(int numOfArguments) { m_NumOfArguments = numOfArguments; } + +// ----------------------------------------------------------------------------- +UnaryOperator::Pointer UnaryOperator::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} diff --git a/Source/SIMPLib/CoreFilters/util/UnaryOperator.h b/Source/SIMPLib/CoreFilters/util/UnaryOperator.h index b07b710e52..a10dec4d7e 100644 --- a/Source/SIMPLib/CoreFilters/util/UnaryOperator.h +++ b/Source/SIMPLib/CoreFilters/util/UnaryOperator.h @@ -1,84 +1,93 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include "CalculatorOperator.h" +#include "SIMPLib/DataArrays/DataArray.hpp" + class SIMPLib_EXPORT UnaryOperator : public CalculatorOperator { - public: - SIMPL_SHARED_POINTERS(UnaryOperator) - - static Pointer New() - { - return Pointer(new UnaryOperator()); - } +public: + using Self = UnaryOperator; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New() + { + return Pointer(new UnaryOperator()); + } - ~UnaryOperator() override; + ~UnaryOperator() override; - void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack &executionStack) override; + void calculate(AbstractFilter* filter, DataArrayPath calculatedArrayPath, QStack& executionStack) override; - CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& msg) final; + CalculatorItem::ErrorCode checkValidity(QVector infixVector, int currentIndex, QString& msg) final; - int getNumberOfArguments(); + int getNumberOfArguments(); - protected: - UnaryOperator(); +protected: + UnaryOperator(); - void setNumberOfArguments(int numOfArguments); + void setNumberOfArguments(int numOfArguments); - private: - int m_NumOfArguments; +private: + int m_NumOfArguments; - public: - UnaryOperator(const UnaryOperator&) = delete; // Copy Constructor Not Implemented - UnaryOperator(UnaryOperator&&) = delete; // Move Constructor Not Implemented - UnaryOperator& operator=(const UnaryOperator&) = delete; // Copy Assignment Not Implemented - UnaryOperator& operator=(UnaryOperator&&) = delete; // Move Assignment Not Implemented +public: + UnaryOperator(const UnaryOperator&) = delete; // Copy Constructor Not Implemented + UnaryOperator(UnaryOperator&&) = delete; // Move Constructor Not Implemented + UnaryOperator& operator=(const UnaryOperator&) = delete; // Copy Assignment Not Implemented + UnaryOperator& operator=(UnaryOperator&&) = delete; // Move Assignment Not Implemented }; #define CREATE_NEW_ARRAY_STANDARD_UNARY(filter, calculatedArrayPath, executionStack, func) \ ArrayCalculator* calculatorFilter = dynamic_cast(filter); \ \ - if(executionStack.size() >= 1 && nullptr != executionStack.top() && nullptr != calculatorFilter) \ + if(!executionStack.empty() && nullptr != executionStack.top() && nullptr != calculatorFilter) \ { \ ICalculatorArray::Pointer arrayPtr = executionStack.pop(); \ \ DoubleArrayType::Pointer newArray = \ - DoubleArrayType::CreateArray(arrayPtr->getArray()->getNumberOfTuples(), arrayPtr->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName()); \ + DoubleArrayType::CreateArray(arrayPtr->getArray()->getNumberOfTuples(), arrayPtr->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName(), true); \ \ int numComps = newArray->getNumberOfComponents(); \ for(int i = 0; i < newArray->getNumberOfTuples(); i++) \ @@ -98,12 +107,12 @@ class SIMPLib_EXPORT UnaryOperator : public CalculatorOperator #define CREATE_NEW_ARRAY_TRIG(filter, calculatedArrayPath, executionStack, func) \ ArrayCalculator* calculatorFilter = dynamic_cast(filter); \ \ - if(executionStack.size() >= 1 && nullptr != executionStack.top() && nullptr != calculatorFilter) \ + if(!executionStack.empty() && nullptr != executionStack.top() && nullptr != calculatorFilter) \ { \ ICalculatorArray::Pointer arrayPtr = executionStack.pop(); \ \ DoubleArrayType::Pointer newArray = \ - DoubleArrayType::CreateArray(arrayPtr->getArray()->getNumberOfTuples(), arrayPtr->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName()); \ + DoubleArrayType::CreateArray(arrayPtr->getArray()->getNumberOfTuples(), arrayPtr->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName(), true); \ \ int numComps = newArray->getNumberOfComponents(); \ for(int i = 0; i < newArray->getNumberOfTuples(); i++) \ @@ -131,12 +140,12 @@ class SIMPLib_EXPORT UnaryOperator : public CalculatorOperator #define CREATE_NEW_ARRAY_ARCTRIG(filter, calculatedArrayPath, executionStack, func) \ ArrayCalculator* calculatorFilter = dynamic_cast(filter); \ \ - if(executionStack.size() >= 1 && nullptr != executionStack.top() && nullptr != calculatorFilter) \ + if(!executionStack.empty() && nullptr != executionStack.top() && nullptr != calculatorFilter) \ { \ ICalculatorArray::Pointer arrayPtr = executionStack.pop(); \ \ DoubleArrayType::Pointer newArray = \ - DoubleArrayType::CreateArray(arrayPtr->getArray()->getNumberOfTuples(), arrayPtr->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName()); \ + DoubleArrayType::CreateArray(arrayPtr->getArray()->getNumberOfTuples(), arrayPtr->getArray()->getComponentDimensions(), calculatedArrayPath.getDataArrayName(), true); \ \ int numComps = newArray->getNumberOfComponents(); \ for(int i = 0; i < newArray->getNumberOfTuples(); i++) \ @@ -160,4 +169,3 @@ class SIMPLib_EXPORT UnaryOperator : public CalculatorOperator executionStack.push(CalculatorArray::New(newArray, arrayPtr->getType(), true)); \ return; \ } - diff --git a/Source/SIMPLib/DataArrays/DataArray.cpp b/Source/SIMPLib/DataArrays/DataArray.cpp new file mode 100644 index 0000000000..03223b7ece --- /dev/null +++ b/Source/SIMPLib/DataArrays/DataArray.cpp @@ -0,0 +1,1623 @@ +/* ============================================================================ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "DataArray.hpp" + +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + +#if defined(_MSC_VER) +#include +#define SIMPL_BYTE_SWAP_16(x) _byteswap_ushort(x) +#define SIMPL_BYTE_SWAP_32(x) _byteswap_ulong(x) +#define SIMPL_BYTE_SWAP_64(x) _byteswap_uint64(x) + +#elif(defined(__clang__) && __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) +#if(defined(__clang__) && __has_builtin(__builtin_bswap16)) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) +#define SIMPL_BYTE_SWAP_16(x) __builtin_bswap16(x) +#else +#define SIMPL_BYTE_SWAP_16(x) __builtin_bswap32((x) << 16) +#endif +#define SIMPL_BYTE_SWAP_32(x) __builtin_bswap32(x) +#define SIMPL_BYTE_SWAP_64(x) __builtin_bswap64(x) +#elif defined(__linux__) +#include +#define SIMPL_BYTE_SWAP_16(x) bswap_16(x) +#define SIMPL_BYTE_SWAP_32(x) bswap_32(x) +#define SIMPL_BYTE_SWAP_64(x) bswap_64(x) +#endif + +#include +#include +#include +#include +#include + +#include + +#include "SIMPLib/HDF5/H5DataArrayReader.h" +#include "SIMPLib/HDF5/H5DataArrayWriter.hpp" + +namespace +{ +// Can be replaced with std::bit_cast in C++ 20 + +template ::value && std::is_trivial::value>> +To bit_cast(const From& src) noexcept +{ + To dst; + std::memcpy(&dst, &src, sizeof(To)); + return dst; +} + +template +T byteSwap(T value) +{ + static_assert(std::is_arithmetic_v, "byteSwap only works on arithmetic types"); + + if constexpr(sizeof(T) == sizeof(uint16_t)) + { + return SIMPL_BYTE_SWAP_16(value); + } + else if constexpr(sizeof(T) == sizeof(uint32_t)) + { + if constexpr(std::is_floating_point_v) + { + return bit_cast(SIMPL_BYTE_SWAP_32(bit_cast(value))); + } + else + { + return SIMPL_BYTE_SWAP_32(value); + } + } + else if constexpr(sizeof(T) == sizeof(uint64_t)) + { + if constexpr(std::is_floating_point_v) + { + return bit_cast(SIMPL_BYTE_SWAP_64(bit_cast(value))); + } + else + { + return SIMPL_BYTE_SWAP_64(value); + } + } + + return value; +} + +} // namespace + +template +typename DataArray::Pointer DataArray::NullPointer() +{ + return nullptr; +} + +template +QString DataArray::getNameOfClass() const +{ + return ClassName(); +} + +template +QString DataArray::ClassName() +{ + return "DataArray"; +} + +template +int32_t DataArray::getClassVersion() const +{ + return 2; +} + +//========================================= Constructing DataArray Objects ================================= +template +DataArray::DataArray() = default; + +/** + * @brief Constructor + * @param numTuples The number of Tuples in the DataArray + * @param name The name of the DataArray + * @param initValue The value to use when initializing each element of the array + */ +template +DataArray::DataArray(size_t numTuples, const QString& name, T initValue) +: IDataArray(name) +, m_InitValue(initValue) +{ + resizeTuples(numTuples); +} + +/** + * @brief DataArray + * @param numTuples The number of Tuples in the DataArray + * @param name The name of the DataArray + * @param compDims The number of elements in each axis dimension. + * @param initValue The value to use when initializing each element of the array + * + * For example if you have a 2D image dimensions of 80(w) x 60(h) then the "cdims" would be [80][60] + */ +template +DataArray::DataArray(size_t numTuples, const QString& name, const comp_dims_type& compDims, T initValue) +: IDataArray(name) +, m_NumTuples(numTuples) +, m_InitValue(initValue) +, m_CompDims(compDims) +{ + m_NumComponents = std::accumulate(m_CompDims.cbegin(), m_CompDims.cend(), static_cast(1), std::multiplies<>()); + m_Array = resizeAndExtend(m_NumTuples * m_NumComponents); +} + +/** + * @brief Protected Constructor + * @param numTuples The number of Tuples in the DataArray + * @param name The name of the DataArray + * @param compDims The number of elements in each axis dimension. + * @param initValue The value to use when initializing each element of the array + * @param allocate Will all the memory be allocated at time of construction + */ +template +DataArray::DataArray(size_t numTuples, const QString& name, const comp_dims_type& compDims, T initValue, bool allocate) +: IDataArray(name) +, m_NumTuples(numTuples) +, m_InitValue(initValue) +, m_CompDims(compDims) +{ + m_NumComponents = std::accumulate(m_CompDims.cbegin(), m_CompDims.cend(), static_cast(1), std::multiplies<>()); + if(allocate) + { + resizeTuples(numTuples); + } + else + { + m_Size = m_NumTuples * m_NumComponents; + m_MaxId = (m_Size > 0) ? m_Size - 1 : m_Size; + } +#if 0 + MUD_FLAP_0 = MUD_FLAP_1 = MUD_FLAP_2 = MUD_FLAP_3 = MUD_FLAP_4 = MUD_FLAP_5 = 0xABABABABABABABABul; +#endif +} + +template +DataArray::~DataArray() +{ + clear(); +} + +// ----------------------------------------------------------------------------- +template +typename DataArray::Pointer DataArray::CreateArray(size_t numTuples, const QString& name, bool allocate) +{ + if(name.isEmpty()) + { + return nullptr; + } + comp_dims_type cDims = {1}; + auto d = std::make_shared>(numTuples, name, cDims, static_cast(0), allocate); + if(allocate) + { + if(d->allocate() < 0) + { + // Could not allocate enough memory, reset the pointer to null and return + return nullptr; + } + } + return d; +} +// ----------------------------------------------------------------------------- +template +typename DataArray::Pointer DataArray::CreateArray(size_t numTuples, const std::string& name, bool allocate) +{ + if(name.empty()) + { + return nullptr; + } + comp_dims_type cDims = {1}; + auto d = std::make_shared>(numTuples, QString::fromStdString(name), cDims, static_cast(0), allocate); + if(allocate) + { + if(d->allocate() < 0) + { + // Could not allocate enough memory, reset the pointer to null and return + return nullptr; + } + } + return d; +} + +// ----------------------------------------------------------------------------- +template +typename DataArray::Pointer DataArray::CreateArray(size_t numTuples, int32_t rank, const size_t* dims, const QString& name, bool allocate) +{ + if(name.isEmpty()) + { + return nullptr; + } + comp_dims_type cDims(static_cast(rank)); + std::copy(dims, dims + rank, cDims.begin()); + auto d = std::make_shared>(numTuples, name, cDims, static_cast(0), allocate); + if(allocate) + { + if(d->allocate() < 0) + { + // Could not allocate enough memory, reset the pointer to null and return + return nullptr; + } + } + return d; +} + +// ----------------------------------------------------------------------------- +template +typename DataArray::Pointer DataArray::CreateArray(size_t numTuples, const comp_dims_type& compDims, const QString& name, bool allocate) +{ + if(name.isEmpty()) + { + return nullptr; + } + auto d = std::make_shared>(numTuples, name, compDims, static_cast(0), allocate); + if(allocate) + { + if(d->allocate() < 0) + { + // Could not allocate enough memory, reset the pointer to null and return + return nullptr; + } + } + return d; +} + +// ----------------------------------------------------------------------------- +template +typename DataArray::Pointer DataArray::CreateArray(const comp_dims_type& tupleDims, const comp_dims_type& compDims, const QString& name, bool allocate) +{ + if(name.isEmpty()) + { + return nullptr; + } + + size_t numTuples = std::accumulate(tupleDims.cbegin(), tupleDims.cend(), static_cast(1), std::multiplies<>()); + + auto d = std::make_shared>(numTuples, name, compDims, static_cast(0), allocate); + if(allocate) + { + if(d->allocate() < 0) + { + // Could not allocate enough memory, reset the pointer to null and return + return nullptr; + } + } + return d; +} + +template +IDataArray::Pointer DataArray::createNewArray(size_t numTuples, int32_t rank, const size_t* compDims, const QString& name, bool allocate) const +{ + return DataArray::CreateArray(numTuples, rank, compDims, name, allocate); +} + +template +IDataArray::Pointer DataArray::createNewArray(size_t numTuples, const comp_dims_type& compDims, const QString& name, bool allocate) const +{ + return DataArray::CreateArray(numTuples, compDims, name, allocate); +} + +// ----------------------------------------------------------------------------- +template +typename DataArray::Pointer DataArray::FromQVector(const QVector& vec, const QString& name) +{ + Pointer p = CreateArray(static_cast(vec.size()), name, true); + if(nullptr != p) + { + std::copy(vec.cbegin(), vec.cend(), p->begin()); + } + return p; +} + +// ----------------------------------------------------------------------------- +template +typename DataArray::Pointer DataArray::FromStdVector(const std::vector& vec, const QString& name) +{ + comp_dims_type cDims = {1}; + Pointer p = CreateArray(vec.size(), cDims, name, true); + if(nullptr != p) + { + std::copy(vec.cbegin(), vec.cend(), p->begin()); + } + return p; +} + +// ----------------------------------------------------------------------------- +template +typename DataArray::Pointer DataArray::CopyFromPointer(const T* data, size_t size, const QString& name) +{ + Pointer p = CreateArray(size, name, true); + if(nullptr != p) + { + std::copy(data, data + size, p->begin()); + } + return p; +} + +/** + * @brief WrapPointer Creates a DataArray object that references the pointer. The original caller can + * set if the memory should be "free()'ed" when the object goes away. The original memory MUST have been + * "alloc()'ed" and NOT new 'ed. + * @param data + * @param numTuples + * @param cDims + * @param name + * @param ownsData + * @return + */ +template +typename DataArray::Pointer DataArray::WrapPointer(T* data, size_t numTuples, const comp_dims_type& compDims, const QString& name, bool ownsData) +{ + // Allocate on the heap + auto d = std::make_shared>(numTuples, name, compDims, static_cast(0), false); + + // Now set the internal array to the raw pointer + d->m_Array = data; + // Set who owns the data, i.e., who is going to "free" the memory + d->m_OwnsData = ownsData; + if(nullptr != data) + { + d->m_IsAllocated = true; + } + + return d; +} + +//========================================= Begin API ================================= +template +IDataArray::Pointer DataArray::deepCopy(bool forceNoAllocate) const +{ + bool allocate = m_IsAllocated; + if(forceNoAllocate) + { + allocate = false; + } + auto daCopy = CreateArray(getNumberOfTuples(), getComponentDimensions(), getName(), allocate); + if(m_IsAllocated && !forceNoAllocate) + { + std::copy(begin(), end(), daCopy->begin()); + } + return daCopy; +} + +/** + * @brief GetTypeName Returns a string representation of the type of data that is stored by this class. This + * can be a primitive like char, float, int or the name of a class. + * @return + */ +template +SIMPL::NumericTypes::Type DataArray::getType() const +{ + if constexpr(std::is_same_v) + { + return SIMPL::NumericTypes::Type::Int8; + } + else if constexpr(std::is_same_v) + { + return SIMPL::NumericTypes::Type::UInt8; + } + else if constexpr(std::is_same_v) + { + return SIMPL::NumericTypes::Type::Int16; + } + else if constexpr(std::is_same_v) + { + return SIMPL::NumericTypes::Type::UInt16; + } + else if constexpr(std::is_same_v) + { + return SIMPL::NumericTypes::Type::Int32; + } + else if constexpr(std::is_same_v) + { + return SIMPL::NumericTypes::Type::UInt32; + } + else if constexpr(std::is_same_v) + { + return SIMPL::NumericTypes::Type::Int64; + } + else if constexpr(std::is_same_v) + { + return SIMPL::NumericTypes::Type::UInt64; + } + else if constexpr(std::is_same_v) + { + return SIMPL::NumericTypes::Type::Float; + } + else if constexpr(std::is_same_v) + { + return SIMPL::NumericTypes::Type::Double; + } + else if constexpr(std::is_same_v) + { + return SIMPL::NumericTypes::Type::Bool; + } + + return SIMPL::NumericTypes::Type::UnknownNumType; +} + +// ----------------------------------------------------------------------------- +template +void DataArray::getXdmfTypeAndSize(QString& xdmfTypeName, int32_t& precision) const +{ + xdmfTypeName = "UNKNOWN"; + precision = 0; + + if constexpr(std::is_same_v) + { + xdmfTypeName = "Char"; + precision = 1; + } + else if constexpr(std::is_same_v) + { + xdmfTypeName = "UChar"; + precision = 1; + } + else if constexpr(std::is_same_v) + { + xdmfTypeName = "Int"; + precision = 2; + } + else if constexpr(std::is_same_v) + { + xdmfTypeName = "UInt"; + precision = 2; + } + else if constexpr(std::is_same_v) + { + xdmfTypeName = "Int"; + precision = 4; + } + else if constexpr(std::is_same_v) + { + xdmfTypeName = "UInt"; + precision = 4; + } + else if constexpr(std::is_same_v) + { + xdmfTypeName = "Int"; + precision = 8; + } + else if constexpr(std::is_same_v) + { + xdmfTypeName = "UInt"; + precision = 8; + } + else if constexpr(std::is_same_v) + { + xdmfTypeName = "Float"; + precision = 4; + } + else if constexpr(std::is_same_v) + { + xdmfTypeName = "Float"; + precision = 8; + } + else if constexpr(std::is_same_v) + { + xdmfTypeName = "UChar"; + precision = 1; + } +} + +// ----------------------------------------------------------------------------- +template +bool DataArray::copyFromArray(size_t destTupleOffset, IDataArray::ConstPointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) +{ + if(!m_IsAllocated) + { + return false; + } + if(nullptr == m_Array) + { + return false; + } + if(destTupleOffset > m_MaxId) + { + return false; + } + if(!sourceArray->isAllocated()) + { + return false; + } + const Self* source = dynamic_cast(sourceArray.get()); + if(source == nullptr) + { + return false; + } + if(nullptr == source->getPointer(0)) + { + return false; + } + + if(sourceArray->getNumberOfComponents() != getNumberOfComponents()) + { + return false; + } + + if(srcTupleOffset + totalSrcTuples > sourceArray->getNumberOfTuples()) + { + return false; + } + + if(totalSrcTuples * static_cast(sourceArray->getNumberOfComponents()) + destTupleOffset * static_cast(getNumberOfComponents()) > m_Size) + { + return false; + } + + auto srcBegin = source->cbegin() + (srcTupleOffset * source->m_NumComponents); + auto srcEnd = srcBegin + (totalSrcTuples * source->m_NumComponents); + auto dstBegin = begin() + (destTupleOffset * m_NumComponents); + std::copy(srcBegin, srcEnd, dstBegin); + return true; +} + +// ----------------------------------------------------------------------------- +template +bool DataArray::copyIntoArray(Pointer dest) const +{ + if(m_IsAllocated && dest->isAllocated() && m_Array && dest->getPointer(0)) + { + std::copy(cbegin(), cend(), dest->begin()); + return true; + } + return false; +} + +// ----------------------------------------------------------------------------- +template +bool DataArray::isAllocated() const +{ + return m_IsAllocated; +} + +// ----------------------------------------------------------------------------- +template +void DataArray::setInitValue(T initValue) +{ + m_InitValue = initValue; +} + +// ----------------------------------------------------------------------------- +template +void DataArray::takeOwnership() +{ + m_OwnsData = true; +} + +// ----------------------------------------------------------------------------- +template +void DataArray::releaseOwnership() +{ + m_OwnsData = false; +} + +// ----------------------------------------------------------------------------- +template +int32_t DataArray::allocate() +{ + if((nullptr != m_Array) && m_OwnsData) + { + deallocate(); + } + m_Array = nullptr; + m_OwnsData = true; + m_IsAllocated = false; + if(m_Size == 0) + { + clear(); + return 1; + } + + size_t newSize = m_Size; + m_Array = new(std::nothrow) T[newSize](); + if(!m_Array) + { + qDebug() << "Unable to allocate " << newSize << " elements of size " << sizeof(T) << " bytes. "; + return -1; + } + m_Size = newSize; + m_IsAllocated = true; + + return 1; +} + +// ----------------------------------------------------------------------------- +template +void DataArray::initializeWithZeros() +{ + if(!m_IsAllocated || nullptr == m_Array) + { + return; + } + std::fill_n(m_Array, m_Size, 0); +} + +// ----------------------------------------------------------------------------- +template +void DataArray::initializeWithValue(T initValue, size_t offset) +{ + if(!m_IsAllocated || nullptr == m_Array) + { + return; + } + std::fill(begin() + offset, end(), initValue); +} + +// ----------------------------------------------------------------------------- +template +int32_t DataArray::eraseTuples(const comp_dims_type& idxs) +{ + int32_t err = 0; + + // If nothing is to be erased just return + if(idxs.empty()) + { + return 0; + } + auto idxs_size = static_cast(idxs.size()); + if(idxs_size >= getNumberOfTuples()) + { + resizeTuples(0); + return 0; + } + + // Sanity Check the Indices in the vector to make sure we are not trying to remove any indices that are + // off the end of the array and return an error code. + for(const size_t& idx : idxs) + { + if(idx * m_NumComponents > m_MaxId) + { + return -100; + } + } + + // Calculate the new size of the array to copy into + size_t newSize = (getNumberOfTuples() - idxs.size()) * m_NumComponents; + + // Create a new m_Array to copy into + T* newArray = new T[newSize](); + +#ifndef NDEBUG + // Splat AB across the array so we know if we are copying the values or not + std::memset(newArray, 0xAB, newSize * sizeof(T)); +#endif + + size_t j = 0; + size_t k = 0; + // Find the first chunk to copy by walking the idxs array until we get an + // index that is NOT a continuous increment from the start + for(k = 0; k < idxs.size(); ++k) + { + if(j == idxs[k]) + { + ++j; + } + else + { + break; + } + } + + // Only front elements are being dropped + if(k == idxs.size()) + { + auto srcBegin = begin() + (j * m_NumComponents); + auto srcEnd = srcBegin + (getNumberOfTuples() - idxs.size()) * m_NumComponents; + std::copy(srcBegin, srcEnd, newArray); + // We are done copying - delete the current m_Array + deallocate(); + m_Size = newSize; + m_Array = newArray; + m_OwnsData = true; + m_MaxId = newSize - 1; + m_IsAllocated = true; + return 0; + } + + comp_dims_type srcIdx(idxs.size() + 1); + comp_dims_type destIdx(idxs.size() + 1); + comp_dims_type copyElements(idxs.size() + 1); + srcIdx[0] = 0; + destIdx[0] = 0; + copyElements[0] = (idxs[0] - 0) * m_NumComponents; + + for(size_t i = 1; i < srcIdx.size(); ++i) + { + srcIdx[i] = (idxs[i - 1] + 1) * m_NumComponents; + + if(i < srcIdx.size() - 1) + { + copyElements[i] = (idxs[i] - idxs[i - 1] - 1) * m_NumComponents; + } + else + { + copyElements[i] = (getNumberOfTuples() - idxs[i - 1] - 1) * m_NumComponents; + } + destIdx[i] = copyElements[i - 1] + destIdx[i - 1]; + } + + // Copy the data + for(size_t i = 0; i < srcIdx.size(); ++i) + { + auto srcBegin = begin() + srcIdx[i]; + auto srcEnd = srcBegin + copyElements[i]; + auto dstBegin = newArray + destIdx[i]; + std::copy(srcBegin, srcEnd, dstBegin); + } + + // We are done copying - delete the current m_Array + deallocate(); + + // Allocation was successful. Save it. + m_Size = newSize; + m_Array = newArray; + // This object has now allocated its memory and owns it. + m_OwnsData = true; + m_IsAllocated = true; + m_MaxId = newSize - 1; + + return err; +} + +// ----------------------------------------------------------------------------- +template +int32_t DataArray::copyTuple(size_t currentPos, size_t newPos) +{ + size_t max = ((m_MaxId + 1) / m_NumComponents); + if(currentPos >= max || newPos >= max) + { + return -1; + } + auto srcBegin = begin() + (currentPos * m_NumComponents); + auto srcEnd = srcBegin + m_NumComponents; + auto dstBegin = begin() + (newPos * m_NumComponents); + std::copy(srcBegin, srcEnd, dstBegin); + return 0; +} + +// ----------------------------------------------------------------------------- +template +size_t DataArray::getTypeSize() const +{ + return sizeof(T); +} + +// ----------------------------------------------------------------------------- +template +size_t DataArray::getNumberOfTuples() const +{ + return m_NumTuples; +} + +// ----------------------------------------------------------------------------- +template +size_t DataArray::getSize() const +{ + return m_Size; +} + +// ----------------------------------------------------------------------------- +template +typename DataArray::comp_dims_type DataArray::getComponentDimensions() const +{ + return m_CompDims; +} + +// ----------------------------------------------------------------------------- +template +int32_t DataArray::getNumberOfComponents() const +{ + return static_cast(m_NumComponents); +} + +// ----------------------------------------------------------------------------- +template +void* DataArray::getVoidPointer(size_t i) +{ + if(i >= m_Size) + { + return nullptr; + } + + return reinterpret_cast(&(m_Array[i])); +} + +// ----------------------------------------------------------------------------- +template +T* DataArray::getPointer(size_t i) const +{ +#ifndef NDEBUG + if(m_Size > 0) + { + Q_ASSERT(i < m_Size); + } +#endif + return m_Array + i; +} + +// ----------------------------------------------------------------------------- +template +T DataArray::getValue(size_t i) const +{ +#ifndef NDEBUG + if(m_Size > 0) + { + Q_ASSERT(i < m_Size); + } +#endif + return m_Array[i]; +} + +// ----------------------------------------------------------------------------- +template +void DataArray::setValue(size_t i, T value) +{ +#ifndef NDEBUG + if(m_Size > 0) + { + Q_ASSERT(i < m_Size); + } +#endif + m_Array[i] = value; +} + +// ----------------------------------------------------------------------------- +template +T DataArray::getComponent(size_t i, int32_t j) const +{ +#ifndef NDEBUG + if(m_Size > 0) + { + Q_ASSERT(i * m_NumComponents + static_cast(j) < m_Size); + } +#endif + return m_Array[i * m_NumComponents + static_cast(j)]; +} + +// ----------------------------------------------------------------------------- +template +void DataArray::setComponent(size_t i, int32_t j, T c) +{ +#ifndef NDEBUG + if(m_Size > 0) + { + Q_ASSERT(i * m_NumComponents + static_cast(j) < m_Size); + } +#endif + m_Array[i * m_NumComponents + static_cast(j)] = c; +} + +// ----------------------------------------------------------------------------- +template +void DataArray::setTuple(size_t tupleIndex, const T* data) +{ +#ifndef NDEBUG + if(m_Size > 0) + { + Q_ASSERT(tupleIndex * m_NumComponents + (m_NumComponents - 1) < m_Size); + } +#endif + std::copy(data, data + m_NumComponents, begin() + (tupleIndex * m_NumComponents)); +} + +// ----------------------------------------------------------------------------- +template +void DataArray::setTuple(size_t tupleIndex, const std::vector& data) +{ +#ifndef NDEBUG + if(m_Size > 0) + { + Q_ASSERT(tupleIndex * m_NumComponents + (m_NumComponents - 1) < m_Size); + } +#endif + auto srcBegin = data.cbegin(); + auto srcEnd = srcBegin + m_NumComponents; + std::copy(srcBegin, srcEnd, begin() + (tupleIndex * m_NumComponents)); +} + +// ----------------------------------------------------------------------------- +template +void DataArray::initializeTuple(size_t i, const void* p) +{ + if(p == nullptr) + { + return; + } + const T* c = reinterpret_cast(p); + fillTuple(i, *c); +} + +// ----------------------------------------------------------------------------- +template +void DataArray::fillTuple(size_t i, T value) +{ + if(!m_IsAllocated) + { + return; + } +#ifndef NDEBUG + if(m_Size > 0) + { + Q_ASSERT(i * m_NumComponents < m_Size); + } +#endif + std::fill_n(begin() + (i * m_NumComponents), m_NumComponents, value); +} + +// ----------------------------------------------------------------------------- +template +T* DataArray::getTuplePointer(size_t tupleIndex) const +{ +#ifndef NDEBUG + if(m_Size > 0) + { + Q_ASSERT(tupleIndex * m_NumComponents < m_Size); + } +#endif + return m_Array + (tupleIndex * m_NumComponents); +} + +// ----------------------------------------------------------------------------- +template +void DataArray::resizeTuples(size_t numTuples) +{ + T* ptr = resizeAndExtend(numTuples * m_NumComponents); + if(nullptr != ptr) + { + m_NumTuples = numTuples; + } +} + +// ----------------------------------------------------------------------------- +template +void DataArray::printTuple(QTextStream& out, size_t i, char delimiter) const +{ + int32_t precision = out.realNumberPrecision(); + if constexpr(std::is_same_v) + { + out.setRealNumberPrecision(8); + } + else if constexpr(std::is_same_v) + { + out.setRealNumberPrecision(16); + } + + for(size_t j = 0; j < m_NumComponents; ++j) + { + if(j != 0) + { + out << delimiter; + } + out << m_Array[i * m_NumComponents + j]; + } + out.setRealNumberPrecision(precision); +} + +// ----------------------------------------------------------------------------- +template +void DataArray::printComponent(QTextStream& out, size_t i, int32_t j) const +{ + out << m_Array[i * m_NumComponents + static_cast(j)]; +} + +// ----------------------------------------------------------------------------- +template +QString DataArray::getFullNameOfClass() const +{ + QString theType = getTypeAsString(); + theType = "DataArray<" + theType + ">"; + return theType; +} + +// ----------------------------------------------------------------------------- +template +QString DataArray::getTypeAsString() const +{ + if constexpr(std::is_same_v) + { + return "int8_t"; + } + else if constexpr(std::is_same_v) + { + return "uint8_t"; + } + else if constexpr(std::is_same_v) + { + return "int16_t"; + } + else if constexpr(std::is_same_v) + { + return "uint16_t"; + } + else if constexpr(std::is_same_v) + { + return "int32_t"; + } + else if constexpr(std::is_same_v) + { + return "uint32_t"; + } + else if constexpr(std::is_same_v) + { + return "int64_t"; + } + else if constexpr(std::is_same_v) + { + return "uint64_t"; + } + else if constexpr(std::is_same_v) + { + return "float"; + } + else if constexpr(std::is_same_v) + { + return "double"; + } + else if constexpr(std::is_same_v) + { + return "bool"; + } + else if constexpr(std::is_same_v) + { + return "size_t"; + } + return "UnknownType"; +} + +// ----------------------------------------------------------------------------- +template +int32_t DataArray::writeH5Data(hid_t parentId, const comp_dims_type& tDims) const +{ + if(m_Array == nullptr) + { + return -85648; + } + return H5DataArrayWriter::writeDataArray(parentId, this, tDims); +} + +// ----------------------------------------------------------------------------- +template +int32_t DataArray::writeXdmfAttribute(QTextStream& out, const int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& label) const +{ + if(m_Array == nullptr) + { + return -85648; + } + QString dimStr; + int32_t precision = 0; + QString xdmfTypeName; + getXdmfTypeAndSize(xdmfTypeName, precision); + if(0 == precision) + { + out << "" + << "\n"; + return -100; + } + + int32_t numComp = getNumberOfComponents(); + out << " \n"; + // Open the Tag + out << R"( \n"; + + out << " " << hdfFileName << groupPath << "/" << getName() << "\n"; + out << " " + << "\n"; + out << " " + << "\n"; + return 1; +} + +// ----------------------------------------------------------------------------- +template +QString DataArray::getInfoString(SIMPL::InfoStringFormat format) const +{ + QLocale usa(QLocale::English, QLocale::UnitedStates); + + QString info; + QTextStream ss(&info); + if(format == SIMPL::HtmlFormat) + { + ss << "\n"; + ss << "\n"; + ss << "\n"; + ss << "\n"; + ss << ""; + + ss << R"("; + + ss << R"("; + QString numStr = usa.toString(static_cast(getNumberOfTuples())); + ss << R"("; + + QString compDimStr = "("; + for(size_t i = 0; i < m_CompDims.size(); i++) + { + compDimStr += QString::number(m_CompDims[i]); + if(i < m_CompDims.size() - 1) + { + compDimStr += ", "; + } + } + compDimStr = compDimStr + ")"; + ss << R"("; + numStr = usa.toString(static_cast(m_Size)); + ss << R"("; + numStr = usa.toString(static_cast(m_Size * sizeof(T))); + ss << R"("; + ss << "
Attribute Array Info
Name:)" << getName() << "
Type: DataArray<)" << getTypeAsString() << ">
Number of Tuples:)" << numStr << "
Component Dimensions:)" << compDimStr << "
Total Elements:)" << numStr << "
Total Memory Required:)" << numStr << "
\n"; + ss << ""; + } + else if(format == SIMPL::MarkDown) + { + ss << "+ Name: " << getName() << "\n"; + ss << "+ Type: " << getTypeAsString() << "\n"; + ss << "+ Num. Tuple: " << getNumberOfTuples() << "\n"; + QString compDimStr = "("; + for(size_t i = 0; i < m_CompDims.size(); i++) + { + compDimStr += QString::number(m_CompDims[i]); + if(i < m_CompDims.size() - 1) + { + compDimStr += ", "; + } + } + compDimStr = compDimStr + ")"; + ss << "+ Comp. Dims: " << compDimStr << "\n"; + ss << "+ Total Elements: " << m_Size << "\n"; + ss << "+ Total Memory: " << (m_Size * sizeof(T)) << "\n"; + } + return info; +} + +// ----------------------------------------------------------------------------- +template +int32_t DataArray::readH5Data(hid_t parentId) +{ + int32_t err = 0; + + resizeTuples(0); + IDataArray::Pointer p = H5DataArrayReader::ReadIDataArray(parentId, getName()); + if(p == nullptr) + { + return -1; + } + m_Array = reinterpret_cast(p->getVoidPointer(0)); + m_Size = p->getSize(); + m_OwnsData = true; + m_MaxId = (m_Size == 0) ? 0 : m_Size - 1; + m_IsAllocated = true; + setName(p->getName()); + m_NumTuples = p->getNumberOfTuples(); + m_CompDims = p->getComponentDimensions(); + m_NumComponents = static_cast(p->getNumberOfComponents()); + + // Tell the intermediate DataArray to release ownership of the data as we are going to be responsible + // for deleting the memory + p->releaseOwnership(); + return err; +} + +// ----------------------------------------------------------------------------- +template +void DataArray::byteSwapElements() +{ + for(auto& value : *this) + { + value = byteSwap(value); + } +} + +template +typename DataArray::iterator DataArray::begin() +{ + return iterator(m_Array); +} + +template +typename DataArray::iterator DataArray::end() +{ + return iterator(m_Array + m_Size); +} + +template +typename DataArray::const_iterator DataArray::begin() const +{ + return const_iterator(m_Array); +} +template +typename DataArray::const_iterator DataArray::end() const +{ + return const_iterator(m_Array + m_Size); +} + +template +typename DataArray::const_iterator DataArray::cbegin() const +{ + return begin(); +} + +template +typename DataArray::const_iterator DataArray::cend() const +{ + return end(); +} + +template +typename DataArray::reverse_iterator DataArray::rbegin() +{ + return std::make_reverse_iterator(end()); +} + +template +typename DataArray::reverse_iterator DataArray::rend() +{ + return std::make_reverse_iterator(begin()); +} + +template +typename DataArray::const_reverse_iterator DataArray::rbegin() const +{ + return std::make_reverse_iterator(end()); +} + +template +typename DataArray::const_reverse_iterator DataArray::rend() const +{ + return std::make_reverse_iterator(begin()); +} + +template +typename DataArray::const_reverse_iterator DataArray::crbegin() const +{ + return rbegin(); +} + +template +typename DataArray::const_reverse_iterator DataArray::crend() const +{ + return rend(); +} + +template +typename DataArray::tuple_iterator DataArray::tupleBegin() +{ + return tuple_iterator(m_Array, m_NumComponents); +} + +template +typename DataArray::tuple_iterator DataArray::tupleEnd() +{ + return tuple_iterator(m_Array + m_Size, m_NumComponents); +} + +template +typename DataArray::const_tuple_iterator DataArray::tupleBegin() const +{ + return const_tuple_iterator(m_Array, m_NumComponents); +} + +template +typename DataArray::const_tuple_iterator DataArray::tupleEnd() const +{ + return const_tuple_iterator(m_Array + m_Size, m_NumComponents); +} + +template +typename DataArray::const_tuple_iterator DataArray::constTupleBegin() const +{ + return tupleBegin(); +} + +template +typename DataArray::const_tuple_iterator DataArray::constTupleEnd() const +{ + return tupleEnd(); +} + +// ######### Capacity ######### +template +typename DataArray::size_type DataArray::size() const +{ + return m_Size; +} + +template +typename DataArray::size_type DataArray::capacity() const noexcept +{ + return m_Size; +} + +template +bool DataArray::empty() const noexcept +{ + return (m_Size == 0); +} + +// ######### Element Access ######### + +// ######### Modifiers ######### + +// ----------------------------------------------------------------------------- +template +void DataArray::assign(size_type n, const value_type& val) // fill (2) +{ + resizeAndExtend(n); + std::fill(begin(), end(), val); +} + +// ----------------------------------------------------------------------------- +template +void DataArray::assign(std::initializer_list il) // initializer list (3) +{ + assign(il.begin(), il.end()); +} + +// ----------------------------------------------------------------------------- +template +void DataArray::push_back(const value_type& val) +{ + resizeAndExtend(m_Size + 1); + m_Array[m_MaxId] = val; +} + +// ----------------------------------------------------------------------------- +template +void DataArray::push_back(value_type&& val) +{ + resizeAndExtend(m_Size + 1); + m_Array[m_MaxId] = val; +} + +// ----------------------------------------------------------------------------- +template +void DataArray::pop_back() +{ + resizeAndExtend(m_Size - 1); +} + +// ----------------------------------------------------------------------------- +template +void DataArray::clear() +{ + if(nullptr != m_Array && m_OwnsData) + { + deallocate(); + } + m_Array = nullptr; + m_Size = 0; + m_OwnsData = true; + m_MaxId = 0; + m_IsAllocated = false; + m_NumTuples = 0; +} + +// =================================== END STL COMPATIBLE INTERFACe =================================================== + +// ----------------------------------------------------------------------------- +template +void DataArray::deallocate() +{ +#ifndef NDEBUG + // We are going to splat 0xABABAB across the first value of the array as a debugging aid + auto cptr = reinterpret_cast(m_Array); + if(nullptr != cptr) + { + if(m_Size > 0) + { + if(sizeof(T) >= 1) + { + cptr[0] = 0xAB; + } + if(sizeof(T) >= 2) + { + cptr[1] = 0xAB; + } + if(sizeof(T) >= 4) + { + cptr[2] = 0xAB; + cptr[3] = 0xAB; + } + if(sizeof(T) >= 8) + { + cptr[4] = 0xAB; + cptr[5] = 0xAB; + cptr[6] = 0xAB; + cptr[7] = 0xAB; + } + } + } +#endif +#if 0 + if (MUD_FLAP_0 != 0xABABABABABABABABul + || MUD_FLAP_1 != 0xABABABABABABABABul + || MUD_FLAP_2 != 0xABABABABABABABABul + || MUD_FLAP_3 != 0xABABABABABABABABul + || MUD_FLAP_4 != 0xABABABABABABABABul + || MUD_FLAP_5 != 0xABABABABABABABABul) + { + Q_ASSERT(false); + } +#endif + + delete[](m_Array); + + m_Array = nullptr; + m_IsAllocated = false; +} + +// ----------------------------------------------------------------------------- +template +int32_t DataArray::resizeTotalElements(size_t size) +{ + // std::cout << "DataArray::resizeTotalElements(" << size << ")" << std::endl; + if(size == 0) + { + clear(); + return 1; + } + T* ptr = resizeAndExtend(size); + if(nullptr != ptr) + { + return 1; + } + return 0; +} + +// ----------------------------------------------------------------------------- +template +T* DataArray::resizeAndExtend(size_t size) +{ + T* newArray = nullptr; + size_t newSize = 0; + size_t oldSize = 0; + + // Requested size is equal to current size. Do nothing. + if(size == m_Size) + { + return m_Array; + } + newSize = size; + oldSize = m_Size; + + // Wipe out the array completely if new size is zero. + if(newSize == 0) + { + clear(); + return m_Array; + } + + newArray = new(std::nothrow) T[newSize](); + if(!newArray) + { + qDebug() << "Unable to allocate " << newSize << " elements of size " << sizeof(T) << " bytes. "; + return nullptr; + } + + // Copy the data from the old array. + if(m_Array != nullptr) + { + auto srcBegin = begin(); + auto srcEnd = srcBegin + (newSize < m_Size ? newSize : m_Size); + std::copy(srcBegin, srcEnd, newArray); + } + + // Allocate a new array if we DO NOT own the current array + if((nullptr != m_Array) && m_OwnsData) + { + // Free the old array + deallocate(); + } + + // Allocation was successful. Save it. + m_Size = newSize; + m_Array = newArray; + + // This object has now allocated its memory and owns it. + m_OwnsData = true; + + m_MaxId = newSize - 1; + m_IsAllocated = true; + + // Initialize the new tuples if newSize is larger than old size + if(newSize > oldSize) + { + initializeWithValue(m_InitValue, oldSize); + } + + return m_Array; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +#if !defined(__APPLE__) && !defined(_MSC_VER) +#undef SIMPLib_EXPORT +#define SIMPLib_EXPORT +#endif + +template class SIMPLib_EXPORT DataArray; + +template class SIMPLib_EXPORT DataArray; + +template class SIMPLib_EXPORT DataArray; +template class SIMPLib_EXPORT DataArray; + +template class SIMPLib_EXPORT DataArray; +template class SIMPLib_EXPORT DataArray; + +template class SIMPLib_EXPORT DataArray; +template class SIMPLib_EXPORT DataArray; + +template class SIMPLib_EXPORT DataArray; +template class SIMPLib_EXPORT DataArray; + +template class SIMPLib_EXPORT DataArray; +template class SIMPLib_EXPORT DataArray; + +#if defined(__APPLE__) || defined(_MSC_VER) +template class SIMPLib_EXPORT DataArray; +#endif diff --git a/Source/SIMPLib/DataArrays/DataArray.hpp b/Source/SIMPLib/DataArrays/DataArray.hpp old mode 100755 new mode 100644 index 7edafb1532..7ab6088665 --- a/Source/SIMPLib/DataArrays/DataArray.hpp +++ b/Source/SIMPLib/DataArrays/DataArray.hpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -36,213 +36,111 @@ #pragma once // STL Includes -#include +#include +#include +#include #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/DataArrays/IDataArray.h" -#include "SIMPLib/HDF5/H5DataArrayReader.h" -#include "SIMPLib/HDF5/H5DataArrayWriter.hpp" -#include "SIMPLib/SIMPLib.h" - -#define mxa_bswap(s, d, t) \ - t[0] = ptr[s]; \ - ptr[s] = ptr[d]; \ - ptr[d] = t[0]; - -/** @brief Resizes the DataArray Shared m_Array and assigns its internal data pointer - * - */ -#define RESIZE_ARRAY(sharedArray, pointer, size) pointer = sharedArray->WritePointer(0, size); +#include +#include -#define DECLARE_WRAPPED_ARRAY(pubVar, priVar, Type) \ - DataArray::Pointer priVar; \ - Type* pubVar; +#include "H5Support/H5SupportTypeDefs.h" -#define INIT_DataArray(var, Type) var = DataArray::CreateArray(0, #var); +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataArrays/IDataArray.h" /** - * @class DataArray DataArray.hpp DREAM3DLib/Common/DataArray.hpp - * @brief Template class for wrapping raw arrays of data. - * @author mjackson - * @date July 3, 2008 - * @version $Revision: 1.2 $ + * @class DataArray + * @brief Template class for wrapping raw arrays of data and is the basis for storing data within the SIMPL data structure. */ -template class DataArray : public IDataArray +template +class DataArray : public IDataArray { public: - SIMPL_SHARED_POINTERS(DataArray) - SIMPL_TYPE_MACRO_SUPER(DataArray, IDataArray) - SIMPL_CLASS_VERSION(2) + using Self = DataArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; - DataArray(const DataArray&) = delete; // Copy Constructor Not Implemented - DataArray(DataArray&&) = delete; // Move Constructor Not Implemented - DataArray& operator=(const DataArray&) = delete; // Copy Assignment Not Implemented - DataArray& operator=(DataArray&&) = delete; // Move Assignment Not Implemented - - using ContainterType = QVector; + static Pointer NullPointer(); /** - * @brief GetTypeName Returns a string representation of the type of data that is stored by this class. This - * can be a primitive like char, float, int or the name of a class. - * @return + * @brief Returns the name of the class for AbstractMessage */ - void getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) override - { - T value = static_cast(0x00); - xdmfTypeName = "UNKNOWN"; - precision = 0; - if(typeid(value) == typeid(int8_t)) - { - xdmfTypeName = "Char"; - precision = 1; - } - if(typeid(value) == typeid(uint8_t)) - { - xdmfTypeName = "UChar"; - precision = 1; - } - - if(typeid(value) == typeid(int16_t)) - { - xdmfTypeName = "Int"; - precision = 2; - } - if(typeid(value) == typeid(uint16_t)) - { - xdmfTypeName = "UInt"; - precision = 2; - } - - if(typeid(value) == typeid(int32_t)) - { - xdmfTypeName = "Int"; - precision = 4; - } - if(typeid(value) == typeid(uint32_t)) - { - xdmfTypeName = "UInt"; - precision = 4; - } - - if(typeid(value) == typeid(int64_t)) - { - xdmfTypeName = "Int"; - precision = 8; - } - if(typeid(value) == typeid(uint64_t)) - { - xdmfTypeName = "UInt"; - precision = 8; - } - - if(typeid(value) == typeid(float)) - { - xdmfTypeName = "Float"; - precision = 4; - } - if(typeid(value) == typeid(double)) - { - xdmfTypeName = "Float"; - precision = 8; - } - - if(typeid(value) == typeid(bool)) - { - xdmfTypeName = "uchar"; - precision = 1; - } - } + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for AbstractMessage + */ + static QString ClassName(); /** - * @brief GetTypeName Returns a string representation of the type of data that is stored by this class. This - * can be a primitive like char, float, int or the name of a class. + * @brief Returns the version of this class. * @return */ + int32_t getClassVersion() const override; - SIMPL::NumericTypes::Type getType() - { - T value = static_cast(0x00); - if(typeid(value) == typeid(int8_t)) - { - return SIMPL::NumericTypes::Type::Int8; - } - if(typeid(value) == typeid(uint8_t)) - { - return SIMPL::NumericTypes::Type::UInt8; - } + DataArray(const DataArray&) = default; // Copy Constructor default Implemented + DataArray(DataArray&&) = delete; // Move Constructor Not Implemented + DataArray& operator=(const DataArray&) = delete; // Copy Assignment Not Implemented + DataArray& operator=(DataArray&&) = delete; // Move Assignment Not Implemented - if(typeid(value) == typeid(int16_t)) - { - return SIMPL::NumericTypes::Type::Int16; - } - if(typeid(value) == typeid(uint16_t)) - { - return SIMPL::NumericTypes::Type::UInt16; - } + //========================================= STL INTERFACE COMPATIBILITY ================================= + using comp_dims_type = std::vector; + using size_type = size_t; + using value_type = T; + using reference = T&; + using pointer = T*; + using difference_type = ptrdiff_t; - if(typeid(value) == typeid(int32_t)) - { - return SIMPL::NumericTypes::Type::Int32; - } - if(typeid(value) == typeid(uint32_t)) - { - return SIMPL::NumericTypes::Type::UInt32; - } + //========================================= SIMPL INTERFACE COMPATIBILITY ================================= + using ContainterType = std::vector; - if(typeid(value) == typeid(int64_t)) - { - return SIMPL::NumericTypes::Type::Int64; - } - if(typeid(value) == typeid(uint64_t)) - { - return SIMPL::NumericTypes::Type::UInt64; - } + //========================================= Constructing DataArray Objects ================================= + DataArray(); - if(typeid(value) == typeid(float)) - { - return SIMPL::NumericTypes::Type::Float; - } - if(typeid(value) == typeid(double)) - { - return SIMPL::NumericTypes::Type::Double; - } + /** + * @brief Constructor + * @param numTuples The number of Tuples in the DataArray + * @param name The name of the DataArray + * @param initValue The value to use when initializing each element of the array + */ + DataArray(size_t numTuples, const QString& name, T initValue); + /** + * @brief DataArray + * @param numTuples The number of Tuples in the DataArray + * @param name The name of the DataArray + * @param compDims The number of elements in each axis dimension. + * @param initValue The value to use when initializing each element of the array + * + * For example if you have a 2D image dimensions of 80(w) x 60(h) then the "cdims" would be [80][60] + */ + DataArray(size_t numTuples, const QString& name, const comp_dims_type& compDims, T initValue); - if(typeid(value) == typeid(bool)) - { - return SIMPL::NumericTypes::Type::Bool; - } + /** + * @brief Protected Constructor + * @param numTuples The number of Tuples in the DataArray + * @param name The name of the DataArray + * @param compDims The number of elements in each axis dimension. + * @param initValue The value to use when initializing each element of the array + * @param allocate Will all the memory be allocated at time of construction + */ + DataArray(size_t numTuples, const QString& name, const comp_dims_type& compDims, T initValue, bool allocate); - return SIMPL::NumericTypes::Type::UnknownNumType; - } + ~DataArray() override; + //========================================= Static Constructing DataArray Objects ================================= /** * @brief Static constructor * @param numElements The number of elements in the internal array. * @param name The name of the array + * @param allocate Will all the memory be allocated at time of construction * @return Std::Shared_Ptr wrapping an instance of DataArrayTemplate */ - static Pointer CreateArray(size_t numElements, const QString& name, bool allocate = true) - { - if(name.isEmpty()) - { - return NullPointer(); - } - QVector cDims(1, 1); - auto d = new DataArray(numElements, cDims, name, allocate); - if(allocate) - { - if(d->allocate() < 0) - { - // Could not allocate enough memory, reset the pointer to null and return - delete d; - return DataArray::NullPointer(); - } - } - Pointer ptr(d); - return ptr; - } + static Pointer CreateArray(size_t numTuples, const QString& name, bool allocate); + static Pointer CreateArray(size_t numTuples, const std::string& name, bool allocate); /** * @brief Static constructor @@ -250,119 +148,53 @@ template class DataArray : public IDataArray * @param rank The number of dimensions of the attribute on each Tuple * @param dims The actual dimensions of the attribute on each Tuple * @param name The name of the array + * @param allocate Will all the memory be allocated at time of construction * @return Std::Shared_Ptr wrapping an instance of DataArrayTemplate */ - static Pointer CreateArray(size_t numTuples, int rank, const size_t* dims, const QString& name, bool allocate = true) - { - if(name.isEmpty()) - { - return NullPointer(); - } - QVector cDims(rank); - for(int i = 0; i < rank; i++) - { - cDims[i] = dims[i]; - } - auto d = new DataArray(numTuples, cDims, name, allocate); - if(allocate) - { - if(d->allocate() < 0) - { - // Could not allocate enough memory, reset the pointer to null and return - delete d; - return DataArray::NullPointer(); - } - } - Pointer ptr(d); - return ptr; - } + static Pointer CreateArray(size_t numTuples, int32_t rank, const size_t* dims, const QString& name, bool allocate); /** * @brief Static constructor * @param numTuples The number of tuples in the array. - * @param dims The actual dimensions of the attribute on each Tuple + * @param compDims The actual dimensions of the attribute on each Tuple * @param name The name of the array + * @param allocate Will all the memory be allocated at time of construction * @return Std::Shared_Ptr wrapping an instance of DataArrayTemplate */ - static Pointer CreateArray(size_t numTuples, const std::vector& cDims, const QString& name, bool allocate = true) - { - if(name.isEmpty()) - { - return NullPointer(); - } - DataArray* d = new DataArray(numTuples, QVector::fromStdVector(cDims), name, allocate); - if(allocate) - { - if(d->allocate() < 0) - { - // Could not allocate enough memory, reset the pointer to null and return - delete d; - return DataArray::NullPointer(); - } - } - Pointer ptr(d); - return ptr; - } + static Pointer CreateArray(size_t numTuples, const comp_dims_type& compDims, const QString& name, bool allocate); /** * @brief Static constructor * @param numTuples The number of tuples in the array. - * @param dims The actual dimensions of the attribute on each Tuple + * @param tDims The actual dimensions of the Tuples + * @param compDims The number of elements in each axis dimension. * @param name The name of the array + * @param allocate Will all the memory be allocated at time of construction * @return Std::Shared_Ptr wrapping an instance of DataArrayTemplate */ - static Pointer CreateArray(size_t numTuples, QVector cDims, const QString& name, bool allocate = true) - { - if(name.isEmpty()) - { - return NullPointer(); - } - auto d = new DataArray(numTuples, cDims, name, allocate); - if(allocate) - { - if(d->allocate() < 0) - { - // Could not allocate enough memory, reset the pointer to null and return - delete d; - return DataArray::NullPointer(); - } - } - Pointer ptr(d); - return ptr; - } + static Pointer CreateArray(const comp_dims_type& tupleDims, const comp_dims_type& compDims, const QString& name, bool allocate); + //========================================= Instance Constructing DataArray Objects ================================= /** - * @brief Static constructor + * @brief createNewArray Creates a new DataArray object using the same POD type as the existing instance * @param numTuples The number of tuples in the array. - * @param tDims The actual dimensions of the Tuples - * @param cDims The actual dimensions of the attribute on each Tuple + * @param rank The number of dimensions of the attribute on each Tuple + * @param dims The actual dimensions of the attribute on each Tuple + * @param name The name of the array + * @param allocate Will all the memory be allocated at time of construction + * @return + */ + IDataArray::Pointer createNewArray(size_t numTuples, int32_t rank, const size_t* compDims, const QString& name, bool allocate) const override; + + /** + * @brief createNewArray + * @param numTuples The number of tuples in the array. + * @param compDims The number of elements in each axis dimension. * @param name The name of the array + * @param allocate Will all the memory be allocated at time of construction * @return Std::Shared_Ptr wrapping an instance of DataArrayTemplate */ - static Pointer CreateArray(QVector tDims, QVector cDims, const QString& name, bool allocate = true) - { - if(name.isEmpty()) - { - return NullPointer(); - } - size_t numTuples = tDims[0]; - for(int i = 1; i < tDims.size(); i++) - { - numTuples *= tDims[i]; - } - auto d = new DataArray(numTuples, cDims, name, allocate); - if(allocate) - { - if(d->allocate() < 0) - { - // Could not allocate enough memory, reset the pointer to null and return - delete d; - return DataArray::NullPointer(); - } - } - Pointer ptr(d); - return ptr; - } + IDataArray::Pointer createNewArray(size_t numTuples, const comp_dims_type& compDims, const QString& name, bool allocate) const override; /** * @brief Static Method to create a DataArray from a QVector through a deep copy of the data @@ -371,34 +203,16 @@ template class DataArray : public IDataArray * @param name The name of the array * @return Std::Shared_Ptr wrapping an instance of DataArrayTemplate */ - static Pointer FromQVector(QVector& vec, const QString& name, bool allocate = true) - { - - Pointer p = CreateArray(vec.size(), name, allocate); - if(nullptr != p.get()) - { - std::memcpy(p->getPointer(0), vec.data(), vec.size() * sizeof(T)); - } - return p; - } + static Pointer FromQVector(const QVector& vec, const QString& name); /** - * @brief Static Method to create a DataArray from a QVector through a deep copy of the data + * @brief Static Method to create a DataArray from a std::vector through a deep copy of the data * contained in the vector. The number of components will be set to 1. * @param vec The vector to copy the data from * @param name The name of the array * @return Std::Shared_Ptr wrapping an instance of DataArrayTemplate */ - static Pointer FromStdVector(std::vector& vec, const QString& name, bool allocate = true) - { - QVector cDims(1, 1); - Pointer p = CreateArray(vec.size(), cDims, name, allocate); - if(nullptr != p.get()) - { - std::memcpy(p->getPointer(0), &(vec.front()), vec.size() * sizeof(T)); - } - return p; - } + static Pointer FromStdVector(const std::vector& vec, const QString& name); /** * @brief FromPointer Creates a DataArray object with a DEEP COPY of the data @@ -407,15 +221,7 @@ template class DataArray : public IDataArray * @param name * @return */ - static Pointer CopyFromPointer(T* data, size_t size, const QString& name, bool allocate = true) - { - Pointer p = CreateArray(size, name, allocate); - if(nullptr != p.get()) - { - std::memcpy(p->getPointer(0), data, size * sizeof(T)); - } - return p; - } + static Pointer CopyFromPointer(const T* data, size_t size, const QString& name); /** * @brief WrapPointer Creates a DataArray object that references the pointer. The original caller can @@ -428,23 +234,31 @@ template class DataArray : public IDataArray * @param ownsData * @return */ - static Pointer WrapPointer(T* data, size_t numTuples, QVector cDims, const QString& name, bool ownsData) - { - // Allocate on the heap - auto d = new DataArray(numTuples, cDims, name, false); - // Wrap that heap pointer with a shared_pointer to make it reference counted - Pointer p(d); + static Pointer WrapPointer(T* data, size_t numTuples, const comp_dims_type& compDims, const QString& name, bool ownsData); - p->m_Array = data; // Now set the internal array to the raw pointer - p->m_OwnsData = ownsData; // Set who owns the data, i.e., who is going to "free" the memory - if(nullptr != data) - { - p->m_IsAllocated = true; - } + //========================================= Begin API ================================= - return p; - } + /** + * @brief deepCopy + * @param forceNoAllocate + * @return + */ + IDataArray::Pointer deepCopy(bool forceNoAllocate = false) const override; + + /** + * @brief GetTypeName Returns a string representation of the type of data that is stored by this class. This + * can be a primitive like char, float, int or the name of a class. + * @return + */ + SIMPL::NumericTypes::Type getType() const; + + /** + * @brief GetTypeName Returns a string representation of the type of data that is stored by this class. This + * can be a primitive like char, float, int or the name of a class. + * @return + */ + void getXdmfTypeAndSize(QString& xdmfTypeName, int32_t& precision) const override; // This line must be here, because we are overloading the copyData pure virtual function in IDataArray. // This is required so that other classes can call this version of copyData from the subclasses. using IDataArray::copyFromArray; @@ -468,252 +282,61 @@ template class DataArray : public IDataArray * @param sourceArray * @return */ - bool copyFromArray(size_t destTupleOffset, IDataArray::Pointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) override - { - if(!m_IsAllocated) - { - return false; - } - if(nullptr == m_Array) - { - return false; - } - if(destTupleOffset > m_MaxId) - { - return false; - } - if(!sourceArray->isAllocated()) - { - return false; - } - Self* source = dynamic_cast(sourceArray.get()); - if(nullptr == source->getPointer(0)) - { - return false; - } - - if(sourceArray->getNumberOfComponents() != getNumberOfComponents()) - { - return false; - } - - if(srcTupleOffset + totalSrcTuples > sourceArray->getNumberOfTuples()) - { - return false; - } - - if(totalSrcTuples * sourceArray->getNumberOfComponents() + destTupleOffset * getNumberOfComponents() > m_Size) - { - return false; - } - - size_t elementStart = destTupleOffset * getNumberOfComponents(); - size_t totalBytes = (totalSrcTuples * sourceArray->getNumberOfComponents()) * sizeof(T); - std::memcpy(m_Array + elementStart, source->getPointer(srcTupleOffset * sourceArray->getNumberOfComponents()), totalBytes); - return true; - } + bool copyFromArray(size_t destTupleOffset, IDataArray::ConstPointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) override; /** * @brief copyIntoArray * @param dest */ - bool copyIntoArray(Pointer dest) - { - if(m_IsAllocated && dest->isAllocated() && m_Array && dest->getPointer(0)) - { - size_t totalBytes = m_Size * sizeof(T); - std::memcpy(dest->getPointer(0), m_Array, totalBytes); - return true; - } - return false; - } + bool copyIntoArray(Pointer dest) const; /** - * @brief createNewArray - * @param numTuples - * @param rank - * @param dims - * @param name + * @brief isAllocated * @return */ - IDataArray::Pointer createNewArray(size_t numTuples, int rank, size_t* dims, const QString& name, bool allocate = true) override - { - IDataArray::Pointer p = DataArray::CreateArray(numTuples, rank, dims, name, allocate); - return p; - } - + bool isAllocated() const override; /** - * @brief createNewArray - * @param numTuples - * @param dims - * @param name - * @return + * @brief Gives this array a human readable name + * @param name The name of this array */ - IDataArray::Pointer createNewArray(size_t numTuples, std::vector dims, const QString& name, bool allocate = true) override - { - IDataArray::Pointer p = DataArray::CreateArray(numTuples, dims, name, allocate); - return p; - } + void setInitValue(T initValue); /** - * @brief createNewArray - * @param numTuples - * @param dims - * @param name + * @brief Returns the initial value for the array. * @return */ - IDataArray::Pointer createNewArray(size_t numTuples, QVector dims, const QString& name, bool allocate = true) override + T getInitValue() const { - IDataArray::Pointer p = DataArray::CreateArray(numTuples, dims, name, allocate); - return p; + return m_InitValue; } /** - * @brief Destructor + * @brief Makes this class responsible for freeing the memory */ - ~DataArray() override - { - // qDebug() << "~DataArrayTemplate '" << m_Name << "'" ; - if((nullptr != m_Array) && (true == m_OwnsData)) - { - _deallocate(); - } - } + void takeOwnership() override; /** - * @brief isAllocated - * @return + * @brief This class will NOT free the memory associated with the internal pointer. + * This can be useful if the user wishes to keep the data around after this + * class goes out of scope. */ - bool isAllocated() override - { - return m_IsAllocated; - } + void releaseOwnership() override; /** - * @brief Gives this array a human readable name - * @param name The name of this array + * @brief Allocates the memory needed for this class + * @return 1 on success, -1 on failure */ - virtual void setInitValue(T initValue) - { - m_InitValue = initValue; - } + int32_t allocate(); /** - * @brief Gives this array a human readable name - * @param name The name of this array + * @brief Sets all the values to zero. */ - void setName(const QString& name) override - { - m_Name = name; - } + void initializeWithZeros() override; /** - * @brief Returns the human readable name of this array - * @return + * @brief Sets all the values to value. */ - QString getName() override - { - return m_Name; - } - - /** - * @brief Makes this class responsible for freeing the memory - */ - void takeOwnership() override - { - m_OwnsData = true; - } - - /** - * @brief This class will NOT free the memory associated with the internal pointer. - * This can be useful if the user wishes to keep the data around after this - * class goes out of scope. - */ - void releaseOwnership() override - { - m_OwnsData = false; - } - - /** - * @brief Allocates the memory needed for this class - * @return 1 on success, -1 on failure - */ - virtual int32_t allocate() - { - if((nullptr != m_Array) && (true == m_OwnsData)) - { - _deallocate(); - } - m_Array = nullptr; - m_OwnsData = true; - m_IsAllocated = false; - if(m_Size == 0) - { - clear(); - return 1; - } - - size_t newSize = m_Size; -#if defined(AIM_USE_SSE) && defined(__SSE2__) - m_Array = static_cast(_mm_malloc(newSize * sizeof(T), 16)); -#else - m_Array = (T*)malloc(newSize * sizeof(T)); -#endif - if(!m_Array) - { - qDebug() << "Unable to allocate " << newSize << " elements of size " << sizeof(T) << " bytes. "; - return -1; - } - m_Size = newSize; - m_IsAllocated = true; - - return 1; - } - - /** - * @brief Removes all elements from the array (which are destroyed), leaving the container with a size of 0. - */ - virtual void clear() - { - if(nullptr != m_Array && true == m_OwnsData) - { - _deallocate(); - } - m_Array = nullptr; - m_Size = 0; - m_OwnsData = true; - m_MaxId = 0; - m_IsAllocated = false; - m_NumTuples = 0; - } - - /** - * @brief Sets all the values to zero. - */ - void initializeWithZeros() override - { - if(!m_IsAllocated || nullptr == m_Array) - { - return; - } - size_t typeSize = sizeof(T); - ::memset(m_Array, 0, m_Size * typeSize); - } - - /** - * @brief Sets all the values to value. - */ - virtual void initializeWithValue(T initValue, size_t offset = 0) - { - if(!m_IsAllocated || nullptr == m_Array) - { - return; - } - for(size_t i = offset; i < m_Size; i++) - { - m_Array[i] = initValue; - } - } + void initializeWithValue(T initValue, size_t offset = 0); /** * @brief Removes Tuples from the m_Array. If the size of the vector is Zero nothing is done. If the size of the @@ -723,115 +346,7 @@ template class DataArray : public IDataArray * @param idxs The indices to remove * @return error code. */ - int eraseTuples(QVector& idxs) override - { - int err = 0; - - // If nothing is to be erased just return - if(idxs.empty()) - { - return 0; - } - auto idxs_size = static_cast(idxs.size()); - if(idxs_size >= getNumberOfTuples()) - { - resize(0); - return 0; - } - - // Sanity Check the Indices in the vector to make sure we are not trying to remove any indices that are - // off the end of the array and return an error code. - for(size_t& idx : idxs) - { - if(idx * m_NumComponents > m_MaxId) - { - return -100; - } - } - - // Calculate the new size of the array to copy into - size_t newSize = (getNumberOfTuples() - idxs.size()) * m_NumComponents; - - // Create a new m_Array to copy into - T* newArray = (T*)malloc(newSize * sizeof(T)); - // Splat AB across the array so we know if we are copying the values or not - ::memset(newArray, 0xAB, newSize * sizeof(T)); - - // Keep the current Destination Pointer - T* currentDest = newArray; - size_t j = 0; - int k = 0; - // Find the first chunk to copy by walking the idxs array until we get an - // index that is NOT a continuous increment from the start - for(k = 0; k < idxs.size(); ++k) - { - if(j == idxs[k]) - { - ++j; - } - else - { - break; - } - } - - if(k == idxs.size()) // Only front elements are being dropped - { - T* currentSrc = m_Array + (j * m_NumComponents); - std::memcpy(currentDest, currentSrc, (getNumberOfTuples() - idxs.size()) * m_NumComponents * sizeof(T)); - _deallocate(); // We are done copying - delete the current m_Array - m_Size = newSize; - m_Array = newArray; - m_OwnsData = true; - m_MaxId = newSize - 1; - m_IsAllocated = true; - return 0; - } - - QVector srcIdx(idxs.size() + 1); - QVector destIdx(idxs.size() + 1); - QVector copyElements(idxs.size() + 1); - srcIdx[0] = 0; - destIdx[0] = 0; - copyElements[0] = (idxs[0] - 0) * m_NumComponents; - - for(int i = 1; i < srcIdx.size(); ++i) - { - srcIdx[i] = (idxs[i - 1] + 1) * m_NumComponents; - - if(i < srcIdx.size() - 1) - { - copyElements[i] = (idxs[i] - idxs[i - 1] - 1) * m_NumComponents; - } - else - { - copyElements[i] = (getNumberOfTuples() - idxs[i - 1] - 1) * m_NumComponents; - } - destIdx[i] = copyElements[i - 1] + destIdx[i - 1]; - } - - // Copy the data - for(int i = 0; i < srcIdx.size(); ++i) - { - currentDest = newArray + destIdx[i]; - T* currentSrc = m_Array + srcIdx[i]; - size_t bytes = copyElements[i] * sizeof(T); - std::memcpy(currentDest, currentSrc, bytes); - } - - // We are done copying - delete the current m_Array - _deallocate(); - - // Allocation was successful. Save it. - m_Size = newSize; - m_Array = newArray; - // This object has now allocated its memory and owns it. - m_OwnsData = true; - m_IsAllocated = true; - m_MaxId = newSize - 1; - - return err; - } + int32_t eraseTuples(const comp_dims_type& idxs) override; /** * @brief @@ -839,19 +354,7 @@ template class DataArray : public IDataArray * @param newPos * @return */ - int copyTuple(size_t currentPos, size_t newPos) override - { - size_t max = ((m_MaxId + 1) / m_NumComponents); - if(currentPos >= max || newPos >= max) - { - return -1; - } - T* src = m_Array + (currentPos * m_NumComponents); - T* dest = m_Array + (newPos * m_NumComponents); - size_t bytes = sizeof(T) * m_NumComponents; - std::memcpy(dest, src, bytes); - return 0; - } + int32_t copyTuple(size_t currentPos, size_t newPos) override; /** * @brief Returns the number of bytes that make up the data type. @@ -860,46 +363,31 @@ template class DataArray : public IDataArray * 4 = 32 bit integer/Float * 8 = 64 bit integer/Double */ - size_t getTypeSize() override - { - return sizeof(T); - } + size_t getTypeSize() const override; /** * @brief Returns the number of elements in the internal array. */ - size_t getNumberOfTuples() override - { - return m_NumTuples; - } + size_t getNumberOfTuples() const override; /** * @brief Returns the total number of elements that make up this array. Equal to NumTuples * NumComponents */ - size_t getSize() override - { - return m_Size; - } + size_t getSize() const override; /** * @brief Returns the dimensions for the data residing at each Tuple. For example if you have a simple Scalar value * at each tuple then this will return a single element QVector. If you have a 1x3 array (like EUler Angles) then * this will return a 3 Element QVector. */ - QVector getComponentDimensions() override - { - return m_CompDims; - } + comp_dims_type getComponentDimensions() const override; /** * @brief Returns the number component values at each Tuple location. For example if you have a * 3 element component (vector) then this will be 3. If you are storing a small image of size 80x60 * at each Tuple (like EBSD Kikuchi patterns) then the result would be 4800. */ - int getNumberOfComponents() override - { - return m_NumComponents; - } + int32_t getNumberOfComponents() const override; /** * @brief Returns a void pointer pointing to the index of the array. nullptr @@ -908,41 +396,7 @@ template class DataArray : public IDataArray * @param i The index to have the returned pointer pointing to. * @return Void Pointer. Possibly nullptr. */ - void* getVoidPointer(size_t i) override - { - if(i >= m_Size) - { - return nullptr; - } - - return (void*)(&(m_Array[i])); - } - - /** - * @brief Returns a list of the contents of DataArray (For Python Binding) - * @return std::list. Possibly empty - */ - std::list getArray() - { - return std::list(m_Array, m_Array + (m_Size * sizeof(T)) / sizeof(T)); - } - - /** - * @brief Sets the contents of the array to the list (For Python Binding) - * @param std::list. New array contents - */ - void setArray(std::list newArray) - { - if(newArray.size() != m_Size) - { - return; - } - int i = 0; - for(auto elem : newArray) - { - m_Array[i++] = elem; - } - } + void* getVoidPointer(size_t i) override; /** * @brief Returns the pointer to a specific index into the array. No checks are made @@ -951,61 +405,25 @@ template class DataArray : public IDataArray * @param i The index to return the pointer to. * @return The pointer to the index */ - virtual T* getPointer(size_t i) - { -#ifndef NDEBUG - if(m_Size > 0) - { - Q_ASSERT(i < m_Size); - } -#endif - return (T*)(&(m_Array[i])); - } + T* getPointer(size_t i) const; /** * @brief Returns the value for a given index * @param i The index to return the value at * @return The value at index i */ - virtual T getValue(size_t i) - { -#ifndef NDEBUG - if(m_Size > 0) - { - Q_ASSERT(i < m_Size); - } -#endif - return m_Array[i]; - } + T getValue(size_t i) const; /** * @brief Sets a specific value in the array * @param i The index of the value to set * @param value The new value to be set at the specified index */ - void setValue(size_t i, T value) - { -#ifndef NDEBUG - if(m_Size > 0) - { - Q_ASSERT(i < m_Size); - } -#endif - m_Array[i] = value; - } + void setValue(size_t i, T value); //---------------------------------------------------------------------------- // These can be overridden for more efficiency - T getComponent(size_t i, int j) - { -#ifndef NDEBUG - if(m_Size > 0) - { - Q_ASSERT(i * m_NumComponents + j < m_Size); - } -#endif - return m_Array[i * m_NumComponents + j]; - } + T getComponent(size_t i, int32_t j) const; /** * @brief Sets a specific component of the Tuple located at i @@ -1013,757 +431,847 @@ template class DataArray : public IDataArray * @param j The Component index into the Tuple * @param c The value to set */ - void setComponent(size_t i, int j, T c) - { -#ifndef NDEBUG - if(m_Size > 0) - { - Q_ASSERT(i * m_NumComponents + j < m_Size); - } -#endif - m_Array[i * m_NumComponents + j] = c; - } + void setComponent(size_t i, int32_t j, T c); /** * @brief setTuple * @param tupleIndex * @param data */ - void setTuple(size_t tupleIndex, T* data) - { -#ifndef NDEBUG - if(m_Size > 0) - { - Q_ASSERT(tupleIndex * m_NumComponents + (m_NumComponents - 1) < m_Size); - } -#endif - std::memcpy(getTuplePointer(tupleIndex), data, m_NumComponents * sizeof(T)); - } + void setTuple(size_t tupleIndex, const T* data); /** * @brief setTuple * @param tupleIndex * @param data */ - void setTuple(size_t tupleIndex, const std::vector& data) + void setTuple(size_t tupleIndex, const std::vector& data); + + /** + * @brief Splats the same value c across all values in the Tuple + * @param i The index of the Tuple + * @param c The value to splat across all components in the tuple + */ + void initializeTuple(size_t i, const void* p) override; + + /** + * @brief Sets all the components of tuple i to value + * @param i + * @param value + */ + void fillTuple(size_t i, T value); + + /** + * @brief getTuplePointer Returns the pointer to a specific tuple + * @param tupleIndex The index of tuple + */ + T* getTuplePointer(size_t tupleIndex) const; + + /** + * @brief resize + * @param numTuples + * @return + */ + void resizeTuples(size_t numTuples) override; + + /** + * @brief printTuple + * @param out + * @param i + * @param delimiter + */ + void printTuple(QTextStream& out, size_t i, char delimiter = ',') const override; + + /** + * @brief printComponent + * @param out + * @param i + * @param j + */ + void printComponent(QTextStream& out, size_t i, int32_t j) const override; + + /** + * @brief Returns the HDF Type for a given primitive value. + * @param value A value to use. Can be anything. Just used to get the type info + * from + * @return The HDF5 native type for the value + */ + QString getFullNameOfClass() const; + + /** + * @brief getTypeAsString + * @return + */ + QString getTypeAsString() const override; + + /** + * + * @param parentId + * @return + */ + int32_t writeH5Data(hid_t parentId, const comp_dims_type& tDims) const override; + + /** + * @brief writeXdmfAttribute + * @param out + * @param volDims + * @return + */ + int32_t writeXdmfAttribute(QTextStream& out, const int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& label) const override; + + /** + * @brief Returns a ToolTipGenerator for creating HTML tooltip tables + * with values populated to match the current DataArray. + * @return + */ + ToolTipGenerator getToolTipGenerator() const override { -#ifndef NDEBUG - if(m_Size > 0) + ToolTipGenerator toolTipGen; + QLocale usa(QLocale::English, QLocale::UnitedStates); + + toolTipGen.addTitle("Attribute Array Info"); + toolTipGen.addValue("Name", getName()); + toolTipGen.addValue("Type", getTypeAsString()); + toolTipGen.addValue("Number of Tuples", usa.toString(static_cast(getNumberOfTuples()))); + + QString compDimStr = "("; + for(size_t i = 0; i < m_CompDims.size(); i++) { - Q_ASSERT(tupleIndex * m_NumComponents + (m_NumComponents - 1) < m_Size); + compDimStr = compDimStr + QString::number(m_CompDims[i]); + if(i < m_CompDims.size() - 1) + { + compDimStr = compDimStr + QString(", "); + } } -#endif - std::memcpy(getTuplePointer(tupleIndex), data.data(), m_NumComponents * sizeof(T)); + compDimStr += ")"; + toolTipGen.addValue("Component Dimensions", compDimStr); + toolTipGen.addValue("Total Elements", usa.toString(static_cast(m_Size))); + toolTipGen.addValue("Total Memory Required", usa.toString(static_cast(m_Size * sizeof(T)))); + + return toolTipGen; } /** - * @brief Splats the same value c across all values in the Tuple - * @param i The index of the Tuple - * @param c The value to splat across all components in the tuple + * @brief getInfoString + * @return Returns a formatted string that contains general infomation about + * the instance of the object. */ - void initializeTuple(size_t i, void* p) override + QString getInfoString(SIMPL::InfoStringFormat format) const override; + + /** + * @brief + * @param parentId + * @return + */ + int32_t readH5Data(hid_t parentId) override; + + /** + * @brief + */ + void byteSwapElements(); + + //========================================= STL INTERFACE COMPATIBILITY ================================= + + class tuple_iterator { - if(!m_IsAllocated) + public: + using self_type = tuple_iterator; + using value_type = T; + using reference = T&; + using pointer = T*; + using difference_type = ptrdiff_t; + using iterator_category = std::random_access_iterator_tag; + + tuple_iterator() = delete; + + self_type& operator++() + { + ptr_ += num_comps_; + return *this; + } // PREFIX + self_type operator++([[maybe_unused]] int32_t unused) + { + self_type i = *this; + ptr_ += num_comps_; + return i; + } // POSTFIX + self_type& operator--() + { + ptr_ -= num_comps_; + return *this; + } // PREFIX + self_type operator--([[maybe_unused]] int32_t unused) + { + self_type i = *this; + ptr_ -= num_comps_; + return i; + } // POSTFIX + self_type& operator+=(difference_type amt) + { + ptr_ += amt * num_comps_; + return *this; + } + self_type operator+(difference_type amt) const + { + return self_type(ptr_ + amt * num_comps_, num_comps_); + } + self_type& operator-=(difference_type amt) + { + ptr_ -= amt * num_comps_; + return *this; + } + self_type operator-(difference_type amt) const + { + return self_type(ptr_ - amt * num_comps_, num_comps_); + } + difference_type operator-(const self_type& rhs) const + { + return (ptr_ - rhs.ptr_) / static_cast(num_comps_); + } + friend self_type operator+(difference_type lhs, const self_type& rhs) + { + return self_type(lhs * rhs.num_comps_ + rhs.ptr_, rhs.num_comps_); + } + reference operator[](difference_type amt) const + { + return ptr_[amt * num_comps_]; + } + reference operator*() const + { + return *ptr_; + } + pointer operator->() const + { + return ptr_; + } + bool operator==(const self_type& rhs) const + { + return ptr_ == rhs.ptr_; + } + bool operator!=(const self_type& rhs) const + { + return ptr_ != rhs.ptr_; + } + bool operator>(const self_type& rhs) const + { + return ptr_ > rhs.ptr_; + } + bool operator<(const self_type& rhs) const + { + return ptr_ < rhs.ptr_; + } + bool operator>=(const self_type& rhs) const + { + return ptr_ >= rhs.ptr_; + } + bool operator<=(const self_type& rhs) const + { + return ptr_ <= rhs.ptr_; + } + + reference comp_value(size_type comp) + { + return *(ptr_ + comp); + } + + protected: + tuple_iterator(pointer ptr, size_type numComps) + : ptr_(ptr) + , num_comps_(numComps) + { + } + + friend class DataArray; + + private: + pointer ptr_; + size_t num_comps_; + }; + + class const_tuple_iterator + { + public: + using self_type = const_tuple_iterator; + using value_type = T; + using reference = const T&; + using pointer = const T*; + using difference_type = ptrdiff_t; + using iterator_category = std::random_access_iterator_tag; + + const_tuple_iterator() = delete; + + self_type& operator++() + { + ptr_ += num_comps_; + return *this; + } // PREFIX + self_type operator++([[maybe_unused]] int32_t unused) + { + self_type i = *this; + ptr_ += num_comps_; + return i; + } // POSTFIX + self_type& operator--() + { + ptr_ -= num_comps_; + return *this; + } // PREFIX + self_type operator--([[maybe_unused]] int32_t unused) + { + self_type i = *this; + ptr_ -= num_comps_; + return i; + } // POSTFIX + self_type& operator+=(difference_type amt) + { + ptr_ += amt * num_comps_; + return *this; + } + self_type operator+(difference_type amt) const + { + return self_type(ptr_ + amt * num_comps_, num_comps_); + } + self_type& operator-=(difference_type amt) + { + ptr_ -= amt * num_comps_; + return *this; + } + self_type operator-(difference_type amt) const + { + return self_type(ptr_ - amt * num_comps_, num_comps_); + } + difference_type operator-(const self_type& rhs) const + { + return (ptr_ - rhs.ptr_) / static_cast(num_comps_); + } + friend self_type operator+(difference_type lhs, const self_type& rhs) + { + return self_type(lhs * rhs.num_comps_ + rhs.ptr_, rhs.num_comps_); + } + reference operator[](difference_type amt) const + { + return ptr_[amt * num_comps_]; + } + reference operator*() const { - return; + return *ptr_; } -#ifndef NDEBUG - if(m_Size > 0) + pointer operator->() const { - Q_ASSERT(i * m_NumComponents < m_Size); + return ptr_; } -#endif - if(nullptr == p) + bool operator==(const self_type& rhs) const { - return; + return ptr_ == rhs.ptr_; } - T* c = reinterpret_cast(p); - for(size_t j = 0; j < m_NumComponents; ++j) + bool operator!=(const self_type& rhs) const { - m_Array[i * m_NumComponents + j] = *c; + return ptr_ != rhs.ptr_; } - } - - /** - * @brief getTuplePointer Returns the pointer to a specific tuple - * @param tupleIndex The index of tuple - */ - T* getTuplePointer(size_t tupleIndex) - { -#ifndef NDEBUG - if(m_Size > 0) + bool operator>(const self_type& rhs) const { - Q_ASSERT(tupleIndex * m_NumComponents < m_Size); + return ptr_ > rhs.ptr_; } -#endif - return m_Array + (tupleIndex * m_NumComponents); - } - - /** - * @brief resize - * @param numTuples - * @return - */ - int32_t resize(size_t numTuples) override - { - int32_t check = resizeTotalElements(numTuples * m_NumComponents); - if(check > 0) + bool operator<(const self_type& rhs) const { - m_NumTuples = numTuples; + return ptr_ < rhs.ptr_; } - return check; - } - - /** - * @brief printTuple - * @param out - * @param i - * @param delimiter - */ - void printTuple(QTextStream& out, size_t i, char delimiter = ',') override - { - int precision = out.realNumberPrecision(); - T value = static_cast(0x00); - if(typeid(value) == typeid(float)) + bool operator>=(const self_type& rhs) const { - out.setRealNumberPrecision(8); + return ptr_ >= rhs.ptr_; } - if(typeid(value) == typeid(double)) + bool operator<=(const self_type& rhs) const { - out.setRealNumberPrecision(16); + return ptr_ <= rhs.ptr_; } - for(size_t j = 0; j < m_NumComponents; ++j) + reference comp_value(size_type comp) const { - if(j != 0) - { - out << delimiter; - } - out << m_Array[i * m_NumComponents + j]; + return *(ptr_ + comp); } - out.setRealNumberPrecision(precision); - } - /** - * @brief printComponent - * @param out - * @param i - * @param j - */ - void printComponent(QTextStream& out, size_t i, int j) override - { - out << m_Array[i * m_NumComponents + j]; - } + protected: + const_tuple_iterator(pointer ptr, size_type numComps) + : ptr_(ptr) + , num_comps_(numComps) + { + } - /** - * @brief Returns the HDF Type for a given primitive value. - * @param value A value to use. Can be anything. Just used to get the type info - * from - * @return The HDF5 native type for the value - */ - QString getFullNameOfClass() - { - QString theType = getTypeAsString(); - theType = "DataArray<" + theType + ">"; - return theType; - } + friend class DataArray; - /** - * @brief getTypeAsString - * @return - */ - QString getTypeAsString() override + private: + pointer ptr_; + size_t num_comps_; + }; + + class iterator { - T value = static_cast(0); - if(typeid(value) == typeid(float)) - { - return "float"; - } - if(typeid(value) == typeid(double)) + public: + using self_type = iterator; + using value_type = T; + using reference = T&; + using pointer = T*; + using difference_type = ptrdiff_t; + using iterator_category = std::random_access_iterator_tag; + + iterator() = delete; + + iterator(const self_type& iter) + : ptr_(iter.ptr_) { - return "double"; } - if(typeid(value) == typeid(int8_t)) + self_type& operator++() { - return "int8_t"; - } - if(typeid(value) == typeid(uint8_t)) + ptr_++; + return *this; + } // PREFIX + self_type operator++([[maybe_unused]] int32_t unused) + { + self_type i = *this; + ptr_++; + return i; + } // POSTFIX + self_type& operator--() + { + ptr_--; + return *this; + } // PREFIX + self_type operator--([[maybe_unused]] int32_t unused) { - return "uint8_t"; + self_type i = *this; + ptr_--; + return i; + } // POSTFIX + self_type& operator+=(difference_type amt) + { + ptr_ += amt; + return *this; } -#if CMP_TYPE_CHAR_IS_SIGNED - if(typeid(value) == typeid(char)) + self_type operator+(difference_type amt) const { - return "char"; + return self_type(ptr_ + amt); } -#else - if(typeid(value) == typeid(char)) + self_type& operator-=(difference_type amt) { - return "char"; + ptr_ -= amt; + return *this; } -#endif - if(typeid(value) == typeid(signed char)) + self_type operator-(difference_type amt) const { - return "signed char"; + return self_type(ptr_ - amt); } - if(typeid(value) == typeid(unsigned char)) + difference_type operator-(const self_type& rhs) const { - return "unsigned char"; + return ptr_ - rhs.ptr_; } - - if(typeid(value) == typeid(int16_t)) + friend self_type operator+(difference_type lhs, const self_type& rhs) { - return "int16_t"; + return self_type(lhs + rhs.ptr_); } - if(typeid(value) == typeid(short)) + reference operator[](difference_type amt) const { - return "short"; + return ptr_[amt]; } - if(typeid(value) == typeid(signed short)) + reference operator*() const { - return "signed short"; + return *ptr_; } - if(typeid(value) == typeid(uint16_t)) + pointer operator->() const { - return "uint16_t"; + return ptr_; } - if(typeid(value) == typeid(unsigned short)) + bool operator==(const self_type& rhs) const { - return "unsigned short"; + return ptr_ == rhs.ptr_; } - - if(typeid(value) == typeid(int32_t)) + bool operator!=(const self_type& rhs) const { - return "int32_t"; + return ptr_ != rhs.ptr_; } - if(typeid(value) == typeid(uint32_t)) + bool operator>(const self_type& rhs) const { - return "uint32_t"; + return ptr_ > rhs.ptr_; } -#if(CMP_SIZEOF_INT == 4) - if(typeid(value) == typeid(int)) + bool operator<(const self_type& rhs) const { - return "int"; + return ptr_ < rhs.ptr_; } - if(typeid(value) == typeid(signed int)) + bool operator>=(const self_type& rhs) const { - return "signed int"; + return ptr_ >= rhs.ptr_; } - if(typeid(value) == typeid(unsigned int)) + bool operator<=(const self_type& rhs) const { - return "unsigned int"; + return ptr_ <= rhs.ptr_; } -#endif - if(typeid(value) == typeid(int64_t)) + protected: + iterator(pointer ptr) + : ptr_(ptr) { - return "int64_t"; } - if(typeid(value) == typeid(uint64_t)) + + friend class DataArray; + + private: + pointer ptr_; + }; + + using reverse_iterator = std::reverse_iterator; + + class const_iterator + { + public: + using self_type = const_iterator; + using value_type = T; + using reference = const T&; + using pointer = const T*; + using difference_type = ptrdiff_t; + using iterator_category = std::random_access_iterator_tag; + + const_iterator() = delete; + + const_iterator(const self_type& iter) + : ptr_(iter.ptr_) { - return "uint64_t"; } -#if(CMP_SIZEOF_LONG == 4) - if(typeid(value) == typeid(long int)) + self_type& operator++() { - return "long int"; - } - if(typeid(value) == typeid(signed long int)) + ptr_++; + return *this; + } // PREFIX + self_type operator++([[maybe_unused]] int32_t unused) { - return "signed long int"; - } - if(typeid(value) == typeid(unsigned long int)) + self_type i = *this; + ptr_++; + return i; + } // POSTFIX + self_type& operator--() { - return "unsigned long int"; - } -#elif(CMP_SIZEOF_LONG == 8) - if(typeid(value) == typeid(long int)) + ptr_--; + return *this; + } // PREFIX + self_type operator--([[maybe_unused]] int32_t unused) + { + self_type i = *this; + ptr_--; + return i; + } // POSTFIX + self_type& operator+=(difference_type amt) { - return "long int"; + ptr_ += amt; + return *this; } - if(typeid(value) == typeid(signed long int)) + self_type operator+(difference_type amt) const { - return "signed long int"; + return self_type(ptr_ + amt); } - if(typeid(value) == typeid(unsigned long int)) + self_type& operator-=(difference_type amt) { - return "unsigned long int"; + ptr_ -= amt; + return *this; } -#endif - -#if(CMP_SIZEOF_LONG_LONG == 8) - if(typeid(value) == typeid(long long int)) + self_type operator-(difference_type amt) const { - return "long long int"; + return self_type(ptr_ - amt); } - if(typeid(value) == typeid(signed long long int)) + difference_type operator-(const self_type& rhs) const { - return "signed long long int"; + return ptr_ - rhs.ptr_; } - if(typeid(value) == typeid(unsigned long long int)) + friend self_type operator+(difference_type lhs, const self_type& rhs) { - return "unsigned long long int"; + return self_type(lhs + rhs.ptr_); } -#endif - - if(typeid(value) == typeid(bool)) + reference operator[](difference_type amt) const { - return "bool"; + return ptr_[amt]; } - - // qDebug() << "Error: HDFTypeForPrimitive - Unknown Type: " << (typeid(value).name()) ; - const char* name = typeid(value).name(); - if(nullptr != name && name[0] == 'l') + reference operator*() const { - qDebug() << "You are using 'long int' as a type which is not 32/64 bit safe. Suggest you use one of the H5SupportTypes defined in such as int32_t or uint32_t."; + return *ptr_; } - return "UnknownType"; - } - - /** - * @brief deepCopy - * @param forceNoAllocate - * @return - */ - IDataArray::Pointer deepCopy(bool forceNoAllocate = false) override - { - IDataArray::Pointer daCopy = createNewArray(getNumberOfTuples(), getComponentDimensions(), getName(), m_IsAllocated); - if(m_IsAllocated && !forceNoAllocate) + pointer operator->() const { - T* src = getPointer(0); - void* dest = daCopy->getVoidPointer(0); - size_t totalBytes = (getNumberOfTuples() * getNumberOfComponents() * sizeof(T)); - std::memcpy(dest, src, totalBytes); + return ptr_; } - return daCopy; - } - - /** - * - * @param parentId - * @return - */ - int writeH5Data(hid_t parentId, QVector tDims) override - { - if(m_Array == nullptr) + bool operator==(const self_type& rhs) const { - return -85648; + return ptr_ == rhs.ptr_; } - return H5DataArrayWriter::writeDataArray(parentId, this, tDims); - } - - /** - * @brief writeXdmfAttribute - * @param out - * @param volDims - * @return - */ - int writeXdmfAttribute(QTextStream& out, int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& label) override - { - if(m_Array == nullptr) + bool operator!=(const self_type& rhs) const { - return -85648; + return ptr_ != rhs.ptr_; } - QString dimStr; - int precision = 0; - QString xdmfTypeName; - getXdmfTypeAndSize(xdmfTypeName, precision); - if(0 == precision) + bool operator>(const self_type& rhs) const { - out << "" - << "\n"; - return -100; + return ptr_ > rhs.ptr_; } - - int numComp = getNumberOfComponents(); - out << " =(const self_type& rhs) const { - out << "AttributeType=\"Tensor6\" "; - dimStr = QString("%1 %2 %3 %4 ").arg(volDims[2]).arg(volDims[1]).arg(volDims[0]).arg(numComp); + return ptr_ >= rhs.ptr_; } - else if(numComp == 9) + bool operator<=(const self_type& rhs) const { - out << "AttributeType=\"Tensor\" "; - dimStr = QString("%1 %2 %3 %4 ").arg(volDims[2]).arg(volDims[1]).arg(volDims[0]).arg(numComp); + return ptr_ <= rhs.ptr_; } - else + + protected: + const_iterator(pointer ptr) + : ptr_(ptr) { - out << "AttributeType=\"Vector\" "; - dimStr = QString("%1 %2 %3 %4 ").arg(volDims[2]).arg(volDims[1]).arg(volDims[0]).arg(numComp); } - out << "Center=\"Cell\">\n"; - // Open the Tag - out << R"( \n"; - out << " " << hdfFileName << groupPath << "/" << getName() << "\n"; - out << " " - << "\n"; - out << " " - << "\n"; - return 1; - } + friend class DataArray; - /** - * @brief getInfoString - * @return Returns a formatted string that contains general infomation about - * the instance of the object. - */ - QString getInfoString(SIMPL::InfoStringFormat format) override - { + private: + pointer ptr_; + }; - QLocale usa(QLocale::English, QLocale::UnitedStates); + using const_reverse_iterator = std::reverse_iterator; - QString info; - QTextStream ss(&info); - if(format == SIMPL::HtmlFormat) - { - ss << "\n"; - ss << "\n"; - ss << "\n"; - ss << "\n"; - ss << ""; + // ######### Iterators ######### - ss << R"("; + tuple_iterator tupleBegin(); - ss << R"("; - QString numStr = usa.toString(static_cast(getNumberOfTuples())); - ss << R"("; + tuple_iterator tupleEnd(); - QString compDimStr = "("; - for(int i = 0; i < m_CompDims.size(); i++) - { - compDimStr = compDimStr + QString::number(m_CompDims[i]); - if(i < m_CompDims.size() - 1) - { - compDimStr = compDimStr + QString(", "); - } - } - compDimStr = compDimStr + ")"; - ss << R"("; - numStr = usa.toString(static_cast(m_Size)); - ss << R"("; - numStr = usa.toString(static_cast(m_Size * sizeof(T))); - ss << R"("; - ss << "
Attribute Array Info
Name:)" << getName() << "
Type: DataArray<)" << getTypeAsString() << ">
Number of Tuples:)" << numStr << "
Component Dimensions:)" << compDimStr << "
Total Elements:)" << numStr << "
Total Memory Required:)" << numStr << "
\n"; - ss << ""; + const_tuple_iterator tupleBegin() const; + + const_tuple_iterator tupleEnd() const; + + const_tuple_iterator constTupleBegin() const; + + const_tuple_iterator constTupleEnd() const; + + iterator begin(); + + iterator end(); + + const_iterator begin() const; + + const_iterator end() const; + + const_iterator cbegin() const; + + const_iterator cend() const; + + reverse_iterator rbegin(); + + reverse_iterator rend(); + + const_reverse_iterator rbegin() const; + + const_reverse_iterator rend() const; + + const_reverse_iterator crbegin() const; + + const_reverse_iterator crend() const; + + // ######### Capacity ######### + + size_type size() const; + + size_type capacity() const noexcept; + bool empty() const noexcept; + + // ######### Element Access ######### + + inline reference operator[](size_type index) + { + assert(index < m_Size); + return m_Array[index]; + } + + inline const T& operator[](size_type index) const + { + assert(index < m_Size); + return m_Array[index]; + } + + inline reference at(size_type index) + { + if(index >= m_Size) + { + throw std::out_of_range("DataArray subscript out of range"); } - else + return m_Array[index]; + } + + inline const T& at(size_type index) const + { + if(index >= m_Size) { + throw std::out_of_range("DataArray subscript out of range"); } - return info; + return m_Array[index]; } - /** - * @brief - * @param parentId - * @return - */ - int readH5Data(hid_t parentId) override + inline reference front() + { + return m_Array[0]; + } + inline const T& front() const + { + return m_Array[0]; + } + + inline reference back() { - int err = 0; - - resize(0); - IDataArray::Pointer p = H5DataArrayReader::ReadIDataArray(parentId, getName()); - if(p.get() == nullptr) - { - return -1; - } - m_Array = reinterpret_cast(p->getVoidPointer(0)); - m_Size = p->getSize(); - m_OwnsData = true; - m_MaxId = (m_Size == 0) ? 0 : m_Size - 1; - m_IsAllocated = true; - m_Name = p->getName(); - m_NumTuples = p->getNumberOfTuples(); - m_CompDims = p->getComponentDimensions(); - m_NumComponents = p->getNumberOfComponents(); - - // Tell the intermediate DataArray to release ownership of the data as we are going to be responsible - // for deleting the memory - p->releaseOwnership(); - return err; + return m_Array[m_MaxId]; } + inline const T& back() const + { + return m_Array[m_MaxId]; + } + + inline T* data() noexcept + { + return m_Array; + } + inline const T* data() const noexcept + { + return m_Array; + } + + // ######### Modifiers ######### /** - * @brief + * @brief In the range version (1), the new contents are elements constructed from each of the elements in the range + * between first and last, in the same order. */ - virtual void byteSwapElements() + template + void assign(InputIterator first, InputIterator last) // range (1) { - char* ptr = (char*)(m_Array); - char t[8]; - size_t size = getTypeSize(); - for(uint64_t var = 0; var < m_Size; ++var) + size_type size = last - first; + resizeAndExtend(size); + size_type idx = 0; + while(first != last) { - if(sizeof(T) == 2) - { - mxa_bswap(0, 1, t); - } - else if(sizeof(T) == 4) - { - mxa_bswap(0, 3, t); - mxa_bswap(1, 2, t); - } - else if(sizeof(T) == 8) - { - mxa_bswap(0, 7, t); - mxa_bswap(1, 6, t); - mxa_bswap(2, 5, t); - mxa_bswap(3, 4, t); - } - ptr += size; // increment the pointer + m_Array[idx] = *first; + first++; } } /** - * @brief operator [] - * @param i - * @return + * @brief In the fill version (2), the new contents are n elements, each initialized to a copy of val. + * @param n + * @param val */ - inline T& operator[](size_t i) - { - Q_ASSERT(i < m_Size); - return m_Array[i]; - } + void assign(size_type n, const value_type& val); -protected: /** - * @brief Protected Constructor - * @param numTuples The number of elements in the internal array. - * @param rank The number of dimensions the attribute on each Tuple has. - * @param dims The actual dimensions the attribute on each Tuple has. - * @param takeOwnership Will the class clean up the memory. Default=true - */ - DataArray(size_t numTuples, QVector compDims, QString name, bool ownsData = true) - : m_Array(nullptr) - , m_OwnsData(ownsData) - , m_IsAllocated(false) - , m_Name(std::move(name)) - , m_NumTuples(numTuples) - { - // Set the Component Dimensions and compute the number of components at each tuple for caching - m_CompDims = compDims; - m_NumComponents = m_CompDims[0]; - for(int i = 1; i < m_CompDims.size(); i++) - { - m_NumComponents = m_NumComponents * m_CompDims[i]; - } + * @brief In the initializer list version (3), the new contents are copies of the values passed as initializer list, in the same order. + * @param il + */ + void assign(std::initializer_list il); - m_Size = m_NumTuples * m_NumComponents; - m_MaxId = (m_Size > 0) ? m_Size - 1 : m_Size; + /** + * @brief push_back + * @param val + */ + void push_back(const value_type& val); + /** + * @brief push_back + * @param val + */ + void push_back(value_type&& val); - m_InitValue = static_cast(0); - // MUD_FLAP_0 = MUD_FLAP_1 = MUD_FLAP_2 = MUD_FLAP_3 = MUD_FLAP_4 = MUD_FLAP_5 = 0xABABABABABABABABul; - } + /** + * @brief pop_back + */ + void pop_back(); /** - * @brief deallocates the memory block + * @brief Removes all elements from the array (which are destroyed), leaving the container with a size of 0. + */ + void clear(); + + /** + * @brief equal + * @param range1 + * @param range2 + * @return */ - void _deallocate() + template + bool equal(Range1 const& range1, Range2 const& range2) { - // We are going to splat 0xABABAB across the first value of the array as a debugging aid - auto cptr = reinterpret_cast(m_Array); - if(nullptr != cptr) + if(range1.size() != range2.size()) { - if(m_Size > 0) - { - if(sizeof(T) >= 1) - { - cptr[0] = 0xAB; - } - if(sizeof(T) >= 2) - { - cptr[1] = 0xAB; - } - if(sizeof(T) >= 4) - { - cptr[2] = 0xAB; - cptr[3] = 0xAB; - } - if(sizeof(T) >= 8) - { - cptr[4] = 0xAB; - cptr[5] = 0xAB; - cptr[6] = 0xAB; - cptr[7] = 0xAB; - } - } + return false; } -#if 0 - if (MUD_FLAP_0 != 0xABABABABABABABABul - || MUD_FLAP_1 != 0xABABABABABABABABul - || MUD_FLAP_2 != 0xABABABABABABABABul - || MUD_FLAP_3 != 0xABABABABABABABABul - || MUD_FLAP_4 != 0xABABABABABABABABul - || MUD_FLAP_5 != 0xABABABABABABABABul) - { - Q_ASSERT(false); - } -#endif -#if defined(AIM_USE_SSE) && defined(__SSE2__) - _mm_free(m_buffer); -#else - free(m_Array); -#endif - m_Array = nullptr; - m_IsAllocated = false; + return std::equal(begin(range1), end(range1), begin(range2)); } + // =================================== END STL COMPATIBLE INTERFACe =================================================== + +protected: + /** + * @brief deallocates the memory block + */ + void deallocate(); + /** * @brief Resizes the internal array * @param size The new size of the internal array * @return 1 on success, 0 on failure */ - int32_t resizeTotalElements(size_t size) override - { - // std::cout << "DataArray::resizeTotalElements(" << size << ")" << std::endl; - if(size == 0) - { - clear(); - return 1; - } - T* ptr = resizeAndExtend(size); - if(nullptr != ptr) - { - return 1; - } - return 0; - } + int32_t resizeTotalElements(size_t size) override; /** * @brief resizes the internal array to be 'size' elements in length * @param size * @return Pointer to the internal array */ - virtual T* resizeAndExtend(size_t size) - { - T* newArray; - size_t newSize; - size_t oldSize; - - if(size == m_Size) // Requested size is equal to current size. Do nothing. - { - return m_Array; - } - newSize = size; - oldSize = m_Size; - - // Wipe out the array completely if new size is zero. - if(newSize == 0) - { - clear(); - return m_Array; - } - // OS X's realloc does not free memory if the new block is smaller. This - // is a very serious problem and causes huge amount of memory to be - // wasted. Do not use realloc on the Mac. - bool dontUseRealloc = false; -#if defined __APPLE__ - dontUseRealloc = true; -#endif - - // Allocate a new array if we DO NOT own the current array - if((nullptr != m_Array) && (false == m_OwnsData)) - { - // The old array is owned by the user so we cannot try to - // reallocate it. Just allocate new memory that we will own. - newArray = (T*)malloc(newSize * sizeof(T)); - if(!newArray) - { - qDebug() << "Unable to allocate " << newSize << " elements of size " << sizeof(T) << " bytes. "; - return nullptr; - } - - // Copy the data from the old array. - std::memcpy(newArray, m_Array, (newSize < m_Size ? newSize : m_Size) * sizeof(T)); - } - else if(!dontUseRealloc) - { - // Try to reallocate with minimal memory usage and possibly avoid copying. - newArray = (T*)realloc(m_Array, newSize * sizeof(T)); - if(!newArray) - { - qDebug() << "Unable to allocate " << newSize << " elements of size " << sizeof(T) << " bytes. "; - return nullptr; - } - } - else - { - newArray = (T*)malloc(newSize * sizeof(T)); - if(!newArray) - { - qDebug() << "Unable to allocate " << newSize << " elements of size " << sizeof(T) << " bytes. "; - return nullptr; - } + T* resizeAndExtend(size_t size); - // Copy the data from the old array. - if(m_Array != nullptr) - { - std::memcpy(newArray, m_Array, (newSize < m_Size ? newSize : m_Size) * sizeof(T)); - } - // Free the old array - _deallocate(); - } - - // Allocation was successful. Save it. - m_Size = newSize; - m_Array = newArray; +private: + T* m_Array = nullptr; + size_t m_Size = 0; + size_t m_MaxId = 0; + size_t m_NumTuples = 0; + size_t m_NumComponents = 1; + T m_InitValue = static_cast(0); + comp_dims_type m_CompDims = {1}; + bool m_IsAllocated = false; + bool m_OwnsData = true; +}; - // This object has now allocated its memory and owns it. - m_OwnsData = true; +// ----------------------------------------------------------------------------- +// Declare our extern templates +extern template class DataArray; - m_MaxId = newSize - 1; - m_IsAllocated = true; +extern template class DataArray; +extern template class DataArray; - // Initialize the new tuples if newSize is larger than old size - if(newSize > oldSize) - { - initializeWithValue(m_InitValue, oldSize); - } +extern template class DataArray; +extern template class DataArray; +extern template class DataArray; +extern template class DataArray; +extern template class DataArray; +extern template class DataArray; +extern template class DataArray; +extern template class DataArray; - return m_Array; - } +extern template class DataArray; +extern template class DataArray; -private: - // unsigned long long int MUD_FLAP_0; - T* m_Array; - // unsigned long long int MUD_FLAP_1; - size_t m_Size; - // unsigned long long int MUD_FLAP_4; - bool m_OwnsData; - // unsigned long long int MUD_FLAP_2; - size_t m_MaxId; - - bool m_IsAllocated; - // unsigned long long int MUD_FLAP_3; - QString m_Name; - // unsigned long long int MUD_FLAP_5; - - size_t m_NumTuples; - - QVector m_CompDims; - size_t m_NumComponents; - - T m_InitValue; -}; +extern template class DataArray; +#ifndef SIMPL_DATA_ARRAY_ALIAS +#define SIMPL_DATA_ARRAY_ALIAS // ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- - +// Declare our aliases using BoolArrayType = DataArray; +using CharArrayType = DataArray; using UCharArrayType = DataArray; using Int8ArrayType = DataArray; @@ -1782,3 +1290,4 @@ using FloatArrayType = DataArray; using DoubleArrayType = DataArray; using SizeTArrayType = DataArray; +#endif diff --git a/Source/SIMPLib/DataArrays/DynamicListArray.hpp b/Source/SIMPLib/DataArrays/DynamicListArray.hpp old mode 100755 new mode 100644 index 41664fc21f..99c1addb3b --- a/Source/SIMPLib/DataArrays/DynamicListArray.hpp +++ b/Source/SIMPLib/DataArrays/DynamicListArray.hpp @@ -1,56 +1,93 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include +#include #include -//-- DREAM3D Includes -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + #include "SIMPLib/SIMPLib.h" /** - * @brief The MeshFaceNeighbors class contains arrays of Faces for each Node in the mesh. This allows quick query to the node - * to determine what Cells the node is a part of. + * @brief */ -template class DynamicListArray +template +class DynamicListArray { public: - SIMPL_SHARED_POINTERS(DynamicListArray) - SIMPL_STATIC_NEW_MACRO(DynamicListArray) - SIMPL_TYPE_MACRO(DynamicListArray) + using Self = DynamicListArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer() + { + return Pointer(static_cast(nullptr)); + } + + /** + * @brief Returns the name of the class for AbstractMessage + */ + QString getNameOfClass() const + { + return QString("DynamicListArray"); + } + /** + * @brief Returns the name of the class for AbstractMessage + */ + static QString ClassName() + { + return QString("DynamicListArray"); + } + + /** + * @brief Returns the version of this class. + * @return + */ + int32_t getClassVersion() + { + return 1; + } + + static Pointer New() + { + return std::shared_ptr(new DynamicListArray); + } class ElementList { @@ -72,7 +109,7 @@ template class DynamicListArray delete[] this->m_Array[i].cells; } } - // Now delete all the "NeighborLists" structures + // Now delete all the "ElementList" structures if(this->m_Array != nullptr) { delete[] this->m_Array; @@ -83,7 +120,7 @@ template class DynamicListArray * @brief size * @return */ - size_t size() + size_t size() const { return m_Size; } @@ -93,7 +130,7 @@ template class DynamicListArray * @param forceNoAllocate * @return */ - Pointer deepCopy(bool forceNoAllocate = false) + Pointer deepCopy(bool forceNoAllocate = false) const { DynamicListArray::Pointer copy = DynamicListArray::New(); std::vector linkCounts(m_Size, 0); @@ -135,7 +172,7 @@ template class DynamicListArray * @param ptId * @return */ - ElementList& getElementList(size_t ptId) + ElementList& getElementList(size_t ptId) const { return this->m_Array[ptId]; } @@ -155,6 +192,7 @@ template class DynamicListArray } if(nullptr != m_Array[ptId].cells && m_Array[ptId].ncells > 0) { + delete[] this->m_Array[ptId].cells; m_Array[ptId].cells = nullptr; m_Array[ptId].ncells = 0; } @@ -181,6 +219,7 @@ template class DynamicListArray } if(nullptr != m_Array[ptId].cells && m_Array[ptId].ncells > 0) { + delete[] this->m_Array[ptId].cells; m_Array[ptId].cells = nullptr; m_Array[ptId].ncells = 0; } @@ -196,7 +235,7 @@ template class DynamicListArray * @param ptId * @return */ - T getNumberOfElements(size_t ptId) + T getNumberOfElements(size_t ptId) const { return this->m_Array[ptId].ncells; } @@ -206,35 +245,11 @@ template class DynamicListArray * @param ptId * @return */ - K* getElementListPointer(size_t ptId) + K* getElementListPointer(size_t ptId) const { return this->m_Array[ptId].cells; } - /** - * @brief deserializeLinks - * @param buffer - * @param nElements - */ - void deserializeLinks(QVector& buffer, size_t nElements) - { - size_t offset = 0; - allocate(nElements); // Allocate all the links with 0 and nullptr; - uint8_t* bufPtr = buffer.data(); - - // Walk the array and allocate all the array links to Zero and nullptr - T* ncells = nullptr; - for(size_t i = 0; i < nElements; ++i) - { - ncells = reinterpret_cast(bufPtr + offset); - this->m_Array[i].ncells = *ncells; // Set the number of cells in this link - offset += 2; - this->m_Array[i].cells = new K[(*ncells)]; // Allocate a new chunk of memory to store the list - ::memcpy(this->m_Array[i].cells, bufPtr + offset, (*ncells) * sizeof(K)); // Copy from the buffer into the new list memory - offset += (*ncells) * sizeof(K); // Increment the offset - } - } - /** * @brief deserializeLinks * @param buffer @@ -261,44 +276,30 @@ template class DynamicListArray } /** - * @brief allocateLists + * @brief * @param linkCounts */ - void allocateLists(QVector& linkCounts) + template + void allocateLists(const Container& linkCounts) { allocate(linkCounts.size()); for(typename std::vector::size_type i = 0; i < linkCounts.size(); i++) { this->m_Array[i].ncells = linkCounts[i]; - this->m_Array[i].cells = new K[this->m_Array[i].ncells]; - } - } - - /** - * @brief allocateLists - * @param linkCounts - */ - void allocateLists(std::vector& linkCounts) - { - allocate(linkCounts.size()); - for(typename std::vector::size_type i = 0; i < linkCounts.size(); i++) - { - this->m_Array[i].ncells = linkCounts[i]; - this->m_Array[i].cells = new K[this->m_Array[i].ncells]; + if(linkCounts[i] > 0) + { + this->m_Array[i].cells = new K[this->m_Array[i].ncells]; + } } } protected: - DynamicListArray() - : m_Array(nullptr) - , m_Size(0) - { - } + DynamicListArray() = default; //---------------------------------------------------------------------------- // This will allocate memory to hold all the NeighborList structures where each // structure is initialized to Zero Entries and a nullptr Pointer - void allocate(size_t sz, size_t ext = 1000) + void allocate(size_t sz) { static typename DynamicListArray::ElementList linkInit = {0, nullptr}; @@ -310,7 +311,7 @@ template class DynamicListArray delete[] this->m_Array[i].cells; } } - // Now delete all the "NeighborLists" structures + // Now delete all the "ElementList" structures if(this->m_Array != nullptr) { delete[] this->m_Array; @@ -328,11 +329,10 @@ template class DynamicListArray } private: - ElementList* m_Array; // pointer to data - size_t m_Size; + ElementList* m_Array = nullptr; // pointer to data + size_t m_Size = 0; }; typedef DynamicListArray Int32Int32DynamicListArray; typedef DynamicListArray UInt16Int64DynamicListArray; typedef DynamicListArray Int64Int64DynamicListArray; - diff --git a/Source/SIMPLib/DataArrays/IDataArray.cpp b/Source/SIMPLib/DataArrays/IDataArray.cpp index 6c25becec1..68edbe9715 100644 --- a/Source/SIMPLib/DataArrays/IDataArray.cpp +++ b/Source/SIMPLib/DataArrays/IDataArray.cpp @@ -11,10 +11,15 @@ #include "IDataArray.h" +#include + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IDataArray::IDataArray() = default; +IDataArray::IDataArray(const QString& name) +: IDataStructureNode(name) +{ +} // ----------------------------------------------------------------------------- // @@ -24,7 +29,35 @@ IDataArray::~IDataArray() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool IDataArray::copyFromArray(size_t destTupleOffset, IDataArray::Pointer sourceArray) +bool IDataArray::copyFromArray(size_t destTupleOffset, IDataArray::ConstPointer sourceArray) { return copyFromArray(destTupleOffset, sourceArray, 0, sourceArray->getNumberOfTuples()); } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataArrayPath IDataArray::getDataArrayPath() const +{ + DataArrayPath path = getParentPath(); + path.setDataArrayName(getName()); + return path; +} + +// ----------------------------------------------------------------------------- +IDataArray::Pointer IDataArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString IDataArray::getNameOfClass() const +{ + return QString("IDataArray"); +} + +// ----------------------------------------------------------------------------- +QString IDataArray::ClassName() +{ + return QString("IDataArray"); +} diff --git a/Source/SIMPLib/DataArrays/IDataArray.h b/Source/SIMPLib/DataArrays/IDataArray.h old mode 100755 new mode 100644 index 987b200f48..cca04ff1eb --- a/Source/SIMPLib/DataArrays/IDataArray.h +++ b/Source/SIMPLib/DataArrays/IDataArray.h @@ -10,315 +10,307 @@ /////////////////////////////////////////////////////////////////////////////// #pragma once - //-- C++ +#include #include -#include +#include "H5Support/H5SupportTypeDefs.h" //--Qt Includes #include +#include #include -//SIMPLib Includes -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/IDataStructureNode.h" +#include "SIMPLib/Utilities/ToolTipGenerator.h" +class IDataArray; +using IDataArrayShPtrType = std::shared_ptr; /** -* @class IDataArray IDataArray.h PathToHeader/IDataArray.h -* @brief This class holds a raw pointer to some allocated data that can be stored -* into or read from an HDF5 data file. -* The class design was borrowed heavily from the vtkDataArray class from www.vtk.org. -* The work was all performed by those individuals. I have merely changed a few -* methods to meet my specific needs. -* @author mjackson -* @date Jan 3, 2008 -* @version $Revision: 1.2 $ -*/ -class SIMPLib_EXPORT IDataArray + * @class IDataArray IDataArray.h PathToHeader/IDataArray.h + * @brief This class holds a raw pointer to some allocated data that can be stored + * into or read from an HDF5 data file. + * The class design was borrowed heavily from the vtkDataArray class from www.vtk.org. + * The work was all performed by those individuals. I have merely changed a few + * methods to meet my specific needs. + * @author mjackson + * @date Jan 3, 2008 + * @version $Revision: 1.2 $ + */ +class SIMPLib_EXPORT IDataArray : public IDataStructureNode { - PYB11_CREATE_BINDINGS(IDataArray) - PYB11_PROPERTY(QString Name READ getName WRITE setName) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(IDataArray) + PYB11_SHARED_POINTERS(IDataArray) + PYB11_PROPERTY(QString Name READ getName WRITE setName) PYB11_METHOD(QString getTypeAsString) - PYB11_METHOD(QVector getComponentDimensions) + PYB11_METHOD(std::vector getComponentDimensions) PYB11_METHOD(size_t getNumberOfTuples) - PYB11_METHOD(int getNumberOfComponents) - - public: - SIMPL_SHARED_POINTERS(IDataArray) - SIMPL_TYPE_MACRO(IDataArray) - - /** - * This templated method is used to get at the low level pointer that points - * to the actual data by testing the conversion with dynamic_cast<> first to - * see if it can be done, the finally returns the low level pointer. - * @code - * typedef DataArray Int32ArrayType; - * int32_t* iPtr = IDataArray::SafeReinterpretCast(ptr.get()); - * Q_ASSERT(nullptr != iPtr); - * @endcode - * @param x The Pointer to IDataArray - * @return - */ - template - static Raw SafeReinterpretCast(Source x) - { - if( dynamic_cast(x) != x ) - { - return 0; - } - return reinterpret_cast(x->getVoidPointer(0)); - } - - - IDataArray(); - virtual ~IDataArray(); - - virtual void setName(const QString& name) = 0; - virtual QString getName() = 0; - - virtual Pointer createNewArray(size_t numElements, int rank, size_t* dims, const QString& name, bool allocate = true) = 0; - virtual Pointer createNewArray(size_t numElements, std::vector dims, const QString& name, bool allocate = true) = 0; - virtual Pointer createNewArray(size_t numElements, QVector dims, const QString& name, bool allocate = true) = 0; - - virtual int getClassVersion() = 0; - - /** - * @brief Has all the memory needed for this class been allocated? - */ - virtual bool isAllocated() = 0; - - /** - * @brief Makes this class responsible for freeing the memory. - */ - virtual void takeOwnership () = 0; - - /** - * @brief This class will NOT free the memory associated with the internal pointer. - * This can be useful if the user wishes to keep the data around after this - * class goes out of scope. - */ - virtual void releaseOwnership () = 0; - - /** - * @brief Returns a void pointer pointing to the index of the array. nullptr - * pointers are entirely possible. No checks are performed to make sure - * the index is with in the range of the internal data array. - * @param i The index to have the returned pointer pointing to. - * @return Void Pointer. Possibly nullptr. - */ - virtual void* getVoidPointer ( size_t i) = 0; - - /** - * @brief Returns the number of Tuples in the array. - */ - virtual size_t getNumberOfTuples () = 0; - - - /** - * @brief Return the number of elements in the array - * @return - */ - virtual size_t getSize() = 0; - - virtual int getNumberOfComponents() = 0; - virtual QVector getComponentDimensions() = 0; - - - /** - * @brief Returns the number of bytes that make up the data type. - * 1 = char - * 2 = 16 bit integer - * 4 = 32 bit integer/Float - * 8 = 64 bit integer/Double - */ - virtual size_t getTypeSize() = 0; - - /** - * @brief GetTypeName Returns a string representation of the type of data that is stored by this class. This - * can be a primitive like char, float, int or the name of a class. - * @return - */ - virtual void getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) = 0; - - /** - * @brief Erases tuples based on a list of specific Tuple indices - * @param idxs The indices to erase - * @return - */ - virtual int eraseTuples(QVector& idxs) = 0; - - /** - * @brief Copies a Tuple from one position to another. - * @param currentPos The index of the source data - * @param newPos The destination index to place the copied data - * @return - */ - virtual int copyTuple(size_t currentPos, size_t newPos) = 0; - - /** - * @brief copyData This method copies all data from the sourceArray into - * the current array starting at the target destination tuple offset value. - * - * The method will check to ensure that various conditions are properly met - * before attempting to copy the data into the array at the give offset to avoid - * the possibility of walking off the end of the array into application memory - * or causing a General protection fault by the OS. - * - * For example if the DataArray has 10 tuples and the destTupleOffset = 5 then - * then source data will be copied into the destination array starting at - * destination tuple 5. In psuedo code it would be the following: - * @code - * destArray[5] = sourceArray[0]; - * destArray[6] = sourceArray[1]; - * ..... - * @endcode - * @param destTupleOffset - * @param sourceArray - * @return - */ - bool copyFromArray(size_t destTupleOffset, IDataArray::Pointer sourceArray); - - /** - * @brief copyData This method copies the number of tuples specified by the - * totalSrcTuples value starting from the source tuple offset value in sourceArray - * into the current array starting at the target destination tuple offset value. - * - * For example if the DataArray has 10 tuples, the source DataArray has 10 tuples, - * the destTupleOffset = 5, the srcTupleOffset = 5, and the totalSrcTuples = 3, - * then tuples 5, 6, and 7 will be copied from the source into tuples 5, 6, and 7 - * of the destination array. In psuedo code it would be the following: - * @code - * destArray[5] = sourceArray[5]; - * destArray[6] = sourceArray[6]; - * destArray[7] = sourceArray[7]; - * ..... - * @endcode - * @param destTupleOffset - * @param sourceArray - * @return - */ - virtual bool copyFromArray(size_t destTupleOffset, IDataArray::Pointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) = 0; - - /** - * @brief Splats the same value c across all values in the Tuple - * @param pos The index of the Tuple - * @param value pointer to value - */ - virtual void initializeTuple(size_t pos, void* value) = 0; - - /** - * @brief Sets all the values to zero. - */ - virtual void initializeWithZeros() = 0; - - /** - * @brief Resizes the internal array - * @param size The new size of the internal array - * @return 1 on success, 0 on failure - */ - virtual int32_t resizeTotalElements(size_t size) = 0; - - /** - * @brief Reseizes the internal array - * @param size The new size of the internal array - * @return 1 on success, 0 on failure - */ - virtual int32_t resize(size_t numTuples) = 0; - - /** - * @brief printTuple - * @param out - * @param i - * @param delimiter - */ - virtual void printTuple(QTextStream& out, size_t i, char delimiter = ',') = 0; - - /** - * @brief printComponent - * @param out - * @param i - * @param j - */ - virtual void printComponent(QTextStream& out, size_t i, int j) = 0; - - /** - * @brief deepCopy - * @param forceNoAllocate - * @return - */ - virtual IDataArray::Pointer deepCopy(bool forceNoAllocate = false) = 0; - - /** - * @brief writeH5Data - * @param parentId - * @param tDims - * @return - */ - virtual int writeH5Data(hid_t parentId, QVector tDims) = 0; - - /** - * @brief readH5Data - * @param parentId - * @return - */ - virtual int readH5Data(hid_t parentId) = 0; - - /** - * @brief writeXdmfAttribute - * @param out - * @param volDims - * @param hdfFileName - * @param groupPath - * @param label - * @return - */ - virtual int writeXdmfAttribute(QTextStream& out, int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& label) = 0; - - /** - * @brief getTypeAsString - * @return - */ - virtual QString getTypeAsString() = 0; - - /** - * @brief getInfoString - * @return Returns a formatted string that contains general infomation about - * the instance of the object. - */ - virtual QString getInfoString(SIMPL::InfoStringFormat format) = 0; - - protected: - - private: - IDataArray (const IDataArray&); //Not Implemented - void operator=(const IDataArray&); //Not Implemented - + PYB11_METHOD(int32_t getNumberOfComponents) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = IDataArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for IDataArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for IDataArray + */ + static QString ClassName(); + + IDataArray(const QString& name = ""); + ~IDataArray() override; + + virtual Pointer createNewArray(size_t numElements, int32_t rank, const size_t* dims, const QString& name, bool allocate = true) const = 0; + virtual Pointer createNewArray(size_t numElements, const std::vector& dims, const QString& name, bool allocate = true) const = 0; + // virtual Pointer createNewArray(size_t numElements, std::vector dims, const QString& name, bool allocate = true) = 0; + + /** + * @brief Creates and returns a DataArrayPath for the DataArray + * @return + */ + DataArrayPath getDataArrayPath() const override; + + virtual int32_t getClassVersion() const = 0; + + /** + * @brief Has all the memory needed for this class been allocated? + */ + virtual bool isAllocated() const = 0; + + /** + * @brief Makes this class responsible for freeing the memory. + */ + virtual void takeOwnership() = 0; + + /** + * @brief This class will NOT free the memory associated with the internal pointer. + * This can be useful if the user wishes to keep the data around after this + * class goes out of scope. + */ + virtual void releaseOwnership() = 0; + + /** + * @brief Returns a void pointer pointing to the index of the array. nullptr + * pointers are entirely possible. No checks are performed to make sure + * the index is with in the range of the internal data array. + * @param i The index to have the returned pointer pointing to. + * @return Void Pointer. Possibly nullptr. + */ + virtual void* getVoidPointer(size_t i) = 0; + + /** + * @brief Returns the number of Tuples in the array. + */ + virtual size_t getNumberOfTuples() const = 0; + + /** + * @brief Return the number of elements in the array + * @return + */ + virtual size_t getSize() const = 0; + + virtual int32_t getNumberOfComponents() const = 0; + virtual std::vector getComponentDimensions() const = 0; + + /** + * @brief Returns the number of bytes that make up the data type. + * 1 = char + * 2 = 16 bit integer + * 4 = 32 bit integer/Float + * 8 = 64 bit integer/Double + */ + virtual size_t getTypeSize() const = 0; + + /** + * @brief GetTypeName Returns a string representation of the type of data that is stored by this class. This + * can be a primitive like char, float, int or the name of a class. + * @return + */ + virtual void getXdmfTypeAndSize(QString& xdmfTypeName, int32_t& precision) const = 0; + + /** + * @brief Erases tuples based on a list of specific Tuple indices + * @param idxs The indices to erase + * @return + */ + virtual int32_t eraseTuples(const std::vector& idxs) = 0; + + /** + * @brief Copies a Tuple from one position to another. + * @param currentPos The index of the source data + * @param newPos The destination index to place the copied data + * @return + */ + virtual int32_t copyTuple(size_t currentPos, size_t newPos) = 0; + + /** + * @brief copyData This method copies all data from the sourceArray into + * the current array starting at the target destination tuple offset value. + * + * The method will check to ensure that various conditions are properly met + * before attempting to copy the data into the array at the give offset to avoid + * the possibility of walking off the end of the array into application memory + * or causing a General protection fault by the OS. + * + * For example if the DataArray has 10 tuples and the destTupleOffset = 5 then + * then source data will be copied into the destination array starting at + * destination tuple 5. In psuedo code it would be the following: + * @code + * destArray[5] = sourceArray[0]; + * destArray[6] = sourceArray[1]; + * ..... + * @endcode + * @param destTupleOffset + * @param sourceArray + * @return + */ + bool copyFromArray(size_t destTupleOffset, IDataArray::ConstPointer sourceArray); + + /** + * @brief copyData This method copies the number of tuples specified by the + * totalSrcTuples value starting from the source tuple offset value in sourceArray + * into the current array starting at the target destination tuple offset value. + * + * For example if the DataArray has 10 tuples, the source DataArray has 10 tuples, + * the destTupleOffset = 5, the srcTupleOffset = 5, and the totalSrcTuples = 3, + * then tuples 5, 6, and 7 will be copied from the source into tuples 5, 6, and 7 + * of the destination array. In psuedo code it would be the following: + * @code + * destArray[5] = sourceArray[5]; + * destArray[6] = sourceArray[6]; + * destArray[7] = sourceArray[7]; + * ..... + * @endcode + * @param destTupleOffset + * @param sourceArray + * @return + */ + virtual bool copyFromArray(size_t destTupleOffset, IDataArray::ConstPointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) = 0; + + /** + * @brief Splats the same value c across all values in the Tuple + * @param pos The index of the Tuple + * @param value pointer to value + */ + virtual void initializeTuple(size_t pos, const void* value) = 0; + + /** + * @brief Sets all the values to zero. + */ + virtual void initializeWithZeros() = 0; + + /** + * @brief Resizes the internal array + * @param size The new size of the internal array + * @return 1 on success, 0 on failure + */ + virtual int32_t resizeTotalElements(size_t size) = 0; + + /** + * @brief resize + * @param count + */ + virtual void resizeTuples(size_t count) = 0; + + /** + * @brief printTuple + * @param out + * @param i + * @param delimiter + */ + virtual void printTuple(QTextStream& out, size_t i, char delimiter = ',') const = 0; + + /** + * @brief printComponent + * @param out + * @param i + * @param j + */ + virtual void printComponent(QTextStream& out, size_t i, int32_t j) const = 0; + + /** + * @brief deepCopy + * @param forceNoAllocate + * @return + */ + virtual IDataArray::Pointer deepCopy(bool forceNoAllocate = false) const = 0; + + /** + * @brief writeH5Data + * @param parentId + * @param tDims + * @return + */ + virtual int32_t writeH5Data(hid_t parentId, const std::vector& tDims) const = 0; + + /** + * @brief readH5Data + * @param parentId + * @return + */ + virtual int32_t readH5Data(hid_t parentId) = 0; + + /** + * @brief writeXdmfAttribute + * @param out + * @param volDims + * @param hdfFileName + * @param groupPath + * @param label + * @return + */ + virtual int32_t writeXdmfAttribute(QTextStream& out, const int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& label) const = 0; + + /** + * @brief getTypeAsString + * @return + */ + virtual QString getTypeAsString() const = 0; + + /** + * @brief getInfoString + * @return Returns a formatted string that contains general infomation about + * the instance of the object. + */ + virtual QString getInfoString(SIMPL::InfoStringFormat format) const = 0; + + /** + * @brief Returns a ToolTipGenerator for creating HTML tooltip tables + * with values populated to match the current DataArray. + * @return + */ + virtual ToolTipGenerator getToolTipGenerator() const = 0; + +protected: +private: + IDataArray(const IDataArray&); // Not Implemented + void operator=(const IDataArray&); // Not Implemented }; - - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -template +template class CheckDataArrayType { - public: - CheckDataArrayType() = default; - virtual ~CheckDataArrayType() = default; - bool operator()(IDataArray::Pointer p) - { - return (std::dynamic_pointer_cast(p).get() != nullptr); - } +public: + CheckDataArrayType() = default; + virtual ~CheckDataArrayType() = default; + bool operator()(IDataArrayShPtrType p) + { + return (std::dynamic_pointer_cast(p).get() != nullptr); + } }; - - - - - - - diff --git a/Source/SIMPLib/DataArrays/IDataArrayFilter.cpp b/Source/SIMPLib/DataArrays/IDataArrayFilter.cpp index cfcaca3554..5cf5dcba9d 100644 --- a/Source/SIMPLib/DataArrays/IDataArrayFilter.cpp +++ b/Source/SIMPLib/DataArrays/IDataArrayFilter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "IDataArrayFilter.h" #include "SIMPLib/DataArrays/IDataArray.h" diff --git a/Source/SIMPLib/DataArrays/IDataArrayFilter.h b/Source/SIMPLib/DataArrays/IDataArrayFilter.h old mode 100755 new mode 100644 index 33050fa493..57a783e6fc --- a/Source/SIMPLib/DataArrays/IDataArrayFilter.h +++ b/Source/SIMPLib/DataArrays/IDataArrayFilter.h @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once @@ -51,9 +51,8 @@ class SIMPLib_EXPORT IDataArrayFilter int execute(IDataArray* input, IDataArray* output); public: - IDataArrayFilter(const IDataArrayFilter&) = delete; // Copy Constructor Not Implemented - IDataArrayFilter(IDataArrayFilter&&) = delete; // Move Constructor Not Implemented + IDataArrayFilter(const IDataArrayFilter&) = delete; // Copy Constructor Not Implemented + IDataArrayFilter(IDataArrayFilter&&) = delete; // Move Constructor Not Implemented IDataArrayFilter& operator=(const IDataArrayFilter&) = delete; // Copy Assignment Not Implemented IDataArrayFilter& operator=(IDataArrayFilter&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/DataArrays/NeighborList.cpp b/Source/SIMPLib/DataArrays/NeighborList.cpp new file mode 100644 index 0000000000..d8ee27fa24 --- /dev/null +++ b/Source/SIMPLib/DataArrays/NeighborList.cpp @@ -0,0 +1,1029 @@ +#include "NeighborList.hpp" + +#include +#include + +#include "H5Support/H5Lite.h" +#include "H5Support/H5Utilities.h" +#include "H5Support/QH5Lite.h" + +#include "SIMPLib/Common/Constants.h" + +#include "SIMPLib/DataArrays/DataArray.hpp" + +// ----------------------------------------------------------------------------- +template +NeighborList::NeighborList(size_t numTuples, const QString name) +: IDataArray(name) +, m_NumTuples(numTuples) +, m_IsAllocated(false) +{ +} + +// ----------------------------------------------------------------------------- +template +typename NeighborList::Pointer NeighborList::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} +// ----------------------------------------------------------------------------- +template +QString NeighborList::getNameOfClass() const +{ + return ClassName(); +} +// ----------------------------------------------------------------------------- +template +QString NeighborList::ClassName() +{ + return QString("NeighborList"); +} +// ----------------------------------------------------------------------------- +template +int32_t NeighborList::getClassVersion() const +{ + return 2; +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::setNumNeighborsArrayName(const QString& name) +{ + m_NumNeighborsArrayName = name; +} + +// ----------------------------------------------------------------------------- +template +QString NeighborList::getNumNeighborsArrayName() +{ + return m_NumNeighborsArrayName; +} + +// ----------------------------------------------------------------------------- +template +typename NeighborList::Pointer NeighborList::New() +{ + return CreateArray(0, std::string("NeighborList"), false); +} + +// ----------------------------------------------------------------------------- +template +typename NeighborList::Pointer NeighborList::CreateArray(size_t numTuples, const QString& name, bool allocate) +{ + // std::cout << "NeighborList::CreateArray name= " << name.toStdString() << " numTuples= " << numTuples << std::endl; + if(name.isEmpty()) + { + return NullPointer(); + } + NeighborList::Pointer ptr = Pointer(new NeighborList(numTuples, name)); + if(allocate) + { + ptr->resizeTuples(numTuples); + } + return ptr; +} + +// ----------------------------------------------------------------------------- +template +typename NeighborList::Pointer NeighborList::CreateArray(size_t numTuples, const std::string& name, bool allocate) +{ + // std::cout << "NeighborList::CreateArray name= " << name.toStdString() << " numTuples= " << numTuples << std::endl; + if(name.empty()) + { + return NullPointer(); + } + NeighborList::Pointer ptr = Pointer(new NeighborList(numTuples, QString::fromStdString(name))); + if(allocate) + { + ptr->resizeTuples(numTuples); + } + return ptr; +} +// ----------------------------------------------------------------------------- +template +typename NeighborList::Pointer NeighborList::CreateArray(size_t numTuples, int rank, const size_t* dims, const QString& name, bool allocate) +{ + // std::cout << "NeighborList::CreateArray name= " << name.toStdString() << " numTuples= " << numTuples << std::endl; + if(name.isEmpty()) + { + return NullPointer(); + } + + size_t numElements = numTuples; + for(int iter = 0; iter < rank; iter++) + { + numElements *= dims[iter]; + } + NeighborList::Pointer ptr = Pointer(new NeighborList(numElements, name)); + if(allocate) + { + ptr->resizeTuples(numElements); + } + return ptr; +} + +// ----------------------------------------------------------------------------- +template +typename NeighborList::Pointer NeighborList::CreateArray(size_t numTuples, const std::vector& cDims, const QString& name, bool allocate) +{ + if(name.isEmpty()) + { + return NullPointer(); + } + size_t numElements = std::accumulate(cDims.begin(), cDims.end(), numTuples, std::multiplies<>()); + + NeighborList::Pointer ptr = Pointer(new NeighborList(numElements, name)); + if(allocate) + { + ptr->resizeTuples(numElements); + } + return ptr; +} + +// ----------------------------------------------------------------------------- +template +typename NeighborList::Pointer NeighborList::CreateArray(const std::vector& tDims, const std::vector& cDims, const QString& name, bool allocate) +{ + if(name.isEmpty()) + { + return NullPointer(); + } + size_t numElements = tDims[0]; + for(int iter = 1; iter < tDims.size(); iter++) + { + numElements *= tDims[iter]; + } + for(int iter = 0; iter < cDims.size(); iter++) + { + numElements *= cDims[iter]; + } + NeighborList::Pointer ptr = Pointer(new NeighborList(numElements, name)); + if(allocate) + { + ptr->resizeTuples(numElements); + } + return ptr; +} + +// ----------------------------------------------------------------------------- +template +IDataArray::Pointer NeighborList::createNewArray(size_t numElements, int rank, const size_t* dims, const QString& name, bool allocate) const +{ + return NeighborList::CreateArray(numElements, rank, dims, name, allocate); +} + +// ----------------------------------------------------------------------------- +template +IDataArray::Pointer NeighborList::createNewArray(size_t numElements, const std::vector& dims, const QString& name, bool allocate) const +{ + return NeighborList::CreateArray(numElements, dims, name, allocate); +} + +// ----------------------------------------------------------------------------- +template +bool NeighborList::isAllocated() const +{ + return true; +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::setInitValue(T initValue) +{ + m_InitValue = initValue; +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::initializeWithValue(T initValue, size_t offset) +{ +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) const +{ + xdmfTypeName = "UNKNOWN"; + precision = 0; +} + +// ----------------------------------------------------------------------------- +template +QString NeighborList::getFullNameOfClass() const +{ + QString theType = getTypeAsString(); + theType = "NeighborList<" + theType + ">"; + return theType; +} + +// ----------------------------------------------------------------------------- +template +QString NeighborList::getTypeAsString() const +{ + if constexpr(std::is_same_v) + { + return "int8_t"; + } + else if constexpr(std::is_same_v) + { + return "uint8_t"; + } + else if constexpr(std::is_same_v) + { + return "int16_t"; + } + else if constexpr(std::is_same_v) + { + return "uint16_t"; + } + else if constexpr(std::is_same_v) + { + return "int32_t"; + } + else if constexpr(std::is_same_v) + { + return "uint32_t"; + } + else if constexpr(std::is_same_v) + { + return "int64_t"; + } + else if constexpr(std::is_same_v) + { + return "uint64_t"; + } + else if constexpr(std::is_same_v) + { + return "float"; + } + else if constexpr(std::is_same_v) + { + return "double"; + } + else if constexpr(std::is_same_v) + { + return "bool"; + } + + return "UnknownType"; +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::takeOwnership() +{ +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::releaseOwnership() +{ +} + +// ----------------------------------------------------------------------------- +template +void* NeighborList::getVoidPointer(size_t i) +{ + return nullptr; +} + +// ----------------------------------------------------------------------------- +template +int NeighborList::eraseTuples(const std::vector& idxs) +{ + int err = 0; + // If nothing is to be erased just return + if(idxs.empty()) + { + return 0; + } + + size_t idxsSize = static_cast(idxs.size()); + if(idxsSize >= getNumberOfTuples()) + { + resizeTuples(0); + return 0; + } + + size_t arraySize = m_Array.size(); + // Sanity Check the Indices in the vector to make sure we are not trying to remove any indices that are + // off the end of the array and return an error code. + for(std::vector::size_type i = 0; i < idxs.size(); ++i) + { + if(idxs[i] >= arraySize) + { + return -100; + } + } + + std::vector replacement(arraySize - idxsSize); + + size_t idxsIndex = 0; + size_t rIdx = 0; + for(size_t dIdx = 0; dIdx < arraySize; ++dIdx) + { + if(dIdx != idxs[idxsIndex]) + { + replacement[rIdx] = m_Array[dIdx]; + ++rIdx; + } + else + { + ++idxsIndex; + if(idxsIndex == idxsSize) + { + idxsIndex--; + } + } + } + m_Array = replacement; + m_NumTuples = m_Array.size(); + return err; +} + +// ----------------------------------------------------------------------------- +template +int NeighborList::copyTuple(size_t currentPos, size_t newPos) +{ + m_Array[newPos] = m_Array[currentPos]; + return 0; +} + +// ----------------------------------------------------------------------------- +template +bool NeighborList::copyFromArray(size_t destTupleOffset, IDataArray::ConstPointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) +{ + if(!m_IsAllocated) + { + return false; + } + if(destTupleOffset >= m_Array.size()) + { + return false; + } + if(!sourceArray->isAllocated()) + { + return false; + } + const Self* source = dynamic_cast(sourceArray.get()); + + if(source == nullptr) + { + return false; + } + + if(sourceArray->getNumberOfComponents() != getNumberOfComponents()) + { + return false; + } + + if(srcTupleOffset + totalSrcTuples > sourceArray->getNumberOfTuples()) + { + return false; + } + + if(totalSrcTuples * sourceArray->getNumberOfComponents() + destTupleOffset * getNumberOfComponents() > m_Array.size()) + { + return false; + } + + for(size_t i = srcTupleOffset; i < srcTupleOffset + totalSrcTuples; i++) + { + m_Array[destTupleOffset + i] = source->getList(i); + } + return true; + + // if(!m_IsAllocated) { return false; } + // if(nullptr == m_Array) { return false; } + // if(destTupleOffset > m_MaxId) { return false; } + // if(!sourceArray->isAllocated()) { return false; } + // Self* source = dynamic_cast(sourceArray.get()); + // if(nullptr == source->getPointer(0)) { return false; } + + // if(sourceArray->getNumberOfComponents() != getNumberOfComponents()) { return false; } + + // if (srcTupleOffset + totalSrcTuples > sourceArray->getNumberOfTuples()) { return false; } + + // if( totalSrcTuples*sourceArray->getNumberOfComponents() + destTupleOffset*getNumberOfComponents() > m_Size) { return false; } + + // size_t elementStart = destTupleOffset*getNumberOfComponents(); + // size_t totalBytes = (totalSrcTuples*sourceArray->getNumberOfComponents()) * sizeof(T); + // std::memcpy(m_Array + elementStart, source->getPointer(srcTupleOffset * sourceArray->getNumberOfComponents()), totalBytes); + // return true; +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::initializeTuple(size_t i, const void* p) +{ + Q_UNUSED(i); + Q_UNUSED(p); + Q_ASSERT(false); +} + +// ----------------------------------------------------------------------------- +template +size_t NeighborList::getNumberOfTuples() const +{ + return m_NumTuples; +} + +// ----------------------------------------------------------------------------- +template +size_t NeighborList::getSize() const +{ + size_t total = 0; + for(size_t dIdx = 0; dIdx < m_Array.size(); ++dIdx) + { + total += m_Array[dIdx]->size(); + } + return total; +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::setNumberOfComponents(int nc) +{ +} + +// ----------------------------------------------------------------------------- +template +int NeighborList::getNumberOfComponents() const +{ + return 1; +} + +// ----------------------------------------------------------------------------- +template +std::vector NeighborList::getComponentDimensions() const +{ + std::vector dims = {1}; + return dims; +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::SetRank(int rnk) +{ +} + +// ----------------------------------------------------------------------------- +template +int NeighborList::getRank() const +{ + return 1; +} + +// ----------------------------------------------------------------------------- +template +size_t NeighborList::getTypeSize() const +{ + return sizeof(SharedVectorType); +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::initializeWithZeros() +{ + m_Array.clear(); + m_IsAllocated = false; +} + +// ----------------------------------------------------------------------------- +template +IDataArray::Pointer NeighborList::deepCopy(bool forceNoAllocate) const +{ + bool allocate = m_IsAllocated; + if(forceNoAllocate) + { + allocate = false; + } + + typename NeighborList::Pointer daCopyPtr = NeighborList::CreateArray(getNumberOfTuples(), getName(), allocate); + + if(m_IsAllocated && !forceNoAllocate) + { + size_t count = (m_IsAllocated ? getNumberOfTuples() : 0); + for(size_t i = 0; i < count; i++) + { + typename NeighborList::SharedVectorType sharedNeiLst(new std::vector(*(m_Array[i]))); + daCopyPtr->setList(static_cast(i), sharedNeiLst); + } + } + return daCopyPtr; +} + +// ----------------------------------------------------------------------------- +template +int32_t NeighborList::resizeTotalElements(size_t size) +{ + // std::cout << "NeighborList::resizeTotalElements(" << size << ")" << std::endl; + size_t old = m_Array.size(); + m_Array.resize(size); + m_NumTuples = size; + if(size == 0) + { + m_IsAllocated = false; + } + else + { + m_IsAllocated = true; + } + // Initialize with zero length Vectors + for(size_t i = old; i < m_Array.size(); ++i) + { + m_Array[i] = SharedVectorType(new VectorType); + } + return 1; +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::resizeTuples(size_t numTuples) +{ + resizeTotalElements(numTuples); +} + +// FIXME: These need to be implemented +// ----------------------------------------------------------------------------- +template +void NeighborList::printTuple(QTextStream& out, size_t i, char delimiter) const +{ + SharedVectorType sharedVec = m_Array[i]; + VectorType* vec = sharedVec.get(); + size_t size = vec->size(); + out << size; + for(size_t j = 0; j < size; j++) + { + out << delimiter << vec->at(j); + } +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::printComponent(QTextStream& out, size_t i, int j) const +{ + Q_ASSERT(false); +} + +// ----------------------------------------------------------------------------- +template +int NeighborList::writeH5Data(hid_t parentId, const std::vector& tDims) const +{ + int err = 0; + + // Generate the NumNeighbors array and also compute the total number + // of elements that would be needed to flatten the array so we + // can compare this with what is written in the file. If they are + // different we are going to overwrite what is in the file with what + // we compute here. + + QString numNeighborsArrayName = m_NumNeighborsArrayName; + + if(numNeighborsArrayName.isEmpty()) + { + numNeighborsArrayName = getName() + "_NumNeighbors"; + } + + Int32ArrayType::Pointer numNeighborsPtr = Int32ArrayType::CreateArray(m_Array.size(), numNeighborsArrayName, true); + int32_t* numNeighbors = numNeighborsPtr->getPointer(0); + size_t total = 0; + for(size_t dIdx = 0; dIdx < m_Array.size(); ++dIdx) + { + numNeighbors[dIdx] = static_cast(m_Array[dIdx]->size()); + total += m_Array[dIdx]->size(); + } + + // Check to see if the NumNeighbors is already written to the file + bool rewrite = false; + if(!QH5Lite::datasetExists(parentId, numNeighborsArrayName)) + { + // The NumNeighbors Array is NOT already in the file so write it to the file + numNeighborsPtr->writeH5Data(parentId, tDims); + } + else + { + // The NumNeighbors array is in the dream3d file so read it up into memory and compare with what + // we have in memory. + std::vector fileNumNeigh(m_Array.size()); + err = H5Lite::readVectorDataset(parentId, numNeighborsArrayName.toStdString(), fileNumNeigh); + if(err < 0) + { + return -602; + } + + // Compare the 2 vectors to make sure they are exactly the same; + if(fileNumNeigh.size() != numNeighborsPtr->getNumberOfTuples()) + { + rewrite = true; + } + // The sizes are the same, now compare each value; + int32_t* fileNumNeiPtr = &(fileNumNeigh.front()); + size_t nBytes = numNeighborsPtr->getNumberOfTuples() * sizeof(int32_t); + if(::memcmp(numNeighbors, fileNumNeiPtr, nBytes) != 0) + { + rewrite = true; + } + } + + // Write out the NumNeighbors Array because something was different between what we computed at + // the top of the function versus what is in memory + if(rewrite) + { + numNeighborsPtr->writeH5Data(parentId, tDims); + } + + // Allocate an array of the proper size so we can concatenate all the arrays together into a single array that + // can be written to the HDF5 File. This operation can ballon the memory size temporarily until this operation + // is complete. + QVector flat(total); + size_t currentStart = 0; + for(size_t dIdx = 0; dIdx < m_Array.size(); ++dIdx) + { + size_t nEle = m_Array[dIdx]->size(); + if(nEle == 0) + { + continue; + } + T* start = m_Array[dIdx]->data(); // get theNeighborList::Pointer to the front of the array + // T* end = start + nEle; // get theNeighborList::Pointer to the end of the array + T* dst = flat.data() + currentStart; + ::memcpy(dst, start, nEle * sizeof(T)); + + currentStart += m_Array[dIdx]->size(); + } + + // Now we can actually write the actual array data. + int32_t rank = 1; + hsize_t dims[1] = {total}; + if(total > 0) + { + err = QH5Lite::writePointerDataset(parentId, getName(), rank, dims, flat.data()); + if(err < 0) + { + return -605; + } + + err = QH5Lite::writeScalarAttribute(parentId, getName(), SIMPL::HDF5::DataArrayVersion, getClassVersion()); + if(err < 0) + { + return -604; + } + err = QH5Lite::writeStringAttribute(parentId, getName(), SIMPL::HDF5::ObjectType, getNameOfClass()); + if(err < 0) + { + return -607; + } + + // Write the tuple dimensions as an attribute + hsize_t size = tDims.size(); + err = QH5Lite::writePointerAttribute(parentId, getName(), SIMPL::HDF5::TupleDimensions, 1, &size, tDims.data()); + if(err < 0) + { + return -609; + } + + std::vector cDims = getComponentDimensions(); + // write the component dimensions as an attribute + size = cDims.size(); + err = QH5Lite::writePointerAttribute(parentId, getName(), SIMPL::HDF5::ComponentDimensions, 1, &size, cDims.data()); + if(err < 0) + { + return -610; + } + + err = QH5Lite::writeStringAttribute(parentId, getName(), "Linked NumNeighbors Dataset", numNeighborsArrayName); + if(err < 0) + { + return -608; + } + } + return err; +} + +// ----------------------------------------------------------------------------- +template +int NeighborList::writeXdmfAttribute(QTextStream& out, const int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& label) const +{ + int precision = 0; + QString xdmfTypeName; + getXdmfTypeAndSize(xdmfTypeName, precision); + + out << " "; + out << " "; + out << " " << hdfFileName.toLatin1().data() << groupPath.toLatin1().data() << "/" << getName(); + out << " "; + out << " "; + return 1; +} + +// ----------------------------------------------------------------------------- +template +ToolTipGenerator NeighborList::getToolTipGenerator() const +{ + ToolTipGenerator toolTipGen; + QLocale usa(QLocale::English, QLocale::UnitedStates); + + toolTipGen.addTitle("Attribute Array Info"); + toolTipGen.addValue("Name", getName()); + toolTipGen.addValue("Type", getTypeAsString()); + toolTipGen.addValue("Number of Tuples", usa.toString(static_cast(getNumberOfTuples()))); + toolTipGen.addValue("Number of Lists", usa.toString(static_cast(getNumberOfLists()))); + + return toolTipGen; +} + +// ----------------------------------------------------------------------------- +template +QString NeighborList::getInfoString(SIMPL::InfoStringFormat format) const +{ + QLocale usa(QLocale::English, QLocale::UnitedStates); + + QString info; + QTextStream ss(&info); + + if(format == SIMPL::HtmlFormat) + { + ss << "\n"; + ss << "\n"; + ss << "\n"; + ss << "\n"; + ss << ""; + + ss << R"("; + + ss << R"("; + QString numStr = usa.toString(static_cast(getNumberOfTuples())); + ss << R"("; + + ss << "
Attribute Array Info
Name:)" << getName() << "
Type: NeighborList<)" << getTypeAsString() << ">
Number of Tuples:)" << numStr << "
\n"; + ss << ""; + } + else if(format == SIMPL::MarkDown) + { + ss << "+ Name: " << getName() << "\n"; + ss << "+ Type: " << getTypeAsString() << "\n"; + ss << "+ Num. Tuple: " << getNumberOfTuples() << "\n"; + QString compDimStr = "(variable)"; + + ss << "+ Comp. Dims: " << compDimStr << "\n"; + ss << "+ Total Elements: " << m_Array.size() << "\n"; + ss << "+ Minimum Memory: " << (m_Array.size() * sizeof(T)) << "\n"; + } + return info; +} + +// ----------------------------------------------------------------------------- +template +int NeighborList::readH5Data(hid_t parentId) +{ + int err = 0; + + std::vector flat; + err = QH5Lite::readVectorDataset(parentId, getName(), flat); + if(err < 0) + { + return err; + } + + QString numNeighborsArrayName = m_NumNeighborsArrayName; + + if(numNeighborsArrayName.isEmpty()) + { + numNeighborsArrayName = getName() + "_NumNeighbors"; + } + + // Read the Attribute Off the data set to find the name of the array that holds all the sizes + err = QH5Lite::readStringAttribute(parentId, getName(), "Linked NumNeighbors Dataset", numNeighborsArrayName); + if(err < 0) + { + return err; + } + // Generate the number of neighbors array and also compute the total number + // of elements that would be needed to flatten the array + std::vector numNeighbors; + + // Check to see if the NumNeighbors exists in the file, which it must. + if(QH5Lite::datasetExists(parentId, numNeighborsArrayName)) + { + err = QH5Lite::readVectorDataset(parentId, numNeighborsArrayName, numNeighbors); + if(err < 0) + { + return -702; + } + } + else + { + return -703; + } + + // int32_t totalElements = std::accumulate(numNeighbors.begin(), numNeighbors.end(), 0); + + // Loop over all the entries and make new Vectors to hold the incoming data + m_Array.resize(numNeighbors.size()); + m_IsAllocated = true; + size_t currentStart = 0; + qint32 count = static_cast(numNeighbors.size()); + for(QVector::size_type dIdx = 0; dIdx < count; ++dIdx) + { + size_t nEle = numNeighbors[dIdx]; + if(nEle > 0) + { + m_Array[dIdx] = SharedVectorType(new VectorType(numNeighbors[dIdx])); + + T* dst = m_Array[dIdx]->data(); // get theNeighborList::Pointer to the front of the array + // T* end = start + nEle; // get theNeighborList::Pointer to the end of the array + T* start = flat.data() + currentStart; + ::memcpy(dst, start, nEle * sizeof(T)); + currentStart += nEle; + } + else + { + m_Array[dIdx] = SharedVectorType(new VectorType(0)); + } + } + m_NumTuples = m_Array.size(); // Sync up the numTuples property with the size of the internal array + return err; +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::addEntry(int grainId, T value) +{ + if(grainId >= static_cast(m_Array.size())) + { + size_t old = m_Array.size(); + m_Array.resize(grainId + 1); + m_IsAllocated = true; + // Initialize with zero length Vectors + for(size_t i = old; i < m_Array.size(); ++i) + { + m_Array[i] = SharedVectorType(new VectorType); + } + } + m_Array[grainId]->push_back(value); + m_NumTuples = m_Array.size(); +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::clearAllLists() +{ + m_Array.clear(); + m_IsAllocated = false; +} + +// ----------------------------------------------------------------------------- +template +void NeighborList::setList(int grainId, SharedVectorType neighborList) +{ + if(grainId >= static_cast(m_Array.size())) + { + size_t old = m_Array.size(); + m_Array.resize(grainId + 1); + m_IsAllocated = true; + // Initialize with zero length Vectors + for(size_t i = old; i < m_Array.size(); ++i) + { + m_Array[i] = SharedVectorType(new VectorType); + } + } + m_Array[grainId] = neighborList; +} + +// ----------------------------------------------------------------------------- +template +T NeighborList::getValue(int grainId, int index, bool& ok) const +{ +#ifndef NDEBUG + if(m_Array.size() > 0u) + { + Q_ASSERT(grainId < static_cast(m_Array.size())); + } +#endif + SharedVectorType vec = m_Array[grainId]; + if(index < 0 || static_cast(index) >= vec->size()) + { + ok = false; + return -1; + } + return (*vec)[index]; +} + +// ----------------------------------------------------------------------------- +template +int NeighborList::getNumberOfLists() const +{ + return static_cast(m_Array.size()); +} + +// ----------------------------------------------------------------------------- +template +int NeighborList::getListSize(int grainId) const +{ +#ifndef NDEBUG + if(m_Array.size() > 0u) + { + Q_ASSERT(grainId < static_cast(m_Array.size())); + } +#endif + return static_cast(m_Array[grainId]->size()); +} + +// ----------------------------------------------------------------------------- +template +typename NeighborList::VectorType& NeighborList::getListReference(int grainId) const +{ +#ifndef NDEBUG + if(m_Array.size() > 0u) + { + Q_ASSERT(grainId < static_cast(m_Array.size())); + } +#endif + return *(m_Array[grainId]); +} + +// ----------------------------------------------------------------------------- +template +typename NeighborList::SharedVectorType NeighborList::getList(int grainId) const +{ +#ifndef NDEBUG + if(m_Array.size() > 0u) + { + Q_ASSERT(grainId < static_cast(m_Array.size())); + } +#endif + return m_Array[grainId]; +} + +// ----------------------------------------------------------------------------- +template +typename NeighborList::VectorType NeighborList::copyOfList(int grainId) const +{ +#ifndef NDEBUG + if(m_Array.size() > 0u) + { + Q_ASSERT(grainId < static_cast(m_Array.size())); + } +#endif + + VectorType copy(*(m_Array[grainId])); + return copy; +} + +// ----------------------------------------------------------------------------- +template +typename NeighborList::VectorType& NeighborList::operator[](int grainId) +{ +#ifndef NDEBUG + if(m_Array.size() > 0u) + { + Q_ASSERT(grainId < static_cast(m_Array.size())); + } +#endif + return *(m_Array[grainId]); +} + +// ----------------------------------------------------------------------------- +template +typename NeighborList::VectorType& NeighborList::operator[](size_t grainId) +{ +#ifndef NDEBUG + if(m_Array.size() > 0ul) + { + Q_ASSERT(grainId < m_Array.size()); + } +#endif + return *(m_Array[grainId]); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +#if !defined(__APPLE__) && !defined(_MSC_VER) +#undef SIMPLib_EXPORT +#define SIMPLib_EXPORT +#endif + +template class SIMPLib_EXPORT NeighborList; + +template class SIMPLib_EXPORT NeighborList; +template class SIMPLib_EXPORT NeighborList; + +template class SIMPLib_EXPORT NeighborList; +template class SIMPLib_EXPORT NeighborList; + +template class SIMPLib_EXPORT NeighborList; +template class SIMPLib_EXPORT NeighborList; + +template class SIMPLib_EXPORT NeighborList; +template class SIMPLib_EXPORT NeighborList; + +template class SIMPLib_EXPORT NeighborList; +template class SIMPLib_EXPORT NeighborList; + +#if defined(__APPLE__) || defined(_MSC_VER) +template class SIMPLib_EXPORT NeighborList; +#endif diff --git a/Source/SIMPLib/DataArrays/NeighborList.hpp b/Source/SIMPLib/DataArrays/NeighborList.hpp old mode 100755 new mode 100644 index a7e4085d90..e8b8faece3 --- a/Source/SIMPLib/DataArrays/NeighborList.hpp +++ b/Source/SIMPLib/DataArrays/NeighborList.hpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,23 +35,16 @@ #pragma once +#include +#include #include #include -#include -#include - -#include "H5Support/H5Lite.h" -#include "H5Support/H5Utilities.h" -#include "H5Support/QH5Lite.h" +#include "H5Support/H5SupportTypeDefs.h" #include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/Constants.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataArrays/IDataArray.h" -#include "SIMPLib/DataArrays/DataArray.hpp" - /** * @class NeighborList NeighborList.hpp DREAM3DLib/Common/NeighborList.hpp @@ -60,1039 +53,447 @@ * @date July 3, 2008 * @version 1.0 */ -template +template class NeighborList : public IDataArray { - public: - SIMPL_SHARED_POINTERS(NeighborList ) - SIMPL_TYPE_MACRO_SUPER(NeighborList, IDataArray) - SIMPL_CLASS_VERSION(2) - - SIMPL_INSTANCE_STRING_PROPERTY(NumNeighborsArrayName) - - static Pointer New() - { - return CreateArray(0, "NeighborList", false); - } - - /** - * @brief CreateArray - * @param numTuples - * @param name - * @param allocate - * @return - */ - static Pointer CreateArray(size_t numTuples, const QString& name, bool allocate = true) - { - //std::cout << "NeighborList::CreateArray name= " << name.toStdString() << " numTuples= " << numTuples << std::endl; - if(name.isEmpty()) - { - return NullPointer(); - } - Pointer ptr = Pointer(new NeighborList(numTuples, name)); - if(allocate) - { - ptr->resizeTuples(numTuples); - } - return ptr; - } - - /** - * @brief CreateArray - * @param numTuples - * @param rank - * @param dims - * @param name - * @param allocate - * @return - */ - static Pointer CreateArray(size_t numTuples, int rank, size_t* dims, const QString& name, bool allocate = true) - { - //std::cout << "NeighborList::CreateArray name= " << name.toStdString() << " numTuples= " << numTuples << std::endl; - if(name.isEmpty()) - { - return NullPointer(); - } - - size_t numElements = numTuples; - for(int iter = 0; iter < rank; iter++) - { - numElements *= dims[iter]; - } - Pointer ptr = Pointer(new NeighborList(numElements, name)); - if(allocate) - { - ptr->resizeTuples(numElements); - } - return ptr; - } - - /** - * @brief CreateArray - * @param numTuples - * @param cDims - * @param name - * @param allocate - * @return - */ - static Pointer CreateArray(size_t numTuples, std::vector cDims, const QString& name, bool allocate = true) - { - if(name.isEmpty()) - { - return NullPointer(); - } - size_t numElements = numTuples; - for(size_t iter = 0; iter < cDims.size(); iter++) - { - numElements *= cDims[iter]; - } - Pointer ptr = Pointer(new NeighborList(numElements, name)); - if(allocate) - { - ptr->resizeTuples(numElements); - } - return ptr; - } - - /** - * @brief CreateArray - * @param numTuples - * @param cDims - * @param name - * @param allocate - * @return - */ - static Pointer CreateArray(size_t numTuples, QVector cDims, const QString& name, bool allocate = true) - { - if(name.isEmpty()) - { - return NullPointer(); - } - size_t numElements = numTuples; - for(int iter = 0; iter < cDims.size(); iter++) - { - numElements *= cDims[iter]; - } - Pointer ptr = Pointer(new NeighborList(numElements, name)); - if(allocate) - { - ptr->resizeTuples(numElements); - } - return ptr; - } - - /** - * @brief CreateArray - * @param tDims - * @param cDims - * @param name - * @param allocate - * @return - */ - static Pointer CreateArray(QVector tDims, QVector cDims, const QString& name, bool allocate = true) - { - if(name.isEmpty()) - { - return NullPointer(); - } - size_t numElements = tDims[0]; - for(int iter = 1; iter < tDims.size(); iter++) - { - numElements *= tDims[iter]; - } - for(int iter = 0; iter < cDims.size(); iter++) - { - numElements *= cDims[iter]; - } - Pointer ptr = Pointer(new NeighborList(numElements, name)); - if(allocate) - { - ptr->resizeTuples(numElements); - } - return ptr; - } - - /** - * @brief createNewArray - * @param numElements - * @param rank - * @param dims - * @param name - * @return - */ - IDataArray::Pointer createNewArray(size_t numElements, int rank, size_t* dims, const QString& name, bool allocate = true) override - { - return NeighborList::CreateArray(numElements, rank, dims, name, allocate); - } - - /** - * @brief createNewArray - * @param numElements - * @param dims - * @param name - * @return - */ - IDataArray::Pointer createNewArray(size_t numElements, std::vector dims, const QString& name, bool allocate = true) override - { - return NeighborList::CreateArray(numElements, dims, name, allocate); - } - - /** - * @brief createNewArray - * @param numElements - * @param dims - * @param name - * @return - */ - IDataArray::Pointer createNewArray(size_t numElements, QVector dims, const QString& name, bool allocate = true) override - { - return NeighborList::CreateArray(numElements, dims, name, allocate); - } - - using VectorType = std::vector; - using SharedVectorType = std::shared_ptr; - - // ----------------------------------------------------------------------------- - ~NeighborList() override = default; - - /** - * @brief isAllocated - * @return - */ - bool isAllocated() override { return true; } - - /** - * @brief Gives this array a human readable name - * @param name The name of this array - */ - virtual void setInitValue(T initValue) - { - m_InitValue = initValue; - } - - /** - * @brief Sets all the values to value. - */ - virtual void initializeWithValue(T initValue, size_t offset = 0) - { - - } - - /** - * @brief getTypeName Returns a string representation of the type of data that is stored by this class. This - * can be a primitive like char, float, int or the name of a class. - * @return - */ - void getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) override - { - T value = 0x00; - xdmfTypeName = "UNKNOWN"; - precision = 0; - if (typeid(value) == typeid(int8_t)) { xdmfTypeName = "Char"; precision = 1;} - if (typeid(value) == typeid(uint8_t)) { xdmfTypeName = "UChar"; precision = 1;} - - if (typeid(value) == typeid(int16_t)) { xdmfTypeName = "16 BIT NOT SUPPORTED BY XDMF"; precision = 0;} - if (typeid(value) == typeid(uint16_t)) { xdmfTypeName = "16 BIT NOT SUPPORTED BY XDMF"; precision = 0;} - - if (typeid(value) == typeid(int32_t)) { xdmfTypeName = "Int"; precision = 4;} - if (typeid(value) == typeid(uint32_t)) { xdmfTypeName = "UInt"; precision = 4;} - - if (typeid(value) == typeid(int64_t)) { xdmfTypeName = "Int"; precision = 8;} - if (typeid(value) == typeid(uint64_t)) { xdmfTypeName = "UInt"; precision = 8;} - - if (typeid(value) == typeid(float)) { xdmfTypeName = "Float"; precision = 4;} - if (typeid(value) == typeid(double)) { xdmfTypeName = "Float"; precision = 8;} - - if (typeid(value) == typeid(bool)) { xdmfTypeName = "uchar"; precision = 1;} - } - - - /** - * @brief getTypeAsString - * @return - */ - QString getTypeAsString() override { return NeighborList::ClassName();} - - /** - * @brief setName - * @param name - */ - void setName(const QString& name) override { m_Name = name; } - - /** - * @brief getName - * @return - */ - QString getName() override { return m_Name; } - - /** - * @brief takeOwnership - */ - void takeOwnership() override { } - - /** - * @brief releaseOwnership - */ - void releaseOwnership() override { } - - /** - * @brief getVoidPointer - * @param i - * @return - */ - void* getVoidPointer(size_t i) override { return nullptr; } - - /** - * @brief Removes Tuples from the Array. If the size of the vector is Zero nothing is done. If the size of the - * vector is greater than or Equal to the number of Tuples then the Array is Resized to Zero. If there are - * indices that are larger than the size of the original (before erasing operations) then an error code (-100) is - * returned from the program. - * @param idxs The indices to remove - * @return error code. - */ - int eraseTuples(QVector& idxs) override - { - int err = 0; - // If nothing is to be erased just return - if(idxs.empty()) - { - return 0; - } - - size_t idxsSize = static_cast(idxs.size()); - if (idxsSize >= getNumberOfTuples() ) - { - resizeTuples(0); - return 0; - } - - size_t arraySize = m_Array.size(); - // Sanity Check the Indices in the vector to make sure we are not trying to remove any indices that are - // off the end of the array and return an error code. - for(QVector::size_type i = 0; i < idxs.size(); ++i) - { - if (idxs[i] >= arraySize) { return -100; } - } - - std::vector replacement(arraySize - idxsSize); - - size_t idxsIndex = 0; - size_t rIdx = 0; - for(size_t dIdx = 0; dIdx < arraySize; ++dIdx) - { - if (dIdx != idxs[idxsIndex]) - { - replacement[rIdx] = m_Array[dIdx]; - ++rIdx; - } - else - { - ++idxsIndex; - if (idxsIndex == idxsSize ) { idxsIndex--;} - } - } - m_Array = replacement; - m_NumTuples = m_Array.size(); - return err; - } - - /** - * @brief copyTuple - * @param currentPos - * @param newPos - * @return - */ - int copyTuple(size_t currentPos, size_t newPos) override - { - m_Array[newPos] = m_Array[currentPos]; - return 0; - } - - // This line must be here, because we are overloading the copyData pure virtual function in IDataArray. - // This is required so that other classes can call this version of copyData from the subclasses. - using IDataArray::copyFromArray; - - /** - * @brief copyData This method copies the number of tuples specified by the - * totalSrcTuples value starting from the source tuple offset value in sourceArray - * into the current array starting at the target destination tuple offset value. - * - * For example if the DataArray has 10 tuples, the source DataArray has 10 tuples, - * the destTupleOffset = 5, the srcTupleOffset = 5, and the totalSrcTuples = 3, - * then tuples 5, 6, and 7 will be copied from the source into tuples 5, 6, and 7 - * of the destination array. In psuedo code it would be the following: - * @code - * destArray[5] = sourceArray[5]; - * destArray[6] = sourceArray[6]; - * destArray[7] = sourceArray[7]; - * ..... - * @endcode - * @param destTupleOffset - * @param sourceArray - * @return - */ - bool copyFromArray(size_t destTupleOffset, IDataArray::Pointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) override - { - if(!m_IsAllocated) { return false; } - if(destTupleOffset >= m_Array.size() ) { return false; } - if(!sourceArray->isAllocated()) { return false; } - Self* source = dynamic_cast(sourceArray.get()); - - if(sourceArray->getNumberOfComponents() != getNumberOfComponents()) - { - return false; - } - - if(srcTupleOffset + totalSrcTuples > sourceArray->getNumberOfTuples()) - { - return false; - } - - if(totalSrcTuples * sourceArray->getNumberOfComponents() + destTupleOffset * getNumberOfComponents() > m_Array.size()) - { - return false; - } - - for(size_t i = srcTupleOffset; i < srcTupleOffset + totalSrcTuples; i++) - { - m_Array[destTupleOffset + i] = source->getList(i); - } - return true; - - // if(!m_IsAllocated) { return false; } - // if(nullptr == m_Array) { return false; } - // if(destTupleOffset > m_MaxId) { return false; } - // if(!sourceArray->isAllocated()) { return false; } - // Self* source = dynamic_cast(sourceArray.get()); - // if(nullptr == source->getPointer(0)) { return false; } - - // if(sourceArray->getNumberOfComponents() != getNumberOfComponents()) { return false; } - - // if (srcTupleOffset + totalSrcTuples > sourceArray->getNumberOfTuples()) { return false; } - - // if( totalSrcTuples*sourceArray->getNumberOfComponents() + destTupleOffset*getNumberOfComponents() > m_Size) { return false; } - - // size_t elementStart = destTupleOffset*getNumberOfComponents(); - // size_t totalBytes = (totalSrcTuples*sourceArray->getNumberOfComponents()) * sizeof(T); - // std::memcpy(m_Array + elementStart, source->getPointer(srcTupleOffset * sourceArray->getNumberOfComponents()), totalBytes); - // return true; - } - - - /** - * @brief Splats the same value c across all values in the Tuple - * @param i The index of the Tuple - * @param c The value to splat across all components in the tuple - */ - void initializeTuple(size_t i, void* p) override - { - Q_UNUSED(i); - Q_UNUSED(p); - Q_ASSERT(false); - } - - /** - * @brief Returns the number of elements in the internal array. - */ - size_t getNumberOfTuples() override - { - return m_NumTuples; - } - - - /** - * @brief getSize Returns the total number of data items that are being stored. This is the sum of all the sizes - * of the internal storage arrays for this class. - * @return - */ - size_t getSize() override - { - size_t total = 0; - for(size_t dIdx = 0; dIdx < m_Array.size(); ++dIdx) - { - total += m_Array[dIdx]->size(); - } - return total; - } - - /** - * @brief setNumberOfComponents - * @param nc - */ - void setNumberOfComponents(int nc) { } - - /** - * @brief getNumberOfComponents - * @return - */ - int getNumberOfComponents() override { return 1; } - - /** - * @brief getComponentDimensions - * @return - */ - QVector getComponentDimensions() override - { - QVector dims(1, 1); - return dims; - } - - /** - * @brief SetRank - * @param rnk - */ - void SetRank(int rnk) { } - - /** - * @brief getRank - * @return - */ - int getRank() { return 1; } - - /** - * @brief getTypeSize - * @return - */ - size_t getTypeSize() override { return sizeof(SharedVectorType); } - - /** - * @brief initializeWithZeros - */ - void initializeWithZeros() override { - m_Array.clear(); - m_IsAllocated = false; - } - - /** - * @brief deepCopy - * @return - */ - IDataArray::Pointer deepCopy(bool forceNoAllocate = false) override - { - typename NeighborList::Pointer daCopyPtr = NeighborList::CreateArray(getNumberOfTuples(), getName(), m_IsAllocated); - - if(!forceNoAllocate) - { - size_t count = (m_IsAllocated ? getNumberOfTuples(): 0); - for(size_t i = 0; i < count; i++) - { - typename NeighborList::SharedVectorType sharedNeiLst(new std::vector(*(m_Array[i]))); - daCopyPtr->setList(static_cast(i), sharedNeiLst); - } - } - return daCopyPtr; - } - - /** - * @brief resizeTotalElements - * @param size - * @return - */ - int32_t resizeTotalElements(size_t size) override - { - //std::cout << "NeighborList::resizeTotalElements(" << size << ")" << std::endl; - size_t old = m_Array.size(); - m_Array.resize(size); - m_NumTuples = size; - if (size == 0) { m_IsAllocated = false; } - else { m_IsAllocated = true; } - // Initialize with zero length Vectors - for (size_t i = old; i < m_Array.size(); ++i) - { - m_Array[i] = SharedVectorType(new VectorType); - } - return 1; - } - - /** - * @brief Resizes the internal array to accomondate numTuples - * @param numTuples - */ - void resizeTuples(size_t numTuples) - { - resizeTotalElements(numTuples); - } - - /** - * @brief Resizes the internal array to accomondate numTuples - * @param numTuples - */ - int32_t resize(size_t numTuples) override - { - return resizeTotalElements(numTuples); - } - - //FIXME: These need to be implemented - void printTuple(QTextStream& out, size_t i, char delimiter = ',') override - { - SharedVectorType sharedVec = m_Array[i]; - VectorType* vec = sharedVec.get(); - size_t size = vec->size(); - out << size; - for(size_t j = 0; j < size; j++) - { - out << delimiter << vec->at(j); - } - } - - /** - * @brief printComponent - * @param out - * @param i - * @param j - */ - void printComponent(QTextStream& out, size_t i, int j) override - { - Q_ASSERT(false); - } - - /** - * - * @param parentId - * @return - */ - int writeH5Data(hid_t parentId, QVector tDims) override - { - int err = 0; - - // Generate the NumNeighbors array and also compute the total number - // of elements that would be needed to flatten the array so we - // can compare this with what is written in the file. If they are - // different we are going to overwrite what is in the file with what - // we compute here. - if(m_NumNeighborsArrayName.isEmpty()) - { - m_NumNeighborsArrayName = getName() + "_NumNeighbors"; - } - Int32ArrayType::Pointer numNeighborsPtr = Int32ArrayType::CreateArray(m_Array.size(), m_NumNeighborsArrayName); - int32_t* numNeighbors = numNeighborsPtr->getPointer(0); - size_t total = 0; - for(size_t dIdx = 0; dIdx < m_Array.size(); ++dIdx) - { - numNeighbors[dIdx] = static_cast(m_Array[dIdx]->size()); - total += m_Array[dIdx]->size(); - } - - // Check to see if the NumNeighbors is already written to the file - bool rewrite = false; - if(!QH5Lite::datasetExists(parentId, m_NumNeighborsArrayName)) - { - // The NumNeighbors Array is NOT already in the file so write it to the file - numNeighborsPtr->writeH5Data(parentId, tDims); - } - else - { - // The NumNeighbors array is in the dream3d file so read it up into memory and compare with what - // we have in memory. - std::vector fileNumNeigh(m_Array.size()); - err = QH5Lite::readVectorDataset(parentId, m_NumNeighborsArrayName, fileNumNeigh); - if (err < 0) - { - return -602; - } - - // Compare the 2 vectors to make sure they are exactly the same; - if (fileNumNeigh.size() != numNeighborsPtr->getNumberOfTuples()) - { - rewrite = true; - } - // The sizes are the same, now compare each value; - int32_t* fileNumNeiPtr = &(fileNumNeigh.front()); - size_t nBytes = numNeighborsPtr->getNumberOfTuples() * sizeof(int32_t); - if (::memcmp(numNeighbors, fileNumNeiPtr, nBytes) != 0) - { - rewrite = true; - } - } - - // Write out the NumNeighbors Array because something was different between what we computed at - // the top of the function versus what is in memory - if(rewrite) - { - numNeighborsPtr->writeH5Data(parentId, tDims); - } - - // Allocate an array of the proper size so we can concatenate all the arrays together into a single array that - // can be written to the HDF5 File. This operation can ballon the memory size temporarily until this operation - // is complete. - QVector flat (total); - size_t currentStart = 0; - for(size_t dIdx = 0; dIdx < m_Array.size(); ++dIdx) - { - size_t nEle = m_Array[dIdx]->size(); - if(nEle == 0) - { - continue; - } - T* start = m_Array[dIdx]->data(); // get the pointer to the front of the array - // T* end = start + nEle; // get the pointer to the end of the array - T* dst = flat.data() + currentStart; - ::memcpy(dst, start, nEle * sizeof(T)); - - currentStart += m_Array[dIdx]->size(); - } - - // Now we can actually write the actual array data. - int32_t rank = 1; - hsize_t dims[1] = { total }; - if (total > 0) - { - err = QH5Lite::writePointerDataset(parentId, getName(), rank, dims, flat.data()); - if(err < 0) - { - return -605; - } - - err = QH5Lite::writeScalarAttribute(parentId, getName(), SIMPL::HDF5::DataArrayVersion, getClassVersion()); - if(err < 0) - { - return -604; - } - err = QH5Lite::writeStringAttribute(parentId, getName(), SIMPL::HDF5::ObjectType, getNameOfClass()); - if(err < 0) - { - return -607; - } - - // Write the tuple dimensions as an attribute - hsize_t size = tDims.size(); - err = QH5Lite::writePointerAttribute(parentId, getName(), SIMPL::HDF5::TupleDimensions, 1, &size, tDims.data()); - if (err < 0) - { - return -609; - } - - QVector cDims = getComponentDimensions(); - // write the component dimensions as an attribute - size = cDims.size(); - err = QH5Lite::writePointerAttribute(parentId, getName(), SIMPL::HDF5::ComponentDimensions, 1, &size, cDims.data()); - if (err < 0) - { - return -610; - } - - err = QH5Lite::writeStringAttribute(parentId, getName(), "Linked NumNeighbors Dataset", m_NumNeighborsArrayName); - if(err < 0) - { - return -608; - } - } - return err; - } - - /** - * @brief writeXdmfAttribute - * @param out - * @param volDims - * @param hdfFileName - * @param groupPath - * @return - */ - int writeXdmfAttribute(QTextStream& out, int64_t* volDims, const QString& hdfFileName, - const QString& groupPath, const QString& label) override - { - int precision = 0; - QString xdmfTypeName; - getXdmfTypeAndSize(xdmfTypeName, precision); - - out << " "; - out << " "; - out << " " << hdfFileName.toLatin1().data() << groupPath.toLatin1().data() << "/" << getName(); - out << " "; - out << " "; - return 1; - } - - /** - * @brief getInfoString - * @return Returns a formatted string that contains general infomation about - * the instance of the object. - */ - QString getInfoString(SIMPL::InfoStringFormat format) override - { - QString info; - QTextStream ss (&info); - if(format == SIMPL::HtmlFormat) - { - ss << "\n"; - ss << "\n"; - ss << "\n"; - ss << "\n"; - ss << ""; - - ss << ""; - - ss << ""; - QLocale usa(QLocale::English, QLocale::UnitedStates); - QString numStr = usa.toString(static_cast(getNumberOfTuples())); - ss << ""; - ss << ""; - - ss << "
Attribute Array Info
Name:" << getName() << "
Type:" << getTypeAsString() << "
Number of Tuples:" << numStr << "
Number of Lists:" << getNumberOfLists() << "
\n"; - ss << "
"; - ss << ""; - } - else - { - - } - return info; - } - /** - * - * @param parentId - * @return - */ - int readH5Data(hid_t parentId) override - { - int err = 0; - - std::vector flat; - err = QH5Lite::readVectorDataset(parentId, getName(), flat); - if(err < 0) - { - return err; - } - - // Read the Attribute Off the data set to find the name of the array that holds all the sizes - err = QH5Lite::readStringAttribute(parentId, getName(), "Linked NumNeighbors Dataset", m_NumNeighborsArrayName); - if(err < 0) - { - return err; - } - // Generate the number of neighbors array and also compute the total number - // of elements that would be needed to flatten the array - std::vector numNeighbors; - - // Check to see if the NumNeighbors exists in the file, which it must. - if(QH5Lite::datasetExists(parentId, m_NumNeighborsArrayName)) - { - err = QH5Lite::readVectorDataset(parentId, m_NumNeighborsArrayName, numNeighbors); - if(err < 0) - { - return -702; - } - } - else - { - return -703; - } - - // int32_t totalElements = std::accumulate(numNeighbors.begin(), numNeighbors.end(), 0); - - // Loop over all the entries and make new Vectors to hold the incoming data - m_Array.resize(numNeighbors.size()); - m_IsAllocated = true; - size_t currentStart = 0; - qint32 count = static_cast(numNeighbors.size()); - for(QVector::size_type dIdx = 0; dIdx < count; ++dIdx) - { - size_t nEle = numNeighbors[dIdx]; - if(nEle > 0) - { - m_Array[dIdx] = SharedVectorType(new VectorType(numNeighbors[dIdx])); - - T* dst = m_Array[dIdx]->data(); // get the pointer to the front of the array - // T* end = start + nEle; // get the pointer to the end of the array - T* start = flat.data() + currentStart; - ::memcpy(dst, start, nEle * sizeof(T)); - currentStart += nEle; - } - else - { - m_Array[dIdx] = SharedVectorType(new VectorType(0)); - } - } - m_NumTuples = m_Array.size(); // Sync up the numTuples property with the size of the internal array - return err; - } - - /** - * @brief addEntry - * @param grainId - * @param value - */ - void addEntry(int grainId, T value) - { - if(grainId >= static_cast(m_Array.size()) ) - { - size_t old = m_Array.size(); - m_Array.resize(grainId + 1); - m_IsAllocated = true; - // Initialize with zero length Vectors - for(size_t i = old; i < m_Array.size(); ++i) - { - m_Array[i] = SharedVectorType(new VectorType); - } - } - m_Array[grainId]->push_back(value); - m_NumTuples = m_Array.size(); - } - - /** - * @brief clearAllLists - */ - void clearAllLists() - { - m_Array.clear(); - m_IsAllocated = false; - } - - - /** - * @brief setList - * @param grainId - * @param neighborList - */ - void setList(int grainId, SharedVectorType neighborList) - { - if(grainId >= static_cast(m_Array.size()) ) - { - size_t old = m_Array.size(); - m_Array.resize(grainId + 1); - m_IsAllocated = true; - // Initialize with zero length Vectors - for(size_t i = old; i < m_Array.size(); ++i) - { - m_Array[i] = SharedVectorType(new VectorType); - } - } - m_Array[grainId] = neighborList; - } - - /** - * @brief getValue - * @param grainId - * @param index - * @param ok - * @return - */ - T getValue(int grainId, int index, bool& ok) - { -#ifndef NDEBUG - if (m_Array.size() > 0u) { Q_ASSERT(grainId < static_cast(m_Array.size()));} -#endif - SharedVectorType vec = m_Array[grainId]; - if(index < 0 || static_cast(index) >= vec->size()) - { - ok = false; - return -1; - } - return (*vec)[index]; - } - - /** - * @brief getNumberOfLists - * @return - */ - int getNumberOfLists() - { - return static_cast(m_Array.size()); - } - - /** - * @brief getListSize - * @param grainId - * @return - */ - int getListSize(int grainId) - { -#ifndef NDEBUG - if (m_Array.size() > 0u) { Q_ASSERT(grainId < static_cast(m_Array.size()));} -#endif - return static_cast(m_Array[grainId]->size()); - } - - VectorType& getListReference(int grainId) - { -#ifndef NDEBUG - if (m_Array.size() > 0u) { Q_ASSERT(grainId < static_cast(m_Array.size()));} -#endif - return *(m_Array[grainId]); - } - - /** - * @brief getList - * @param grainId - * @return - */ - SharedVectorType getList(int grainId) - { -#ifndef NDEBUG - if (m_Array.size() > 0u) { Q_ASSERT(grainId < static_cast(m_Array.size()));} -#endif - return m_Array[grainId]; - } - - /** - * @brief copyOfList - * @param grainId - * @return - */ - VectorType copyOfList(int grainId) - { -#ifndef NDEBUG - if (m_Array.size() > 0u) { Q_ASSERT(grainId < static_cast(m_Array.size()));} -#endif - - VectorType copy(*(m_Array[grainId])); - return copy; - } - - /** - * @brief operator [] - * @param grainId - * @return - */ - VectorType& operator[](int grainId) - { -#ifndef NDEBUG - if (m_Array.size() > 0u) { Q_ASSERT(grainId < static_cast(m_Array.size()));} -#endif - return *(m_Array[grainId]); - } - - /** - * @brief operator [] - * @param grainId - * @return - */ - VectorType& operator[](size_t grainId) - { -#ifndef NDEBUG - if (m_Array.size() > 0ul) { Q_ASSERT(grainId < m_Array.size());} -#endif - return *(m_Array[grainId]); - - } - - - protected: - /** - * @brief NeighborList - */ - NeighborList(size_t numTuples, const QString& name) - : m_NumNeighborsArrayName() - , m_Name(name) - , m_NumTuples(numTuples) - , m_IsAllocated(false) - { - } - - private: - std::vector m_Array; - QString m_Name; - size_t m_NumTuples; - bool m_IsAllocated; - T m_InitValue; - - public: - NeighborList(const NeighborList&) = delete; // Copy Constructor Not Implemented - NeighborList(NeighborList&&) = delete; // Move Constructor Not Implemented - NeighborList& operator=(const NeighborList&) = delete; // Copy Assignment Not Implemented - NeighborList& operator=(NeighborList&&) = delete; // Move Assignment Not Implemented +public: + using Self = NeighborList; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + static Pointer NullPointer(); + + using value_type = T; + + /** + * @brief Returns the name of the class for AbstractMessage + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for AbstractMessage + */ + static QString ClassName(); + + /** + * @brief Returns the version of this class. + * @return + */ + int32_t getClassVersion() const override; + + void setNumNeighborsArrayName(const QString& name); + + QString getNumNeighborsArrayName(); + + static Pointer New(); + + /** + * @brief CreateArray + * @param numTuples + * @param name + * @param allocate + * @return + */ + static Pointer CreateArray(size_t numTuples, const QString& name, bool allocate = true); + /** + * @brief CreateArray + * @param numTuples + * @param name + * @param allocate + * @return + */ + static Pointer CreateArray(size_t numTuples, const std::string& name, bool allocate = true); + + /** + * @brief CreateArray + * @param numTuples + * @param rank + * @param dims + * @param name + * @param allocate + * @return + */ + static Pointer CreateArray(size_t numTuples, int rank, const size_t* dims, const QString& name, bool allocate = true); + + /** + * @brief CreateArray + * @param numTuples + * @param cDims + * @param name + * @param allocate + * @return + */ + static Pointer CreateArray(size_t numTuples, const std::vector& cDims, const QString& name, bool allocate = true); + + /** + * @brief CreateArray + * @param tDims + * @param cDims + * @param name + * @param allocate + * @return + */ + static Pointer CreateArray(const std::vector& tDims, const std::vector& cDims, const QString& name, bool allocate); + + /** + * @brief createNewArray + * @param numElements + * @param rank + * @param dims + * @param name + * @return + */ + IDataArray::Pointer createNewArray(size_t numElements, int rank, const size_t* dims, const QString& name, bool allocate = true) const override; + + /** + * @brief createNewArray + * @param numElements + * @param dims + * @param name + * @return + */ + IDataArray::Pointer createNewArray(size_t numElements, const std::vector& dims, const QString& name, bool allocate = true) const override; + + using VectorType = std::vector; + using SharedVectorType = std::shared_ptr; + + // ----------------------------------------------------------------------------- + ~NeighborList() override = default; + + /** + * @brief isAllocated + * @return + */ + bool isAllocated() const override; + + /** + * @brief Gives this array a human readable name + * @param name The name of this array + */ + virtual void setInitValue(T initValue); + + /** + * @brief Sets all the values to value. + */ + virtual void initializeWithValue(T initValue, size_t offset = 0); + + /** + * @brief getXdmfTypeAndSize Returns the XDMF Type Name and precision. + * @return Returns UNKNOWN and 0 Since NeighborLists are not written to XDMF + */ + void getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) const override; + + /** + * @brief Returns the HDF Type for a given primitive value. + * @param value A value to use. Can be anything. Just used to get the type info + * from + * @return The HDF5 native type for the value + */ + QString getFullNameOfClass() const; + + /** + * @brief getTypeAsString + * @return + */ + QString getTypeAsString() const override; + + /** + * @brief takeOwnership + */ + void takeOwnership() override; + + /** + * @brief releaseOwnership + */ + void releaseOwnership() override; + + /** + * @brief getVoidPointer + * @param i + * @return + */ + void* getVoidPointer(size_t i) override; + + /** + * @brief Removes Tuples from the Array. If the size of the vector is Zero nothing is done. If the size of the + * vector is greater than or Equal to the number of Tuples then the Array is Resized to Zero. If there are + * indices that are larger than the size of the original (before erasing operations) then an error code (-100) is + * returned from the program. + * @param idxs The indices to remove + * @return error code. + */ + int eraseTuples(const std::vector& idxs) override; + + /** + * @brief copyTuple + * @param currentPos + * @param newPos + * @return + */ + int copyTuple(size_t currentPos, size_t newPos) override; + + // This line must be here, because we are overloading the copyData pure virtual function in IDataArray. + // This is required so that other classes can call this version of copyData from the subclasses. + using IDataArray::copyFromArray; + + /** + * @brief copyData This method copies the number of tuples specified by the + * totalSrcTuples value starting from the source tuple offset value in sourceArray + * into the current array starting at the target destination tuple offset value. + * + * For example if the DataArray has 10 tuples, the source DataArray has 10 tuples, + * the destTupleOffset = 5, the srcTupleOffset = 5, and the totalSrcTuples = 3, + * then tuples 5, 6, and 7 will be copied from the source into tuples 5, 6, and 7 + * of the destination array. In psuedo code it would be the following: + * @code + * destArray[5] = sourceArray[5]; + * destArray[6] = sourceArray[6]; + * destArray[7] = sourceArray[7]; + * ..... + * @endcode + * @param destTupleOffset + * @param sourceArray + * @return + */ + bool copyFromArray(size_t destTupleOffset, IDataArray::ConstPointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) override; + + /** + * @brief Splats the same value c across all values in the Tuple + * @param i The index of the Tuple + * @param c The value to splat across all components in the tuple + */ + void initializeTuple(size_t i, const void* p) override; + /** + * @brief Returns the number of elements in the internal array. + */ + size_t getNumberOfTuples() const override; + + /** + * @brief getSize Returns the total number of data items that are being stored. This is the sum of all the sizes + * of the internal storage arrays for this class. + * @return + */ + size_t getSize() const override; + + /** + * @brief setNumberOfComponents + * @param nc + */ + void setNumberOfComponents(int nc); + + /** + * @brief getNumberOfComponents + * @return + */ + int getNumberOfComponents() const override; + + /** + * @brief getComponentDimensions + * @return + */ + std::vector getComponentDimensions() const override; + + /** + * @brief SetRank + * @param rnk + */ + void SetRank(int rnk); + + /** + * @brief getRank + * @return + */ + int getRank() const; + + /** + * @brief getTypeSize + * @return + */ + size_t getTypeSize() const override; + + /** + * @brief initializeWithZeros + */ + void initializeWithZeros() override; + + /** + * @brief deepCopy + * @return + */ + IDataArray::Pointer deepCopy(bool forceNoAllocate = false) const override; + + /** + * @brief resizeTotalElements + * @param size + * @return + */ + int32_t resizeTotalElements(size_t size) override; + + /** + * @brief Resizes the internal array to accomondate numTuples + * @param numTuples + */ + void resizeTuples(size_t numTuples) override; + + // FIXME: These need to be implemented + void printTuple(QTextStream& out, size_t i, char delimiter = ',') const override; + + /** + * @brief printComponent + * @param out + * @param i + * @param j + */ + void printComponent(QTextStream& out, size_t i, int j) const override; + + /** + * + * @param parentId + * @return + */ + int writeH5Data(hid_t parentId, const std::vector& tDims) const override; + + /** + * @brief writeXdmfAttribute + * @param out + * @param volDims + * @param hdfFileName + * @param groupPath + * @return + */ + int writeXdmfAttribute(QTextStream& out, const int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& label) const override; + + /** + * @brief Returns a ToolTipGenerator for creating HTML tooltip tables + * with values populated to match the current DataArray. + * @return + */ + ToolTipGenerator getToolTipGenerator() const override; + + /** + * @brief getInfoString + * @return Returns a formatted string that contains general infomation about + * the instance of the object. + */ + QString getInfoString(SIMPL::InfoStringFormat format) const override; + /** + * + * @param parentId + * @return + */ + int readH5Data(hid_t parentId) override; + + /** + * @brief addEntry + * @param grainId + * @param value + */ + void addEntry(int grainId, T value); + + /** + * @brief clearAllLists + */ + void clearAllLists(); + + /** + * @brief setList + * @param grainId + * @param neighborList + */ + void setList(int grainId, SharedVectorType neighborList); + + /** + * @brief getValue + * @param grainId + * @param index + * @param ok + * @return + */ + T getValue(int grainId, int index, bool& ok) const; + + /** + * @brief getNumberOfLists + * @return + */ + int getNumberOfLists() const; + + /** + * @brief getListSize + * @param grainId + * @return + */ + int getListSize(int grainId) const; + + VectorType& getListReference(int grainId) const; + + /** + * @brief getList + * @param grainId + * @return + */ + SharedVectorType getList(int grainId) const; + + /** + * @brief copyOfList + * @param grainId + * @return + */ + VectorType copyOfList(int grainId) const; + + /** + * @brief operator [] + * @param grainId + * @return + */ + VectorType& operator[](int grainId); + + /** + * @brief operator [] + * @param grainId + * @return + */ + VectorType& operator[](size_t grainId); + +protected: + /** + * @brief NeighborList + */ + NeighborList(size_t numTuples, const QString name); + +private: + QString m_NumNeighborsArrayName; + std::vector m_Array; + size_t m_NumTuples; + bool m_IsAllocated; + T m_InitValue; + +public: + NeighborList(const NeighborList&) = delete; // Copy Constructor Not Implemented + NeighborList(NeighborList&&) = delete; // Move Constructor Not Implemented + NeighborList& operator=(const NeighborList&) = delete; // Copy Assignment Not Implemented + NeighborList& operator=(NeighborList&&) = delete; // Move Assignment Not Implemented }; using Int32NeighborListType = NeighborList; using FloatNeighborListType = NeighborList; + +// ----------------------------------------------------------------------------- +// Declare our extern templates + +extern template class NeighborList; +extern template class NeighborList; + +extern template class NeighborList; +extern template class NeighborList; +extern template class NeighborList; +extern template class NeighborList; +extern template class NeighborList; +extern template class NeighborList; +extern template class NeighborList; +extern template class NeighborList; + +extern template class NeighborList; +extern template class NeighborList; + +extern template class NeighborList; diff --git a/Source/SIMPLib/DataArrays/SourceList.cmake b/Source/SIMPLib/DataArrays/SourceList.cmake index 3dabfff1fc..7535a33ba9 100755 --- a/Source/SIMPLib/DataArrays/SourceList.cmake +++ b/Source/SIMPLib/DataArrays/SourceList.cmake @@ -14,15 +14,16 @@ set(SIMPLib_${SUBDIR_NAME}_HDRS ) set(SIMPLib_${SUBDIR_NAME}_SRCS + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataArray.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IDataArray.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IDataArrayFilter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/StatsDataArray.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/StringDataArray.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/NeighborList.cpp ) cmp_IDE_SOURCE_PROPERTIES( "${SUBDIR_NAME}" "${SIMPLib_${SUBDIR_NAME}_HDRS};${SIMPLib_${SUBDIR_NAME}_Moc_HDRS}" "${SIMPLib_${SUBDIR_NAME}_SRCS}" "${PROJECT_INSTALL_HEADERS}") cmp_IDE_SOURCE_PROPERTIES( "Generated/${SUBDIR_NAME}" "" "${SIMPLib_${SUBDIR_NAME}_Generated_MOC_SRCS}" "0") -message(STATUS "SIMPL_BUILD_TESTING: ${SIMPL_BUILD_TESTING}") #------------------------------------------------------------------------------- # Add the unit testing sources # -------------------------------------------------------------------- diff --git a/Source/SIMPLib/DataArrays/StatsDataArray.cpp b/Source/SIMPLib/DataArrays/StatsDataArray.cpp index 6bf88203a3..759971a656 100644 --- a/Source/SIMPLib/DataArrays/StatsDataArray.cpp +++ b/Source/SIMPLib/DataArrays/StatsDataArray.cpp @@ -1,57 +1,61 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "StatsDataArray.h" +#include #include +#include + +#include "H5Support/H5ScopedSentinel.h" +#include "H5Support/QH5Lite.h" +#include "H5Support/QH5Utilities.h" #include "SIMPLib/Common/PhaseType.h" +#include "SIMPLib/HDF5/H5DataArrayWriter.hpp" #include "SIMPLib/StatsData/BoundaryStatsData.h" #include "SIMPLib/StatsData/MatrixStatsData.h" #include "SIMPLib/StatsData/PrecipitateStatsData.h" #include "SIMPLib/StatsData/PrimaryStatsData.h" #include "SIMPLib/StatsData/TransformationStatsData.h" -#include "H5Support/H5ScopedSentinel.h" -#include "H5Support/QH5Utilities.h" - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- StatsDataArray::StatsDataArray() -: m_Name(SIMPL::EnsembleData::Statistics) +: IDataArray(SIMPL::EnsembleData::Statistics) { m_IsAllocated = true; } @@ -79,30 +83,26 @@ StatsDataArray::Pointer StatsDataArray::CreateArray(size_t numElements, const QS } return ptr; } - -// ----------------------------------------------------------------------------- -// // ----------------------------------------------------------------------------- -StatsDataArray::Pointer StatsDataArray::CreateArray(size_t numTuples, int rank, size_t* dims, const QString& name, bool allocate) +StatsDataArray::Pointer StatsDataArray::CreateArray(size_t numElements, const std::string& name, bool allocate) { - if(name.isEmpty()) + if(name.empty()) { return NullPointer(); } StatsDataArray::Pointer ptr = StatsDataArray::New(); - ptr->setName(name); - std::vector phase_types(numTuples, PhaseType::Type::Unknown); - if(allocate) + ptr->setName(QString::fromStdString(name)); + std::vector phase_types(numElements, PhaseType::Type::Unknown); + if(allocate && numElements > 0) { - ptr->fillArrayWithNewStatsData(numTuples, &(phase_types.front())); + ptr->fillArrayWithNewStatsData(numElements, &(phase_types.front())); } return ptr; } - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -StatsDataArray::Pointer StatsDataArray::CreateArray(size_t numTuples, std::vector cDims, const QString& name, bool allocate) +StatsDataArray::Pointer StatsDataArray::CreateArray(size_t numTuples, int rank, const size_t* dims, const QString& name, bool allocate) { if(name.isEmpty()) { @@ -121,7 +121,7 @@ StatsDataArray::Pointer StatsDataArray::CreateArray(size_t numTuples, std::vecto // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -StatsDataArray::Pointer StatsDataArray::CreateArray(size_t numTuples, QVector cDims, const QString& name, bool allocate) +StatsDataArray::Pointer StatsDataArray::CreateArray(size_t numTuples, const std::vector& cDims, const QString& name, bool allocate) { if(name.isEmpty()) { @@ -140,7 +140,7 @@ StatsDataArray::Pointer StatsDataArray::CreateArray(size_t numTuples, QVector tDims, QVector cDims, const QString& name, bool allocate) +StatsDataArray::Pointer StatsDataArray::CreateArray(const std::vector& tDims, const std::vector& cDims, const QString& name, bool allocate) { if(name.isEmpty()) { @@ -165,7 +165,7 @@ StatsDataArray::Pointer StatsDataArray::CreateArray(QVector tDims, QVect // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IDataArray::Pointer StatsDataArray::createNewArray(size_t numElements, int rank, size_t* dims, const QString& name, bool allocate) +IDataArray::Pointer StatsDataArray::createNewArray(size_t numElements, int rank, const size_t* dims, const QString& name, bool allocate) const { return StatsDataArray::NullPointer(); } @@ -173,7 +173,7 @@ IDataArray::Pointer StatsDataArray::createNewArray(size_t numElements, int rank, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IDataArray::Pointer StatsDataArray::createNewArray(size_t numElements, std::vector dims, const QString& name, bool allocate) +IDataArray::Pointer StatsDataArray::createNewArray(size_t numElements, const std::vector& dims, const QString& name, bool allocate) const { return StatsDataArray::NullPointer(); } @@ -181,30 +181,7 @@ IDataArray::Pointer StatsDataArray::createNewArray(size_t numElements, std::vect // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IDataArray::Pointer StatsDataArray::createNewArray(size_t numElements, QVector dims, const QString& name, bool allocate) -{ - return StatsDataArray::NullPointer(); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void StatsDataArray::setName(const QString& name) -{ - m_Name = name; -} -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString StatsDataArray::getName() -{ - return m_Name; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString StatsDataArray::getFullNameOfClass() +QString StatsDataArray::getFullNameOfClass() const { return QString("Statistics"); } @@ -244,7 +221,7 @@ void* StatsDataArray::getVoidPointer(size_t i) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -size_t StatsDataArray::getNumberOfTuples() +size_t StatsDataArray::getNumberOfTuples() const { return m_StatsDataArray.size(); } @@ -252,7 +229,7 @@ size_t StatsDataArray::getNumberOfTuples() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -size_t StatsDataArray::getSize() +size_t StatsDataArray::getSize() const { return m_StatsDataArray.size(); } @@ -260,7 +237,7 @@ size_t StatsDataArray::getSize() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int StatsDataArray::getNumberOfComponents() +int StatsDataArray::getNumberOfComponents() const { return 1; } @@ -268,16 +245,16 @@ int StatsDataArray::getNumberOfComponents() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector StatsDataArray::getComponentDimensions() +std::vector StatsDataArray::getComponentDimensions() const { - QVector dims(1, 1); + std::vector dims = {1}; return dims; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -size_t StatsDataArray::getTypeSize() +size_t StatsDataArray::getTypeSize() const { return sizeof(StatsData); } @@ -285,7 +262,7 @@ size_t StatsDataArray::getTypeSize() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int StatsDataArray::eraseTuples(QVector& idxs) +int StatsDataArray::eraseTuples(const std::vector& idxs) { int err = 0; @@ -297,15 +274,15 @@ int StatsDataArray::eraseTuples(QVector& idxs) if(static_cast(idxs.size()) >= getNumberOfTuples()) { - resize(0); + resizeTuples(0); return 0; } // Sanity Check the Indices in the vector to make sure we are not trying to remove any indices that are // off the end of the array and return an error code. - for(QVector::size_type i = 0; i < idxs.size(); ++i) + for(const auto& idx : idxs) { - if(idxs[i] >= static_cast(m_StatsDataArray.size())) + if(idx >= static_cast(m_StatsDataArray.size())) { return -100; } @@ -347,7 +324,7 @@ int StatsDataArray::copyTuple(size_t currentPos, size_t newPos) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool StatsDataArray::copyFromArray(size_t destTupleOffset, IDataArray::Pointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) +bool StatsDataArray::copyFromArray(size_t destTupleOffset, IDataArray::ConstPointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) { if(!m_IsAllocated) { @@ -365,7 +342,12 @@ bool StatsDataArray::copyFromArray(size_t destTupleOffset, IDataArray::Pointer s { return false; } - Self* source = dynamic_cast(sourceArray.get()); + const Self* source = dynamic_cast(sourceArray.get()); + + if(source == nullptr) + { + return false; + } if(sourceArray->getNumberOfComponents() != getNumberOfComponents()) { @@ -393,7 +375,7 @@ bool StatsDataArray::copyFromArray(size_t destTupleOffset, IDataArray::Pointer s // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void StatsDataArray::initializeTuple(size_t i, void* p) +void StatsDataArray::initializeTuple(size_t i, const void* p) { Q_ASSERT(false); } @@ -403,21 +385,17 @@ void StatsDataArray::initializeTuple(size_t i, void* p) // ----------------------------------------------------------------------------- void StatsDataArray::initializeWithZeros() { - - for(qint32 i = 0; i < m_StatsDataArray.size(); ++i) - { - m_StatsDataArray[i]->initialize(); - } + Q_ASSERT(false); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IDataArray::Pointer StatsDataArray::deepCopy(bool forceNoAllocate) +IDataArray::Pointer StatsDataArray::deepCopy(bool forceNoAllocate) const { StatsDataArray::Pointer daCopyPtr = StatsDataArray::CreateArray(getNumberOfTuples() * getNumberOfComponents(), getName()); - daCopyPtr->resize(getNumberOfTuples()); + daCopyPtr->resizeTuples(getNumberOfTuples()); for(size_t i = 0; i < getNumberOfTuples(); i++) { // This should be a Deep Copy of each of the StatsData subclasses instead of a reference copy @@ -446,22 +424,22 @@ int32_t StatsDataArray::resizeTotalElements(size_t size) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int32_t StatsDataArray::resize(size_t numTuples) +void StatsDataArray::resizeTuples(size_t numTuples) { - return resizeTotalElements(numTuples); + resizeTotalElements(numTuples); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void StatsDataArray::printTuple(QTextStream& out, size_t i, char delimiter) +void StatsDataArray::printTuple(QTextStream& out, size_t i, char delimiter) const { Q_ASSERT(false); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void StatsDataArray::printComponent(QTextStream& out, size_t i, int j) +void StatsDataArray::printComponent(QTextStream& out, size_t i, int j) const { Q_ASSERT(false); } @@ -469,15 +447,15 @@ void StatsDataArray::printComponent(QTextStream& out, size_t i, int j) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int StatsDataArray::writeH5Data(hid_t parentId, QVector tDims) +int StatsDataArray::writeH5Data(hid_t parentId, const std::vector& tDims) const { herr_t err = 0; - hid_t gid = QH5Utilities::createGroup(parentId, m_Name); + hid_t gid = QH5Utilities::createGroup(parentId, getName()); if(gid < 0) { return -1; } - H5ScopedGroupSentinel scopedFileSentinel(&gid, false); // This makes sure our H5Group is closed up as we exit this function + H5ScopedGroupSentinel scopedFileSentinel(gid, false); // This makes sure our H5Group is closed up as we exit this function // We start numbering our phases at 1. Anything in slot 0 is considered "Dummy" or invalid for(qint32 i = 1; i < m_StatsDataArray.size(); ++i) @@ -495,7 +473,7 @@ int StatsDataArray::writeH5Data(hid_t parentId, QVector tDims) } } - QVector cDims(1, 1); + std::vector cDims(1, 1); err = H5DataArrayWriter::writeDataArrayAttributes(parentId, this, tDims, cDims); return err; @@ -508,14 +486,14 @@ int StatsDataArray::readH5Data(hid_t parentId) bool ok = false; int err = 0; QString statsType; - hid_t gid = QH5Utilities::openHDF5Object(parentId, m_Name); + hid_t gid = QH5Utilities::openHDF5Object(parentId, getName()); if(gid < 0) { return err; } QList names; - err = QH5Utilities::getGroupObjects(gid, H5Utilities::H5Support_GROUP, names); + err = QH5Utilities::getGroupObjects(gid, H5Utilities::CustomHDFDataTypes::Group, names); if(err < 0) { err |= QH5Utilities::closeHDF5Object(gid); @@ -582,7 +560,7 @@ int StatsDataArray::readH5Data(hid_t parentId) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int StatsDataArray::writeToJson(QJsonObject& jsonRoot, UInt32ArrayType::Pointer crystalStructures) +int StatsDataArray::writeToJson(QJsonObject& jsonRoot, UInt32ArrayType::Pointer crystalStructures) const { int error = 0; @@ -676,7 +654,7 @@ int StatsDataArray::readFromJson(const QJsonObject& jsonRoot) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int StatsDataArray::writeXdmfAttribute(QTextStream& out, int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& labelb) +int StatsDataArray::writeXdmfAttribute(QTextStream& out, const int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& labelb) const { out << " "; return -1; @@ -685,39 +663,38 @@ int StatsDataArray::writeXdmfAttribute(QTextStream& out, int64_t* volDims, const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString StatsDataArray::getInfoString(SIMPL::InfoStringFormat format) +QString StatsDataArray::getInfoString(SIMPL::InfoStringFormat format) const { - QString info; - QTextStream ss(&info); if(format == SIMPL::HtmlFormat) { - ss << "\n"; - ss << "\n"; - ss << "\n"; - ss << "\n"; - ss << ""; - - ss << ""; - - ss << ""; - QLocale usa(QLocale::English, QLocale::UnitedStates); - QString numStr = usa.toString(static_cast(getNumberOfTuples())); - ss << ""; - - ss << "
Attribute Array Info
Name:" << getName() << "
Type:" << getTypeAsString() << "
Number of Tuples:" << numStr << "
\n"; - ss << "
"; - ss << ""; + return getToolTipGenerator().generateHTML(); } else { } - return info; + return QString(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +ToolTipGenerator StatsDataArray::getToolTipGenerator() const +{ + ToolTipGenerator toolTipGen; + QLocale usa(QLocale::English, QLocale::UnitedStates); + + toolTipGen.addTitle("Attribute Array Info"); + toolTipGen.addValue("Name", getName()); + toolTipGen.addValue("Type", getTypeAsString()); + toolTipGen.addValue("Number of Tuples", usa.toString(static_cast(getNumberOfTuples()))); + + return toolTipGen; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString StatsDataArray::getTypeAsString() +QString StatsDataArray::getTypeAsString() const { return "StatsDataArray"; } @@ -725,7 +702,7 @@ QString StatsDataArray::getTypeAsString() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void StatsDataArray::getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) +void StatsDataArray::getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) const { xdmfTypeName = getNameOfClass(); precision = 0; @@ -734,7 +711,7 @@ void StatsDataArray::getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool StatsDataArray::isAllocated() +bool StatsDataArray::isAllocated() const { return m_IsAllocated; } @@ -813,27 +790,27 @@ void StatsDataArray::fillArrayWithNewStatsData(size_t n, PhaseType::Type* phase_ void StatsDataArray::fillArrayWithNewStatsData(size_t n, PhaseType::EnumType* phase_types) { m_StatsDataArray.resize(n); - for (size_t i = 0; i < n; ++i) + for(size_t i = 0; i < n; ++i) { - if (phase_types != nullptr) + if(phase_types != nullptr) { - if (phase_types[i] == static_cast(PhaseType::Type::Primary)) + if(phase_types[i] == static_cast(PhaseType::Type::Primary)) { m_StatsDataArray[i] = PrimaryStatsData::New(); } - else if (phase_types[i] == static_cast(PhaseType::Type::Precipitate)) + else if(phase_types[i] == static_cast(PhaseType::Type::Precipitate)) { m_StatsDataArray[i] = PrecipitateStatsData::New(); } - else if (phase_types[i] == static_cast(PhaseType::Type::Transformation)) + else if(phase_types[i] == static_cast(PhaseType::Type::Transformation)) { m_StatsDataArray[i] = TransformationStatsData::New(); } - else if (phase_types[i] == static_cast(PhaseType::Type::Boundary)) + else if(phase_types[i] == static_cast(PhaseType::Type::Boundary)) { m_StatsDataArray[i] = BoundaryStatsData::New(); } - else if (phase_types[i] == static_cast(PhaseType::Type::Matrix)) + else if(phase_types[i] == static_cast(PhaseType::Type::Matrix)) { m_StatsDataArray[i] = MatrixStatsData::New(); } @@ -842,7 +819,7 @@ void StatsDataArray::fillArrayWithNewStatsData(size_t n, PhaseType::EnumType* ph m_StatsDataArray[i] = StatsData::New(); } } - if (phase_types == nullptr) + if(phase_types == nullptr) { m_StatsDataArray[i] = StatsData::New(); } @@ -852,7 +829,7 @@ void StatsDataArray::fillArrayWithNewStatsData(size_t n, PhaseType::EnumType* ph // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -StatsData::Pointer StatsDataArray::getStatsData(int idx) +StatsData::Pointer StatsDataArray::getStatsData(int idx) const { #ifndef NDEBUG if(!m_StatsDataArray.empty()) @@ -866,7 +843,7 @@ StatsData::Pointer StatsDataArray::getStatsData(int idx) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -StatsData::Pointer StatsDataArray::operator[](int idx) +StatsData::Pointer StatsDataArray::operator[](int idx) const { #ifndef NDEBUG if(!m_StatsDataArray.empty()) @@ -876,3 +853,46 @@ StatsData::Pointer StatsDataArray::operator[](int idx) #endif return m_StatsDataArray[idx]; } + +// ----------------------------------------------------------------------------- +StatsDataArray::Pointer StatsDataArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +StatsDataArray::Pointer StatsDataArray::New() +{ + Pointer sharedPtr(new(StatsDataArray)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString StatsDataArray::getNameOfClass() const +{ + return QString("StatsDataArray"); +} + +// ----------------------------------------------------------------------------- +QString StatsDataArray::ClassName() +{ + return QString("StatsDataArray"); +} + +// ----------------------------------------------------------------------------- +void StatsDataArray::setStatsDataArray(const QVector& value) +{ + m_StatsDataArray = value; +} + +// ----------------------------------------------------------------------------- +QVector StatsDataArray::getStatsDataArray() const +{ + return m_StatsDataArray; +} + +// ----------------------------------------------------------------------------- +int StatsDataArray::getClassVersion() const +{ + return 2; +} diff --git a/Source/SIMPLib/DataArrays/StatsDataArray.h b/Source/SIMPLib/DataArrays/StatsDataArray.h old mode 100755 new mode 100644 index d3d8896d56..30d668b167 --- a/Source/SIMPLib/DataArrays/StatsDataArray.h +++ b/Source/SIMPLib/DataArrays/StatsDataArray.h @@ -1,70 +1,91 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include +#include -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataArrays/IDataArray.h" #include "SIMPLib/StatsData/StatsData.h" - /** * @brief The StatsDataArray class */ class SIMPLib_EXPORT StatsDataArray : public IDataArray { // clang-format off - PYB11_CREATE_BINDINGS(StatsDataArray SUPER IDataArray) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(StatsDataArray SUPERCLASS IDataArray) + PYB11_SHARED_POINTERS(StatsDataArray) + PYB11_STATIC_NEW_MACRO(StatsDataArray) PYB11_STATIC_CREATION(CreateArray OVERLOAD size_t QString bool) PYB11_STATIC_CREATION(CreateArray OVERLOAD size_t int size_t* QString bool) PYB11_STATIC_CREATION(CreateArray OVERLOAD size_t std::vector QString bool) - PYB11_STATIC_CREATION(CreateArray OVERLOAD size_t QVector QString bool) - PYB11_STATIC_CREATION(CreateArray OVERLOAD QVector QVector QString bool) + PYB11_STATIC_CREATION(CreateArray OVERLOAD size_t std::vector QString bool) + PYB11_STATIC_CREATION(CreateArray OVERLOAD std::vector std::vector QString bool) PYB11_METHOD(void setStatsData ARGS int,index StatsData::Pointer,statsData) PYB11_METHOD(StatsData::Pointer getStatsData ARGS int,index) PYB11_METHOD(void fillArrayWithNewStatsData OVERLOAD size_t,n PhaseType::Type*,phase_types) PYB11_METHOD(void fillArrayWithNewStatsData OVERLOAD size_t,n PhaseType::EnumType*,phase_types) + PYB11_END_BINDINGS() + // End Python bindings declarations // clang-format on public: - SIMPL_SHARED_POINTERS(StatsDataArray) - SIMPL_STATIC_NEW_MACRO(StatsDataArray) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(StatsDataArray, IDataArray) - SIMPL_CLASS_VERSION(2) + using Self = StatsDataArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for StatsDataArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for StatsDataArray + */ + static QString ClassName(); + + int getClassVersion() const override; ~StatsDataArray() override; @@ -75,6 +96,7 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray * @return Std::Shared_Ptr wrapping an instance of DataArrayTemplate */ static Pointer CreateArray(size_t numElements, const QString& name, bool allocate = true); + static Pointer CreateArray(size_t numElements, const std::string& name, bool allocate = true); /** * @brief CreateArray @@ -85,17 +107,7 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray * @param allocate * @return */ - static Pointer CreateArray(size_t numTuples, int rank, size_t* dims, const QString& name, bool allocate = true); - - /** - * @brief CreateArray - * @param numTuples - * @param cDims - * @param name - * @param allocate - * @return - */ - static Pointer CreateArray(size_t numTuples, std::vector cDims, const QString& name, bool allocate = true); + static Pointer CreateArray(size_t numTuples, int rank, const size_t* dims, const QString& name, bool allocate = true); /** * @brief CreateArray @@ -105,7 +117,7 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray * @param allocate * @return */ - static Pointer CreateArray(size_t numTuples, QVector cDims, const QString& name, bool allocate = true); + static Pointer CreateArray(size_t numTuples, const std::vector& cDims, const QString& name, bool allocate = true); /** * @brief CreateArray @@ -115,33 +127,39 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray * @param allocate * @return */ - static Pointer CreateArray(QVector tDims, QVector cDims, const QString& name, bool allocate = true); + static Pointer CreateArray(const std::vector& tDims, const std::vector& cDims, const QString& name, bool allocate = true); /** * @brief GetTypeName Returns a string representation of the type of data that is stored by this class. This * can be a primitive like char, float, int or the name of a class. * @return */ - void getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) override; + void getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) const override; /** * @brief getTypeAsString * @return */ - QString getTypeAsString() override; - - SIMPL_INSTANCE_PROPERTY(QVector, StatsDataArray) + QString getTypeAsString() const override; - IDataArray::Pointer createNewArray(size_t numElements, int rank, size_t* dims, const QString& name, bool allocate = true) override; + /** + * @brief Setter property for StatsDataArray + */ + void setStatsDataArray(const QVector& value); + /** + * @brief Getter property for StatsDataArray + * @return Value of StatsDataArray + */ + QVector getStatsDataArray() const; - IDataArray::Pointer createNewArray(size_t numElements, std::vector dims, const QString& name, bool allocate = true) override; + IDataArray::Pointer createNewArray(size_t numElements, int rank, const size_t* dims, const QString& name, bool allocate = true) const override; - IDataArray::Pointer createNewArray(size_t numElements, QVector dims, const QString& name, bool allocate = true) override; + IDataArray::Pointer createNewArray(size_t numElements, const std::vector& dims, const QString& name, bool allocate = true) const override; /** * @brief */ - bool isAllocated() override; + bool isAllocated() const override; /** * @@ -166,26 +184,23 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray /** * */ - StatsData::Pointer getStatsData(int idx); + StatsData::Pointer getStatsData(int idx) const; /** * @brief operator [] * @param idx * @return */ - StatsData::Pointer operator[](int idx); + StatsData::Pointer operator[](int idx) const; /* **************** This is the interface for the IDataArray Class which MUST * Be implemented. Most of it is useless and will simply ASSERT if called. */ - void setName(const QString& name) override; - QString getName() override; - /** * @brief getFullNameOfClass * @return */ - QString getFullNameOfClass(); + QString getFullNameOfClass() const; /** * @brief Makes this class responsible for freeing the memory. @@ -211,25 +226,25 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray /** * @brief Returns the number of Tuples in the array. */ - size_t getNumberOfTuples() override; + size_t getNumberOfTuples() const override; /** * @brief Return the number of elements in the array * @return */ - size_t getSize() override; + size_t getSize() const override; /** * @brief getNumberOfComponents * @return */ - int getNumberOfComponents() override; + int getNumberOfComponents() const override; /** * @brief getComponentDimensions * @return */ - QVector getComponentDimensions() override; + std::vector getComponentDimensions() const override; /** * @brief Returns the number of bytes that make up the data type. @@ -238,7 +253,7 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray * 4 = 32 bit integer/Float * 8 = 64 bit integer/Double */ - size_t getTypeSize() override; + size_t getTypeSize() const override; /** * @brief Removes Tuples from the Array. If the size of the vector is Zero nothing is done. If the size of the @@ -248,7 +263,7 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray * @param idxs The indices to remove * @return error code. */ - int eraseTuples(QVector& idxs) override; + int eraseTuples(const std::vector& idxs) override; /** * @brief Copies a Tuple from one position to another. @@ -281,14 +296,14 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray * @param sourceArray * @return */ - bool copyFromArray(size_t destTupleOffset, IDataArray::Pointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) override; + bool copyFromArray(size_t destTupleOffset, IDataArray::ConstPointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) override; /** * @brief Splats the same value c across all values in the Tuple * @param i The index of the Tuple * @param c The value to splat across all components in the tuple */ - void initializeTuple(size_t i, void* p) override; + void initializeTuple(size_t i, const void* p) override; /** * @brief Sets all the values to zero. @@ -300,7 +315,7 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray * @param forceNoAllocate * @return */ - IDataArray::Pointer deepCopy(bool forceNoAllocate = false) override; + IDataArrayShPtrType deepCopy(bool forceNoAllocate = false) const override; /** * @brief Reseizes the internal array @@ -310,11 +325,10 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray int32_t resizeTotalElements(size_t size) override; /** - * @brief Reseizes the internal array - * @param size The new size of the internal array - * @return 1 on success, 0 on failure + * @brief Resizes the internal array to accomondate numTuples + * @param numTuples */ - int32_t resize(size_t numTuples) override; + void resizeTuples(size_t numTuples) override; /** * @brief printTuple @@ -322,7 +336,7 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray * @param i * @param delimiter */ - void printTuple(QTextStream& out, size_t i, char delimiter = ',') override; + void printTuple(QTextStream& out, size_t i, char delimiter = ',') const override; /** * @brief printComponent @@ -330,14 +344,14 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray * @param i * @param j */ - void printComponent(QTextStream& out, size_t i, int j) override; + void printComponent(QTextStream& out, size_t i, int j) const override; /** * * @param parentId * @return */ - int writeH5Data(hid_t parentId, QVector tDims) override; + int writeH5Data(hid_t parentId, const std::vector& tDims) const override; /** * @brief readH5Data @@ -354,14 +368,21 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray * @param groupPath * @return */ - int writeXdmfAttribute(QTextStream& out, int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& labelb) override; + int writeXdmfAttribute(QTextStream& out, const int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& labelb) const override; /** * @brief getInfoString * @param format * @return */ - QString getInfoString(SIMPL::InfoStringFormat format) override; + QString getInfoString(SIMPL::InfoStringFormat format) const override; + + /** + * @brief Returns a ToolTipGenerator for creating HTML tooltip tables + * with values populated to match the current DataArray. + * @return + */ + ToolTipGenerator getToolTipGenerator() const override; /** * @brief StatsDataArray::readFromJson @@ -376,13 +397,14 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray * @param crystalStructures * @return */ - int writeToJson(QJsonObject& jsonRoot, UInt32ArrayType::Pointer crystalStructures); + int writeToJson(QJsonObject& jsonRoot, UInt32ArrayType::Pointer crystalStructures) const; protected: StatsDataArray(); private: - QString m_Name; + QVector m_StatsDataArray = {}; + bool m_IsAllocated; public: @@ -391,5 +413,3 @@ class SIMPLib_EXPORT StatsDataArray : public IDataArray StatsDataArray& operator=(const StatsDataArray&) = delete; // Copy Assignment Not Implemented StatsDataArray& operator=(StatsDataArray&&) = delete; // Move Assignment Not Implemented }; - - diff --git a/Source/SIMPLib/DataArrays/StringDataArray.cpp b/Source/SIMPLib/DataArrays/StringDataArray.cpp index 6073182b14..f00627a5d0 100644 --- a/Source/SIMPLib/DataArrays/StringDataArray.cpp +++ b/Source/SIMPLib/DataArrays/StringDataArray.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -34,30 +34,30 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "StringDataArray.h" +#include + +#include "H5Support/H5Lite.h" + #include "SIMPLib/HDF5/H5DataArrayReader.h" #include "SIMPLib/HDF5/H5DataArrayWriter.hpp" - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -StringDataArray::StringDataArray() -: m_Name("") -, _ownsData(false) +StringDataArray::StringDataArray() +: _ownsData(false) { } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -StringDataArray::StringDataArray(size_t numTuples, const QString name, bool allocate) -: m_Name(name) +StringDataArray::StringDataArray(size_t numTuples, const QString& name, bool allocate) +: IDataArray(name) , _ownsData(true) { - // if (allocate == true) - { - m_Array.resize(numTuples); - } + m_Array.resize(numTuples); + setName(name); } // ----------------------------------------------------------------------------- @@ -70,22 +70,30 @@ StringDataArray::Pointer StringDataArray::CreateArray(size_t numTuples, const QS return NullPointer(); } StringDataArray* d = new StringDataArray(numTuples, name, allocate); - d->setName(name); Pointer ptr(d); return ptr; } - +// ----------------------------------------------------------------------------- +StringDataArray::Pointer StringDataArray::CreateArray(size_t numTuples, const std::string& name, bool allocate) +{ + if(name.empty()) + { + return NullPointer(); + } + StringDataArray* d = new StringDataArray(numTuples, QString::fromStdString(name), allocate); + Pointer ptr(d); + return ptr; +} // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -StringDataArray::Pointer StringDataArray::CreateArray(size_t numTuples, QVector compDims, const QString& name, bool allocate) +StringDataArray::Pointer StringDataArray::CreateArray(size_t numTuples, const std::vector& compDims, const QString& name, bool allocate) { if(name.isEmpty()) { return NullPointer(); } StringDataArray* d = new StringDataArray(numTuples, name, allocate); - d->setName(name); Pointer ptr(d); return ptr; } @@ -93,7 +101,7 @@ StringDataArray::Pointer StringDataArray::CreateArray(size_t numTuples, QVector< // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IDataArray::Pointer StringDataArray::createNewArray(size_t numElements, int rank, size_t* dims, const QString& name, bool allocate) +IDataArray::Pointer StringDataArray::createNewArray(size_t numElements, int rank, const size_t* dims, const QString& name, bool allocate) const { IDataArray::Pointer p = StringDataArray::CreateArray(numElements, name, allocate); return p; @@ -102,7 +110,7 @@ IDataArray::Pointer StringDataArray::createNewArray(size_t numElements, int rank // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IDataArray::Pointer StringDataArray::createNewArray(size_t numElements, std::vector dims, const QString& name, bool allocate) +IDataArray::Pointer StringDataArray::createNewArray(size_t numElements, const std::vector& dims, const QString& name, bool allocate) const { IDataArray::Pointer p = StringDataArray::CreateArray(numElements, name, allocate); return p; @@ -111,18 +119,19 @@ IDataArray::Pointer StringDataArray::createNewArray(size_t numElements, std::vec // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IDataArray::Pointer StringDataArray::createNewArray(size_t numElements, QVector dims, const QString& name, bool allocate) -{ - IDataArray::Pointer p = StringDataArray::CreateArray(numElements, name, allocate); - return p; -} +// IDataArray::Pointer StringDataArray::createNewArray(size_t numElements, std::vector dims, const QString& name, bool allocate) +//{ +// IDataArray::Pointer p = StringDataArray::CreateArray(numElements, name, +// allocate); +// return p; +//} StringDataArray::~StringDataArray() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool StringDataArray::isAllocated() +bool StringDataArray::isAllocated() const { return true; } @@ -146,7 +155,7 @@ void StringDataArray::setInitValue(const QString& initValue) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void StringDataArray::getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) +void StringDataArray::getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) const { xdmfTypeName = getNameOfClass(); precision = 0; @@ -155,27 +164,11 @@ void StringDataArray::getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString StringDataArray::getTypeAsString() +QString StringDataArray::getTypeAsString() const { return "StringDataArray"; } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void StringDataArray::setName(const QString& name) -{ - m_Name = name; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString StringDataArray::getName() -{ - return m_Name; -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -203,7 +196,7 @@ void* StringDataArray::getVoidPointer(size_t i) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -size_t StringDataArray::getNumberOfTuples() +size_t StringDataArray::getNumberOfTuples() const { return m_Array.size(); } @@ -211,7 +204,7 @@ size_t StringDataArray::getNumberOfTuples() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -size_t StringDataArray::getSize() +size_t StringDataArray::getSize() const { return m_Array.size(); } @@ -219,7 +212,7 @@ size_t StringDataArray::getSize() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int StringDataArray::getNumberOfComponents() +int StringDataArray::getNumberOfComponents() const { return 1; } @@ -227,9 +220,9 @@ int StringDataArray::getNumberOfComponents() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector StringDataArray::getComponentDimensions() +std::vector StringDataArray::getComponentDimensions() const { - QVector dims(1, 1); + std::vector dims = {1}; return dims; } @@ -243,7 +236,7 @@ void StringDataArray::SetRank(int rnk) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int StringDataArray::getRank() +int StringDataArray::getRank() const { return 1; } @@ -251,7 +244,7 @@ int StringDataArray::getRank() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -size_t StringDataArray::getTypeSize() +size_t StringDataArray::getTypeSize() const { return sizeof(QString); } @@ -259,7 +252,7 @@ size_t StringDataArray::getTypeSize() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int StringDataArray::eraseTuples(QVector& idxs) +int StringDataArray::eraseTuples(const std::vector& idxs) { int err = 0; @@ -272,15 +265,16 @@ int StringDataArray::eraseTuples(QVector& idxs) size_t idxs_size = static_cast(idxs.size()); if(idxs_size >= getNumberOfTuples()) { - resize(0); + resizeTuples(0); return 0; } // Sanity Check the Indices in the vector to make sure we are not trying to remove any indices that are // off the end of the array and return an error code. - for(QVector::size_type i = 0; i < idxs.size(); ++i) + // for(std::vector::size_type i = 0; i < idxs.size(); ++i) + for(auto& value : idxs) { - if(idxs[i] >= static_cast(m_Array.size())) + if(value >= static_cast(m_Array.size())) { return -100; } @@ -292,7 +286,7 @@ int StringDataArray::eraseTuples(QVector& idxs) for(QVector::size_type i = 0; i < m_Array.size(); ++i) { bool keep = true; - for(QVector::size_type j = start; j < idxs.size(); ++j) + for(std::vector::size_type j = start; j < idxs.size(); ++j) { if(static_cast(i) == idxs[j]) { @@ -330,7 +324,7 @@ int StringDataArray::copyTuple(size_t currentPos, size_t newPos) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool StringDataArray::copyFromArray(size_t destTupleOffset, IDataArray::Pointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) +bool StringDataArray::copyFromArray(size_t destTupleOffset, IDataArray::ConstPointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) { if(destTupleOffset >= m_Array.size()) { @@ -341,7 +335,11 @@ bool StringDataArray::copyFromArray(size_t destTupleOffset, IDataArray::Pointer return false; } - Self* source = dynamic_cast(sourceArray.get()); + const Self* source = dynamic_cast(sourceArray.get()); + if(source == nullptr) + { + return false; + } if(srcTupleOffset + totalSrcTuples > sourceArray->getNumberOfTuples()) { @@ -362,9 +360,9 @@ bool StringDataArray::copyFromArray(size_t destTupleOffset, IDataArray::Pointer // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void StringDataArray::initializeTuple(size_t pos, void* value) +void StringDataArray::initializeTuple(size_t pos, const void* value) { - m_Array[pos] = *(reinterpret_cast(value)); + m_Array[pos] = *(reinterpret_cast(value)); } // ----------------------------------------------------------------------------- @@ -378,7 +376,7 @@ void StringDataArray::initializeWithZeros() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void StringDataArray::initializeWithValue(QString value) +void StringDataArray::initializeWithValue(const QString& value) { m_Array.assign(m_Array.size(), value); } @@ -394,9 +392,9 @@ void StringDataArray::initializeWithValue(const std::string& value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IDataArray::Pointer StringDataArray::deepCopy(bool forceNoAllocate) +IDataArray::Pointer StringDataArray::deepCopy(bool forceNoAllocate) const { - StringDataArray::Pointer daCopy = StringDataArray::CreateArray(getNumberOfTuples(), getName()); + StringDataArray::Pointer daCopy = StringDataArray::CreateArray(getNumberOfTuples(), getName(), true); if(!forceNoAllocate) { for(std::vector::size_type i = 0; i < m_Array.size(); ++i) @@ -419,10 +417,9 @@ int32_t StringDataArray::resizeTotalElements(size_t size) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int32_t StringDataArray::resize(size_t numTuples) +void StringDataArray::resizeTuples(size_t numTuples) { m_Array.resize(numTuples); - return 1; } // ----------------------------------------------------------------------------- @@ -440,7 +437,7 @@ void StringDataArray::initialize() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void StringDataArray::printTuple(QTextStream& out, size_t i, char delimiter) +void StringDataArray::printTuple(QTextStream& out, size_t i, char delimiter) const { out << m_Array[i]; } @@ -448,7 +445,7 @@ void StringDataArray::printTuple(QTextStream& out, size_t i, char delimiter) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void StringDataArray::printComponent(QTextStream& out, size_t i, int j) +void StringDataArray::printComponent(QTextStream& out, size_t i, int j) const { out << m_Array[i]; } @@ -456,7 +453,7 @@ void StringDataArray::printComponent(QTextStream& out, size_t i, int j) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString StringDataArray::getFullNameOfClass() +QString StringDataArray::getFullNameOfClass() const { return "StringDataArray"; } @@ -464,7 +461,7 @@ QString StringDataArray::getFullNameOfClass() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int StringDataArray::writeH5Data(hid_t parentId, QVector tDims) +int StringDataArray::writeH5Data(hid_t parentId, const std::vector& tDims) const { return H5DataArrayWriter::writeStringDataArray(parentId, this); } @@ -472,7 +469,7 @@ int StringDataArray::writeH5Data(hid_t parentId, QVector tDims) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int StringDataArray::writeXdmfAttribute(QTextStream& out, int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& labelb) +int StringDataArray::writeXdmfAttribute(QTextStream& out, const int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& labelb) const { out << " "; return -1; @@ -481,30 +478,32 @@ int StringDataArray::writeXdmfAttribute(QTextStream& out, int64_t* volDims, cons // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString StringDataArray::getInfoString(SIMPL::InfoStringFormat format) +QString StringDataArray::getInfoString(SIMPL::InfoStringFormat format) const { - QString info; - QTextStream ss(&info); if(format == SIMPL::HtmlFormat) { - ss << "\n"; - ss << "\n"; - ss << "\n"; - ss << "\n"; - ss << ""; - ss << ""; - ss << ""; - QLocale usa(QLocale::English, QLocale::UnitedStates); - QString numStr = usa.toString(static_cast(getNumberOfTuples())); - ss << ""; - ss << "
Attribute Array Info
Name:" << getName() << "
Type:" << getTypeAsString() << "
Number of Tuples:" << numStr << "
\n"; - ss << "
"; - ss << ""; + return getToolTipGenerator().generateHTML(); } else { } - return info; + return QString(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +ToolTipGenerator StringDataArray::getToolTipGenerator() const +{ + ToolTipGenerator toolTipGen; + QLocale usa(QLocale::English, QLocale::UnitedStates); + + toolTipGen.addTitle("Attribute Array Info"); + toolTipGen.addValue("Name", getName()); + toolTipGen.addValue("Type", getTypeAsString()); + toolTipGen.addValue("Number of Tuples", usa.toString(static_cast(getNumberOfTuples()))); + + return toolTipGen; } // ----------------------------------------------------------------------------- @@ -513,7 +512,7 @@ QString StringDataArray::getInfoString(SIMPL::InfoStringFormat format) int StringDataArray::readH5Data(hid_t parentId) { int err = 0; - this->resize(0); + this->resizeTuples(0); std::vector strings; err = H5Lite::readVectorOfStringDataset(parentId, getName().toStdString(), strings); @@ -549,7 +548,38 @@ void StringDataArray::setValue(size_t i, const QString& value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString StringDataArray::getValue(size_t i) +QString StringDataArray::getValue(size_t i) const { return m_Array.at(i); } + +// ----------------------------------------------------------------------------- +StringDataArray::Pointer StringDataArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +StringDataArray::Pointer StringDataArray::New() +{ + Pointer sharedPtr(new(StringDataArray)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString StringDataArray::getNameOfClass() const +{ + return QString("StringDataArray"); +} + +// ----------------------------------------------------------------------------- +QString StringDataArray::ClassName() +{ + return QString("StringDataArray"); +} + +// ----------------------------------------------------------------------------- +int StringDataArray::getClassVersion() const +{ + return 2; +} diff --git a/Source/SIMPLib/DataArrays/StringDataArray.h b/Source/SIMPLib/DataArrays/StringDataArray.h index 64c099182f..eed287e660 100755 --- a/Source/SIMPLib/DataArrays/StringDataArray.h +++ b/Source/SIMPLib/DataArrays/StringDataArray.h @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,16 +35,15 @@ #pragma once +#include #include #include #include +#include -#include "H5Support/H5Lite.h" - -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/DataArrays/IDataArray.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/IDataArray.h" /** * @class StringDataArray StringDataArray.h DREAM3DLib/Common/StringDataArray.h @@ -56,21 +55,43 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray { // clang-format off - PYB11_CREATE_BINDINGS(StringDataArray SUPER IDataArray) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(StringDataArray SUPERCLASS IDataArray) + PYB11_SHARED_POINTERS(StringDataArray) + PYB11_STATIC_NEW_MACRO(StringDataArray) PYB11_STATIC_CREATION(CreateArray OVERLOAD size_t QString bool) - PYB11_STATIC_CREATION(CreateArray OVERLOAD size_t QVector QString bool) + PYB11_STATIC_CREATION(CreateArray OVERLOAD size_t std::vector QString bool) PYB11_PROPERTY(QString Name READ getName WRITE setName) PYB11_METHOD(QString getValue ARGS size_t,i) PYB11_METHOD(void setValue ARGS size_t,i const.QString.&,value) PYB11_METHOD(size_t getSize) PYB11_METHOD(size_t getNumberOfTuples) + PYB11_END_BINDINGS() + // End Python bindings declarations // clang-format on public: - SIMPL_SHARED_POINTERS(StringDataArray) - SIMPL_STATIC_NEW_MACRO(StringDataArray) - SIMPL_TYPE_MACRO_SUPER(StringDataArray, IDataArray) - SIMPL_CLASS_VERSION(2) + using Self = StringDataArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + using value_type = QString; + + /** + * @brief Returns the name of the class for StringDataArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for StringDataArray + */ + static QString ClassName(); + + int getClassVersion() const override; /** * @brief CreateArray @@ -80,7 +101,7 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @return */ static Pointer CreateArray(size_t numTuples, const QString& name, bool allocate = true); - + static Pointer CreateArray(size_t numTuples, const std::string& name, bool allocate = true); /** * @brief CreateArray * @param numTuples @@ -89,7 +110,7 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @param allocate * @return */ - static Pointer CreateArray(size_t numTuples, QVector compDims, const QString& name, bool allocate = true); + static Pointer CreateArray(size_t numTuples, const std::vector& compDims, const QString& name, bool allocate = true); /** * @brief createNewArray * @param numElements @@ -97,7 +118,7 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @param name * @return */ - IDataArray::Pointer createNewArray(size_t numElements, int rank, size_t* dims, const QString& name, bool allocate = true) override; + IDataArrayShPtrType createNewArray(size_t numElements, int rank, const size_t* dims, const QString& name, bool allocate = true) const override; /** * @brief createNewArray @@ -107,17 +128,7 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @param allocate * @return */ - IDataArray::Pointer createNewArray(size_t numElements, std::vector dims, const QString& name, bool allocate = true) override; - - /** - * @brief createNewArray - * @param numElements - * @param dims - * @param name - * @param allocate - * @return - */ - IDataArray::Pointer createNewArray(size_t numElements, QVector dims, const QString& name, bool allocate = true) override; + IDataArray::Pointer createNewArray(size_t numElements, const std::vector& dims, const QString& name, bool allocate = true) const override; /** * @brief ~StringDataArray @@ -128,7 +139,7 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @brief isAllocated * @return */ - bool isAllocated() override; + bool isAllocated() const override; /** * @brief Gives this array a human readable name @@ -147,24 +158,12 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * can be a primitive like char, float, int or the name of a class. * @return */ - void getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) override; + void getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) const override; /** * @brief getTypeAsString * @return */ - QString getTypeAsString() override; - - /** - * @brief Gives this array a human readable name - * @param name The name of this array - */ - void setName(const QString& name) override; - - /** - * @brief Returns the human readable name of this array - * @return - */ - QString getName() override; + QString getTypeAsString() const override; /** * @brief @@ -187,17 +186,17 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray /** * @brief Returns the number of Tuples in the array. */ - size_t getNumberOfTuples() override; + size_t getNumberOfTuples() const override; /** * @brief Return the number of elements in the array * @return */ - size_t getSize() override; + size_t getSize() const override; - int getNumberOfComponents() override; + int getNumberOfComponents() const override; - QVector getComponentDimensions() override; + std::vector getComponentDimensions() const override; // Description: // Set/Get the dimension (n) of the rank. Must be >= 1. Make sure that @@ -208,7 +207,7 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @brief getRank * @return */ - int getRank(); + int getRank() const; /** * @brief Returns the number of bytes that make up the data type. @@ -217,7 +216,7 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * 4 = 32 bit integer/Float * 8 = 64 bit integer/Double */ - size_t getTypeSize() override; + size_t getTypeSize() const override; /** * @brief Removes Tuples from the Array. If the size of the vector is Zero nothing is done. If the size of the @@ -227,7 +226,7 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @param idxs The indices to remove * @return error code. */ - int eraseTuples(QVector& idxs) override; + int eraseTuples(const std::vector& idxs) override; /** * @brief Copies a Tuple from one position to another. @@ -260,14 +259,14 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @param sourceArray * @return */ - bool copyFromArray(size_t destTupleOffset, IDataArray::Pointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) override; + bool copyFromArray(size_t destTupleOffset, IDataArray::ConstPointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) override; /** * @brief Does Nothing * @param pos The index of the Tuple * @param value pointer to value */ - void initializeTuple(size_t pos, void* value) override; + void initializeTuple(size_t pos, const void* value) override; /** * @brief Sets all the values to empty string. @@ -278,7 +277,7 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @brief initializeWithValue * @param value */ - virtual void initializeWithValue(QString value); + virtual void initializeWithValue(const QString& value); /** * @brief initializeWithValue @@ -291,7 +290,7 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @param forceNoAllocate * @return */ - IDataArray::Pointer deepCopy(bool forceNoAllocate = false) override; + IDataArrayShPtrType deepCopy(bool forceNoAllocate = false) const override; /** * @brief Reseizes the internal array @@ -301,11 +300,10 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray int32_t resizeTotalElements(size_t size) override; /** - * @brief Reseizes the internal array - * @param size The new size of the internal array - * @return 1 on success, 0 on failure + * @brief Resizes the internal array to accomondate numTuples + * @param numTuples */ - int32_t resize(size_t numTuples) override; + void resizeTuples(size_t numTuples) override; /** * @brief Initializes this class to zero bytes freeing any data that it currently owns @@ -318,7 +316,7 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @param i * @param delimiter */ - void printTuple(QTextStream& out, size_t i, char delimiter = ',') override; + void printTuple(QTextStream& out, size_t i, char delimiter = ',') const override; /** * @brief printComponent @@ -326,20 +324,20 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @param i * @param j */ - void printComponent(QTextStream& out, size_t i, int j) override; + void printComponent(QTextStream& out, size_t i, int j) const override; /** * @brief getFullNameOfClass * @return */ - QString getFullNameOfClass(); + QString getFullNameOfClass() const; /** * * @param parentId * @return */ - int writeH5Data(hid_t parentId, QVector tDims) override; + int writeH5Data(hid_t parentId, const std::vector& tDims) const override; /** * @brief writeXdmfAttribute @@ -349,14 +347,21 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @param groupPath * @return */ - int writeXdmfAttribute(QTextStream& out, int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& labelb) override; + int writeXdmfAttribute(QTextStream& out, const int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& labelb) const override; /** * @brief getInfoString * @return Returns a formatted string that contains general infomation about * the instance of the object. */ - QString getInfoString(SIMPL::InfoStringFormat format) override; + QString getInfoString(SIMPL::InfoStringFormat format) const override; + + /** + * @brief Returns a ToolTipGenerator for creating HTML tooltip tables + * with values populated to match the current DataArray. + * @return + */ + ToolTipGenerator getToolTipGenerator() const override; /** * @brief readH5Data @@ -371,13 +376,12 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @param value */ void setValue(size_t i, const QString& value); - /** * @brief getValue * @param i * @return */ - QString getValue(size_t i); + QString getValue(size_t i) const; protected: /** @@ -385,12 +389,11 @@ class SIMPLib_EXPORT StringDataArray : public IDataArray * @param numElements The number of elements in the internal array. * @param takeOwnership Will the class clean up the memory. Default=true */ - StringDataArray(size_t numTuples, const QString name, bool allocate = true); + StringDataArray(size_t numTuples, const QString& name, bool allocate = true); StringDataArray(); private: - QString m_Name; QString m_InitValue; std::vector m_Array; bool _ownsData; diff --git a/Source/SIMPLib/DataArrays/StructArray.hpp b/Source/SIMPLib/DataArrays/StructArray.hpp old mode 100755 new mode 100644 index 317016884a..a40624fd50 --- a/Source/SIMPLib/DataArrays/StructArray.hpp +++ b/Source/SIMPLib/DataArrays/StructArray.hpp @@ -4,775 +4,835 @@ // FA8650-07-D-5800 // /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/IDataArray.h" #include "SIMPLib/DataArrays/IDataArrayFilter.h" -#include "SIMPLib/SIMPLib.h" -template +template class StructArray : public IDataArray { - public: - SIMPL_SHARED_POINTERS(StructArray ) - SIMPL_TYPE_MACRO_SUPER(StructArray, IDataArray) - SIMPL_CLASS_VERSION(2) - - /** - * @brief Static constructor - * @param numElements The number of elements in the internal array. - * @param name The name of the array - * @return Std::Shared_Ptr wrapping an instance of StructArrayTemplate - */ - static Pointer CreateArray(size_t numElements, const QString& name, bool allocate = true) - { - if (name.isEmpty() == true) - { - return NullPointer(); - } - StructArray* d = new StructArray (numElements, true); - if(allocate) - { - if (d->Allocate() < 0) - { - // Could not allocate enough memory, reset the pointer to null and return - delete d; - return StructArray::NullPointer(); - } - } - d->setName(name); - Pointer ptr(d); - return ptr; +public: + using Self = StructArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer() + { + return Pointer(static_cast(nullptr)); + } + + /** + * @brief Returns the name of the class for AbstractMessage + */ + QString getNameOfClass() const override + { + return QString("StructArray"); + } + /** + * @brief Returns the name of the class for AbstractMessage + */ + static QString ClassName() + { + return QString("StructArray"); + } + + /** + * @brief Returns the version of this class. + * @return + */ + int32_t getClassVersion() const override + { + return 2; + } + + /** + * @brief Static constructor + * @param numElements The number of elements in the internal array. + * @param name The name of the array + * @return Std::Shared_Ptr wrapping an instance of StructArrayTemplate + */ + static Pointer CreateArray(size_t numElements, const QString& name, bool allocate = true) + { + if(name.isEmpty()) + { + return NullPointer(); + } + Pointer ptr = std::shared_ptr(new Self(numElements, true)); + if(allocate) + { + if(ptr->Allocate() < 0) + { + return Self::NullPointer(); + } + } + ptr->setName(name); + return ptr; + } + + /** + * @brief Static constructor + * @param numElements The number of elements in the internal array. + * @param name The name of the array + * @return Std::Shared_Ptr wrapping an instance of StructArrayTemplate + */ + static Pointer CreateArray(size_t numElements, const std::string& name, bool allocate = true) + { + if(name.empty()) + { + return NullPointer(); + } + Pointer ptr = std::shared_ptr(new Self(numElements, true)); + if(allocate) + { + if(ptr->Allocate() < 0) + { + return Self::NullPointer(); + } + } + ptr->setName(QString::fromStdString(name)); + return ptr; + } + + /** + * @brief Static Method to create a DataArray from a QVector through a deep copy of the data + * contained in the vector. The number of components will be set to 1. + * @param vec The vector to copy the data from + * @param name The name of the array + * @return Std::Shared_Ptr wrapping an instance of DataArrayTemplate + */ + IDataArray::Pointer createNewArray(size_t numElements, int rank, const size_t* dims, const QString& name, bool allocate = true) const override + { + IDataArray::Pointer p = StructArray::CreateArray(numElements, name, allocate); + return p; + } + + IDataArray::Pointer createNewArray(size_t numElements, const std::vector& dims, const QString& name, bool allocate = true) const override + { + IDataArray::Pointer p = StructArray::CreateArray(numElements, name, allocate); + return p; + } + + /** + * @brief Destructor + */ + ~StructArray() override + { + // qDebug() << "~StructArrayTemplate '" << m_Name << "'" ; + if((nullptr != m_Array) && (m_OwnsData)) + { + deallocate(); + } + } + + /** + * @brief isAllocated + * @return + */ + bool isAllocated() const override + { + return m_IsAllocated; + } + + /** + * @brief GetTypeName Returns a string representation of the type of data that is stored by this class. This + * can be a primitive like char, float, int or the name of a class. + * @return + */ + void getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) const override + { + xdmfTypeName = getNameOfClass(); + precision = 0; + } + + /** + * @brief getTypeAsString + * @return + */ + QString getTypeAsString() const override + { + return "struct"; + } + + /** + * @brief Returns the HDF Type for a given primitive value. + * @param value A value to use. Can be anything. Just used to get the type info + * from + * @return The HDF5 native type for the value + */ + virtual QString getFullNameOfClass() const + { + QString theType = getTypeAsString(); + theType = "StructArray<" + theType + ">"; + return theType; + } + + /** + * @brief Makes this class responsible for freeing the memory + */ + void takeOwnership() override + { + m_OwnsData = true; + } + + /** + * @brief This class will NOT free the memory associated with the internal pointer. + * This can be useful if the user wishes to keep the data around after this + * class goes out of scope. + */ + void releaseOwnership() override + { + m_OwnsData = false; + } + + /** + * @brief Allocates the memory needed for this class + * @return 1 on success, -1 on failure + */ + int32_t Allocate() + { + if((nullptr != m_Array) && (m_OwnsData)) + { + deallocate(); + } + m_Array = nullptr; + m_OwnsData = true; + m_IsAllocated = false; + + if(m_Size == 0) + { + initialize(); + return 1; } - /** - * @brief Static Method to create a DataArray from a QVector through a deep copy of the data - * contained in the vector. The number of components will be set to 1. - * @param vec The vector to copy the data from - * @param name The name of the array - * @return Std::Shared_Ptr wrapping an instance of DataArrayTemplate - */ - IDataArray::Pointer createNewArray(size_t numElements, int rank, size_t* dims, const QString& name, bool allocate = true) override + size_t newSize = m_Size; + m_Array = new T[newSize](); + + if(!m_Array) { - IDataArray::Pointer p = StructArray::CreateArray(numElements, name, allocate); - return p; + qDebug() << "Unable to allocate " << newSize << " elements of size " << sizeof(T) << " bytes. "; + return -1; } - - IDataArray::Pointer createNewArray(size_t numElements, std::vector dims, const QString& name, bool allocate = true) override + m_IsAllocated = true; + m_Size = newSize; + return 1; + } + + /** + * @brief Initializes this class to zero bytes freeing any data that it currently owns + */ + virtual void initialize() + { + if(nullptr != m_Array && m_OwnsData) + { + deallocate(); + } + m_Array = nullptr; + m_Size = 0; + m_OwnsData = true; + m_MaxId = 0; + m_IsAllocated = false; + } + + /** + * @brief Sets all the values to zero. + */ + void initializeWithZeros() override + { + size_t typeSize = sizeof(T); + ::memset(m_Array, 0, m_Size * typeSize); + } + + /** + * @brief Sets all the values to value. + */ + void initializeWithValue(T value, size_t offset = 0) + { + for(size_t i = offset; i < m_Size; i++) + { + m_Array[i] = value; + } + } + + /** + * @brief Removes Tuples from the Array. If the size of the vector is Zero nothing is done. If the size of the + * vector is greater than or Equal to the number of Tuples then the Array is Resized to Zero. If there are + * indices that are larger than the size of the original (before erasing operations) then an error code (-100) is + * returned from the program. + * @param idxs The indices to remove + * @return error code. + */ + int eraseTuples(const std::vector& idxs) override + { + + int err = 0; + + // If nothing is to be erased just return + if(idxs.empty()) { - IDataArray::Pointer p = StructArray::CreateArray(numElements, name, allocate); - return p; + return 0; } - IDataArray::Pointer createNewArray(size_t numElements, QVector dims, const QString& name, bool allocate = true) override + size_t idxs_size = static_cast(idxs.size()); + if(idxs_size >= getNumberOfTuples()) { - IDataArray::Pointer p = StructArray::CreateArray(numElements, name, allocate); - return p; + resizeTuples(0); + return 0; } - /** - * @brief Destructor - */ - ~StructArray() override + // Sanity Check the Indices in the vector to make sure we are not trying to remove any indices that are + // off the end of the array and return an error code. + for(std::vector::size_type i = 0; i < idxs.size(); ++i) { - //qDebug() << "~StructArrayTemplate '" << m_Name << "'" ; - if ((nullptr != m_Array) && (true == this->_ownsData)) + if(idxs[i] > m_MaxId) { - _deallocate(); + return -100; } } - /** - * @brief isAllocated - * @return - */ - bool isAllocated() override - { - return m_IsAllocated; - } - - - /** - * @brief GetTypeName Returns a string representation of the type of data that is stored by this class. This - * can be a primitive like char, float, int or the name of a class. - * @return - */ - void getXdmfTypeAndSize(QString& xdmfTypeName, int& precision) override - { - xdmfTypeName = getNameOfClass(); - precision = 0; - } - - /** - * @brief getTypeAsString - * @return - */ - QString getTypeAsString() override { return "struct"; } - - /** - * @brief Returns the HDF Type for a given primitive value. - * @param value A value to use. Can be anything. Just used to get the type info - * from - * @return The HDF5 native type for the value - */ - virtual QString getFullNameOfClass() - { - QString theType = getTypeAsString(); - theType = "StructArray<" + theType + ">"; - return theType; - } - + // Calculate the new size of the array to copy into + size_t newSize = (getNumberOfTuples() - idxs.size()); + T* currentSrc = nullptr; - /** - * @brief Gives this array a human readable name - * @param name The name of this array - */ - void setName(const QString& name) override - { - m_Name = name; - } - - /** - * @brief Returns the human readable name of this array - * @return - */ - QString getName() override - { - return m_Name; - } - - /** - * @brief Makes this class responsible for freeing the memory - */ - void takeOwnership() override - { - this->_ownsData = true; - } - - /** - * @brief This class will NOT free the memory associated with the internal pointer. - * This can be useful if the user wishes to keep the data around after this - * class goes out of scope. - */ - void releaseOwnership() override - { - this->_ownsData = false; - } + // Create a new Array to copy into + T* newArray = new T[newSize](); + // Splat AB across the array so we know if we are copying the values or not + ::memset(newArray, 0xAB, newSize * sizeof(T)); - /** - * @brief Allocates the memory needed for this class - * @return 1 on success, -1 on failure - */ - int32_t Allocate() + // Keep the current Destination Pointer + T* currentDest = newArray; + size_t j = 0; + size_t k = 0; + // Find the first chunk to copy by walking the idxs array until we get an + // index that is NOT a continuous increment from the start + for(k = 0; k < idxs.size(); ++k) { - if ((nullptr != m_Array) && (true == this->_ownsData)) - { - _deallocate(); - } - m_Array = nullptr; - this->_ownsData = true; - this->m_IsAllocated = false; - - if (this->m_Size == 0) + if(j == idxs[k]) { - initialize(); - return 1; + ++j; } - - - size_t newSize = this->m_Size; -#if defined ( AIM_USE_SSE ) && defined ( __SSE2__ ) - Array = static_cast( _mm_malloc (newSize * sizeof(T), 16) ); -#else - m_Array = (T*)malloc(newSize * sizeof(T)); -#endif - if (!m_Array) + else { - qDebug() << "Unable to allocate " << newSize << " elements of size " << sizeof(T) << " bytes. " ; - return -1; + break; } - this->m_IsAllocated = true; - this->m_Size = newSize; - return 1; } - /** - * @brief Initializes this class to zero bytes freeing any data that it currently owns - */ - virtual void initialize() + if(k == idxs.size()) // Only front elements are being dropped { - if (nullptr != m_Array && true == this->_ownsData) - { - _deallocate(); - } - m_Array = nullptr; - this->m_Size = 0; - this->_ownsData = true; - this->m_MaxId = 0; - this->m_IsAllocated = false; + currentSrc = m_Array + (j); + ::memcpy(currentDest, currentSrc, (getNumberOfTuples() - idxs.size()) * sizeof(T)); + deallocate(); // We are done copying - delete the current Array + m_Size = newSize; + m_Array = newArray; + m_OwnsData = true; + m_MaxId = newSize - 1; + return 0; } - /** - * @brief Sets all the values to zero. - */ - void initializeWithZeros() override - { - size_t typeSize = sizeof(T); - ::memset(m_Array, 0, this->m_Size * typeSize); - } + std::vector srcIdx(idxs.size() + 1); + std::vector destIdx(idxs.size() + 1); + std::vector copyElements(idxs.size() + 1); + srcIdx[0] = 0; + destIdx[0] = 0; + copyElements[0] = (idxs[0] - 0); - /** - * @brief Sets all the values to value. - */ - void initializeWithValue(T value, size_t offset = 0) + for(size_t i = 1; i < srcIdx.size(); ++i) { - for (size_t i = offset; i < this->m_Size; i++) - { - m_Array[i] = value; - } - } + srcIdx[i] = (idxs[i - 1] + 1); - /** - * @brief Removes Tuples from the Array. If the size of the vector is Zero nothing is done. If the size of the - * vector is greater than or Equal to the number of Tuples then the Array is Resized to Zero. If there are - * indices that are larger than the size of the original (before erasing operations) then an error code (-100) is - * returned from the program. - * @param idxs The indices to remove - * @return error code. - */ - int eraseTuples(QVector& idxs) override - { - - int err = 0; - - // If nothing is to be erased just return - if(idxs.size() == 0) - { - return 0; - } - - size_t idxs_size = static_cast(idxs.size()); - if (idxs_size >= getNumberOfTuples() ) - { - resize(0); - return 0; - } - - // Sanity Check the Indices in the vector to make sure we are not trying to remove any indices that are - // off the end of the array and return an error code. - for(QVector::size_type i = 0; i < idxs.size(); ++i) - { - if (idxs[i] > this->m_MaxId) { return -100; } - } - - // Calculate the new size of the array to copy into - size_t newSize = (getNumberOfTuples() - idxs.size()); - T* currentSrc = nullptr; - - // Create a new Array to copy into - T* newArray = (T*)malloc(newSize * sizeof(T)); - // Splat AB across the array so we know if we are copying the values or not - ::memset(newArray, 0xAB, newSize * sizeof(T)); - - // Keep the current Destination Pointer - T* currentDest = newArray; - size_t j = 0; - int k = 0; - // Find the first chunk to copy by walking the idxs array until we get an - // index that is NOT a continuous increment from the start - for (k = 0; k < idxs.size(); ++k) - { - if(j == idxs[k]) - { - ++j; - } - else - { - break; - } - } - - if(k == idxs.size()) // Only front elements are being dropped - { - currentSrc = m_Array + (j); - ::memcpy(currentDest, currentSrc, (getNumberOfTuples() - idxs.size()) * sizeof(T)); - _deallocate(); // We are done copying - delete the current Array - this->m_Size = newSize; - m_Array = newArray; - this->_ownsData = true; - this->m_MaxId = newSize - 1; - return 0; - } - - QVector srcIdx(idxs.size() + 1); - QVector destIdx(idxs.size() + 1); - QVector copyElements(idxs.size() + 1); - srcIdx[0] = 0; - destIdx[0] = 0; - copyElements[0] = (idxs[0] - 0); - - for (int i = 1; i < srcIdx.size(); ++i) + if(i < srcIdx.size() - 1) { - srcIdx[i] = (idxs[i - 1] + 1); - - if(i < srcIdx.size() - 1) - { - copyElements[i] = (idxs[i] - idxs[i - 1] - 1); - } - else - { - copyElements[i] = (getNumberOfTuples() - idxs[i - 1] - 1); - } - destIdx[i] = copyElements[i - 1] + destIdx[i - 1]; + copyElements[i] = (idxs[i] - idxs[i - 1] - 1); } - - // Copy the data - for (int i = 0; i < srcIdx.size(); ++i) + else { - currentDest = newArray + destIdx[i]; - currentSrc = m_Array + srcIdx[i]; - size_t bytes = copyElements[i] * sizeof(T); - ::memcpy(currentDest, currentSrc, bytes); + copyElements[i] = (getNumberOfTuples() - idxs[i - 1] - 1); } - - // We are done copying - delete the current Array - _deallocate(); - - // Allocation was successful. Save it. - this->m_Size = newSize; - m_Array = newArray; - // This object has now allocated its memory and owns it. - this->_ownsData = true; - - this->m_MaxId = newSize - 1; - - return err; - } - - /** - * @brief - * @param currentPos - * @param newPos - * @return - */ - int copyTuple(size_t currentPos, size_t newPos) override - { - size_t max = ((this->m_MaxId + 1)); - if (currentPos >= max - || newPos >= max ) - {return -1;} - if (currentPos == newPos) { return 0; } - T* src = m_Array + (currentPos); - T* dest = m_Array + (newPos); - size_t bytes = sizeof(T); - ::memcpy(dest, src, bytes); - return 0; + destIdx[i] = copyElements[i - 1] + destIdx[i - 1]; } - // This line must be here, because we are overloading the copyData pure virtual function in IDataArray. - // This is required so that other classes can call this version of copyData from the subclasses. - using IDataArray::copyFromArray; - - /** - * @brief copyData This method copies the number of tuples specified by the - * totalSrcTuples value starting from the source tuple offset value in sourceArray - * into the current array starting at the target destination tuple offset value. - * - * For example if the DataArray has 10 tuples, the source DataArray has 10 tuples, - * the destTupleOffset = 5, the srcTupleOffset = 5, and the totalSrcTuples = 3, - * then tuples 5, 6, and 7 will be copied from the source into tuples 5, 6, and 7 - * of the destination array. In psuedo code it would be the following: - * @code - * destArray[5] = sourceArray[5]; - * destArray[6] = sourceArray[6]; - * destArray[7] = sourceArray[7]; - * ..... - * @endcode - * @param destTupleOffset - * @param sourceArray - * @return - */ - bool copyFromArray(size_t destTupleOffset, IDataArray::Pointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) override - { - if(!m_IsAllocated) - { - return false; - } - if(nullptr == m_Array) - { - return false; - } - if(destTupleOffset >= m_MaxId) - { - return false; - } - if(!sourceArray->isAllocated()) - { - return false; - } - Self* source = dynamic_cast(sourceArray.get()); - if(nullptr == source->getPointer(0)) - { - return false; - } + // Copy the data + for(int i = 0; i < srcIdx.size(); ++i) + { + currentDest = newArray + destIdx[i]; + currentSrc = m_Array + srcIdx[i]; + size_t bytes = copyElements[i] * sizeof(T); + ::memcpy(currentDest, currentSrc, bytes); + } - if(srcTupleOffset + totalSrcTuples > sourceArray->getNumberOfTuples()) - { - return false; - } + // We are done copying - delete the current Array + deallocate(); - if(totalSrcTuples + destTupleOffset > m_Size) - { - return false; - } + // Allocation was successful. Save it. + m_Size = newSize; + m_Array = newArray; + // This object has now allocated its memory and owns it. + m_OwnsData = true; - T* src = source->getPointer(srcTupleOffset); - T* dest = m_Array + destTupleOffset; - size_t bytes = (totalSrcTuples) * sizeof(T); - ::memcpy(dest, src, bytes); + m_MaxId = newSize - 1; - return true; - } + return err; + } - /** - * @brief Returns the number of bytes that make up the data type. - * 1 = char - * 2 = 16 bit integer - * 4 = 32 bit integer/Float - * 8 = 64 bit integer/Double - */ - size_t getTypeSize() override + /** + * @brief + * @param currentPos + * @param newPos + * @return + */ + int copyTuple(size_t currentPos, size_t newPos) override + { + size_t max = ((m_MaxId + 1)); + if(currentPos >= max || newPos >= max) { - return sizeof(T); + return -1; } - - /** - * @brief Returns the number of elements in the internal array. - */ - size_t getNumberOfTuples() override + if(currentPos == newPos) { - if (m_Size == 0) { return 0; } - return (this->m_MaxId + 1); + return 0; } + T* src = m_Array + (currentPos); + T* dest = m_Array + (newPos); + size_t bytes = sizeof(T); + ::memcpy(dest, src, bytes); + return 0; + } - /** - * @brief getSize - * @return - */ - size_t getSize() override - { - return m_Size; - } + // This line must be here, because we are overloading the copyData pure virtual function in IDataArray. + // This is required so that other classes can call this version of copyData from the subclasses. + using IDataArray::copyFromArray; - /** - * @brief getNumberOfComponents - * @return - */ - int getNumberOfComponents() override + /** + * @brief copyData This method copies the number of tuples specified by the + * totalSrcTuples value starting from the source tuple offset value in sourceArray + * into the current array starting at the target destination tuple offset value. + * + * For example if the DataArray has 10 tuples, the source DataArray has 10 tuples, + * the destTupleOffset = 5, the srcTupleOffset = 5, and the totalSrcTuples = 3, + * then tuples 5, 6, and 7 will be copied from the source into tuples 5, 6, and 7 + * of the destination array. In psuedo code it would be the following: + * @code + * destArray[5] = sourceArray[5]; + * destArray[6] = sourceArray[6]; + * destArray[7] = sourceArray[7]; + * ..... + * @endcode + * @param destTupleOffset + * @param sourceArray + * @return + */ + bool copyFromArray(size_t destTupleOffset, IDataArray::ConstPointer sourceArray, size_t srcTupleOffset, size_t totalSrcTuples) override + { + if(!m_IsAllocated) { - return 1; + return false; } - - /** - * @brief getNumberOfComponents - * @return - */ - QVector getComponentDimensions() override + if(nullptr == m_Array) { - QVector dims(1, 1); - return dims; + return false; } - - // Description: - // Set/Get the dimension (n) of the rank. Must be >= 1. Make sure that - // this is set before allocation. - void SetRank(int rnk) + if(destTupleOffset >= m_MaxId) { - + return false; } - - /** - * @brief getRank - * @return - */ - int getRank() + if(!sourceArray->isAllocated()) { - return 1; + return false; } - - - /** - * @brief Returns a void pointer pointing to the index of the array. nullptr - * pointers are entirely possible. No checks are performed to make sure - * the index is with in the range of the internal data array. - * @param i The index to have the returned pointer pointing to. - * @return Void Pointer. Possibly nullptr. - */ - void* getVoidPointer(size_t i) override + const Self* source = dynamic_cast(sourceArray.get()); + if(source == nullptr) { - if (i >= m_Size) { return nullptr;} - - return (void*)(&(m_Array[i])); + return false; } - - - /** - * @brief Returns the pointer to a specific index into the array. No checks are made - * as to the correctness of the index being passed in. If you ask for an index off - * then end of the array they you will likely cause your program to abort. - * @param i The index to return the pointer to. - * @return The pointer to the index - */ - virtual T* getPointer(size_t i) + if(nullptr == source->getPointer(0)) { -#ifndef NDEBUG - if (m_Size > 0) { Q_ASSERT(i < m_Size);} -#endif - return (T*)(&(m_Array[i])); + return false; } - /** - * @brief Splats the same value c across all values in the Tuple - * @param i The index of the Tuple - * @param c The value to splat across all components in the tuple - */ - void initializeTuple(size_t i, void* p) override + if(srcTupleOffset + totalSrcTuples > sourceArray->getNumberOfTuples()) { -#ifndef NDEBUG - if (m_Size > 0) { Q_ASSERT(i < m_Size);} -#endif - Q_ASSERT(false); - //T c = static_cast(p); - //for (int j = 0; j < this->NumberOfComponents; ++j) - { - // Array[i] = c; - } + return false; } - IDataArray::Pointer deepCopy(bool forceNoAllocate = false) override + if(totalSrcTuples + destTupleOffset > m_Size) { - IDataArray::Pointer daCopy = createNewArray(getNumberOfTuples(), getComponentDimensions(), getName(), m_IsAllocated); - if(m_IsAllocated == true && forceNoAllocate == false) - { - T* src = getPointer(0); - void* dest = daCopy->getVoidPointer(0); - size_t totalBytes = (getNumberOfTuples() * getNumberOfComponents() * sizeof(T)); - ::memcpy(dest, src, totalBytes); - } - return daCopy; + return false; } - /** - * @brief Reseizes the internal array - * @param size The new size of the internal array - * @return 1 on success, 0 on failure - */ - int32_t resizeTotalElements(size_t size) override - { - if (this->resizeAndExtend(size) || size == 0) - { - return 1; - } - else - { - return 0; - } - } + T* src = source->getPointer(srcTupleOffset); + T* dest = m_Array + destTupleOffset; + size_t bytes = (totalSrcTuples) * sizeof(T); + ::memcpy(dest, src, bytes); - /** - * @brief Resize - * @param numTuples - * @return - */ - int32_t resize(size_t numTuples) override - { - return resizeTotalElements(numTuples ); - } + return true; + } - /** - * @brief printTuple - * @param out - * @param i - * @param delimiter - */ - void printTuple(QTextStream& out, size_t i, char delimiter = ',') override - { - Q_ASSERT(false); - // for(int j = 0; j < NumberOfComponents; ++j) - // { - // if (j != 0) { out << delimiter; } - // out << Array[i + j]; - // } - } + /** + * @brief Returns the number of bytes that make up the data type. + * 1 = char + * 2 = 16 bit integer + * 4 = 32 bit integer/Float + * 8 = 64 bit integer/Double + */ + size_t getTypeSize() const override + { + return sizeof(T); + } - /** - * @brief printComponent - * @param out - * @param i - * @param j - */ - void printComponent(QTextStream& out, size_t i, int j) override + /** + * @brief Returns the number of elements in the internal array. + */ + size_t getNumberOfTuples() const override + { + if(m_Size == 0) { - Q_ASSERT(false); - // out << Array[i + j]; + return 0; } - - - /** - * - * @param parentId - * @return - */ - int writeH5Data(hid_t parentId, QVector tDims) override + return (m_MaxId + 1); + } + + /** + * @brief getSize + * @return + */ + size_t getSize() const override + { + return m_Size; + } + + /** + * @brief getNumberOfComponents + * @return + */ + int getNumberOfComponents() const override + { + return 1; + } + + /** + * @brief getNumberOfComponents + * @return + */ + std::vector getComponentDimensions() const override + { + std::vector dims(1, 1); + return dims; + } + + // Description: + // Set/Get the dimension (n) of the rank. Must be >= 1. Make sure that + // this is set before allocation. + void SetRank(int rnk) + { + } + + /** + * @brief getRank + * @return + */ + int getRank() const + { + return 1; + } + + /** + * @brief Returns a void pointer pointing to the index of the array. nullptr + * pointers are entirely possible. No checks are performed to make sure + * the index is with in the range of the internal data array. + * @param i The index to have the returned pointer pointing to. + * @return Void Pointer. Possibly nullptr. + */ + void* getVoidPointer(size_t i) override + { + if(i >= m_Size) + { + return nullptr; + } + + return reinterpret_cast(m_Array + i); + } + + /** + * @brief Returns the pointer to a specific index into the array. No checks are made + * as to the correctness of the index being passed in. If you ask for an index off + * then end of the array they you will likely cause your program to abort. + * @param i The index to return the pointer to. + * @return The pointer to the index + */ + virtual T* getPointer(size_t i) const + { +#ifndef NDEBUG + if(m_Size > 0) { - Q_ASSERT(false); - return -1; + Q_ASSERT(i < m_Size); } - - - /** - * @brief writeXdmfAttribute - * @param out - * @param volDims - * @param hdfFileName - * @param groupPath - * @return - */ - int writeXdmfAttribute(QTextStream& out, int64_t* volDims, const QString& hdfFileName, - const QString& groupPath, const QString& labelb) override +#endif + return reinterpret_cast(m_Array + i); + } + + /** + * @brief Splats the same value c across all values in the Tuple + * @param i The index of the Tuple + * @param c The value to splat across all components in the tuple + */ + void initializeTuple(size_t i, const void* p) override + { +#ifndef NDEBUG + if(m_Size > 0) { - out << " "; - return -1; + Q_ASSERT(i < m_Size); } - - /** - * @brief getInfoString - * @return Returns a formatted string that contains general infomation about - * the instance of the object. - */ - QString getInfoString(SIMPL::InfoStringFormat format) override +#endif + Q_ASSERT(false); + // T c = static_cast(p); + // for (int j = 0; j < this->NumberOfComponents; ++j) { - QString info; - QTextStream ss (&info); - if(format == SIMPL::HtmlFormat) - { - ss << "\n"; - ss << "\n"; - ss << "\n"; - ss << "\n"; - ss << ""; - ss << ""; - ss << ""; - QLocale usa(QLocale::English, QLocale::UnitedStates); - QString numStr = usa.toString(static_cast(getNumberOfTuples())); - ss << ""; - ss << "
Attribute Array Info
Name:" << getName() << "
Type:" << getTypeAsString() << "
Number of Tuples:" << numStr << "
\n"; - ss << "
"; - ss << ""; - } - else - { - - } - return info; + // Array[i] = c; } + } - /** - * @brief - * @param parentId - * @return - */ - int readH5Data(hid_t parentId) override + IDataArray::Pointer deepCopy(bool forceNoAllocate = false) const override + { + bool allocate = m_IsAllocated; + if(forceNoAllocate) { - Q_ASSERT(false); - int err = -1; - - return err; + allocate = false; } - - /** - * @brief operator [] - * @param i - * @return - */ - inline T& operator[](size_t i) + IDataArray::Pointer daCopy = createNewArray(getNumberOfTuples(), getComponentDimensions(), getName(), allocate); + if(m_IsAllocated && !forceNoAllocate) { - Q_ASSERT(i < m_Size); - return m_Array[i]; + T* src = getPointer(0); + void* dest = daCopy->getVoidPointer(0); + size_t totalBytes = (getNumberOfTuples() * getNumberOfComponents() * sizeof(T)); + ::memcpy(dest, src, totalBytes); } + return daCopy; + } - - protected: - /** - * @brief Protected Constructor - * @param numElements The number of elements in the internal array. - * @param takeOwnership Will the class clean up the memory. Default=true - */ - StructArray(size_t numElements, bool ownsData = true) : - m_Array(nullptr), - m_Size(numElements), - _ownsData(ownsData), - m_IsAllocated(false) + /** + * @brief Reseizes the internal array + * @param size The new size of the internal array + * @return 1 on success, 0 on failure + */ + int32_t resizeTotalElements(size_t size) override + { + if(resizeAndExtend(size) || size == 0) { - m_MaxId = (m_Size > 0) ? m_Size - 1 : m_Size; - // MUD_FLAP_0 = MUD_FLAP_1 = MUD_FLAP_2 = MUD_FLAP_3 = MUD_FLAP_4 = MUD_FLAP_5 = 0xABABABABABABABABul; + return 1; } - - /** - * @brief deallocates the memory block - */ - void _deallocate() - { - // We are going to splat 0xABABAB across the first value of the array as a debugging aid - unsigned char* cptr = reinterpret_cast(m_Array); - if(nullptr != cptr) - { - if (m_Size > 0) + return 0; + } + + /** + * @brief Resizes the internal array to accomondate numTuples + * @param numTuples + */ + void resizeTuples(size_t numTuples) override + { + resizeTotalElements(numTuples); + } + + /** + * @brief printTuple + * @param out + * @param i + * @param delimiter + */ + void printTuple(QTextStream& out, size_t i, char delimiter = ',') const override + { + Q_ASSERT(false); + // for(int j = 0; j < NumberOfComponents; ++j) + // { + // if (j != 0) { out << delimiter; } + // out << Array[i + j]; + // } + } + + /** + * @brief printComponent + * @param out + * @param i + * @param j + */ + void printComponent(QTextStream& out, size_t i, int j) const override + { + Q_ASSERT(false); + // out << Array[i + j]; + } + + /** + * + * @param parentId + * @return + */ + int writeH5Data(hid_t parentId, const std::vector& tDims) const override + { + Q_ASSERT(false); + return -1; + } + + /** + * @brief writeXdmfAttribute + * @param out + * @param volDims + * @param hdfFileName + * @param groupPath + * @return + */ + int writeXdmfAttribute(QTextStream& out, const int64_t* volDims, const QString& hdfFileName, const QString& groupPath, const QString& labelb) const override + { + out << " "; + return -1; + } + + /** + * @brief Returns a ToolTipGenerator for creating HTML tooltip tables + * with values populated to match the current DataArray. + * @return + */ + ToolTipGenerator getToolTipGenerator() const override + { + ToolTipGenerator toolTipGen; + QLocale usa(QLocale::English, QLocale::UnitedStates); + + toolTipGen.addTitle("Attribute Array Info"); + toolTipGen.addValue("Name", getName()); + toolTipGen.addValue("Type", getTypeAsString()); + toolTipGen.addValue("Number of Tuples", usa.toString(static_cast(getNumberOfTuples()))); + + return toolTipGen; + } + + /** + * @brief getInfoString + * @return Returns a formatted string that contains general infomation about + * the instance of the object. + */ + QString getInfoString(SIMPL::InfoStringFormat format) const override + { + if(format == SIMPL::HtmlFormat) + { + return getToolTipGenerator().generateHTML(); + } + else + { + } + return QString(); + } + + /** + * @brief + * @param parentId + * @return + */ + int readH5Data(hid_t parentId) override + { + Q_ASSERT(false); + int err = -1; + + return err; + } + + /** + * @brief operator [] + * @param i + * @return + */ + inline T& operator[](size_t i) + { + Q_ASSERT(i < m_Size); + return m_Array[i]; + } + +protected: + /** + * @brief Protected Constructor + * @param numElements The number of elements in the internal array. + * @param takeOwnership Will the class clean up the memory. Default=true + */ + StructArray(size_t numElements, bool ownsData = true) + : m_Array(nullptr) + , m_Size(numElements) + , m_OwnsData(ownsData) + , m_IsAllocated(false) + { + m_MaxId = (m_Size > 0) ? m_Size - 1 : m_Size; + // MUD_FLAP_0 = MUD_FLAP_1 = MUD_FLAP_2 = MUD_FLAP_3 = MUD_FLAP_4 = MUD_FLAP_5 = 0xABABABABABABABABul; + } + + /** + * @brief deallocates the memory block + */ + void deallocate() + { + // We are going to splat 0xABABAB across the first value of the array as a debugging aid + unsigned char* cptr = reinterpret_cast(m_Array); + if(nullptr != cptr) + { + if(m_Size > 0) + { + if(sizeof(T) >= 1) + { + cptr[0] = 0xAB; + } + if(sizeof(T) >= 2) + { + cptr[1] = 0xAB; + } + if(sizeof(T) >= 4) { - if (sizeof(T) >= 1) { cptr[0] = 0xAB; } - if (sizeof(T) >= 2) { cptr[1] = 0xAB; } - if (sizeof(T) >= 4) { cptr[2] = 0xAB; cptr[3] = 0xAB;} - if (sizeof(T) >= 8) { cptr[4] = 0xAB; cptr[5] = 0xAB; cptr[6] = 0xAB; cptr[7] = 0xAB;} + cptr[2] = 0xAB; + cptr[3] = 0xAB; + } + if(sizeof(T) >= 8) + { + cptr[4] = 0xAB; + cptr[5] = 0xAB; + cptr[6] = 0xAB; + cptr[7] = 0xAB; } } + } #if 0 if (MUD_FLAP_0 != 0xABABABABABABABABul || MUD_FLAP_1 != 0xABABABABABABABABul @@ -785,128 +845,84 @@ class StructArray : public IDataArray } #endif -#if defined ( AIM_USE_SSE ) && defined ( __SSE2__ ) - _mm_free( this->m_buffer ); -#else - free(m_Array); -#endif - m_Array = nullptr; - this->m_IsAllocated = false; - } - - /** - * @brief resizes the internal array to be 'size' elements in length - * @param size - * @return Pointer to the internal array - */ - virtual T* resizeAndExtend(size_t size) - { - T* newArray; - size_t newSize; - - if (size > this->m_Size) - { - newSize = size; - } - else if (size == this->m_Size) // Requested size is equal to current size. Do nothing. - { - return m_Array; - } - else // Requested size is smaller than current size. Squeeze the memory. - { - newSize = size; - } + delete[](m_Array); - // Wipe out the array completely if new size is zero. - if (newSize == 0) - { - this->initialize(); - return m_Array; - } - // OS X's realloc does not free memory if the new block is smaller. This - // is a very serious problem and causes huge amount of memory to be - // wasted. Do not use realloc on the Mac. - bool dontUseRealloc = false; -#if defined __APPLE__ - dontUseRealloc = true; -#endif + m_Array = nullptr; + m_IsAllocated = false; + } - // Allocate a new array if we DO NOT own the current array - if ((nullptr != m_Array) && (false == this->_ownsData)) - { - // The old array is owned by the user so we cannot try to - // reallocate it. Just allocate new memory that we will own. - newArray = (T*)malloc(newSize * sizeof(T)); - if (!newArray) - { - qDebug() << "Unable to allocate " << newSize << " elements of size " << sizeof(T) << " bytes. " ; - return 0; - } + /** + * @brief resizes the internal array to be 'size' elements in length + * @param size + * @return Pointer to the internal array + */ + virtual T* resizeAndExtend(size_t size) + { + T* newArray = nullptr; + size_t newSize = 0; - // Copy the data from the old array. - memcpy(newArray, m_Array, (newSize < this->m_Size ? newSize : this->m_Size) * sizeof(T)); - } - else if (!dontUseRealloc) - { - // Try to reallocate with minimal memory usage and possibly avoid copying. - newArray = (T*)realloc(m_Array, newSize * sizeof(T)); - if (!newArray) - { - qDebug() << "Unable to allocate " << newSize << " elements of size " << sizeof(T) << " bytes. " ; - return 0; - } - } - else - { - newArray = (T*)malloc(newSize * sizeof(T)); - if (!newArray) - { - qDebug() << "Unable to allocate " << newSize << " elements of size " << sizeof(T) << " bytes. " ; - return 0; - } - - // Copy the data from the old array. - if (m_Array != nullptr) - { - memcpy(newArray, m_Array, (newSize < this->m_Size ? newSize : this->m_Size) * sizeof(T)); - } - // Free the old array - _deallocate(); - } - - // Allocation was successful. Save it. - this->m_Size = newSize; - m_Array = newArray; - // This object has now allocated its memory and owns it. - this->_ownsData = true; - - this->m_MaxId = newSize - 1; - this->m_IsAllocated = true; + if(size == m_Size) // Requested size is equal to current size. Do nothing. + { + return m_Array; + } + newSize = size; + // Wipe out the array completely if new size is zero. + if(newSize == 0) + { + initialize(); return m_Array; } - private: + newArray = new T[newSize](); + if(!newArray) + { + qDebug() << "Unable to allocate " << newSize << " elements of size " << sizeof(T) << " bytes. "; + return nullptr; + } - // unsigned long long int MUD_FLAP_0; - T* m_Array; - // unsigned long long int MUD_FLAP_1; - size_t m_Size; - // unsigned long long int MUD_FLAP_4; - bool _ownsData; - // unsigned long long int MUD_FLAP_2; - size_t m_MaxId; + // Copy the data from the old array. + if(m_Array != nullptr) + { + std::memcpy(newArray, m_Array, (newSize < m_Size ? newSize : m_Size) * sizeof(T)); + } - bool m_IsAllocated; - // unsigned long long int MUD_FLAP_3; - QString m_Name; - // unsigned long long int MUD_FLAP_5; + // Allocate a new array if we DO NOT own the current array + if((nullptr != m_Array) && m_OwnsData) + { + // Free the old array + deallocate(); + } - StructArray(const StructArray&); //Not Implemented - void operator=(const StructArray&); //Not Implemented + // Allocation was successful. Save it. + m_Size = newSize; + m_Array = newArray; + // This object has now allocated its memory and owns it. + m_OwnsData = true; + m_MaxId = newSize - 1; + m_IsAllocated = true; -}; + return m_Array; + } +private: + // unsigned long long int MUD_FLAP_0; + T* m_Array; + // unsigned long long int MUD_FLAP_1; + size_t m_Size; + // unsigned long long int MUD_FLAP_4; + bool m_OwnsData; + // unsigned long long int MUD_FLAP_2; + size_t m_MaxId; + bool m_IsAllocated; + // unsigned long long int MUD_FLAP_3; + // unsigned long long int MUD_FLAP_5; +public: + StructArray(const StructArray&) = delete; // Copy Constructor Not Implemented + StructArray(StructArray&&) = delete; // Move Constructor Not Implemented + StructArray& operator=(const StructArray&) = delete; // Copy Assignment Not Implemented + StructArray& operator=(StructArray&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/DataArrays/Testing/Cxx/DataArrayTest.cpp b/Source/SIMPLib/DataArrays/Testing/Cxx/DataArrayTest.cpp index f938c9aad9..43ed0bad87 100644 --- a/Source/SIMPLib/DataArrays/Testing/Cxx/DataArrayTest.cpp +++ b/Source/SIMPLib/DataArrays/Testing/Cxx/DataArrayTest.cpp @@ -1,56 +1,61 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include +#include +#include +#include #include +#include #include #include #include #include +#include #include +#include + +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataArrays/IDataArray.h" #include "SIMPLib/DataArrays/NeighborList.hpp" #include "SIMPLib/DataArrays/StringDataArray.h" #include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/Math/SIMPLibMath.h" -#include "SIMPLib/SIMPLib.h" - #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -75,6 +80,35 @@ #define DIM1 3 #define DIM2 4 +//============================= These are for testing the STL Interface ================================================ +std::map test; +std::map::value_type vt; + +bool mypredicate(int32_t i, int32_t j) +{ + return (i == j); +} + +struct Sum +{ + Sum() + : sum{0} + { + } + void operator()(int n) + { + sum += n; + } + int sum; +}; + +template +void print(const T& v) +{ + std::cout << v << " "; +} +//====================================================================================================================== + class DataArrayTest { public: @@ -96,11 +130,12 @@ class DataArrayTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void TestcopyTuplesForType() + template + void TestcopyTuplesForType() { int err = 0; - QVector dims(1, NUM_COMPONENTS_2); - typename DataArray::Pointer array = DataArray::CreateArray(NUM_TUPLES_2, dims, "TestcopyTuples"); + std::vector dims(1, NUM_COMPONENTS_2); + typename DataArray::Pointer array = DataArray::CreateArray(NUM_TUPLES_2, dims, "TestcopyTuples", true); DREAM3D_REQUIRE_EQUAL(array->isAllocated(), true); for(size_t i = 0; i < NUM_TUPLES_2; ++i) @@ -150,18 +185,19 @@ class DataArrayTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void TestEraseElementsForType() + template + void TestEraseElementsForType() { // Test dropping of front elements only { - typename DataArray::Pointer array = DataArray::CreateArray(NUM_ELEMENTS, "Test1"); + typename DataArray::Pointer array = DataArray::CreateArray(NUM_ELEMENTS, std::string("Test1"), true); DREAM3D_REQUIRE_EQUAL(array->isAllocated(), true); for(size_t i = 0; i < NUM_ELEMENTS; ++i) { array->setComponent(i, 0, static_cast(i)); } - QVector eraseElements; + std::vector eraseElements; eraseElements.push_back(0); eraseElements.push_back(1); @@ -175,8 +211,8 @@ class DataArrayTest // Test Dropping of internal elements { - QVector dims(1, NUM_COMPONENTS_2); - typename DataArray::Pointer array = DataArray::CreateArray(NUM_ELEMENTS_2, dims, "Test2"); + std::vector dims(1, NUM_COMPONENTS_2); + typename DataArray::Pointer array = DataArray::CreateArray(NUM_ELEMENTS_2, dims, "Test2", true); DREAM3D_REQUIRE_EQUAL(array->isAllocated(), true); for(size_t i = 0; i < NUM_TUPLES_2; ++i) { @@ -184,7 +220,7 @@ class DataArrayTest array->setComponent(i, 1, static_cast(i)); } - QVector eraseElements; + std::vector eraseElements; eraseElements.push_back(3); eraseElements.push_back(6); eraseElements.push_back(8); @@ -201,8 +237,8 @@ class DataArrayTest // Test Dropping of internal elements { - QVector dims(1, NUM_COMPONENTS_2); - typename DataArray::Pointer array = DataArray::CreateArray(NUM_ELEMENTS_2, dims, "Test3"); + std::vector dims(1, NUM_COMPONENTS_2); + typename DataArray::Pointer array = DataArray::CreateArray(NUM_ELEMENTS_2, dims, "Test3", true); DREAM3D_REQUIRE_EQUAL(array->isAllocated(), true); for(size_t i = 0; i < NUM_TUPLES_2; ++i) { @@ -210,7 +246,7 @@ class DataArrayTest array->setComponent(i, 1, static_cast(i)); } - QVector eraseElements; + std::vector eraseElements; eraseElements.push_back(3); eraseElements.push_back(6); eraseElements.push_back(9); @@ -226,8 +262,8 @@ class DataArrayTest // Test Dropping of internal continuous elements { - QVector dims(1, NUM_COMPONENTS_2); - typename DataArray::Pointer array = DataArray::CreateArray(NUM_ELEMENTS_2, dims, "Test4"); + std::vector dims(1, NUM_COMPONENTS_2); + typename DataArray::Pointer array = DataArray::CreateArray(NUM_ELEMENTS_2, dims, "Test4", true); DREAM3D_REQUIRE_EQUAL(array->isAllocated(), true); for(size_t i = 0; i < NUM_TUPLES_2; ++i) { @@ -235,7 +271,7 @@ class DataArrayTest array->setComponent(i, 1, static_cast(i)); } - QVector eraseElements; + std::vector eraseElements; eraseElements.push_back(3); eraseElements.push_back(4); eraseElements.push_back(5); @@ -251,8 +287,8 @@ class DataArrayTest // Test Dropping of Front and Back Elements { - QVector dims(1, NUM_COMPONENTS_2); - typename DataArray::Pointer array = DataArray::CreateArray(NUM_ELEMENTS_2, dims, "Test5"); + std::vector dims(1, NUM_COMPONENTS_2); + typename DataArray::Pointer array = DataArray::CreateArray(NUM_ELEMENTS_2, dims, "Test5", true); DREAM3D_REQUIRE_EQUAL(array->isAllocated(), true); for(size_t i = 0; i < NUM_TUPLES_2; ++i) { @@ -260,7 +296,7 @@ class DataArrayTest array->setComponent(i, 1, static_cast(i)); } - QVector eraseElements; + std::vector eraseElements; eraseElements.push_back(0); eraseElements.push_back(9); @@ -274,8 +310,8 @@ class DataArrayTest // Test Dropping of Back Elements { - QVector dims(1, NUM_COMPONENTS_2); - typename DataArray::Pointer array = DataArray::CreateArray(NUM_ELEMENTS_2, dims, "Test6"); + std::vector dims(1, NUM_COMPONENTS_2); + typename DataArray::Pointer array = DataArray::CreateArray(NUM_ELEMENTS_2, dims, "Test6", true); DREAM3D_REQUIRE_EQUAL(array->isAllocated(), true); for(size_t i = 0; i < NUM_TUPLES_2; ++i) { @@ -283,7 +319,7 @@ class DataArrayTest array->setComponent(i, 1, static_cast(i)); } - QVector eraseElements; + std::vector eraseElements; eraseElements.push_back(7); eraseElements.push_back(8); eraseElements.push_back(9); @@ -297,8 +333,8 @@ class DataArrayTest // Test Dropping of indices larger than the number of tuples { - QVector dims(1, NUM_COMPONENTS_2); - typename DataArray::Pointer array = DataArray::CreateArray(NUM_TUPLES_2, dims, "Test6"); + std::vector dims(1, NUM_COMPONENTS_2); + typename DataArray::Pointer array = DataArray::CreateArray(NUM_TUPLES_2, dims, "Test6", true); DREAM3D_REQUIRE_EQUAL(array->isAllocated(), true); for(size_t i = 0; i < NUM_TUPLES_2; ++i) { @@ -306,7 +342,7 @@ class DataArrayTest array->setComponent(i, 1, static_cast(i)); } - QVector eraseElements; + std::vector eraseElements; eraseElements.push_back(10); int err = array->eraseTuples(eraseElements); DREAM3D_REQUIRE_EQUAL(err, -100) @@ -340,7 +376,8 @@ class DataArrayTest TestEraseElementsForType(); } - template QString TypeToString(T v) + template + QString TypeToString(T v) { if(typeid(v) == typeid(long)) @@ -382,10 +419,10 @@ class DataArrayTest #define TEST_TYPE_STRING(type) \ { \ - DataArray::Pointer p_##type = DataArray::CreateArray(1, "Test", false); \ + DataArray::Pointer p_##type = DataArray::CreateArray(1, std::string("Test"), false); \ QString s_##type = p_##type->getTypeAsString(); \ - /* qDebug() << #type << s_##type; */ \ - type value = (type)(1); \ + s_##type = s_##type; /* qDebug() << #type << s_##type; */ \ + auto value = static_cast(1); \ value = value; \ /* qDebug() << TypeToString(value); */ \ } @@ -401,8 +438,6 @@ class DataArrayTest TEST_TYPE_STRING(quint16) TEST_TYPE_STRING(qint32) TEST_TYPE_STRING(quint32) - TEST_TYPE_STRING(qint64) - TEST_TYPE_STRING(quint64) TEST_TYPE_STRING(int8_t) TEST_TYPE_STRING(uint8_t) @@ -414,10 +449,6 @@ class DataArrayTest TEST_TYPE_STRING(uint64_t) TEST_TYPE_STRING(float) TEST_TYPE_STRING(double) - // long long int myint = 50; - // std::cout << "myint has type: " << typeid(myint).name() << '\n'; - - // qDebug() << typeid(int64_t).name() << " " << typeid(qint64).name() << " " << typeid(signed long long int).name() << " " << typeid(long long int).name() << " " << typeid(long long).name(); } // ----------------------------------------------------------------------------- @@ -427,7 +458,7 @@ class DataArrayTest { int32_t* ptr = nullptr; { - Int32ArrayType::Pointer d = Int32ArrayType::CreateArray(0, "Test7"); + Int32ArrayType::Pointer d = Int32ArrayType::CreateArray(0, std::string("Test7"), true); DREAM3D_REQUIRE_EQUAL(0, d->getSize()); DREAM3D_REQUIRE_EQUAL(0, d->getNumberOfTuples()); ptr = d->getPointer(0); @@ -436,8 +467,8 @@ class DataArrayTest } { - QVector dims(1, NUM_COMPONENTS); - Int32ArrayType::Pointer int32Array = Int32ArrayType::CreateArray(NUM_ELEMENTS, dims, "Test8"); + std::vector dims(1, NUM_COMPONENTS); + Int32ArrayType::Pointer int32Array = Int32ArrayType::CreateArray(NUM_ELEMENTS, dims, "Test8", true); ptr = int32Array->getPointer(0); DREAM3D_REQUIRE_EQUAL(int32Array->isAllocated(), true); DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS, int32Array->getNumberOfTuples()); @@ -452,7 +483,7 @@ class DataArrayTest } // Resize Larger - int32Array->resize(NUM_TUPLES_2); + int32Array->resizeTuples(NUM_TUPLES_2); DREAM3D_REQUIRE_EQUAL(NUM_TUPLES_2, int32Array->getNumberOfTuples()); DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS_2, int32Array->getSize()); DREAM3D_REQUIRE_EQUAL(int32Array->isAllocated(), true); @@ -467,7 +498,7 @@ class DataArrayTest } // Resize Smaller - Which should have still saved some of our data - int32Array->resize(NUM_TUPLES_3); + int32Array->resizeTuples(NUM_TUPLES_3); DREAM3D_REQUIRE_EQUAL(NUM_TUPLES_3, int32Array->getNumberOfTuples()); DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS_3, int32Array->getSize()); DREAM3D_REQUIRE_EQUAL(int32Array->isAllocated(), true); @@ -501,7 +532,8 @@ class DataArrayTest // ----------------------------------------------------------------------------- // Test the NeighborList Class // ----------------------------------------------------------------------------- - template void TestNeighborListForType() + template + void TestNeighborListForType() { typename NeighborList::Pointer n = NeighborList::New(); n->setName("Test"); @@ -522,7 +554,7 @@ class DataArrayTest } // Remove the front 2 elements and test - QVector eraseElements; + std::vector eraseElements; eraseElements.push_back(0); eraseElements.push_back(1); @@ -597,13 +629,14 @@ class DataArrayTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void TestNeighborListDeepCopyForType() + template + void TestNeighborListDeepCopyForType() { - QVector tDims(10); + std::vector tDims(10); AttributeMatrix::Pointer am = AttributeMatrix::New(tDims, "AttributeMatrix", AttributeMatrix::Type::Cell); - typename NeighborList::Pointer neiList = NeighborList::CreateArray(10, "NeighborList"); + typename NeighborList::Pointer neiList = NeighborList::CreateArray(10, std::string("NeighborList"), true); for(int i = 0; i < 10; ++i) { @@ -648,7 +681,8 @@ class DataArrayTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template int ValidateArrayForType(typename DataArray::Pointer array, size_t numTuples, int numComp) + template + int ValidateArrayForType(typename DataArray::Pointer array, size_t numTuples, int numComp) { int err = 0; DREAM3D_REQUIRED(true, ==, array->isAllocated()); @@ -672,13 +706,13 @@ class DataArrayTest } // Splat another value across the array starting at an offset into the array // and test those values made it into the array correctly - array->initializeWithValue(static_cast(1), numComp); - for(size_t i = numComp; i < numElements; i++) + array->initializeWithValue(static_cast(1)); + for(size_t i = 0; i < numElements; i++) { DREAM3D_REQUIRE_EQUAL(static_cast(1), ptr[i]); } // Initialize the entire array with a value (offset = 0); - array->initializeWithValue(static_cast(2), 0); + array->initializeWithValue(static_cast(2)); for(size_t i = 0; i < numElements; i++) { DREAM3D_REQUIRE_EQUAL(static_cast(2), ptr[i]); @@ -725,17 +759,17 @@ class DataArrayTest } } - /// virtual QVector getComponentDimensions() + /// virtual std::vector getComponentDimensions() // Test resizing the array based on a give number of tuples. The number of Components will stay the same at each tuple - array->resize(numTuples * 2); + array->resizeTuples(numTuples); array->initializeWithZeros(); // Init the grown array to all Zeros nt = array->getNumberOfTuples(); - DREAM3D_REQUIRED(nt, ==, (numTuples * 2)); + DREAM3D_REQUIRED(nt, ==, (numTuples)); nc = array->getNumberOfComponents(); DREAM3D_REQUIRED(nc, ==, numComp); // Test resizing the array to a smaller size - array->resize(numTuples); + array->resizeTuples(numTuples); array->initializeWithZeros(); // Init the grown array to all Zeros nt = array->getNumberOfTuples(); DREAM3D_REQUIRED(nt, ==, (numTuples)); @@ -757,7 +791,7 @@ class DataArrayTest DREAM3D_REQUIRED_PTR(ptr, ==, nullptr); // Test resizing the array to a any larger size - array->resize(numTuples); + array->resizeTuples(numTuples); array->initializeWithZeros(); // Init the grown array to all Zeros nt = array->getNumberOfTuples(); DREAM3D_REQUIRED(nt, ==, (numTuples)); @@ -772,7 +806,8 @@ class DataArrayTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void TestArrayCreationForType() + template + void TestArrayCreationForType() { int err = 0; size_t numTuples = NUM_TUPLES; @@ -780,14 +815,14 @@ class DataArrayTest size_t dims[RANK] = {DIM0, DIM1, DIM2}; int numComp = 1; { - typename DataArray::Pointer array = DataArray::CreateArray(numTuples, "TEST"); + typename DataArray::Pointer array = DataArray::CreateArray(numTuples, std::string("TEST"), true); err = ValidateArrayForType(array, numTuples, numComp); DREAM3D_REQUIRED(err, >=, 0) } { numComp = DIM0 * DIM1 * DIM2; - typename DataArray::Pointer array = DataArray::CreateArray(numTuples, rank, dims, "TEST"); + typename DataArray::Pointer array = DataArray::CreateArray(numTuples, rank, dims, "TEST", true); err = ValidateArrayForType(array, numTuples, numComp); DREAM3D_REQUIRED(err, >=, 0) } @@ -798,29 +833,29 @@ class DataArrayTest vDims[0] = DIM0; vDims[1] = DIM1; vDims[2] = DIM2; - typename DataArray::Pointer array = DataArray::CreateArray(numTuples, vDims, "TEST"); + typename DataArray::Pointer array = DataArray::CreateArray(numTuples, vDims, "TEST", true); err = ValidateArrayForType(array, numTuples, numComp); DREAM3D_REQUIRED(err, >=, 0) } { numComp = DIM0 * DIM1 * DIM2; - QVector vDims(3, 0); + std::vector vDims(3, 0); vDims[0] = DIM0; vDims[1] = DIM1; vDims[2] = DIM2; - typename DataArray::Pointer array = DataArray::CreateArray(numTuples, vDims, "TEST"); + typename DataArray::Pointer array = DataArray::CreateArray(numTuples, vDims, "TEST", true); err = ValidateArrayForType(array, numTuples, numComp); DREAM3D_REQUIRED(err, >=, 0) } { - QVector tDims(2, 4); - QVector vDims(3, 0); + std::vector tDims(2, 4); + std::vector vDims(3, 0); vDims[0] = DIM0; vDims[1] = DIM1; vDims[2] = DIM2; - typename DataArray::Pointer array = DataArray::CreateArray(tDims, vDims, "TEST"); + typename DataArray::Pointer array = DataArray::CreateArray(tDims, vDims, "TEST", true); err = ValidateArrayForType(array, tDims[0] * tDims[1], numComp); DREAM3D_REQUIRED(err, >=, 0) } @@ -841,8 +876,9 @@ class DataArrayTest } mudflap; unsigned char* cptr = nullptr; - QVector tDims(1, 10); - typename DataArray::Pointer array = DataArray::CreateArray(DIM0, "TEST"); + std::vector tDims(1, 10); + typename DataArray::Pointer array = DataArray::CreateArray(DIM0, "TEST", +true); array->initializeWithZeros(); cptr = reinterpret_cast(array->getPointer(0)); @@ -914,10 +950,11 @@ class DataArrayTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void TestDeepCopyDataArrayForType() + template + void TestDeepCopyDataArrayForType() { size_t numTuples = 10; - QVector cDims(1, 5); + std::vector cDims(1, 5); QString name("Source Array"); // First lets try it without allocating any memory @@ -970,10 +1007,11 @@ class DataArrayTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void TestCopyDataForType() + template + void TestCopyDataForType() { size_t numTuples = 10; - QVector cDims(1, 5); + std::vector cDims(1, 5); QString name("Source Array"); // First lets try it without allocating any memory @@ -981,8 +1019,8 @@ class DataArrayTest typename DataArray::Pointer copy = DataArray::CreateArray(numTuples, cDims, name, false); - DREAM3D_REQUIRED(copy->getNumberOfTuples(), ==, src->getNumberOfTuples()); - DREAM3D_REQUIRED(copy->isAllocated(), ==, src->isAllocated()); + DREAM3D_REQUIRED(copy->getNumberOfTuples(), ==, src->getNumberOfTuples()) + DREAM3D_REQUIRED(copy->isAllocated(), ==, src->isAllocated()) // Create the array again, this time allocating the data and putting in some known data src = DataArray::CreateArray(numTuples, cDims, name, true); @@ -1002,7 +1040,7 @@ class DataArrayTest DREAM3D_REQUIRE_EQUAL(didCopy, false); // Resize the DataArray to accomondate the true amount of data that we want (20 Tuples) - src->resize(numTuples * 2); + src->resizeTuples(numTuples * 2); didCopy = src->copyFromArray(numTuples, copy); DREAM3D_REQUIRE_EQUAL(didCopy, true); @@ -1092,9 +1130,10 @@ class DataArrayTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void TestWrapPointerForType() + template + void TestWrapPointerForType() { - QVector cDims = {1}; + std::vector cDims = {1}; T* ptr = new T[TEST_SIZE]; // Allocate on the heap { // Wrap the pointer, write some data to it, and then let the object go @@ -1131,8 +1170,8 @@ class DataArrayTest // ----------------------------------------------------------------------------- void TestPrintDataArray() { - FloatArrayType::Pointer floats = FloatArrayType::CreateArray(1, "Test_Float", true); - floats->setValue(0, SIMPLib::Constants::k_Pif); + FloatArrayType::Pointer floats = FloatArrayType::CreateArray(1, std::string("Test_Float"), true); + floats->setValue(0, SIMPLib::Constants::k_PiF); QString outStr; QTextStream out(&outStr); floats->printTuple(out, 0); @@ -1144,8 +1183,8 @@ class DataArrayTest DREAM3D_REQUIRE_EQUAL(comp, 0); outStr.clear(); - DoubleArrayType::Pointer doubles = DoubleArrayType::CreateArray(1, "Test_Double", true); - doubles->setValue(0, SIMPLib::Constants::k_Pi); + DoubleArrayType::Pointer doubles = DoubleArrayType::CreateArray(1, std::string("Test_Double"), true); + doubles->setValue(0, SIMPLib::Constants::k_PiD); doubles->printTuple(out, 0); matchString = "3.141592653589793"; length = outStr.length(); @@ -1157,20 +1196,21 @@ class DataArrayTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void TestSetTupleForType() + template + void TestSetTupleForType() { size_t numTuples = 10; - QVector cDims(1, 5); + std::vector cDims = {5}; QString name("Source Array"); // Each index of the vector is a tuple with a vector containing the components for that tuple typename std::vector> data; - for (size_t i = 0; i < numTuples; i++) + for(size_t i = 0; i < numTuples; i++) { typename std::vector tempVector; - for (size_t j = 0; j < cDims[0]; j++) + for(size_t j = 0; j < cDims[0]; j++) { tempVector.push_back(static_cast(i + j)); } @@ -1181,19 +1221,22 @@ class DataArrayTest typename DataArray::Pointer src = DataArray::CreateArray(numTuples, cDims, name, true); - for (size_t i = 0; i < numTuples; i++) + for(size_t i = 0; i < numTuples; i++) { src->setTuple(i, data[i]); } // Check each element of the DataArray against the original vector - for (size_t i = 0; i < numTuples; i++) + for(size_t i = 0; i < numTuples; i++) { - for (size_t j = 0; j < cDims[0]; j++) + for(size_t j = 0; j < cDims[0]; j++) { T val = src->getComponent(i, j); DREAM3D_REQUIRE_EQUAL(data[i][j], val) + + T* ptr = src->getPointer((cDims[0] * i) + j); + DREAM3D_REQUIRE_EQUAL(*ptr, val); } } } @@ -1215,6 +1258,227 @@ class DataArrayTest TestSetTupleForType(); } + // ----------------------------------------------------------------------------- + void STLInterfaceTest() + { + std::cout << "STLInterfaceTest Test Starting...." << std::endl; + + DataArray i32Array(10, "Test Array", 0); + DataArray i32Array1(10, "Other Array", 0); + + // Initialize with a value + for(auto& value : i32Array) + { + value = 5; + } + // Initialize with a value + for(auto& value : i32Array1) + { + value = 5; + } + + std::cout << "before:"; + std::for_each(i32Array.begin(), i32Array.end(), print); + std::cout << '\n'; + + std::cout << "using default comparison:" << std::endl; + if(std::equal(i32Array.begin(), i32Array.end(), i32Array1.begin())) + { + std::cout << "The contents of both sequences are equal.\n"; + } + else + { + std::cout << "The contents of both sequences differ.\n"; + } + + std::for_each(i32Array1.begin(), i32Array1.end(), [](int32_t& n) { n++; }); + + std::cout << "using predicate comparison:" << std::endl; + if(std::equal(i32Array.begin(), i32Array.end(), i32Array1.begin(), mypredicate)) + { + std::cout << "The contents of both sequences are equal.\n"; + } + else + { + std::cout << "The contents of both sequences differ.\n"; + } + + std::cout << "Using another predicate to sum the values" << std::endl; + // calls Sum::operator() for each number + Sum s = std::for_each(i32Array1.begin(), i32Array1.end(), Sum()); + + std::cout << "after: "; + std::for_each(i32Array1.begin(), i32Array1.end(), print); + std::cout << '\n'; + std::cout << "sum: " << s.sum << '\n'; + + std::cout << "Modify Array using [] operator..." << std::endl; + for(DataArray::size_type i = 0; i < i32Array.size(); i++) + { + i32Array[i] = static_cast(i * 10); + } + + std::cout << "Print using range based loop..." << std::endl; + for(const auto& value : i32Array) + { + std::cout << value << std::endl; + } + + std::cout << "std::fill" << std::endl; + // std::fill the array with a set value + std::fill(i32Array.begin(), i32Array.end(), -1); + std::for_each(i32Array.begin(), i32Array.end(), print); + std::cout << "" << std::endl; + + std::cout << "std::transform from int32_t to float using a back_inserter" << std::endl; + DataArray f32Array(0, "Float Array", 0.0f); + std::transform(i32Array.begin(), i32Array.end(), std::back_inserter(f32Array), [](int32_t i) -> float { return i * 2.5; }); + std::for_each(f32Array.begin(), f32Array.end(), print); + std::cout << std::endl; + + // Get the front and back + int32_t front = i32Array1.front(); + float back = f32Array.back(); + if(front != back) + { + // do nothing + } + + std::cout << "## Assign Content(1)" << std::endl; + std::vector foo(60, 33); + i32Array.assign(foo.begin(), foo.end()); + std::cout << "i32Array.size() after assign(1): " << i32Array.size() << std::endl; + + i32Array.assign(static_cast(22), 333); + std::cout << "i32Array.size() after assign(2): " << i32Array.size() << std::endl; + + i32Array.assign(std::initializer_list{ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + }); + std::cout << "i32Array.size() after assign(3): " << i32Array.size() << std::endl; + + int32_t* data = i32Array.data(); + if(data[0] != 3) + { + } + // Stick DataArray into a STL container + std::vector> vecOfFloatArrays; + + // ----------------------------------------------------------------------------- + // Let's try something that has components, like an ARGB array + using RgbaType = DataArray; + using CompDimsType = RgbaType::comp_dims_type; + using RgbaIterator = RgbaType::tuple_iterator; + + CompDimsType cDims = {4}; + RgbaType rgba(10, QString("RGBA Array"), cDims, 0); + + RgbaIterator begin = rgba.tupleBegin(); + rgba.initializeWithValue(0xFF); + rgba[0] = 0x65; + rgba[1] = 0x66; + rgba[2] = 0x67; + rgba[3] = 0x68; + + for(RgbaIterator rgbaIter = begin; rgbaIter != rgba.tupleEnd(); rgbaIter++) + { + std::cout << "rgba: " << static_cast(*rgbaIter) << std::endl; + std::cout << " rgba[0] " << static_cast(rgbaIter.comp_value(0)) << " rgba[1] " << static_cast(rgbaIter.comp_value(1)) << " rgba[2] " << static_cast(rgbaIter.comp_value(2)) + << " rgba[3] " << static_cast(rgbaIter.comp_value(3)) << std::endl; + + for(size_t i = 0; i < 4; i++) + { + rgbaIter.comp_value(i) = 55 + i; + } + std::cout << "rgba: " << static_cast(*rgbaIter) << std::endl; + std::cout << " rgba[0] " << static_cast(rgbaIter.comp_value(0)) << " rgba[1] " << static_cast(rgbaIter.comp_value(1)) << " rgba[2] " << static_cast(rgbaIter.comp_value(2)) + << " rgba[3] " << static_cast(rgbaIter.comp_value(3)) << std::endl; + } + } + + template + void TestByteSwapElementType(T init) + { + using DataArrayType = DataArray; + + DataArrayType array(8, QString("Test Array"), init); + +#if 0 + std::cout << array.getTypeAsString().toStdString() << std::endl; + std::cout << "Input: " << init << "\t Compare Value: " << compare << std::endl; + uint8_t* ptr = reinterpret_cast(array.getVoidPointer(0)); + for(size_t i = 0; i < 8 * sizeof(T); i++) + { + if(i % sizeof(T) == 0) + { + printf(" "); + } + printf("%0x", ptr[i]); + } + printf("\n"); +#endif + + std::array in; + ::memcpy(in.data(), &init, sizeof(T)); + + // Reverse the bytes into the comparison + std::array comp; + for(size_t i = 0; i < sizeof(T); i++) + { + comp[i] = in[sizeof(T) - 1 - i]; + } + + uint8_t* ptr = reinterpret_cast(array.getVoidPointer(0)); + size_t size = sizeof(T); + + array.byteSwapElements(); + + for(size_t i = 0; i < 8; i++) + { + int result = std::memcmp(comp.data(), ptr, size); + DREAM3D_REQUIRED(result, ==, 0) + ptr = ptr + size; + } + +#if 0 + for(size_t i = 0; i < 8 * sizeof(T); i++) + { + if(i % sizeof(T) == 0) + { + printf(" "); + } + printf("%0x", ptr[i]); + } + printf("\n"); + printf("---------------\n"); +#endif + } + + // ----------------------------------------------------------------------------- + void TestByteSwapElements() + { + TestByteSwapElementType(0x7F); + TestByteSwapElementType(static_cast(0x7F)); + + TestByteSwapElementType(0xABCD); + TestByteSwapElementType(static_cast(0x8ACF)); + + TestByteSwapElementType(0x55ABCDEF); + TestByteSwapElementType(0x55ABCDEF); + + TestByteSwapElementType(0x5566778899ABCDEF); + TestByteSwapElementType(0x5566778899ABCDEF); + + TestByteSwapElementType(-151057.0f); + TestByteSwapElementType(0x412ABE865D841400); + } + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -1239,13 +1503,16 @@ class DataArrayTest DREAM3D_REGISTER_TEST(TestWrapPointer()) DREAM3D_REGISTER_TEST(TestPrintDataArray()) DREAM3D_REGISTER_TEST(TestSetTuple()) + DREAM3D_REGISTER_TEST(TestByteSwapElements()) #if REMOVE_TEST_FILES DREAM3D_REGISTER_TEST(RemoveTestFiles()) #endif } -private: - DataArrayTest(const DataArrayTest&); // Copy Constructor Not Implemented - void operator=(const DataArrayTest&); // Move assignment Not Implemented +public: + DataArrayTest(const DataArrayTest&) = delete; // Copy Constructor Not Implemented + DataArrayTest(DataArrayTest&&) = delete; // Move Constructor Not Implemented + DataArrayTest& operator=(const DataArrayTest&) = delete; // Copy Assignment Not Implemented + DataArrayTest& operator=(DataArrayTest&&) = delete; // Move Assignment Not Implemented }; diff --git a/Source/SIMPLib/DataArrays/Testing/Cxx/StringDataArrayTest.cpp b/Source/SIMPLib/DataArrays/Testing/Cxx/StringDataArrayTest.cpp index 011cd37382..6cb3303c5b 100644 --- a/Source/SIMPLib/DataArrays/Testing/Cxx/StringDataArrayTest.cpp +++ b/Source/SIMPLib/DataArrays/Testing/Cxx/StringDataArrayTest.cpp @@ -1,48 +1,47 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include #include #include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataArrays/StringDataArray.h" #include "SIMPLib/Geometry/MeshStructs.h" -#include "SIMPLib/SIMPLib.h" - #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -83,7 +82,7 @@ static const QString _6("six"); static const QString _7("seven"); static const QString _8("eight"); static const QString _9("nine"); -} +} // namespace const QString kArrayName("Test Strings"); @@ -110,7 +109,7 @@ class StringDataArrayTest // ----------------------------------------------------------------------------- StringDataArray::Pointer initializeStringDataArray() { - StringDataArray::Pointer data = StringDataArray::CreateArray(k_ArraySize, kArrayName); + StringDataArray::Pointer data = StringDataArray::CreateArray(k_ArraySize, kArrayName, true); size_t nTuples = data->getNumberOfTuples(); DREAM3D_REQUIRE_EQUAL(k_ArraySize, nTuples) @@ -190,7 +189,7 @@ class StringDataArrayTest StringDataArray::Pointer nodes = initializeStringDataArray(); // Resize to a smaller Array - nodes->resize(k_ResizeSmaller); + nodes->resizeTuples(k_ResizeSmaller); size_t nTuples = nodes->getNumberOfTuples(); DREAM3D_REQUIRE_EQUAL(k_ResizeSmaller, nTuples) size_t size = nodes->getSize(); @@ -205,14 +204,14 @@ class StringDataArrayTest DREAM3D_REQUIRE_EQUAL(nodes->getValue(4), ::_4); // Resize to a larger Array - nodes->resize(k_ResizeLarger); + nodes->resizeTuples(k_ResizeLarger); nTuples = nodes->getNumberOfTuples(); DREAM3D_REQUIRE_EQUAL(k_ResizeLarger, nTuples) size = nodes->getSize(); DREAM3D_REQUIRE_EQUAL(k_ResizeLarger, size) // Resize to a Zero Array - nodes->resize(k_InitSize); + nodes->resizeTuples(k_InitSize); nTuples = nodes->getNumberOfTuples(); DREAM3D_REQUIRE_EQUAL(k_InitSize, nTuples) size = nodes->getSize(); @@ -276,7 +275,7 @@ class StringDataArrayTest StringDataArray::Pointer nodes = initializeStringDataArray(); StringDataArray::Pointer copy = initializeStringDataArray(); - nodes->resize(k_ArraySize * 2); + nodes->resizeTuples(k_ArraySize * 2); bool didCopy = nodes->copyFromArray(k_ArraySize, copy); DREAM3D_REQUIRE_EQUAL(didCopy, true) DREAM3D_REQUIRE_EQUAL(nodes->getNumberOfTuples(), k_ArraySize * 2); @@ -297,7 +296,7 @@ class StringDataArrayTest { // Create an Array of 10 Structs StringDataArray::Pointer nodes = initializeStringDataArray(); - QVector idxs(k_ArraySize + 1, 0); + std::vector idxs(k_ArraySize + 1, 0); // Try to erase more indices than there are in the struct array int err = nodes->eraseTuples(idxs); DREAM3D_REQUIRE_EQUAL(err, 0) diff --git a/Source/SIMPLib/DataArrays/Testing/Cxx/StructArrayTest.cpp b/Source/SIMPLib/DataArrays/Testing/Cxx/StructArrayTest.cpp index e01e879975..edc55dd353 100644 --- a/Source/SIMPLib/DataArrays/Testing/Cxx/StructArrayTest.cpp +++ b/Source/SIMPLib/DataArrays/Testing/Cxx/StructArrayTest.cpp @@ -1,48 +1,47 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include #include #include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataArrays/StructArray.hpp" #include "SIMPLib/Geometry/MeshStructs.h" -#include "SIMPLib/SIMPLib.h" - #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -88,10 +87,10 @@ class StructArrayTest } virtual ~StructArrayTest() = default; - typedef struct + struct Vec3Int_t { uint32_t pos[3]; - } Vec3Int_t; + }; typedef StructArray Vec3IntList_t; typedef Vec3IntList_t::Pointer Vec3IntListPointer_t; @@ -110,7 +109,7 @@ class StructArrayTest // ----------------------------------------------------------------------------- Vec3IntListPointer_t initializeStructArray() { - Vec3IntListPointer_t nodes = Vec3IntList_t::CreateArray(k_ArraySize, kArrayName); + Vec3IntListPointer_t nodes = Vec3IntList_t::CreateArray(k_ArraySize, kArrayName, true); size_t nTuples = nodes->getNumberOfTuples(); DREAM3D_REQUIRE_EQUAL(k_ArraySize, nTuples) bool isAllocated = nodes->isAllocated(); @@ -239,7 +238,7 @@ class StructArrayTest Vec3IntListPointer_t nodes = initializeStructArray(); // Resize to a smaller Array - nodes->resize(k_ResizeSmaller); + nodes->resizeTuples(k_ResizeSmaller); size_t nTuples = nodes->getNumberOfTuples(); DREAM3D_REQUIRE_EQUAL(k_ResizeSmaller, nTuples) size_t size = nodes->getSize(); @@ -256,7 +255,7 @@ class StructArrayTest } // Resize to a larger Array - nodes->resize(k_ResizeLarger); + nodes->resizeTuples(k_ResizeLarger); nTuples = nodes->getNumberOfTuples(); DREAM3D_REQUIRE_EQUAL(k_ResizeLarger, nTuples) size = nodes->getSize(); @@ -279,7 +278,7 @@ class StructArrayTest } // Resize to a Zero Array - nodes->resize(k_InitSize); + nodes->resizeTuples(k_InitSize); Vec3Int_t* ptr = reinterpret_cast(nodes->getVoidPointer(0)); DREAM3D_REQUIRED_PTR(ptr, ==, nullptr); ptr = nodes->getPointer(0); @@ -365,7 +364,7 @@ class StructArrayTest Vec3IntListPointer_t nodes = initializeStructArray(); Vec3IntListPointer_t copy = initializeStructArray(); - nodes->resize(k_ArraySize * 2); + nodes->resizeTuples(k_ArraySize * 2); bool didCopy = nodes->copyFromArray(k_ArraySize, copy); DREAM3D_REQUIRE_EQUAL(didCopy, true) DREAM3D_REQUIRE_EQUAL(nodes->getNumberOfTuples(), k_ArraySize * 2); @@ -388,7 +387,7 @@ class StructArrayTest { // Create an Array of 10 Structs Vec3IntListPointer_t nodes = initializeStructArray(); - QVector idxs(k_ArraySize + 1, 0); + std::vector idxs(k_ArraySize + 1, 0); // Try to erase more indices than there are in the struct array int err = nodes->eraseTuples(idxs); DREAM3D_REQUIRE_EQUAL(err, 0) @@ -458,10 +457,11 @@ class StructArrayTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void _TestDeepCopyStructArray() + template + void _TestDeepCopyStructArray() { size_t numTuples = 10; - QVector cDims(1, 1); + std::vector cDims(1, 1); QString name("Source Array"); typename StructArray::Pointer src = StructArray::CreateArray(numTuples, name, false); typename StructArray::Pointer copy = std::dynamic_pointer_cast>(src->deepCopy()); diff --git a/Source/SIMPLib/DataContainers/AttributeMatrix.cpp b/Source/SIMPLib/DataContainers/AttributeMatrix.cpp index a385e019d5..21e8f69c16 100644 --- a/Source/SIMPLib/DataContainers/AttributeMatrix.cpp +++ b/Source/SIMPLib/DataContainers/AttributeMatrix.cpp @@ -1,78 +1,78 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "SIMPLib/DataContainers/AttributeMatrix.h" -// C Includes - // C++ Includes #include #include // HDF5 Includes +#include #include "H5Support/H5ScopedSentinel.h" #include "H5Support/QH5Lite.h" #include "H5Support/QH5Utilities.h" +#include +#include + // DREAM3D Includes -#include "SIMPLib/DataArrays/StatsDataArray.h" #include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataArrays/StatsDataArray.h" +#include "SIMPLib/DataContainers/AttributeMatrixProxy.h" +#include "SIMPLib/DataContainers/DataContainerProxy.h" #include "SIMPLib/HDF5/H5DataArrayReader.h" #include "SIMPLib/HDF5/VTKH5Constants.h" #include "SIMPLib/Math/SIMPLibMath.h" -#include "SIMPLib/DataContainers/AttributeMatrixProxy.h" -#include "SIMPLib/DataContainers/DataContainerProxy.h" #include "SIMPLib/Utilities/SIMPLH5DataReaderRequirements.h" +#include "SIMPLib/Utilities/STLUtilities.hpp" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrix::AttributeMatrix(QVector tDims, const QString& name, AttributeMatrix::Type attrType) -: m_Type(attrType) -, m_Name(name) +AttributeMatrix::AttributeMatrix(const std::vector& tDims, const QString& name, AttributeMatrix::Type attrType) +: IDataStructureContainerNode(name) , m_TupleDims(tDims) +, m_Type(attrType) { } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrix::~AttributeMatrix() -{ - // std::cout << "~AttributeMatrix" << std::endl; -} +AttributeMatrix::~AttributeMatrix() = default; // ----------------------------------------------------------------------------- QString AttributeMatrix::TypeToString(AttributeMatrix::Type t) @@ -209,47 +209,43 @@ AttributeMatrix::Type AttributeMatrix::StringToType(const QString& str) // ----------------------------------------------------------------------------- QVector AttributeMatrix::GetTypesAsStrings() { - QVector choices; - choices.push_back("Vertex"); - choices.push_back("Edge"); - choices.push_back("Face"); - choices.push_back("Cell"); - choices.push_back("VertexFeature"); - choices.push_back("EdgeFeature"); - choices.push_back("FaceFeature"); - choices.push_back("CellFeature"); - choices.push_back("VertexEnsemble"); - choices.push_back("EdgeEnsemble"); - choices.push_back("FaceEnsemble"); - choices.push_back("CellEnsemble"); - choices.push_back("MetaData"); - choices.push_back("Generic"); - choices.push_back("Unknown"); - choices.push_back("Any"); - return choices; + QVector choices; + choices.push_back("Vertex"); + choices.push_back("Edge"); + choices.push_back("Face"); + choices.push_back("Cell"); + choices.push_back("VertexFeature"); + choices.push_back("EdgeFeature"); + choices.push_back("FaceFeature"); + choices.push_back("CellFeature"); + choices.push_back("VertexEnsemble"); + choices.push_back("EdgeEnsemble"); + choices.push_back("FaceEnsemble"); + choices.push_back("CellEnsemble"); + choices.push_back("MetaData"); + choices.push_back("Generic"); + choices.push_back("Unknown"); + choices.push_back("Any"); + return choices; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AttributeMatrix::ReadAttributeMatrixStructure(hid_t containerId, DataContainerProxy* dcProxy, SIMPLH5DataReaderRequirements* req, const QString &h5InternalPath) +void AttributeMatrix::ReadAttributeMatrixStructure(hid_t containerId, DataContainerProxy* dcProxy, SIMPLH5DataReaderRequirements* req, const QString& h5InternalPath) { QList attributeMatrixNames; - QH5Utilities::getGroupObjects(containerId, H5Utilities::H5Support_GROUP, attributeMatrixNames); - foreach(QString attributeMatrixName, attributeMatrixNames) + QH5Utilities::getGroupObjects(containerId, H5Utilities::CustomHDFDataTypes::Group, attributeMatrixNames); + for(QString attributeMatrixName : attributeMatrixNames) { if(attributeMatrixName.compare(SIMPL::Geometry::Geometry) != 0) { - if(__SHOW_DEBUG_MSG__) - { - std::cout << " AttributeMatrix: " << attributeMatrixName.toStdString() << std::endl; - } hid_t attrMatGid = H5Gopen(containerId, attributeMatrixName.toLatin1().constData(), H5P_DEFAULT); if(attrMatGid < 0) { continue; } - H5ScopedGroupSentinel sentinel(&attrMatGid, true); + H5ScopedGroupSentinel sentinel(attrMatGid, true); AttributeMatrixProxy amProxy(attributeMatrixName); amProxy.setName(attributeMatrixName); @@ -259,10 +255,10 @@ void AttributeMatrix::ReadAttributeMatrixStructure(hid_t containerId, DataContai herr_t err = QH5Lite::readScalarAttribute(containerId, attributeMatrixName, SIMPL::StringConstants::AttributeMatrixType, amTypeTmp); if(err >= 0) { - if (req != nullptr) + if(req != nullptr) { AttributeMatrix::Types amTypes = req->getAMTypes(); - if(amTypes.empty() || amTypes.contains(static_cast(amTypeTmp))) + if(amTypes.empty() || SIMPL::contains(amTypes, static_cast(amTypeTmp))) { amProxy.setFlag(Qt::Checked); } @@ -290,22 +286,24 @@ void AttributeMatrix::ReadAttributeMatrixStructure(hid_t containerId, DataContai // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool AttributeMatrix::doesAttributeArrayExist(const QString& name) const +DataArrayPath AttributeMatrix::getDataArrayPath() const { - return m_AttributeArrays.contains(name); + DataArrayPath path = getParentPath(); + path.setAttributeMatrixName(getName()); + return path; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool AttributeMatrix::validateAttributeArraySizes() +bool AttributeMatrix::validateAttributeArraySizes() const { int64_t arraySize = 0; int64_t matrixSize = getNumberOfTuples(); - for(QMap::iterator iter = m_AttributeArrays.begin(); iter != m_AttributeArrays.end(); ++iter) + const AttributeMatrix::Container_t& dataArrays = getChildren(); + for(const auto& dataArray : dataArrays) { - IDataArray::Pointer d = iter.value(); - arraySize = d->getNumberOfTuples(); + arraySize = dataArray->getNumberOfTuples(); if(arraySize != matrixSize) { return false; @@ -314,66 +312,19 @@ bool AttributeMatrix::validateAttributeArraySizes() return true; } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -int AttributeMatrix::addAttributeArray(const QString& name, const IDataArray::Pointer& data) -{ - if(data->getName().compare(name) != 0) - { - qDebug() << "Adding Attribute Array with different array name than key name" - << "\n"; - qDebug() << "Key name: " << name << "\n"; - qDebug() << "Array Name:" << data->getName() << "\n"; - data->setName(name); - } - if(getNumberOfTuples() != data->getNumberOfTuples()) - { - qDebug() << "AttributeMatrix::Name: " << getName() << " dataArray::name: " << data->getName() << " Type: " << data->getTypeAsString(); - qDebug() << "getNumberOfTuples(): " << getNumberOfTuples() << " data->getNumberOfTuples(): " << data->getNumberOfTuples(); - } - Q_ASSERT(getNumberOfTuples() == data->getNumberOfTuples()); - - m_AttributeArrays[name] = data; - return 0; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -IDataArray::Pointer AttributeMatrix::getAttributeArray(const QString& name) -{ - QMap::iterator it; - it = m_AttributeArrays.find(name); - if(it == m_AttributeArrays.end()) - { - return IDataArray::NullPointer(); - } - return it.value(); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -IDataArray::Pointer AttributeMatrix::getAttributeArray(const DataArrayPath& path) -{ - return getAttributeArray(path.getDataArrayName()); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- IDataArray::Pointer AttributeMatrix::removeAttributeArray(const QString& name) { - QMap::iterator it; - it = m_AttributeArrays.find(name); - if(it == m_AttributeArrays.end()) + auto it = find(name); + if(it == end()) { // DO NOT return a NullPointer for any reason other than "Data Array was not found" return IDataArray::NullPointer(); } - IDataArray::Pointer p = it.value(); - m_AttributeArrays.erase(it); + IDataArray::Pointer p = (*it); + erase(it); return p; } @@ -382,32 +333,45 @@ IDataArray::Pointer AttributeMatrix::removeAttributeArray(const QString& name) // ----------------------------------------------------------------------------- RenameErrorCodes AttributeMatrix::renameAttributeArray(const QString& oldname, const QString& newname, bool overwrite) { - QMap::iterator itOld; - QMap::iterator itNew; + // Cannot rename a DataArray when the name does not change. + if(oldname == newname) + { + return SAME_PATH; + } - itNew = m_AttributeArrays.find(newname); - // If new name doesn't exist or we want to overwrite one that does exist... - if(itNew == m_AttributeArrays.end() || overwrite) + bool hasNewName = contains(newname); + if(hasNewName) { - itOld = m_AttributeArrays.find(oldname); - // If old name doesn't exist... - if(itOld == m_AttributeArrays.end()) + if(overwrite) { - return OLD_DOES_NOT_EXIST; + removeAttributeArray(newname); } - IDataArray::Pointer p = itOld.value(); - p->setName(newname); - removeAttributeArray(oldname); - addAttributeArray(newname, p); + else + { + return NEW_EXISTS; + } + } + + // If new name doesn't exist or we want to overwrite one that does exist... + auto oldArray = getChildByName(oldname); + // If old name doesn't exist... + if(nullptr == oldArray) + { + return OLD_DOES_NOT_EXIST; + } + if(oldArray->setName(newname)) + { return SUCCESS; } + + // Rename not successful return NEW_EXISTS; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector AttributeMatrix::getTupleDimensions() +std::vector AttributeMatrix::getTupleDimensions() const { return m_TupleDims; } @@ -415,7 +379,7 @@ QVector AttributeMatrix::getTupleDimensions() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AttributeMatrix::setTupleDimensions(const QVector& tupleDims) +void AttributeMatrix::setTupleDimensions(const std::vector& tupleDims) { resizeAttributeArrays(tupleDims); } @@ -423,7 +387,7 @@ void AttributeMatrix::setTupleDimensions(const QVector& tupleDims) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -size_t AttributeMatrix::getNumberOfTuples() +size_t AttributeMatrix::getNumberOfTuples() const { if(m_TupleDims.empty()) { @@ -431,7 +395,7 @@ size_t AttributeMatrix::getNumberOfTuples() } size_t numTuples = m_TupleDims[0]; - for(int i = 1; i < m_TupleDims.size(); i++) + for(size_t i = 1; i < m_TupleDims.size(); i++) { numTuples *= m_TupleDims[i]; } @@ -441,13 +405,13 @@ size_t AttributeMatrix::getNumberOfTuples() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool AttributeMatrix::removeInactiveObjects(const QVector &activeObjects, DataArray *featureIds) +bool AttributeMatrix::removeInactiveObjects(const QVector& activeObjects, DataArray* featureIds) { bool acceptableMatrix = false; // Only valid for feature or ensemble type matrices if(m_Type == AttributeMatrix::Type::VertexFeature || m_Type == AttributeMatrix::Type::VertexEnsemble || m_Type == AttributeMatrix::Type::EdgeFeature || - m_Type == AttributeMatrix::Type::EdgeEnsemble || m_Type == AttributeMatrix::Type::FaceFeature || m_Type == AttributeMatrix::Type::FaceEnsemble || - m_Type == AttributeMatrix::Type::CellFeature || m_Type == AttributeMatrix::Type::CellEnsemble) + m_Type == AttributeMatrix::Type::EdgeEnsemble || m_Type == AttributeMatrix::Type::FaceFeature || m_Type == AttributeMatrix::Type::FaceEnsemble || m_Type == AttributeMatrix::Type::CellFeature || + m_Type == AttributeMatrix::Type::CellEnsemble) { acceptableMatrix = true; } @@ -455,8 +419,8 @@ bool AttributeMatrix::removeInactiveObjects(const QVector &activeObjects, if(static_cast(activeObjects.size()) == totalTuples && acceptableMatrix) { size_t goodcount = 1; - QVector newNames(totalTuples, 0); - QVector removeList; + std::vector newNames(totalTuples, 0); + std::vector removeList; for(qint32 i = 1; i < activeObjects.size(); i++) { @@ -488,7 +452,7 @@ bool AttributeMatrix::removeInactiveObjects(const QVector &activeObjects, p->eraseTuples(removeList); } } - QVector tDims(1, (totalTuples - removeList.size())); + std::vector tDims(1, (totalTuples - removeList.size())); setTupleDimensions(tDims); // Loop over all the points and correct all the feature names @@ -513,19 +477,19 @@ bool AttributeMatrix::removeInactiveObjects(const QVector &activeObjects, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AttributeMatrix::resizeAttributeArrays(const QVector& tDims) +void AttributeMatrix::resizeAttributeArrays(const std::vector& tDims) { m_TupleDims = tDims; size_t numTuples = m_TupleDims[0]; - for(int i = 1; i < m_TupleDims.size(); i++) + for(size_t i = 1; i < m_TupleDims.size(); i++) { numTuples *= m_TupleDims[i]; } - for(QMap::iterator iter = m_AttributeArrays.begin(); iter != m_AttributeArrays.end(); ++iter) + const AttributeMatrix::Container_t& dataArrays = getChildren(); + for(const auto& dataArray : dataArrays) { - IDataArray::Pointer d = iter.value(); - d->resize(numTuples); + dataArray->resizeTuples(numTuples); } } @@ -534,46 +498,43 @@ void AttributeMatrix::resizeAttributeArrays(const QVector& tDims) // ----------------------------------------------------------------------------- void AttributeMatrix::clearAttributeArrays() { - m_AttributeArrays.clear(); + clear(); } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QList AttributeMatrix::getAttributeArrayNames() +AttributeMatrix::Container_t AttributeMatrix::getAttributeArrays() const { - QList keys; - for(QMap::iterator iter = m_AttributeArrays.begin(); iter != m_AttributeArrays.end(); ++iter) - { - keys.push_back(iter.key()); - } - return keys; + return getChildren(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- +AttributeMatrix::NameList AttributeMatrix::getAttributeArrayNames() const +{ + return getNamesOfChildren(); +} + int AttributeMatrix::getNumAttributeArrays() const { - return static_cast(m_AttributeArrays.size()); + return static_cast(size()); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrix::Pointer AttributeMatrix::deepCopy(bool forceNoAllocate) +AttributeMatrix::Pointer AttributeMatrix::deepCopy(bool forceNoAllocate) const { AttributeMatrix::Pointer newAttrMat = AttributeMatrix::New(getTupleDimensions(), getName(), getType()); - for(QMap::iterator iter = m_AttributeArrays.begin(); iter != m_AttributeArrays.end(); ++iter) + const auto& dataArrays = getChildren(); + for(const auto& d : dataArrays) { - IDataArray::Pointer d = iter.value(); IDataArray::Pointer new_d = d->deepCopy(forceNoAllocate); if(new_d.get() == nullptr) { return AttributeMatrix::NullPointer(); } - newAttrMat->addAttributeArray(new_d->getName(), new_d); + newAttrMat->insertOrAssign(new_d); } return newAttrMat; @@ -581,12 +542,13 @@ AttributeMatrix::Pointer AttributeMatrix::deepCopy(bool forceNoAllocate) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int AttributeMatrix::writeAttributeArraysToHDF5(hid_t parentId) +int AttributeMatrix::writeAttributeArraysToHDF5(hid_t parentId) const { - int err; - for(QMap::iterator iter = m_AttributeArrays.begin(); iter != m_AttributeArrays.end(); ++iter) + int err = 0; + + const auto& dataArrays = getChildren(); + for(const auto& d : dataArrays) { - IDataArray::Pointer d = iter.value(); err = d->writeH5Data(parentId, m_TupleDims); if(err < 0) { @@ -612,7 +574,7 @@ int AttributeMatrix::addAttributeArrayFromHDF5Path(hid_t gid, const QString& nam dPtr = H5DataArrayReader::ReadIDataArray(gid, name, preflight); if(preflight) { - dPtr->resize(getNumberOfTuples()); + dPtr->resizeTuples(getNumberOfTuples()); } } else if(classType.compare("StringDataArray") == 0) @@ -620,7 +582,7 @@ int AttributeMatrix::addAttributeArrayFromHDF5Path(hid_t gid, const QString& nam dPtr = H5DataArrayReader::ReadStringDataArray(gid, name, preflight); if(preflight) { - dPtr->resize(getNumberOfTuples()); + dPtr->resizeTuples(getNumberOfTuples()); } } else if(classType.compare("vector") == 0) @@ -631,7 +593,7 @@ int AttributeMatrix::addAttributeArrayFromHDF5Path(hid_t gid, const QString& nam dPtr = H5DataArrayReader::ReadNeighborListData(gid, name, preflight); if(preflight) { - dPtr->resize(getNumberOfTuples()); + dPtr->resizeTuples(getNumberOfTuples()); } } else if(name.compare(SIMPL::EnsembleData::Statistics) == 0) @@ -642,13 +604,13 @@ int AttributeMatrix::addAttributeArrayFromHDF5Path(hid_t gid, const QString& nam dPtr = statsData; if(preflight) { - dPtr->resize(getNumberOfTuples()); + dPtr->resizeTuples(getNumberOfTuples()); } } if(nullptr != dPtr.get()) { - addAttributeArray(dPtr->getName(), dPtr); + addOrReplaceAttributeArray(dPtr); } return err; @@ -697,7 +659,7 @@ int AttributeMatrix::readAttributeArraysFromHDF5(hid_t amGid, bool preflight, At if(nullptr != dPtr.get()) { - addAttributeArray(dPtr->getName(), dPtr); + addOrReplaceAttributeArray(dPtr); } } H5Gclose(amGid); // Close the Cell Group @@ -707,15 +669,15 @@ int AttributeMatrix::readAttributeArraysFromHDF5(hid_t amGid, bool preflight, At // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString AttributeMatrix::generateXdmfText(const QString& centering, const QString& dataContainerName, const QString& hdfFileName, const uint8_t gridType) +QString AttributeMatrix::generateXdmfText(const QString& centering, const QString& dataContainerName, const QString& hdfFileName, const uint8_t gridType) const { QString xdmfText; QString block; QTextStream out(&xdmfText); - for(QMap::iterator iter = m_AttributeArrays.begin(); iter != m_AttributeArrays.end(); ++iter) + for(auto iter = begin(); iter != end(); ++iter) { - IDataArray::Pointer d = iter.value(); + IDataArray::Pointer d = (*iter); block = writeXdmfAttributeData(d, centering, dataContainerName, hdfFileName, gridType); out << block; } @@ -725,99 +687,102 @@ QString AttributeMatrix::generateXdmfText(const QString& centering, const QStrin // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString AttributeMatrix::getInfoString(SIMPL::InfoStringFormat format) +QString AttributeMatrix::getInfoString(SIMPL::InfoStringFormat format) const { QString info; QTextStream ss(&info); if(format == SIMPL::HtmlFormat) { - ss << "\n"; - ss << "\n"; - ss << "\n"; - ss << "\n"; - ss << ""; + return getToolTipGenerator().generateHTML(); + } + else + { + } + return info; +} +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +ToolTipGenerator AttributeMatrix::getToolTipGenerator() const +{ + ToolTipGenerator toolTipGen; - ss << ""; + toolTipGen.addTitle("Attribute Matrix Info"); + toolTipGen.addValue("Name", getName()); - QString typeString; - switch(m_Type) - { - case AttributeMatrix::Type::Vertex: - typeString = "Vertex"; - break; - case AttributeMatrix::Type::Edge: - typeString = "Edge"; - break; - case AttributeMatrix::Type::Face: - typeString = "Face"; - break; - case AttributeMatrix::Type::Cell: - typeString = "Cell"; - break; - case AttributeMatrix::Type::VertexFeature: - typeString = "Vertex Feature"; - break; - case AttributeMatrix::Type::EdgeFeature: - typeString = "Edge Feature"; - break; - case AttributeMatrix::Type::FaceFeature: - typeString = "Face Feature"; - break; - case AttributeMatrix::Type::CellFeature: - typeString = "Cell Feature"; - break; - case AttributeMatrix::Type::VertexEnsemble: - typeString = "Vertex Ensemble"; - break; - case AttributeMatrix::Type::EdgeEnsemble: - typeString = "Edge Ensemble"; - break; - case AttributeMatrix::Type::FaceEnsemble: - typeString = "Face Ensemble"; - break; - case AttributeMatrix::Type::CellEnsemble: - typeString = "Cell Ensemble"; - break; - case AttributeMatrix::Type::MetaData: - typeString = "MetaData"; - break; - case AttributeMatrix::Type::Generic: - typeString = "Generic"; - break; - default: - typeString = "Unknown"; - break; - } + QString typeString; + switch(m_Type) + { + case AttributeMatrix::Type::Vertex: + typeString = "Vertex"; + break; + case AttributeMatrix::Type::Edge: + typeString = "Edge"; + break; + case AttributeMatrix::Type::Face: + typeString = "Face"; + break; + case AttributeMatrix::Type::Cell: + typeString = "Cell"; + break; + case AttributeMatrix::Type::VertexFeature: + typeString = "Vertex Feature"; + break; + case AttributeMatrix::Type::EdgeFeature: + typeString = "Edge Feature"; + break; + case AttributeMatrix::Type::FaceFeature: + typeString = "Face Feature"; + break; + case AttributeMatrix::Type::CellFeature: + typeString = "Cell Feature"; + break; + case AttributeMatrix::Type::VertexEnsemble: + typeString = "Vertex Ensemble"; + break; + case AttributeMatrix::Type::EdgeEnsemble: + typeString = "Edge Ensemble"; + break; + case AttributeMatrix::Type::FaceEnsemble: + typeString = "Face Ensemble"; + break; + case AttributeMatrix::Type::CellEnsemble: + typeString = "Cell Ensemble"; + break; + case AttributeMatrix::Type::MetaData: + typeString = "MetaData"; + break; + case AttributeMatrix::Type::Generic: + typeString = "Generic"; + break; + default: + typeString = "Unknown"; + break; + } + toolTipGen.addValue("Type", typeString); - QLocale usa(QLocale::English, QLocale::UnitedStates); - ss << ""; - QString tupleStr = "("; - for(int i = 0; i < m_TupleDims.size(); i++) + QLocale usa(QLocale::English, QLocale::UnitedStates); + QString tupleStr = "("; + for(size_t i = 0; i < m_TupleDims.size(); i++) + { + QString numStr = usa.toString(static_cast(m_TupleDims[i])); + tupleStr = tupleStr + numStr; + if(i < m_TupleDims.size() - 1) { - QString numStr = usa.toString(static_cast(m_TupleDims[i])); - tupleStr = tupleStr + numStr; - if(i < m_TupleDims.size() - 1) - { - tupleStr = tupleStr + QString(" x "); - } + tupleStr = tupleStr + QString(" x "); } - tupleStr = tupleStr + ")"; - ss << ""; - - ss << ""; - ss << "
Attribute Matrix Info
Name:" << getName() << "
Type:" << typeString << "
Tuple Dimensions:" << tupleStr << "
Attribute Array Count:" << getNumAttributeArrays() << "
\n"; - ss << ""; - } - else - { } - return info; + tupleStr = tupleStr + ")"; + toolTipGen.addValue("Tuple Dimensions", tupleStr); + + return toolTipGen; } + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString& attrType, const QString& dataContainerName, IDataArray::Pointer array, const QString& centering, int precision, - const QString& xdmfTypeName, const QString& hdfFileName, uint8_t gridType) +QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString& attrType, const QString& dataContainerName, const IDataArray::Pointer& array, const QString& centering, int precision, + const QString& xdmfTypeName, const QString& hdfFileName, uint8_t gridType) const { QString buf; QTextStream out(&buf); @@ -838,7 +803,7 @@ QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString out << "Center=\"" << centering << "\">" << "\n"; // Open the Tag - out << " " << "\n"; @@ -858,7 +823,7 @@ QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString out << "Center=\"" << centering << "\">" << "\n"; // Open the Tag - out << " getName() << " (Feature 0)\" >" << "\n"; @@ -872,7 +837,7 @@ QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString out << " " << dimStrHalf << " " << "\n"; out << "\n"; - out << " " << "\n"; @@ -893,7 +858,7 @@ QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString out << "Center=\"" << centering << "\">" << "\n"; // Open the Tag - out << " getName() << " (Feature 1)\" >" << "\n"; @@ -906,7 +871,7 @@ QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString out << " " << dimStrHalf << " " << "\n"; out << "\n"; - out << " " << "\n"; @@ -924,7 +889,7 @@ QString AttributeMatrix::writeXdmfAttributeDataHelper(int numComp, const QString // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString AttributeMatrix::writeXdmfAttributeData(const IDataArray::Pointer& array, const QString& centering, const QString& dataContainerName, const QString& hdfFileName, const uint8_t gridType) +QString AttributeMatrix::writeXdmfAttributeData(const IDataArray::Pointer& array, const QString& centering, const QString& dataContainerName, const QString& hdfFileName, const uint8_t gridType) const { QString xdmfText; QTextStream out(&xdmfText); @@ -934,8 +899,7 @@ QString AttributeMatrix::writeXdmfAttributeData(const IDataArray::Pointer& array array->getXdmfTypeAndSize(xdmfTypeName, precision); if(0 == precision) { - out << "" + out << "" << "\n"; return xdmfText; } @@ -969,3 +933,102 @@ QString AttributeMatrix::writeXdmfAttributeData(const IDataArray::Pointer& array return xdmfText; } + +// ----------------------------------------------------------------------------- +AttributeMatrix::Pointer AttributeMatrix::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString AttributeMatrix::getNameOfClass() const +{ + return QString("AttributeMatrix"); +} + +// ----------------------------------------------------------------------------- +QString AttributeMatrix::ClassName() +{ + return QString("AttributeMatrix"); +} + +// ----------------------------------------------------------------------------- +void AttributeMatrix::setType(const AttributeMatrix::Type& value) +{ + m_Type = value; +} + +// ----------------------------------------------------------------------------- +AttributeMatrix::Type AttributeMatrix::getType() const +{ + return m_Type; +} +bool AttributeMatrix::addOrReplaceAttributeArray(const IDataArrayShPtrType& data) +{ + // Can not insert a null IDataArray object + if(data.get() == nullptr) + { + return false; + } + if(getNumberOfTuples() != data->getNumberOfTuples()) + { + qDebug() << "AttributeMatrix::Name: " << getName() << " dataArray::name: " << data->getName() << " Type: " << data->getTypeAsString(); + qDebug() << "getNumberOfTuples(): " << getNumberOfTuples() << " data->getNumberOfTuples(): " << data->getNumberOfTuples(); + } + Q_ASSERT(getNumberOfTuples() == data->getNumberOfTuples()); + return insertOrAssign(data); +} + +IDataArrayShPtrType AttributeMatrix::getAttributeArray(const QString& name) const +{ + return getChildByName(name); +} + +IDataArrayShPtrType AttributeMatrix::getAttributeArray(const DataArrayPath& path) const +{ + return getAttributeArray(path.getDataArrayName()); +} + +bool AttributeMatrix::doesAttributeArrayExist(const QString& name) const +{ + return contains(name); +} + +// ----------------------------------------------------------------------------- +IDataArray::Pointer AttributeMatrix::getPrereqIDataArray(AbstractFilter* filter, const QString& attributeArrayName, int err) const +{ + QString ss; + IDataArray::Pointer attributeArray = nullptr; + // Make sure the name is not empty for the AttributeArrayName. This would be detected below + // in the call to get either one BUT the reason for the failure would not be evident so we make these explicit checks + // here and send back nice error messages to ther user/programmer. + if(attributeArrayName.isEmpty()) + { + if(filter) + { + ss = QObject::tr("AttributeMatrix:'%1' The name of a requested Attribute Array was empty. Please provide a name for this array").arg(getName()); + filter->setErrorCondition(err, ss); + } + return attributeArray; + } + // Now ask for the actual AttributeArray from the AttributeMatrix + if(!doesAttributeArrayExist(attributeArrayName)) + { + if(filter) + { + ss = QObject::tr("The AttributeMatrix named '%1' does NOT have a DataArray with name '%2'. This filter requires this DataArray in order to execute.").arg(getName()).arg(attributeArrayName); + filter->setErrorCondition(err, ss); + } + return attributeArray; + } + + attributeArray = getAttributeArray(attributeArrayName); + + if(attributeArray == nullptr) + { + ss = QObject::tr("Unable to cast input array %1 to the necessary type.").arg(attributeArrayName); + filter->setErrorCondition(err, ss); + } + + return attributeArray; +} diff --git a/Source/SIMPLib/DataContainers/AttributeMatrix.h b/Source/SIMPLib/DataContainers/AttributeMatrix.h old mode 100755 new mode 100644 index a03ffc6588..1958170818 --- a/Source/SIMPLib/DataContainers/AttributeMatrix.h +++ b/Source/SIMPLib/DataContainers/AttributeMatrix.h @@ -1,75 +1,75 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#if defined (_MSC_VER) -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#if defined(_MSC_VER) +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #endif - //-- C++ includes #include #include -#include - #include -#include #include -#include #include //-- DREAM3D Includes +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Common/Observable.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataArrays/IDataArray.h" #include "SIMPLib/DataContainers/DataArrayPath.h" -#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataContainers/IDataStructureContainerNode.hpp" +#include "SIMPLib/DataContainers/RenameDataPath.h" +#include "SIMPLib/Filtering/AbstractFilter.h" +#include "SIMPLib/Utilities/ToolTipGenerator.h" class AttributeMatrixProxy; class DataContainerProxy; class SIMPLH5DataReaderRequirements; -template class DataArray; +template +class DataArray; enum RenameErrorCodes { OLD_DOES_NOT_EXIST, SUCCESS, - NEW_EXISTS + NEW_EXISTS, + SAME_PATH }; /** @@ -81,37 +81,56 @@ enum RenameErrorCodes * @date * @version 1.0 */ -class SIMPLib_EXPORT AttributeMatrix : public Observable +class SIMPLib_EXPORT AttributeMatrix : public Observable, public IDataStructureContainerNode { // clang-format off - PYB11_CREATE_BINDINGS(AttributeMatrix) - PYB11_STATIC_CREATION(Create ARGS std::vector QString AttributeMatrix::Type) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(AttributeMatrix) + PYB11_SHARED_POINTERS(AttributeMatrix) + PYB11_STATIC_CREATION(New ARGS std::vector QString AttributeMatrix::Type) PYB11_ENUMERATION(Type) PYB11_ENUMERATION(Category) PYB11_PROPERTY(QString Name READ getName WRITE setName) - PYB11_PROPERTY(QVector TupleDimensions READ getTupleDimensions WRITE setTupleDimensions) - - PYB11_METHOD(int addAttributeArray ARGS Name Array) + PYB11_PROPERTY(std::vector TupleDimensions READ getTupleDimensions WRITE setTupleDimensions) PYB11_METHOD(bool doesAttributeArrayExist ARGS Name) + PYB11_METHOD(bool addOrReplaceAttributeArray OVERLOAD const.IDataArrayShPtrType.&,Data) + PYB11_METHOD(bool insertOrAssign ARGS IDataArrayShPtrType) PYB11_METHOD(IDataArray removeAttributeArray ARGS Name) PYB11_METHOD(int renameAttributeArray ARGS OldName NewName OverWrite) - PYB11_METHOD(IDataArray::Pointer getAttributeArray OVERLOAD const.QString.&,Name) - PYB11_METHOD(IDataArray::Pointer getAttributeArray OVERLOAD const.DataArrayPath.&,Path) + PYB11_METHOD(IDataArray::Pointer getAttributeArray OVERLOAD const.QString.&,Name CONST_METHOD) + PYB11_METHOD(IDataArray::Pointer getAttributeArray OVERLOAD const.DataArrayPath.&,Path CONST_METHOD) + PYB11_CUSTOM() + PYB11_END_BINDINGS() // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(AttributeMatrix) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(AttributeMatrix, Observable) + using Self = AttributeMatrix; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for AttributeMatrix + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for AttributeMatrix + */ + static QString ClassName(); ~AttributeMatrix() override; using EnumType = unsigned int; + using Container_t = std::vector>; /** - * @brief The Type is an enum that describes the type of data that the AttributeMatrix holds - */ + * @brief The Type is an enum that describes the type of data that the AttributeMatrix holds + */ enum class Type : EnumType { Vertex = 0, //!< @@ -132,7 +151,7 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable Any = 4294967295U }; - using Types = QVector; + using Types = std::vector; /** * @brief TypeToString Returns a String representation of the AttributeMatrix Type @@ -167,7 +186,7 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable Unknown = 999, //!< }; - using Categories = QVector; + using Categories = std::vector; /** * @brief New Creates an AttributeMatrix with the give name @@ -176,503 +195,486 @@ class SIMPLib_EXPORT AttributeMatrix : public Observable * @param attrType The type of AttributeMatrix, one of * @return */ - static Pointer New(const QVector &tupleDims, const QString& name, AttributeMatrix::Type attrType) + static Pointer New(const std::vector& tupleDims, const QString& name, AttributeMatrix::Type attrType) { Pointer sharedPtr(new AttributeMatrix(tupleDims, name, attrType)); return sharedPtr; } /** - * @brief New Creates an AttributeMatrix with the give name - * @param tupleDims The dimensions of the Attribute matrix given in the order fastest moving to slowest moving (XYZ) - * @param name The name of the AttributeMatrix. Each AttributeMatrix should have a unique name. - * @param attrType The type of AttributeMatrix, one of + * @brief ReadAttributeMatrixStructure + * @param containerId + * @param dataContainer + * @param h5InternalPath + */ + static void ReadAttributeMatrixStructure(hid_t containerId, DataContainerProxy* dcProxy, SIMPLH5DataReaderRequirements* req, const QString& h5InternalPath); + + /** + * @brief Creates and returns a DataArrayPath for the AttributeMatrix * @return */ - static Pointer Create(const std::vector &tupleDims, const QString& name, AttributeMatrix::Type attrType) + DataArrayPath getDataArrayPath() const override; + + /** + * @brief Type + */ + /** + * @brief Setter property for Type + */ + void setType(const AttributeMatrix::Type& value); + /** + * @brief Getter property for Type + * @return Value of Type + */ + AttributeMatrix::Type getType() const; + + /** + * @brief Adds the IDataArray to the AttributeMatrix. + * @param data The IDataArrayShPtrType that will hold the data + * @return Bool: True if the addition happened, FALSE if an IDataArray with the same name already exists. + */ + bool addOrReplaceAttributeArray(const IDataArrayShPtrType& data); + + /** + * @brief Returns the array for a given named array or the equivelant to a + * null pointer if the name does not exist. + * @param name The name of the data array + */ + IDataArrayShPtrType getAttributeArray(const QString& name) const; + + /** + * @brief getAttributeArray + * @param path + * @return + */ + IDataArrayShPtrType getAttributeArray(const DataArrayPath& path) const; + + /** + * @brief returns a IDataArray based object that is stored in the attribute matrix by a + * given name. + * @param name The name of the array + */ + template + typename ArrayType::Pointer getAttributeArrayAs(const QString& name) const { - Pointer sharedPtr(new AttributeMatrix(QVector::fromStdVector(tupleDims), name, static_cast(attrType))); - return sharedPtr; + IDataArrayShPtrType iDataArray = getAttributeArray(name); + return std::dynamic_pointer_cast(iDataArray); } - /** - * @brief ReadAttributeMatrixStructure - * @param containerId - * @param dataContainer - * @param h5InternalPath - */ - static void ReadAttributeMatrixStructure(hid_t containerId, DataContainerProxy* dcProxy, SIMPLH5DataReaderRequirements* req, const QString& h5InternalPath); - - /** - * @brief Type - */ - SIMPL_INSTANCE_PROPERTY(AttributeMatrix::Type, Type) - - /** - * @brief Name - */ - SIMPL_INSTANCE_PROPERTY(QString, Name) - - - /** - * @brief Adds/overwrites the data for a named array - * @param name The name that the array will be known by - * @param data The IDataArray::Pointer that will hold the data - * @return error code if the addition did not work - */ - virtual int addAttributeArray(const QString& name, const IDataArray::Pointer& data); - - /** - * @brief Returns the array for a given named array or the equivelant to a - * null pointer if the name does not exist. - * @param name The name of the data array - */ - virtual IDataArray::Pointer getAttributeArray(const QString& name); - - /** - * @brief getAttributeArray - * @param path - * @return - */ - virtual IDataArray::Pointer getAttributeArray(const DataArrayPath& path); - - /** - * @brief returns a IDataArray based object that is stored in the attribute matrix by a - * given name. - * @param name The name of the array - */ - template - typename ArrayType::Pointer getAttributeArrayAs(const QString& name) - { - IDataArray::Pointer iDataArray = getAttributeArray(name); - return std::dynamic_pointer_cast< ArrayType >(iDataArray); - } + /** + * @brief Returns bool of whether a named array exists + * @param name The name of the data array + */ + bool doesAttributeArrayExist(const QString& name) const; + /** + * @brief Removes the named data array from the Data Container and returns it to the calling + * method. + * @param name The name of the array + * @return + */ + virtual IDataArrayShPtrType removeAttributeArray(const QString& name); + + /** + * @brief Renames a cell data array from the Data Container + * @param name The name of the array + */ + virtual RenameErrorCodes renameAttributeArray(const QString& oldname, const QString& newname, bool overwrite = false); + + /** + * @brief Removes all the Cell Arrays + */ + virtual void clearAttributeArrays(); + + /** + * @brief Returns the collection of contained DataArrays + * @return + */ + Container_t getAttributeArrays() const; - /** - * @brief Returns bool of whether a named array exists - * @param name The name of the data array - */ - virtual bool doesAttributeArrayExist(const QString& name) const; - - - /** - * @brief Removes the named data array from the Data Container and returns it to the calling - * method. - * @param name The name of the array - * @return - */ - virtual IDataArray::Pointer removeAttributeArray(const QString& name); - - /** - * @brief Renames a cell data array from the Data Container - * @param name The name of the array - */ - virtual RenameErrorCodes renameAttributeArray(const QString& oldname, const QString& newname, bool overwrite = false); - - - /** - * @brief Removes all the Cell Arrays - */ - virtual void clearAttributeArrays(); - - /** - * @brief Returns a list that contains the names of all the arrays currently stored in the - * Cell (Formerly Cell) group - * @return - */ - virtual QList getAttributeArrayNames(); - - /** - * @brief Returns the total number of arrays that are stored in the Cell group - * @return - */ - virtual int getNumAttributeArrays() const; - - - /** - * @brief Resizes an array from the Attribute Matrix - * @param size The new size of the array - */ - void resizeAttributeArrays(const QVector& tDims); - - /** - * @brief Returns bool of whether a named array exists - * @param name The name of the data array - */ - virtual bool validateAttributeArraySizes(); - - /** - * @brief getPrereqArray - * @param filter An instance of an AbstractFilter that is calling this function. Can be nullptr in which case - * no error message will be returned if there is an error. - * @param attributeArrayName The name of the Attribute Array - * @param err The error code to set into the filter if there is an error - * @param cDims The component Dimensions of the Data Array - * @return A valid IDataArray Subclass if the array exists otherwise a null shared pointer. - */ - template - typename ArrayType::Pointer getPrereqArray(Filter* filter, - QString attributeArrayName, - int err, - QVector cDims) + /** + * @brief Returns a list that contains the names of all the arrays currently stored in the + * Cell (Formerly Cell) group + * @return + */ + virtual NameList getAttributeArrayNames() const; + + /** + * @brief Returns the total number of arrays that are stored in the Cell group + * @return + */ + int getNumAttributeArrays() const; + + /** + * @brief Resizes an array from the Attribute Matrix + * @param size The new size of the array + */ + void resizeAttributeArrays(const std::vector& tDims); + + /** + * @brief Returns bool of whether a named array exists + * @param name The name of the data array + */ + virtual bool validateAttributeArraySizes() const; + + /** + * @brief getPrereqArray + * @param filter An instance of an AbstractFilter that is calling this function. Can be nullptr in which case + * no error message will be returned if there is an error. Will only check component dims if cDims is not empty. + * @param attributeArrayName The name of the Attribute Array + * @param err The error code to set into the filter if there is an error + * @param cDims The component Dimensions of the Data Array + * @return A valid IDataArray Subclass if the array exists otherwise a null shared pointer. + */ + template + typename ArrayType::Pointer getPrereqArray(AbstractFilter* filter, const QString& attributeArrayName, int err, const std::vector& cDims = {}) const + { + QString ss; + typename ArrayType::Pointer attributeArray = ArrayType::NullPointer(); + // Make sure the name is not empty for the AttributeArrayName. This would be detected below + // in the call to get either one BUT the reason for the failure would not be evident so we make these explicit checks + // here and send back nice error messages to ther user/programmer. + if(attributeArrayName.isEmpty()) { - QString ss; - typename ArrayType::Pointer attributeArray = ArrayType::NullPointer(); - //Make sure the name is not empty for the AttributeArrayName. This would be detected below - // in the call to get either one BUT the reason for the failure would not be evident so we make these explicit checks - // here and send back nice error messages to ther user/programmer. - if(attributeArrayName.isEmpty()) + if(filter) { - if(filter) - { - filter->setErrorCondition(err); - ss = QObject::tr("AttributeMatrix:'%1' The name of a requested Attribute Array was empty. Please provide a name for this array").arg(getName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - } - // Now ask for the actual AttributeArray from the AttributeMatrix - if(!doesAttributeArrayExist(attributeArrayName)) - { - if(filter) - { - filter->setErrorCondition(err); - ss = QObject::tr("The AttributeMatrix named '%1' does NOT have a DataArray with name '%2'. This filter requires this DataArray in order to execute.").arg(getName()).arg(attributeArrayName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return attributeArray; - } - int NumComp = cDims[0]; - for(int i = 1; i < cDims.size(); i++) - { - NumComp *= cDims[i]; - } - // Check to make sure the AttributeArray we have is of the proper type, size and number of components - if(false == dataArrayCompatibility(attributeArrayName, NumComp, filter) ) - { - return attributeArray; + ss = QObject::tr("AttributeMatrix:'%1' The name of a requested Attribute Array was empty. Please provide a name for this array").arg(getName()); + filter->setErrorCondition(err, ss); } - IDataArray::Pointer iDataArray = getAttributeArray(attributeArrayName); - attributeArray = std::dynamic_pointer_cast< ArrayType >(iDataArray); - if(nullptr == attributeArray.get() && filter) + } + // Now ask for the actual AttributeArray from the AttributeMatrix + if(!doesAttributeArrayExist(attributeArrayName)) + { + if(filter) { - filter->setErrorCondition(err); - ss = QObject::tr("The AttributeMatrix named '%1' contains an array with name '%2' but the DataArray could not be downcast using std::dynamic_pointer_cast.").arg(getName()).arg(attributeArrayName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + ss = QObject::tr("The AttributeMatrix named '%1' does NOT have a DataArray with name '%2'. This filter requires this DataArray in order to execute.").arg(getName()).arg(attributeArrayName); + filter->setErrorCondition(err, ss); } return attributeArray; } - /** - * @brief getExistingPrereqArray - * @param filter - * @param attributeArrayName - * @param err - * @return - */ - template typename ArrayType::Pointer getPrereqIDataArray(Filter* filter, const QString& attributeArrayName, int err) + if(!cDims.empty()) { - QString ss; - typename ArrayType::Pointer attributeArray = ArrayType::NullPointer(); - // Make sure the name is not empty for the AttributeArrayName. This would be detected below - // in the call to get either one BUT the reason for the failure would not be evident so we make these explicit checks - // here and send back nice error messages to ther user/programmer. - if(attributeArrayName.isEmpty()) - { - if(filter) - { - filter->setErrorCondition(err); - ss = QObject::tr("AttributeMatrix:'%1' The name of a requested Attribute Array was empty. Please provide a name for this array").arg(getName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - } - // Now ask for the actual AttributeArray from the AttributeMatrix - if(!doesAttributeArrayExist(attributeArrayName)) + size_t numComp = std::accumulate(cDims.cbegin(), cDims.cend(), static_cast(1), std::multiplies()); + + // Check to make sure the AttributeArray we have is of the proper type, size and number of components + if(false == dataArrayCompatibility(attributeArrayName, numComp, filter)) { - if(filter) - { - filter->setErrorCondition(err); - ss = QObject::tr("The AttributeMatrix named '%1' does NOT have a DataArray with name '%2'. This filter requires this DataArray in order to execute.").arg(getName()).arg(attributeArrayName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } return attributeArray; } + } - IDataArray::Pointer ptr = getAttributeArray(attributeArrayName); - if(std::dynamic_pointer_cast(ptr) != nullptr) - { - return std::dynamic_pointer_cast(ptr); - } + IDataArrayShPtrType iDataArray = getAttributeArray(attributeArrayName); + attributeArray = std::dynamic_pointer_cast(iDataArray); + if(nullptr == attributeArray.get() && filter) + { + ss = QObject::tr("The AttributeMatrix named '%1' contains an array with name '%2' but the DataArray could not be downcast using std::dynamic_pointer_cast.") + .arg(getName()) + .arg(attributeArrayName); + filter->setErrorCondition(err, ss); + } + return attributeArray; + } - filter->setErrorCondition(err); - ss = QObject::tr("Unable to cast input array %1 to the necessary type.").arg(attributeArrayName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + /** + * @brief getExistingPrereqArray + * @param filter + * @param attributeArrayName + * @param err + * @return + */ + IDataArray::Pointer getPrereqIDataArray(AbstractFilter* filter, const QString& attributeArrayName, int err) const; - return attributeArray; - } + /** + * @brief createNonPrereqArray This method will create a new DataArray in the AttributeMatrix. The condition for this + * method to work properly is the name of the attribute array is not empty + * @param filter The instance of the filter the filter that is requesting the new array + * @param attributeArrayName The name of the AttributeArray to create + * @param initValue The initial value of all the elements of the array + * @param size The number of tuples in the Array + * @param dims The dimensions of the components of the AttributeArray + * @return A Shared Pointer to the newly created array + */ + template + typename ArrayType::Pointer createNonPrereqArray(AbstractFilter* filter, const QString& attributeArrayName, typename ArrayType::value_type initValue, const std::vector& compDims, + RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID) + { + typename ArrayType::Pointer attributeArray = ArrayType::NullPointer(); - /** - * @brief createNonPrereqArray This method will create a new DataArray in the AttributeMatrix. The condition for this - * method to work properly is the name of the attribute array is not empty - * @param filter The instance of the filter the filter that is requesting the new array - * @param attributeArrayName The name of the AttributeArray to create - * @param initValue The initial value of all the elements of the array - * @param size The number of tuples in the Array - * @param dims The dimensions of the components of the AttributeArray - * @return A Shared Pointer to the newly created array - */ - template - typename ArrayType::Pointer createNonPrereqArray(Filter* filter, - const QString& attributeArrayName, - T initValue, - QVector compDims) + QString ss; + if(attributeArrayName.isEmpty()) { - typename ArrayType::Pointer attributeArray = ArrayType::NullPointer(); - - QString ss; - if(attributeArrayName.isEmpty()) - { - if(filter) - { - filter->setErrorCondition(-10001); - ss = QObject::tr("The name of the array was empty. Please provide a name for this array."); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return attributeArray; - } - IDataArray::Pointer iDataArray = getAttributeArray(attributeArrayName); - if (nullptr == iDataArray.get()) - { - createAndAddAttributeArray(filter, attributeArrayName, initValue, compDims); - } - else if (filter) - { - filter->setErrorCondition(-10002); - ss = QObject::tr("AttributeMatrix:'%1' An Attribute Array already exists with the name %2.").arg(getName()).arg(attributeArrayName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - return attributeArray; - } - iDataArray = getAttributeArray(attributeArrayName); - if(nullptr == iDataArray && filter) + if(filter) { - filter->setErrorCondition(-10003); - ss = QObject::tr("AttributeMatrix:'%1' An array with name '%2' could not be created.").arg(getName()).arg(attributeArrayName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - attributeArray = std::dynamic_pointer_cast< ArrayType >(iDataArray); - if(nullptr == attributeArray.get() && filter) - { - filter->setErrorCondition(-10004); - ss = QObject::tr("AttributeMatrix:'%1' An array with name '%2' could not be downcast using std::dynamic_pointer_cast.").arg(getName()).arg(attributeArrayName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + ss = QObject::tr("The name of the array was empty. Please provide a name for this array."); + filter->setErrorCondition(-10001, ss); } return attributeArray; } + IDataArrayShPtrType iDataArray = getAttributeArray(attributeArrayName); + if(nullptr == iDataArray.get()) + { + createAndAddAttributeArray(filter, attributeArrayName, initValue, compDims); + } + else if(filter) + { + ss = QObject::tr("AttributeMatrix:'%1' An Attribute Array already exists with the name %2.").arg(getName()).arg(attributeArrayName); + filter->setErrorCondition(-10002, ss); + return attributeArray; + } + iDataArray = getAttributeArray(attributeArrayName); + if(nullptr == iDataArray && filter) + { + ss = QObject::tr("AttributeMatrix:'%1' An array with name '%2' could not be created.").arg(getName()).arg(attributeArrayName); + filter->setErrorCondition(-10003, ss); + } + attributeArray = std::dynamic_pointer_cast(iDataArray); + if(nullptr == attributeArray.get() && filter) + { + ss = QObject::tr("AttributeMatrix:'%1' An array with name '%2' could not be downcast using std::dynamic_pointer_cast.").arg(getName()).arg(attributeArrayName); + filter->setErrorCondition(-10004, ss); + } + else if(nullptr != attributeArray && filter) + { + // Check if path was renamed + // This will crash if no parent node is found + IDataStructureNode* parentPtr = getParentNode(); + RenameDataPath::AlertFilterCreatedPath(filter, id, DataArrayPath(parentPtr->getName(), getName(), attributeArrayName)); + } + return attributeArray; + } - /** - * @brief Creates and Adds the data for a named array - * @param name The name that the array will be known by - * @param dims The size the data on each tuple - */ - template - void createAndAddAttributeArray(Filter* filter, const QString& name, T initValue, QVector compDims) + /** + * @brief Creates and Adds the data for a named array + * @param name The name that the array will be known by + * @param dims The size the data on each tuple + */ + template + void createAndAddAttributeArray(AbstractFilter* filter, const QString& name, typename ArrayType::value_type initValue, std::vector compDims, + RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID) + { + bool allocateData = false; + if(nullptr == filter) + { + allocateData = true; + } + else { - bool allocateData = false; - if(nullptr == filter) { allocateData = true; } - else { allocateData = !filter->getInPreflight(); } - typename ArrayType::Pointer attributeArray = ArrayType::CreateArray(getNumberOfTuples(), compDims, name, allocateData); - if(attributeArray.get() != nullptr) + allocateData = !filter->getInPreflight(); + } + typename ArrayType::Pointer attributeArray = ArrayType::CreateArray(getNumberOfTuples(), compDims, name, allocateData); + if(attributeArray.get() != nullptr) + { + if(allocateData) { - if(allocateData) - { - attributeArray->initializeWithValue(initValue); - } - attributeArray->setInitValue(initValue); - addAttributeArray(name, attributeArray); + attributeArray->initializeWithValue(initValue); } + attributeArray->setInitValue(initValue); + addOrReplaceAttributeArray(attributeArray); + // Check if path was renamed + DataArrayPath path = getDataArrayPath(); + path.setDataArrayName(name); + RenameDataPath::AlertFilterCreatedPath(filter, id, path); } + } - /** - * @brief dataArrayCompatibility - * @param arrayName - * @param numComp - * @param filter - * @return - */ - template - bool dataArrayCompatibility(const QString& arrayName, int numComp, AbstractFilter* filter) + /** + * @brief dataArrayCompatibility + * @param arrayName + * @param numComp + * @param filter + * @return + */ + template + bool dataArrayCompatibility(const QString& arrayName, int numComp, AbstractFilter* filter) const + { + // Make sure the types are the same + IDataArrayShPtrType ida = getAttributeArray(arrayName); + typename ArrayType::Pointer targetDestArray = std::dynamic_pointer_cast(ida); + if(targetDestArray.get() == nullptr) { - // Make sure the types are the same - IDataArray::Pointer ida = getAttributeArray(arrayName); - typename ArrayType::Pointer targetDestArray = std::dynamic_pointer_cast< ArrayType >(ida); - if (targetDestArray.get() == 0) + if(nullptr != filter) { - if (nullptr != filter) - { - typename ArrayType::Pointer validTargetArray = ArrayType::CreateArray(1, "JUNK_INTERNAL_ARRAY", false); - IDataArray::Pointer srcArray = getAttributeArray(arrayName); - QString srcDesc = srcArray->getTypeAsString(); - QString desc = validTargetArray->getTypeAsString(); - QString ss = QObject::tr("The Filter '%1' requires an array of type '%2' but the data array '%3' has a type of '%4'").arg(filter->getHumanLabel()).arg(desc).arg(srcArray->getName()).arg(srcDesc); - filter->setErrorCondition(-501); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return false; + typename ArrayType::Pointer validTargetArray = ArrayType::CreateArray(1, std::string("JUNK_INTERNAL_ARRAY"), false); + IDataArrayShPtrType srcArray = getAttributeArray(arrayName); + QString srcDesc = srcArray->getTypeAsString(); + QString desc = validTargetArray->getTypeAsString(); + QString ss = + QObject::tr("The Filter '%1' requires an array of type '%2' but the data array '%3' has a type of '%4'").arg(filter->getHumanLabel()).arg(desc).arg(srcArray->getName()).arg(srcDesc); + filter->setErrorCondition(-501, ss); } - // Make sure the sizes are equal to what is being asked for - if (getNumberOfTuples() != targetDestArray->getNumberOfTuples()) + return false; + } + // Make sure the sizes are equal to what is being asked for + if(getNumberOfTuples() != targetDestArray->getNumberOfTuples()) + { + if(nullptr != filter) { - if (nullptr != filter) - { - QString ss = QObject::tr("Filter '%1' requires array with name '%2' to have Number of Tuples = %3. The currently selected array " - " has %4").arg(filter->getHumanLabel()).arg(arrayName).arg((getNumberOfTuples())).arg(targetDestArray->getNumberOfTuples()); - filter->setErrorCondition(-502); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return false; + QString ss = QObject::tr("Filter '%1' requires array with name '%2' to have Number of Tuples = %3. The currently selected array " + " has %4") + .arg(filter->getHumanLabel()) + .arg(arrayName) + .arg((getNumberOfTuples())) + .arg(targetDestArray->getNumberOfTuples()); + filter->setErrorCondition(-502, ss); } - // Make sure the number of components match - if (numComp != targetDestArray->getNumberOfComponents()) + return false; + } + // Make sure the number of components match + if(numComp != targetDestArray->getNumberOfComponents()) + { + if(nullptr != filter) { - if (nullptr != filter) - { - QString ss = QObject::tr("Filter '%1' is trying to use array '%2' where the number of components is %3 but the filter requires that array " - " to have %4.").arg(filter->getHumanLabel()).arg(targetDestArray->getName()).arg(targetDestArray->getNumberOfComponents()).arg(numComp); - filter->setErrorCondition(-503); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return false; + QString ss = QObject::tr("Filter '%1' is trying to use array '%2' where the number of components is %3 but the filter requires that array " + " to have %4.") + .arg(filter->getHumanLabel()) + .arg(targetDestArray->getName()) + .arg(targetDestArray->getNumberOfComponents()) + .arg(numComp); + filter->setErrorCondition(-503, ss); } - // Make sure we can downcast to the proper type - typename ArrayType::Pointer array = std::dynamic_pointer_cast(targetDestArray); - if (nullptr == array.get()) + return false; + } + // Make sure we can downcast to the proper type + typename ArrayType::Pointer array = std::dynamic_pointer_cast(targetDestArray); + if(nullptr == array.get()) + { + typename ArrayType::Pointer dat = ArrayType::CreateArray(1, std::string("JUNK-INTERNAL-USE-ONLY"), true); + QString ss = QObject::tr(" - The filter requested an array named '%1' with type '%2' from the filter '%3'.\n" + "An Array with name '%4' is stored in the %5 but is of type %6\n") + .arg(arrayName) + .arg(dat->getTypeAsString()) + .arg(getNameOfClass()) + .arg(arrayName) + .arg(getNameOfClass()) + .arg(targetDestArray->getTypeAsString()); + if(nullptr != filter) { - typename ArrayType::Pointer dat = ArrayType::CreateArray(1, "JUNK-INTERNAL-USE-ONLY"); - QString ss = QObject::tr(" - The filter requested an array named '%1' with type '%2' from the filter '%3'.\n" - "An Array with name '%4' is stored in the %5 but is of type %6\n") - .arg(arrayName).arg(dat->getTypeAsString()).arg(getNameOfClass()).arg(arrayName).arg(getNameOfClass()).arg(targetDestArray->getTypeAsString()); - if (nullptr != filter) - { - filter->setErrorCondition(-504); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return false; + filter->setErrorCondition(-504, ss); } - return true; + return false; } + return true; + } + + /** + * @brief Removes inactive objects from the Attribute Matrix and renumbers the active objects to preserve a compact matrix + (only valid for feature or ensemble type matrices) + * @param size The new size of the array + */ + bool removeInactiveObjects(const QVector& activeObjects, DataArray* featureIds); + + /** + * @brief Sets the Tuple Dimensions for the Attribute Matrix + * @param tupleDims + */ + void setTupleDimensions(const std::vector& tupleDims); + + /** + * @brief Returns the Tuple Dimensions of the AttributeMatrix + * @return + */ + std::vector getTupleDimensions() const; + + /** + * @brief Returns the number of Tuples that the feature data has. For example if there are 32 features + * in during a set of filtering operations then the a value of '32' would be returned. + * @return + */ + size_t getNumberOfTuples() const; + + /** + * @brief creates and returns a copy of the attribute matrix + * @return On error, will return a null pointer. It is the responsibility of the calling function to check for errors and return an error message using the PipelineMessage + */ + virtual AttributeMatrix::Pointer deepCopy(bool forceNoAllocate = false) const; + + /** + * @brief writeAttributeArraysToHDF5 + * @param parentId + * @return + */ + virtual int writeAttributeArraysToHDF5(hid_t parentId) const; + + /** + * @brief addAttributeArrayFromHDF5Path + * @param gid + * @param name + * @param preflight + * @return + */ + virtual int addAttributeArrayFromHDF5Path(hid_t gid, const QString& name, bool preflight); + + /** + * @brief readAttributeArraysFromHDF5 + * @param amGid + * @param preflight + * @param attrMatProxy + * @return + */ + virtual int readAttributeArraysFromHDF5(hid_t amGid, bool preflight, AttributeMatrixProxy* attrMatProxy); + + /** + * @brief generateXdmfText + * @param centering + * @param dataContainerName + * @param hdfFileName + * @param gridType + * @return + */ + virtual QString generateXdmfText(const QString& centering, const QString& dataContainerName, const QString& hdfFileName, uint8_t gridType = 0) const; + + /** + * @brief getInfoString Returns a text string in the given format that has information + * about the attribute Matrix + * @param format A value from the SIMPL::InfoStringFormat enumeration + * @return + */ + virtual QString getInfoString(SIMPL::InfoStringFormat format) const; + + /** + * @brief Returns a ToolTipGenerator for creating HTML tooltip tables + * with values populated to match the current AttributeMatrix. + * @return + */ + virtual ToolTipGenerator getToolTipGenerator() const; + +protected: + AttributeMatrix(const std::vector& tDims, const QString& name, AttributeMatrix::Type attrType); + + /** + * @brief writeXdmfAttributeData + * @param array + * @param centering + * @param dataContainerName + * @param hdfFileName + * @param gridType + * @return + */ + virtual QString writeXdmfAttributeData(const IDataArrayShPtrType& array, const QString& centering, const QString& dataContainerName, const QString& hdfFileName, uint8_t gridType = 0) const; + + /** + * @brief writeXdmfAttributeDataHelper + * @param numComp + * @param attrType + * @param dataContainerName + * @param array + * @param centering + * @param precision + * @param xdmfTypeName + * @param hdfFileName + * @param gridType + * @return + */ + virtual QString writeXdmfAttributeDataHelper(int numComp, const QString& attrType, const QString& dataContainerName, const IDataArrayShPtrType& array, const QString& centering, int precision, + const QString& xdmfTypeName, const QString& hdfFileName, uint8_t gridType = 0) const; + +private: + std::vector m_TupleDims; + AttributeMatrix::Type m_Type = {}; - /** - * @brief Removes inactive objects from the Attribute Matrix and renumbers the active objects to preserve a compact matrix - (only valid for feature or ensemble type matrices) - * @param size The new size of the array - */ - bool removeInactiveObjects(const QVector &activeObjects, DataArray* featureIds); - - /** - * @brief Sets the Tuple Dimensions for the Attribute Matrix - * @param tupleDims - */ - void setTupleDimensions(const QVector& tupleDims); - - /** - * @brief Returns the Tuple Dimensions of the AttributeMatrix - * @return - */ - QVector getTupleDimensions(); - - - /** - * @brief Returns the number of Tuples that the feature data has. For example if there are 32 features - * in during a set of filtering operations then the a value of '32' would be returned. - * @return - */ - size_t getNumberOfTuples(); - - /** - * @brief creates and returns a copy of the attribute matrix - * @return On error, will return a null pointer. It is the responsibility of the calling function to check for errors and return an error message using the PipelineMessage - */ - virtual AttributeMatrix::Pointer deepCopy(bool forceNoAllocate = false); - - /** - * @brief writeAttributeArraysToHDF5 - * @param parentId - * @return - */ - virtual int writeAttributeArraysToHDF5(hid_t parentId); - - /** - * @brief addAttributeArrayFromHDF5Path - * @param gid - * @param name - * @param preflight - * @return - */ - virtual int addAttributeArrayFromHDF5Path(hid_t gid, const QString& name, bool preflight); - - /** - * @brief readAttributeArraysFromHDF5 - * @param amGid - * @param preflight - * @param attrMatProxy - * @return - */ - virtual int readAttributeArraysFromHDF5(hid_t amGid, bool preflight, AttributeMatrixProxy* attrMatProxy); - - /** - * @brief generateXdmfText - * @param centering - * @param dataContainerName - * @param hdfFileName - * @param gridType - * @return - */ - virtual QString generateXdmfText(const QString& centering, const QString& dataContainerName, const QString& hdfFileName, uint8_t gridType = 0); - - /** - * @brief getInfoString Returns a text string in the given format that has information - * about the attribute Matrix - * @param format A value from the SIMPL::InfoStringFormat enumeration - * @return - */ - virtual QString getInfoString(SIMPL::InfoStringFormat format); - - protected: - AttributeMatrix(QVector tDims, const QString& name, AttributeMatrix::Type attrType); - - /** - * @brief writeXdmfAttributeData - * @param array - * @param centering - * @param dataContainerName - * @param hdfFileName - * @param gridType - * @return - */ - virtual QString writeXdmfAttributeData(const IDataArray::Pointer& array, const QString& centering, const QString& dataContainerName, const QString& hdfFileName, const uint8_t gridType = 0); - - /** - * @brief writeXdmfAttributeDataHelper - * @param numComp - * @param attrType - * @param dataContainerName - * @param array - * @param centering - * @param precision - * @param xdmfTypeName - * @param hdfFileName - * @param gridType - * @return - */ - virtual QString writeXdmfAttributeDataHelper(int numComp, const QString& attrType, const QString& dataContainerName, IDataArray::Pointer array, const QString& centering, int precision, - const QString& xdmfTypeName, const QString& hdfFileName, uint8_t gridType = 0); - - private: - QVector m_TupleDims; - QMap m_AttributeArrays; - - AttributeMatrix(const AttributeMatrix&); - void operator =(const AttributeMatrix&); + AttributeMatrix(const AttributeMatrix&); + void operator=(const AttributeMatrix&); }; Q_DECLARE_METATYPE(AttributeMatrix::Type) diff --git a/Source/SIMPLib/DataContainers/AttributeMatrixProxy.cpp b/Source/SIMPLib/DataContainers/AttributeMatrixProxy.cpp index 07a1f34922..3a751c7d25 100644 --- a/Source/SIMPLib/DataContainers/AttributeMatrixProxy.cpp +++ b/Source/SIMPLib/DataContainers/AttributeMatrixProxy.cpp @@ -134,7 +134,7 @@ QJsonArray AttributeMatrixProxy::writeMap(const QMap& m QMap AttributeMatrixProxy::readMap(QJsonArray jsonArray) { QMap map; - for(const auto& val : jsonArray) + for(const auto val : jsonArray) { if(val.isObject()) { @@ -153,68 +153,52 @@ AttributeMatrixProxy::AMTypeFlag AttributeMatrixProxy::AttributeMatrixTypeToFlag { switch(amType) { - case AttributeMatrix::Type::Any: - { + case AttributeMatrix::Type::Any: { return Any_AMType; } - case AttributeMatrix::Type::Cell: - { + case AttributeMatrix::Type::Cell: { return Cell_AMType; } - case AttributeMatrix::Type::CellEnsemble: - { + case AttributeMatrix::Type::CellEnsemble: { return CellEnsemble_AMType; } - case AttributeMatrix::Type::CellFeature: - { + case AttributeMatrix::Type::CellFeature: { return CellFeature_AMType; } - case AttributeMatrix::Type::Edge: - { + case AttributeMatrix::Type::Edge: { return Edge_AMType; } - case AttributeMatrix::Type::EdgeEnsemble: - { + case AttributeMatrix::Type::EdgeEnsemble: { return EdgeEnsemble_AMType; } - case AttributeMatrix::Type::EdgeFeature: - { + case AttributeMatrix::Type::EdgeFeature: { return EdgeFeature_AMType; } - case AttributeMatrix::Type::Face: - { + case AttributeMatrix::Type::Face: { return Face_AMType; } - case AttributeMatrix::Type::FaceEnsemble: - { + case AttributeMatrix::Type::FaceEnsemble: { return FaceEnsemble_AMType; } - case AttributeMatrix::Type::FaceFeature: - { + case AttributeMatrix::Type::FaceFeature: { return FaceFeature_AMType; } - case AttributeMatrix::Type::Generic: - { + case AttributeMatrix::Type::Generic: { return Generic_AMType; } - case AttributeMatrix::Type::MetaData: - { + case AttributeMatrix::Type::MetaData: { return MetaData_AMType; } - case AttributeMatrix::Type::Vertex: - { + case AttributeMatrix::Type::Vertex: { return Vertex_AMType; } - case AttributeMatrix::Type::VertexEnsemble: - { + case AttributeMatrix::Type::VertexEnsemble: { return VertexEnsemble_AMType; } - case AttributeMatrix::Type::VertexFeature: - { + case AttributeMatrix::Type::VertexFeature: { return VertexFeature_AMType; } - case AttributeMatrix::Type::Unknown: - { + case AttributeMatrix::Type::Unknown: { return Unknown_AMType; } } diff --git a/Source/SIMPLib/DataContainers/AttributeMatrixProxy.h b/Source/SIMPLib/DataContainers/AttributeMatrixProxy.h index 78dfd19539..9c32d6d3d2 100644 --- a/Source/SIMPLib/DataContainers/AttributeMatrixProxy.h +++ b/Source/SIMPLib/DataContainers/AttributeMatrixProxy.h @@ -1,56 +1,59 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once #include -#include #include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/DataContainers/DataArrayProxy.h" class SIMPLib_EXPORT AttributeMatrixProxy { - PYB11_CREATE_BINDINGS(AttributeMatrixProxy) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(AttributeMatrixProxy) PYB11_CREATION() PYB11_PROPERTY(StorageType DataArrays READ getDataArrays WRITE setDataArrays CONST_GET_OVERLOAD) PYB11_PROPERTY(QString Name READ getName WRITE setName) PYB11_PROPERTY(AMType AMType READ getAMType WRITE setAMType) PYB11_PROPERTY(uint8_t Flag READ getFlag WRITE setFlag) PYB11_METHOD(DataArrayProxy getDataArrayProxy ARGS name RETURN_VALUE_POLICY py::return_value_policy::reference) + PYB11_END_BINDINGS() + // End Python bindings declarations public: // This enumeration is not a class enumeration because it is not possible to diff --git a/Source/SIMPLib/DataContainers/DataArrayPath.cpp b/Source/SIMPLib/DataContainers/DataArrayPath.cpp index dfa86ab80f..cd5801be2d 100644 --- a/Source/SIMPLib/DataContainers/DataArrayPath.cpp +++ b/Source/SIMPLib/DataContainers/DataArrayPath.cpp @@ -1,46 +1,119 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DataArrayPath.h" +#include + #include #include "SIMPLib/Common/Constants.h" -#include "SIMPLib/DataArrays/NeighborList.hpp" #include "SIMPLib/DataContainers/DataContainerArray.h" +namespace +{ +template +bool ValidateVectorImpl(const Container& other) +{ + static_assert(std::is_same_v); + + using size_type = typename Container::size_type; + + if(other.size() <= 1) + { + return true; + } + + QString dcName = other.front().getDataContainerName(); + QString amName = other.front().getAttributeMatrixName(); + + for(size_type i = 1; i < other.size(); i++) + { + if(other.at(i).getDataContainerName() != dcName || other.at(i).getAttributeMatrixName() != amName) + { + return false; + } + } + + return true; +} + +template +OutputContainer GetDataArrayNamesImpl(const InputContainer& paths) +{ + static_assert(std::is_same_v); + static_assert(std::is_same_v); + + OutputContainer arrayNames; + arrayNames.reserve(paths.size()); + for(const DataArrayPath& path : paths) + { + arrayNames.push_back(path.getDataArrayName()); + } + + return arrayNames; +} + +template +DataArrayPath GetAttributeMatrixPathImpl(const Container& paths) +{ + static_assert(std::is_same_v); + + if(paths.empty()) + { + return DataArrayPath(); + } + + return DataArrayPath(paths.front().getDataContainerName(), paths.front().getAttributeMatrixName(), ""); +} +} // namespace + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataArrayPath::HashType DataArrayPath::GetHash(const QString& name) +{ + if(name.isEmpty()) + { + return 0; + } + + std::hash hashFn; + return hashFn(name.toStdString()); +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -63,7 +136,11 @@ DataArrayPath::DataArrayPath(const QString& dcName, const QString& amName, const : m_DataContainerName(dcName) , m_AttributeMatrixName(amName) , m_DataArrayName(daName) +, m_DataContainerHash(GetHash(dcName)) +, m_AttributeMatrixHash(GetHash(amName)) +, m_DataArrayHash(GetHash(daName)) { + updateDataType(); } // ----------------------------------------------------------------------------- @@ -75,16 +152,18 @@ DataArrayPath::DataArrayPath(const QString& path) if(!tokens.empty()) { - m_DataContainerName = tokens.at(0); + setDataContainerName(tokens.at(0)); } if(tokens.size() > 1) { - m_AttributeMatrixName = tokens.at(1); + setAttributeMatrixName(tokens.at(1)); } if(tokens.size() > 2) { - m_DataArrayName = tokens.at(2); + setDataArrayName(tokens.at(2)); } + + updateDataType(); } // ----------------------------------------------------------------------------- @@ -92,9 +171,14 @@ DataArrayPath::DataArrayPath(const QString& path) // ----------------------------------------------------------------------------- DataArrayPath::DataArrayPath(const DataArrayPath& rhs) { - m_DataContainerName = rhs.getDataContainerName(); - m_AttributeMatrixName = rhs.getAttributeMatrixName(); - m_DataArrayName = rhs.getDataArrayName(); + m_DataContainerName = rhs.m_DataContainerName; + m_AttributeMatrixName = rhs.m_AttributeMatrixName; + m_DataArrayName = rhs.m_DataArrayName; + m_DataContainerHash = rhs.m_DataContainerHash; + m_AttributeMatrixHash = rhs.m_AttributeMatrixHash; + m_DataArrayHash = rhs.m_DataArrayHash; + + updateDataType(); } // ----------------------------------------------------------------------------- @@ -108,7 +192,7 @@ DataArrayPath::~DataArrayPath() = default; QVector DataArrayPath::ConvertToQVector(QStringList& paths) { QVector vPaths; - foreach(const QString sPath, paths) + for(const QString& sPath : paths) { DataArrayPath p(sPath); vPaths.push_back(p); @@ -124,6 +208,11 @@ DataArrayPath& DataArrayPath::operator=(const DataArrayPath& rhs) m_DataContainerName = rhs.m_DataContainerName; m_AttributeMatrixName = rhs.m_AttributeMatrixName; m_DataArrayName = rhs.m_DataArrayName; + m_DataContainerHash = rhs.m_DataContainerHash; + m_AttributeMatrixHash = rhs.m_AttributeMatrixHash; + m_DataArrayHash = rhs.m_DataArrayHash; + + updateDataType(); return *this; } @@ -132,13 +221,30 @@ DataArrayPath& DataArrayPath::operator=(const DataArrayPath& rhs) // ----------------------------------------------------------------------------- bool DataArrayPath::operator==(const DataArrayPath& rhs) const { - return m_DataContainerName == rhs.m_DataContainerName && m_AttributeMatrixName == rhs.m_AttributeMatrixName && m_DataArrayName == rhs.m_DataArrayName; + return m_DataContainerHash == rhs.m_DataContainerHash && m_AttributeMatrixHash == rhs.m_AttributeMatrixHash && m_DataArrayHash == rhs.m_DataArrayHash; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool DataArrayPath::operator!=(const DataArrayPath& rhs) const +{ + bool b = (*this == rhs); + return !b; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool DataArrayPath::operator<(const DataArrayPath& rhs) const +{ + return serialize() < rhs.serialize(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString DataArrayPath::serialize(QString delimiter) const +QString DataArrayPath::serialize(const QString& delimiter) const { QString s = ""; if(!m_DataContainerName.isEmpty()) @@ -162,7 +268,7 @@ QString DataArrayPath::serialize(QString delimiter) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataArrayPath DataArrayPath::Deserialize(QString str, QString delimiter) +DataArrayPath DataArrayPath::Deserialize(const QString& str, const QString& delimiter) { if(str.isEmpty()) { @@ -193,214 +299,117 @@ DataArrayPath DataArrayPath::Deserialize(QString str, QString delimiter) break; } + path.updateDataType(); return path; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool DataArrayPath::CheckRenamePath(DataContainerArrayShPtr oldDca, DataContainerArrayShPtr newDca, DataArrayPath oldPath, DataArrayPath newPath) +void DataArrayPath::setDataContainerName(const QString& name) { - // If the paths are not possible renames, return false - if(!oldPath.possibleRename(newPath)) - { - return false; - } - - // Check that the DataArrayPath targets are compatibles - DataContainer::Pointer oldDc = oldDca->getDataContainer(oldPath.getDataContainerName()); - DataContainer::Pointer newDc = newDca->getDataContainer(newPath.getDataContainerName()); - - // Data Container required - if(oldDc && newDc) - { - IGeometry::Pointer oldGeom = oldDc->getGeometry(); - IGeometry::Pointer newGeom = newDc->getGeometry(); - - bool hasGeom = oldGeom && newGeom; - if((hasGeom && oldGeom->getGeometryType() == newGeom->getGeometryType()) || !hasGeom) - { - // No Attribute Matrix path - if(oldPath.getAttributeMatrixName().isEmpty() && newPath.getAttributeMatrixName().isEmpty()) - { - return true; - } - - AttributeMatrix::Pointer oldAm = oldDc->getAttributeMatrix(oldPath.getAttributeMatrixName()); - AttributeMatrix::Pointer newAm = newDc->getAttributeMatrix(newPath.getAttributeMatrixName()); - - bool hasAttributeMatrix = oldAm && newAm; - if(hasAttributeMatrix && oldAm->getType() == newAm->getType() && oldAm->getNumberOfTuples() == newAm->getNumberOfTuples()) - { - // No Data Array path - if(oldPath.getDataArrayName().isEmpty() && newPath.getDataArrayName().isEmpty()) - { - return true; - } - - IDataArray::Pointer oldDa = oldAm->getAttributeArray(oldPath.getDataArrayName()); - IDataArray::Pointer newDa = newAm->getAttributeArray(newPath.getDataArrayName()); - - bool hasDataArray = oldDa && newDa; - bool hasSameType = oldDa->getTypeAsString() == newDa->getTypeAsString(); - bool hasSameCompDims = oldDa->getComponentDimensions() == newDa->getComponentDimensions(); - bool isNeighborList = hasSameType && newDa->getTypeAsString().startsWith("NeighborList"); - if(hasDataArray && hasSameType && (hasSameCompDims || isNeighborList)) - { - return true; - } - } - } - } - - return false; + m_DataContainerName = name; + m_DataContainerHash = GetHash(m_DataContainerName); + updateDataType(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataArrayPath::RenameContainer DataArrayPath::CheckForRenamedPaths(DataContainerArrayShPtr oldDca, DataContainerArrayShPtr newDca, std::list oldPaths, std::list newPaths) +void DataArrayPath::setAttributeMatrixName(const QString& name) { - RenameContainer container; - std::list duplicatedPaths; - std::list usedNewPaths; - - // For each older path, check for any matching new paths. If only one new path matches, add it as a possibility - for(DataArrayPath oldPath : oldPaths) - { - // If the same path exists in both oldPaths and newPaths, it was not renamed - if(std::find(newPaths.begin(), newPaths.end(), oldPath) != newPaths.end()) - { - continue; - } - - // Find any potential renames in newPaths for the given oldPath - std::list matches; - for(DataArrayPath newPath : newPaths) - { - // If the same path exists in both oldPaths and newPaths, it was not renamed - if(std::find(oldPaths.begin(), oldPaths.end(), newPath) != oldPaths.end()) - { - continue; - } - - // Check that all geometries, AttributeMatrices, and DataArrays are compatible - if(CheckRenamePath(oldDca, newDca, oldPath, newPath)) - { - matches.push_back(newPath); - } - } - // If this path was already used, mark it as duplicate and move on - if(matches.size() == 1) - { - DataArrayPath newPath = (*matches.begin()); - if(usedNewPaths.end() != std::find(usedNewPaths.begin(), usedNewPaths.end(), newPath)) - { - duplicatedPaths.push_back(newPath); - } - else - { - usedNewPaths.push_back(newPath); - container.push_back(RenameType(oldPath, newPath)); - } - } - } - - // Remove items with duplicated paths - for(auto iter = container.begin(); iter != container.end(); ) - { - DataArrayPath checkPath = std::get<1>(*iter); - if(duplicatedPaths.end() != std::find(duplicatedPaths.begin(), duplicatedPaths.end(), checkPath)) - { - iter = container.erase(iter); - } - else - { - iter++; - } - } + m_AttributeMatrixName = name; + m_AttributeMatrixHash = GetHash(m_AttributeMatrixName); + updateDataType(); +} - return container; +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataArrayPath::setDataArrayName(const QString& name) +{ + m_DataArrayName = name; + m_DataArrayHash = GetHash(m_DataArrayName); + updateDataType(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataArrayPath::DataType DataArrayPath::getDataType() +void DataArrayPath::updateDataType() { - if(getDataContainerName().isEmpty()) - { - return DataType::None; - } - if(getAttributeMatrixName().isEmpty() && getDataArrayName().isEmpty()) + const bool dcEmpty = m_DataContainerName.isEmpty(); + const bool amEmpty = m_AttributeMatrixName.isEmpty(); + const bool daEmpty = m_DataArrayName.isEmpty(); + + if(dcEmpty) { - return DataType::DataContainer; + m_DataType = DataArrayPathHelper::DataType::None; + return; } - if(getDataArrayName().isEmpty()) + if(amEmpty) { - return DataType::AttributeMatrix; + if(daEmpty) + { + m_DataType = DataArrayPathHelper::DataType::DataContainer; + return; + } } - if(!getAttributeMatrixName().isEmpty()) + else { - return DataType::DataArray; + if(daEmpty) + { + m_DataType = DataArrayPathHelper::DataType::AttributeMatrix; + return; + } + if(!amEmpty) + { + m_DataType = DataArrayPathHelper::DataType::DataArray; + return; + } } - return DataType::None; + m_DataType = DataArrayPathHelper::DataType::None; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector DataArrayPath::toQVector() +QVector DataArrayPath::toQVector() const { QVector v(3); - v[0] = m_DataContainerName; - v[1] = m_AttributeMatrixName; - v[2] = m_DataArrayName; + v[0] = getDataContainerName(); + v[1] = getAttributeMatrixName(); + v[2] = getDataArrayName(); return v; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool DataArrayPath::isEmpty() const +QList DataArrayPath::GetDataArrayNames(const QVector& paths) { - return m_DataContainerName.isEmpty() && m_AttributeMatrixName.isEmpty() && m_DataArrayName.isEmpty(); + return GetDataArrayNamesImpl>(paths); } // ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -bool DataArrayPath::isValid() const +std::vector DataArrayPath::GetDataArrayNames(const std::vector& paths) { - return !m_DataContainerName.isEmpty() && !m_AttributeMatrixName.isEmpty() && !m_DataArrayName.isEmpty(); + return GetDataArrayNamesImpl>(paths); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QList DataArrayPath::GetDataArrayNames(const QVector& paths) +DataArrayPath DataArrayPath::GetAttributeMatrixPath(const QVector& paths) { - QList arrayNames; - for(int i = 0; i < paths.count(); i++) - { - arrayNames.push_back(paths.at(i).getDataArrayName()); - } - - return arrayNames; + return GetAttributeMatrixPathImpl(paths); } // ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -DataArrayPath DataArrayPath::GetAttributeMatrixPath(const QVector& paths) +DataArrayPath DataArrayPath::GetAttributeMatrixPath(const std::vector& paths) { - if(paths.isEmpty()) - { - return DataArrayPath(); - } - - return DataArrayPath(paths.first().getDataContainerName(), paths.first().getAttributeMatrixName(), ""); + return GetAttributeMatrixPathImpl(paths); } // ----------------------------------------------------------------------------- @@ -409,7 +418,7 @@ DataArrayPath DataArrayPath::GetAttributeMatrixPath(const QVector QStringList DataArrayPath::toQStringList() const { QStringList l; - l << m_DataContainerName << m_AttributeMatrixName << m_DataArrayName; + l << getDataContainerName() << getAttributeMatrixName() << getDataArrayName(); return l; } @@ -418,9 +427,10 @@ QStringList DataArrayPath::toQStringList() const // ----------------------------------------------------------------------------- void DataArrayPath::update(const QString& dcName, const QString& amName, const QString& daName) { - m_DataContainerName = dcName; - m_AttributeMatrixName = amName; - m_DataArrayName = daName; + setDataContainerName(dcName); + setAttributeMatrixName(amName); + setDataArrayName(daName); + updateDataType(); } // ----------------------------------------------------------------------------- @@ -428,7 +438,7 @@ void DataArrayPath::update(const QString& dcName, const QString& amName, const Q // ----------------------------------------------------------------------------- bool DataArrayPath::hasSameDataContainer(const DataArrayPath& other) const { - return (m_DataContainerName == other.m_DataContainerName); + return m_DataContainerHash == other.m_DataContainerHash; } // ----------------------------------------------------------------------------- @@ -436,7 +446,7 @@ bool DataArrayPath::hasSameDataContainer(const DataArrayPath& other) const // ----------------------------------------------------------------------------- bool DataArrayPath::hasSameAttributeMatrix(const DataArrayPath& other) const { - return (m_AttributeMatrixName == other.m_AttributeMatrixName); + return m_AttributeMatrixHash == other.m_AttributeMatrixHash; } // ----------------------------------------------------------------------------- @@ -444,7 +454,7 @@ bool DataArrayPath::hasSameAttributeMatrix(const DataArrayPath& other) const // ----------------------------------------------------------------------------- bool DataArrayPath::hasSameDataArray(const DataArrayPath& other) const { - return (m_DataArrayName == other.m_DataArrayName); + return m_DataArrayHash == other.m_DataArrayHash; } // ----------------------------------------------------------------------------- @@ -458,112 +468,72 @@ bool DataArrayPath::hasSameAttributeMatrixPath(const DataArrayPath& other) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool DataArrayPath::possibleRename(const DataArrayPath& updated) const +bool DataArrayPath::isSubset(const DataArrayPath& other) const { - // Empty DataArrayPaths are not considered renames - // Neither are DataArrayPaths of different lengths - if(updated.getDataContainerName().isEmpty() || getDataContainerName().isEmpty()) - { - return false; - } - if(updated.getAttributeMatrixName().isEmpty() != getAttributeMatrixName().isEmpty()) - { - return false; - } - if(updated.getDataArrayName().isEmpty() != getDataArrayName().isEmpty()) - { - return false; - } + // Check types + const DataArrayPathHelper::DataType type = getDataType(); + const DataArrayPathHelper::DataType otherType = other.getDataType(); - // Check number of differences - int differences = 0; - if(!hasSameDataArray(updated)) + // If both are of the same DataType, require identical paths + if(type == otherType) { - differences++; + return (*this) == other; } - if(!hasSameAttributeMatrix(updated)) + + switch(otherType) { - differences++; + case DataArrayPathHelper::DataType::DataArray: + // [[fallthrough]]; + case DataArrayPathHelper::DataType::AttributeMatrix: + if(type == DataArrayPathHelper::DataType::DataArray) + { + return false; + } + // [[fallthrough]]; + case DataArrayPathHelper::DataType::DataContainer: + if(type == DataArrayPathHelper::DataType::AttributeMatrix || type == DataArrayPathHelper::DataType::DataArray) + { + return false; + } + break; + case DataArrayPathHelper::DataType::None: + if(type != DataArrayPathHelper::DataType::None) + { + return false; + } } - if(!hasSameDataContainer(updated)) + + bool valid = true; + switch(type) { - differences++; + case DataArrayPathHelper::DataType::DataArray: + valid &= m_DataArrayHash == other.m_DataArrayHash; + // [[fallthrough]]; + case DataArrayPathHelper::DataType::AttributeMatrix: + valid &= m_AttributeMatrixHash == other.m_AttributeMatrixHash; + // [[fallthrough]]; + case DataArrayPathHelper::DataType::DataContainer: + valid &= m_DataContainerHash == other.m_DataContainerHash; + break; + case DataArrayPathHelper::DataType::None: + break; } - return 1 == differences; + return valid; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool DataArrayPath::updatePath(const DataArrayPath::RenameType& renamePath) +bool DataArrayPath::ValidateVector(const QVector& other) { - DataArrayPath oldPath; - DataArrayPath newPath; - std::tie(oldPath, newPath) = renamePath; - - // Check for differences with original path - if(!hasSameDataArray(oldPath) && !oldPath.getDataArrayName().isEmpty()) - { - return false; - } - if(!hasSameAttributeMatrix(oldPath) && !oldPath.getAttributeMatrixName().isEmpty()) - { - return false; - } - if(!hasSameDataContainer(oldPath) && !oldPath.getDataContainerName().isEmpty()) - { - return false; - } - if(oldPath.getDataContainerName().isEmpty() || newPath.getDataContainerName().isEmpty()) - { - return false; - } - - // Substitude in the new DataArrayPath - if(hasSameDataContainer(oldPath)) - { - setDataContainerName(newPath.getDataContainerName()); - - if(hasSameAttributeMatrix(oldPath)) - { - setAttributeMatrixName(newPath.getAttributeMatrixName()); - - if(hasSameDataArray(oldPath)) - { - setDataArrayName(newPath.getDataArrayName()); - } - } - } - - return true; + return ValidateVectorImpl(other); } // ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -bool DataArrayPath::ValidateVector(const QVector& other) +bool DataArrayPath::ValidateVector(const std::vector& other) { - QString dcName = ""; - QString amName = ""; - - if(other.isEmpty()) - { - return true; - } - - dcName = other.first().getDataContainerName(); - amName = other.first().getAttributeMatrixName(); - - for(int i = 0; i < other.size(); ++i) - { - if(other.at(i).getDataContainerName() != dcName || other.at(i).getAttributeMatrixName() != amName) - { - return false; - } - } - - return true; + return ValidateVectorImpl(other); } // ----------------------------------------------------------------------------- @@ -595,9 +565,9 @@ bool DataArrayPath::readJson(QJsonObject& json) { if(json["Data Container Name"].isString() && json["Attribute Matrix Name"].isString() && json["Data Array Name"].isString()) { - m_DataContainerName = json["Data Container Name"].toString(); - m_AttributeMatrixName = json["Attribute Matrix Name"].toString(); - m_DataArrayName = json["Data Array Name"].toString(); + setDataContainerName(json["Data Container Name"].toString()); + setAttributeMatrixName(json["Attribute Matrix Name"].toString()); + setDataArrayName(json["Data Array Name"].toString()); return true; } return false; diff --git a/Source/SIMPLib/DataContainers/DataArrayPath.h b/Source/SIMPLib/DataContainers/DataArrayPath.h old mode 100755 new mode 100644 index e383a00e56..196369bf1c --- a/Source/SIMPLib/DataContainers/DataArrayPath.h +++ b/Source/SIMPLib/DataContainers/DataArrayPath.h @@ -1,306 +1,530 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include // for Q_DECLARE_METATYPE -#include // for Q_OBJECT +#include // for Q_DECLARE_METATYPE +#include // for Q_OBJECT #include #include #include +#include #include -#include +#include -#include "SIMPLib/Common/SIMPLibDLLExport.h" // for SIMPLib_EXPORT -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" // for SIMPL_PIMPL_PROPERTY_DECL +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLibDLLExport.h" class DataContainerArray; using DataContainerArrayShPtr = std::shared_ptr; +/** + * @brief The DataArrayPathHelper namespace is used to contain the QMetaType + * and enum DataType without requiring DataArrayPath to be a QObject. + */ +class SIMPLib_EXPORT DataArrayPathHelper final : public QObject +{ + Q_OBJECT + +public: + enum class DataType + { + DataContainer, + AttributeMatrix, + DataArray, + None + }; + Q_ENUM(DataType) + + ~DataArrayPathHelper() override = default; + +private: + DataArrayPathHelper() = default; +}; + /** * @brief The DataArrayPath class holds a complete or partial path to a data array starting at the DataContainer * level. The class is implemented using the PIMPL design pattern. */ -class SIMPLib_EXPORT DataArrayPath : public QObject +class SIMPLib_EXPORT DataArrayPath { - Q_OBJECT - - PYB11_CREATE_BINDINGS(DataArrayPath) - PYB11_CREATION(ARGS QString QString QString) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(DataArrayPath) + PYB11_CREATION(QString QString QString) + PYB11_CREATION(QString) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) PYB11_PROPERTY(QString AttributeMatrixName READ getAttributeMatrixName WRITE setAttributeMatrixName) PYB11_PROPERTY(QString DataArrayName READ getDataArrayName WRITE setDataArrayName) - PYB11_METHOD(bool isEmpty) PYB11_METHOD(bool isValid) PYB11_METHOD(void update ARGS dcName amName daName) + PYB11_CUSTOM() + PYB11_END_BINDINGS() + // End Python bindings declarations + + using HashType = size_t; + +private: + QString m_DataContainerName; + QString m_AttributeMatrixName; + QString m_DataArrayName; + HashType m_DataContainerHash = 0; + HashType m_AttributeMatrixHash = 0; + HashType m_DataArrayHash = 0; + + static HashType GetHash(const QString& name); + +public: + // tuple + using RenameType = std::pair; + using RenameContainer = std::list; + + DataArrayPath(); + + /** + * @brief DataArrayPath + * @param dcName + * @param amName + * @param daName + */ + DataArrayPath(const QString& dcName, const QString& amName, const QString& daName); + + /** + * @brief DataArrayPath + * @param path A path with the '|' delimeters + */ + explicit DataArrayPath(const QString& path); + + /** + * @brief DataArrayPath Copy Constructor + */ + DataArrayPath(const DataArrayPath& rhs); + + /** + * @brief ~DataArrayPath + */ + virtual ~DataArrayPath(); + + /** + * @brief checks that a vector of paths have the same data container and attribute matrix + * @return true if the paths in the vector have the same data container and attribute matrix, false otherwise + */ + static bool ValidateVector(const QVector& other); + + /** + * @brief checks that a vector of paths have the same data container and attribute matrix + * @return true if the paths in the vector have the same data container and attribute matrix, false otherwise + */ + static bool ValidateVector(const std::vector& other); + + /** + * @brief Gets the data array names from a QVector of DataArrayPaths. + * @return Returns the data array names from a QVector of DataArrayPaths, in a QList. + */ + static QList GetDataArrayNames(const QVector& paths); + + /** + * @brief Gets the data array names from a QVector of DataArrayPaths. + * @return Returns the data array names from a QVector of DataArrayPaths, in a QList. + */ + static std::vector GetDataArrayNames(const std::vector& paths); + + /** + * @brief Gets the attribute matrix path from a QVector of DataArrayPaths. + * @return Returns the attribute matrix path as a DataArrayPath from a QVector + * of DataArrayPaths. + */ + static DataArrayPath GetAttributeMatrixPath(const QVector& paths); + + /** + * @brief Gets the attribute matrix path from a QVector of DataArrayPaths. + * @return Returns the attribute matrix path as a DataArrayPath from a QVector + * of DataArrayPaths. + */ + static DataArrayPath GetAttributeMatrixPath(const std::vector& paths); + + /** + * @brief ConvertToQVector Converts a QStringList of DataArrayPaths to a QVector of DataArrayPaths + * @param paths + * @return + */ + static QVector ConvertToQVector(QStringList& paths); + + /** + * @brief serialize Deserializes the string into a DataArrayPath, using the specified delimiter. + * @param delimiter + * @return + */ + static DataArrayPath Deserialize(const QString& str, const QString& delimiter); + + /** + * @brief Returns the DataType matching the current path. + * @return + */ + DataArrayPathHelper::DataType getDataType() const + { + return m_DataType; + } + + /** + * @brief Returns the DataContainer name + * @return + */ + QString getDataContainerName() const + { + return m_DataContainerName; + } + + /** + * @brief Returns the AttributeMatrix name + * @return + */ + QString getAttributeMatrixName() const + { + return m_AttributeMatrixName; + } + + /** + * @brief Returns the DataArray name + * @return + */ + QString getDataArrayName() const + { + return m_DataArrayName; + } + + /** + * @brief Sets the DataContainer name and updates the hash + * @param name + */ + void setDataContainerName(const QString& name); + + /** + * @brief Sets the AttributeMatrix name and updates the hash + * @param name + */ + void setAttributeMatrixName(const QString& name); + + /** + * @brief Sets the DataArray name and updates the hash + * @param name + */ + void setDataArrayName(const QString& name); + + /** + * @brief operator = + */ + DataArrayPath& operator=(const DataArrayPath& rhs); + + /** + * @brief operator == + * @param rhs + * @return + */ + bool operator==(const DataArrayPath& rhs) const; + + /** + * @brief operator != + * @param rhs + * @return + */ + bool operator!=(const DataArrayPath& rhs) const; + + /** + * @brief operator < is required for std::set + * @param rhs + * @return + */ + bool operator<(const DataArrayPath& rhs) const; + + /** + * @brief serialize Returns the path using the '|' charater by default. This can be over ridden by the programmer + * @param delimiter + * @return + */ + QString serialize(const QString& delimiter = "|") const; + + /** + * @brief getAsVector Returns the DataArrayPath represented as a QVector where index[0] = DataContainer Name, + * index[1] = AttributeMatrix Name and index[2] = DataArray Name + * @return + */ + QVector toQVector() const; + + /** + * @brief isEmpty Returns if ALL of the string elements are empty. Note that a class could return FALSE for this + * function and FALSE for isValid() also so this function is not a true indication of a valid path. + * @return + */ + bool isEmpty() const + { + return m_DataType == DataArrayPathHelper::DataType::None; + } + + /** + * @brief isValid Returns if ALL of the string components have some value stored in them so 'valid' in this sense just + * means that all three components have a non-empty string. This does NOT necessarily mean that those strings, once + * serialized into a path actually refer to something in your DataContainer. + * @return + */ + bool isValid() const + { + return m_DataType == DataArrayPathHelper::DataType::DataArray; + } + + /** + * @brief toQStringList Converts the DataArrayPath to a QStringList + * @return + */ + QStringList toQStringList() const; + + /** + * @brief Updates the DataArrayPath with the values in the arguments + * @param dcName The DataContainer Name + * @param amName The AttributeMatrix Name + * @param daName The DataArray Name + */ + void update(const QString& dcName, const QString& amName, const QString& daName); + + /** + * @brief checks that two paths share the same data container + * @param other The other path + * @return true if the two paths share the same data container, false otherwise + */ + bool hasSameDataContainer(const DataArrayPath& other) const; + + /** + * @brief checks that two paths share the same attribute matrix + * @param other The other path + * @return true if the two paths share the same attribute matrix, false otherwise + */ + bool hasSameAttributeMatrix(const DataArrayPath& other) const; + + /** + * @brief checks that two paths share the same data container and attribute matrix + * @param other The other path + * @return true if the two paths share the same data container and attribute matrix, false otherwise + */ + bool hasSameAttributeMatrixPath(const DataArrayPath& other) const; + + /** + * @brief checks that two paths share the same data array + * @param other The other path + * @return true if the two paths share the same data array, false otherwise + */ + bool hasSameDataArray(const DataArrayPath& other) const; + + /** + * @brief Returns true if this DataArrayPath is a subset of the given path. Returns false otherwise. + * @param other + * @return + */ + bool isSubset(const DataArrayPath& other) const; + + /** + * @brief checks if the given DataArrayPath could indicate a possible renamed path. + * This requires that the given path be no longer than the current path and only one value is changed. + * Returns true if this is a possible rename and returns false otherwise. + * @param updated + * @return + */ + bool possibleRename(const DataArrayPath& updated) const + { + // Empty DataArrayPaths are not considered renames + // Neither are DataArrayPaths of different lengths + if(getDataType() != updated.getDataType()) + { + return false; + } - public: - // tuple - using RenameType = std::tuple; - using RenameContainer = std::list; + // Check number of differences + int differences = 0; + if(!hasSameDataArray(updated)) + { + differences++; + } + if(!hasSameAttributeMatrix(updated)) + { + differences++; + } + if(!hasSameDataContainer(updated)) + { + differences++; + } + + return 1 == differences; + } + + /** + * @brief updates the current path based on the newPath if it matches the given previous value + * @param renamePath + * return + */ + bool updatePath(const DataArrayPath::RenameType& renamePath) + { + const DataArrayPath& oldPath = std::get<0>(renamePath); + const DataArrayPath& newPath = std::get<1>(renamePath); + + bool valid = true; + // Check for differences with original path + switch(oldPath.getDataType()) + { + case DataArrayPathHelper::DataType::DataArray: + valid &= hasSameDataArray(oldPath); + // [[fallthrough]]; + case DataArrayPathHelper::DataType::AttributeMatrix: + valid &= hasSameAttributeMatrix(oldPath); + // [[fallthrough]]; + case DataArrayPathHelper::DataType::DataContainer: + valid &= hasSameDataContainer(oldPath); + break; + default: + valid = false; + break; + } + + if(!valid) + { + return false; + } + + // Substitude in the new DataArrayPath + switch(oldPath.getDataType()) + { + case DataArrayPathHelper::DataType::DataArray: + setDataArrayName(newPath.getDataArrayName()); + // [[fallthrough]]; + case DataArrayPathHelper::DataType::AttributeMatrix: + setAttributeMatrixName(newPath.getAttributeMatrixName()); + // [[fallthrough]]; + case DataArrayPathHelper::DataType::DataContainer: + setDataContainerName(newPath.getDataContainerName()); + break; + case DataArrayPathHelper::DataType::None: + break; + } + + return true; + } + + /** + * @brief Creates the missing RenameType resulting from two other RenameTypes. + * This can fail if the previous and new RenameTypes are not adequately related. + * This returns a pair of a bool signifying the success of the operation and the + * resulting RenameType. + * @param oldRename + * @param newRename + * @return std::pair + */ + static std::pair CreateLinkingRename(const RenameType& oldRename, const RenameType& newRename) + { + const DataArrayPath& oldOldPath = oldRename.first; + const DataArrayPath& oldNewPath = oldRename.second; + + const DataArrayPath& newOldPath = newRename.first; + const DataArrayPath& newNewPath = newRename.second; + + // Handle renaming of the same path. + // Rename path should be removed if the path was recreated, + // thus this signifies that a filter's rename was changed. + if((newOldPath == oldOldPath) && (oldNewPath != newNewPath)) + { + return std::make_pair(true, RenameType{oldNewPath, newNewPath}); + } - enum class DataType + // Require newOldPath to be a subset of oldNewPath + const bool isSubset = newOldPath.isSubset(oldNewPath); + if(!isSubset) { - DataContainer, - AttributeMatrix, - DataArray, - None - }; - Q_ENUM(DataType) - - DataArrayPath(); - - /** - * @brief DataArrayPath - * @param dcName - * @param amName - * @param daName - */ - DataArrayPath(const QString& dcName, const QString& amName, const QString& daName); - - /** - * @brief DataArrayPath - * @param path A path with the '|' delimeters - */ - explicit DataArrayPath(const QString& path); - - /** - * @brief DataArrayPath Copy Constructor - */ - DataArrayPath(const DataArrayPath& rhs); - - /** - * @brief ~DataArrayPath - */ - ~DataArrayPath() override; - - /** - * @brief checks that a vector of paths have the same data container and attribute matrix - * @return true if the paths in the vector have the same data container and attribute matrix, false otherwise - */ - static bool ValidateVector(const QVector& other); - - /** - * @brief Gets the data array names from a QVector of DataArrayPaths. - * @return Returns the data array names from a QVector of DataArrayPaths, in a QList. - */ - static QList GetDataArrayNames(const QVector& paths); - - /** - * @brief Gets the attribute matrix path from a QVector of DataArrayPaths. - * @return Returns the attribute matrix path as a DataArrayPath from a QVector - * of DataArrayPaths. - */ - static DataArrayPath GetAttributeMatrixPath(const QVector& paths); - - /** - * @brief ConvertToQVector Converts a QStringList of DataArrayPaths to a QVector of DataArrayPaths - * @param paths - * @return - */ - static QVector ConvertToQVector(QStringList& paths); - - /** - * @brief serialize Deserializes the string into a DataArrayPath, using the specified delimiter. - * @param delimiter - * @return - */ - static DataArrayPath Deserialize(QString str, QString delimiter); - - /** - * @brief checks for and returns any updated DataArrayPaths between two sets - * @param oldPaths - * @param newPaths - * @return - */ - static RenameContainer CheckForRenamedPaths(DataContainerArrayShPtr oldDca, DataContainerArrayShPtr newDca, std::list oldPaths, std::list newPaths); - - /** - * @brief checks if the targets of the old DataArrayPath and new DataArrayPath are compatible in their given DataContainerArrays - * @param oldDca - * @param newDca - * @param oldPath - * @param newPath - */ - static bool CheckRenamePath(DataContainerArrayShPtr oldDca, DataContainerArrayShPtr newDca, DataArrayPath oldPath, DataArrayPath newPath); - - /** - * @brief Returns the DataType matching the current path - * @return - */ - DataType getDataType(); - - SIMPL_INSTANCE_STRING_PROPERTY(DataContainerName) - SIMPL_INSTANCE_STRING_PROPERTY(AttributeMatrixName) - SIMPL_INSTANCE_STRING_PROPERTY(DataArrayName) - - - /** - * @brief operator = - */ - DataArrayPath& operator=(const DataArrayPath& rhs); - - /** - * @brief operator == - * @param rhs - * @return - */ - bool operator==(const DataArrayPath& rhs) const; - - /** - * @brief serialize Returns the path using the '|' charater by default. This can be over ridden by the programmer - * @param delimiter - * @return - */ - QString serialize(QString delimiter = "|") const; - - /** - * @brief getAsVector Returns the DataArrayPath represented as a QVector where index[0] = DataContainer Name, - * index[1] = AttributeMatrix Name and index[2] = DataArray Name - * @return - */ - QVector toQVector(); - - /** - * @brief isEmpty Returns if ALL of the string elements are empty. Note that a class could return FALSE for this - * function and FALSE for isValid() also so this function is not a true indication of a valid path. - * @return - */ - bool isEmpty() const; - - /** - * @brief isValid Returns if ALL of the string components have some value stored in them so 'valid' in this sense just - * means that all three components have a non-empty string. This does NOT necessarily mean that those strings, once - * serialized into a path actually refer to something in your DataContainer. - * @return - */ - bool isValid() const; - - /** - * @brief toQStringList Converts the DataArrayPath to a QStringList - * @return - */ - QStringList toQStringList() const; - - /** - * @brief Updates the DataArrayPath with the values in the arguments - * @param dcName The DataContainer Name - * @param amName The AttributeMatrix Name - * @param daName The DataArray Name - */ - void update(const QString& dcName, const QString& amName, const QString& daName); - - /** - * @brief checks that two paths share the same data container - * @param other The other path - * @return true if the two paths share the same data container, false otherwise - */ - bool hasSameDataContainer(const DataArrayPath& other) const; - - /** - * @brief checks that two paths share the same attribute matrix - * @param other The other path - * @return true if the two paths share the same attribute matrix, false otherwise - */ - bool hasSameAttributeMatrix(const DataArrayPath& other) const; - - /** - * @brief checks that two paths share the same data container and attribute matrix - * @param other The other path - * @return true if the two paths share the same data container and attribute matrix, false otherwise - */ - bool hasSameAttributeMatrixPath(const DataArrayPath& other) const; - - /** - * @brief checks that two paths share the same data array - * @param other The other path - * @return true if the two paths share the same data array, false otherwise - */ - bool hasSameDataArray(const DataArrayPath& other) const; - - /** - * @brief checks if the given DataArrayPath could indicate a possible renamed path. - * This requires that the given path be no longer than the current path and only one value is changed. - * Returns true if this is a possible rename and returns false otherwise. - * @param updated - * @return - */ - bool possibleRename(const DataArrayPath& updated) const; - - /** - * @brief updates the current path based on the newPath if it matches the given previous value - * @param renamePath - * return - */ - bool updatePath(const DataArrayPath::RenameType& renamePath); - - /** - * @brief Writes the contents of the proxy to the json object 'json' - * @param json - * @return - */ - void writeJson(QJsonObject& json) const; - - /** - * @brief Reads the contents of the the json object 'json' into the proxy - * @param json - * @return - */ - bool readJson(QJsonObject& json); - - /** - * @brief Returns a QJsonObject that holds the values of this class. - * @return - */ - QJsonObject toJsonObject() const; - - - protected: - - - - private: + return std::make_pair(false, RenameType{}); + } + // Create output rename + DataArrayPath replacementOldPath = oldOldPath; + replacementOldPath.updatePath(newRename); + DataArrayPath replacementNewPath = oldNewPath; + DataArrayPathHelper::DataType newOldType = newOldPath.getDataType(); + switch(newOldType) + { + case DataArrayPathHelper::DataType::DataArray: + replacementNewPath.setDataArrayName(newNewPath.getDataArrayName()); + // [[fallthrough]]; + case DataArrayPathHelper::DataType::AttributeMatrix: + replacementNewPath.setAttributeMatrixName(newNewPath.getAttributeMatrixName()); + // [[fallthrough]]; + case DataArrayPathHelper::DataType::DataContainer: + replacementNewPath.setDataContainerName(newNewPath.getDataContainerName()); + break; + case DataArrayPathHelper::DataType::None: + break; + } + + return std::make_pair(true, std::make_pair(replacementOldPath, replacementNewPath)); + } + + /** + * @brief Writes the contents of the proxy to the json object 'json' + * @param json + * @return + */ + void writeJson(QJsonObject& json) const; + + /** + * @brief Reads the contents of the the json object 'json' into the proxy + * @param json + * @return + */ + bool readJson(QJsonObject& json); + + /** + * @brief Returns a QJsonObject that holds the values of this class. + * @return + */ + QJsonObject toJsonObject() const; + +protected: + void updateDataType(); + +private: + DataArrayPathHelper::DataType m_DataType = DataArrayPathHelper::DataType::None; }; +using DataArrayPathVec = std::vector; Q_DECLARE_METATYPE(DataArrayPath) -Q_DECLARE_METATYPE(DataArrayPath::DataType) - - - +Q_DECLARE_METATYPE(DataArrayPathHelper::DataType) +Q_DECLARE_METATYPE(DataArrayPathVec) diff --git a/Source/SIMPLib/DataContainers/DataArrayProxy.cpp b/Source/SIMPLib/DataContainers/DataArrayProxy.cpp index e9b327b7f9..bc611f2513 100644 --- a/Source/SIMPLib/DataContainers/DataArrayProxy.cpp +++ b/Source/SIMPLib/DataContainers/DataArrayProxy.cpp @@ -31,6 +31,7 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DataArrayProxy.h" +#include #include "H5Support/H5ScopedSentinel.h" #include "H5Support/QH5Lite.h" #include "H5Support/QH5Utilities.h" @@ -118,14 +119,9 @@ void DataArrayProxy::ReadDataArrayStructure(hid_t attrMatGid, QMap dataArrayNames; - QH5Utilities::getGroupObjects(attrMatGid, H5Utilities::H5Support_DATASET | H5Utilities::H5Support_GROUP, dataArrayNames); - foreach(QString dataArrayName, dataArrayNames) + QH5Utilities::getGroupObjects(attrMatGid, H5Utilities::CustomHDFDataTypes::Dataset | H5Utilities::CustomHDFDataTypes::Group, dataArrayNames); + for(const auto& dataArrayName : dataArrayNames) { - if(__SHOW_DEBUG_MSG__) - { - std::cout << " DataArray: " << dataArrayName.toStdString() << std::endl; - } - DataArrayProxy proxy(h5InternalPath, dataArrayName, SIMPL::Unchecked); herr_t err = QH5Lite::readVectorAttribute(attrMatGid, dataArrayName, SIMPL::HDF5::TupleDimensions, proxy.m_TupleDims); @@ -143,11 +139,21 @@ void DataArrayProxy::ReadDataArrayStructure(hid_t attrMatGid, QMap> cDims = req->getComponentDimensions(); - if(cDims.empty() || cDims.contains(proxy.m_CompDims)) + std::vector> cDims = req->getComponentDimensions(); + if(cDims.empty()) { cDimsResult = true; } + if(!cDimsResult) + { + for(const auto& cDim : cDims) + { + if(cDim == proxy.m_CompDims) + { + cDimsResult = true; + } + } + } } err = QH5Lite::readScalarAttribute(attrMatGid, dataArrayName, SIMPL::HDF5::DataArrayVersion, proxy.m_Version); @@ -192,7 +198,7 @@ bool DataArrayProxy::operator==(const DataArrayProxy& rhs) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QJsonArray DataArrayProxy::writeVector(QVector vector) const +QJsonArray DataArrayProxy::writeVector(const std::vector& vector) const { QJsonArray jsonArray; for(const auto& num : vector) @@ -205,10 +211,10 @@ QJsonArray DataArrayProxy::writeVector(QVector vector) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector DataArrayProxy::readVector(QJsonArray jsonArray) +std::vector DataArrayProxy::readVector(QJsonArray jsonArray) { - QVector vector; - for(const auto& val : jsonArray) + std::vector vector; + for(const auto val : jsonArray) { if(val.isDouble()) { @@ -382,7 +388,7 @@ QString DataArrayProxy::getObjectType() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataArrayProxy::setTupleDims(const QVector& tDims) +void DataArrayProxy::setTupleDims(const std::vector& tDims) { m_TupleDims = tDims; } @@ -390,7 +396,7 @@ void DataArrayProxy::setTupleDims(const QVector& tDims) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector DataArrayProxy::getTupleDims() const +std::vector DataArrayProxy::getTupleDims() const { return m_TupleDims; } @@ -398,7 +404,7 @@ QVector DataArrayProxy::getTupleDims() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataArrayProxy::setCompDims(const QVector& cDims) +void DataArrayProxy::setCompDims(const std::vector& cDims) { m_CompDims = cDims; } @@ -406,7 +412,7 @@ void DataArrayProxy::setCompDims(const QVector& cDims) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector DataArrayProxy::getCompDims() const +std::vector DataArrayProxy::getCompDims() const { return m_CompDims; } diff --git a/Source/SIMPLib/DataContainers/DataArrayProxy.h b/Source/SIMPLib/DataContainers/DataArrayProxy.h old mode 100755 new mode 100644 index c6d9f8581f..5bb03f8ae7 --- a/Source/SIMPLib/DataContainers/DataArrayProxy.h +++ b/Source/SIMPLib/DataContainers/DataArrayProxy.h @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,14 +35,15 @@ #pragma once +#include + #include #include -#include #include -#include -#include +#include "H5Support/H5SupportTypeDefs.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataContainers/DataArrayPath.h" @@ -53,15 +54,19 @@ class SIMPLH5DataReaderRequirements; */ class SIMPLib_EXPORT DataArrayProxy { - PYB11_CREATE_BINDINGS(DataArrayProxy) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(DataArrayProxy) PYB11_CREATION() - PYB11_PROPERTY(QVector tupleDims) - PYB11_PROPERTY(QVector compDims) - PYB11_PROPERTY(QString path) - PYB11_PROPERTY(QString Name) + PYB11_PROPERTY(std::vector TupleDims READ getTupleDims WRITE setTupleDims) + PYB11_PROPERTY(std::vector CompDims READ getCompDims WRITE setCompDims) + PYB11_PROPERTY(QString Path READ getPath WRITE setPath) + PYB11_PROPERTY(QString Name READ getName WRITE setName) PYB11_PROPERTY(uint8_t Flag READ getFlag WRITE setFlag) + PYB11_END_BINDINGS() + // End Python bindings declarations + public: - using CompDimsVector = QVector>; + using CompDimsVector = std::vector>; // This enumeration is not a class enumeration because it is not possible to // do a bit-wise NOT operation on a class enumeration value. We need to be @@ -216,25 +221,25 @@ class SIMPLib_EXPORT DataArrayProxy * @brief setTupleDims * @param tDims */ - void setTupleDims(const QVector& tDims); + void setTupleDims(const std::vector& tDims); /** * @brief getTupleDims * @return */ - QVector getTupleDims() const; + std::vector getTupleDims() const; /** * @brief setCompDims * @param cDims */ - void setCompDims(const QVector& cDims); + void setCompDims(const std::vector& cDims); /** * @brief getCompDims * @return */ - QVector getCompDims() const; + std::vector getCompDims() const; private: uint8_t m_Flag = SIMPL::Unchecked; @@ -242,22 +247,22 @@ class SIMPLib_EXPORT DataArrayProxy QString m_Path; QString m_Name; QString m_ObjectType; - QVector m_TupleDims; - QVector m_CompDims; + std::vector m_TupleDims; + std::vector m_CompDims; /** * @brief writeVector * @param vector * @return */ - QJsonArray writeVector(QVector vector) const; + QJsonArray writeVector(const std::vector& vector) const; /** * @brief readVector * @param jsonArray * @return */ - QVector readVector(QJsonArray jsonArray); + std::vector readVector(QJsonArray jsonArray); }; Q_DECLARE_OPERATORS_FOR_FLAGS(DataArrayProxy::PrimitiveTypeFlags) diff --git a/Source/SIMPLib/DataContainers/DataContainer.cpp b/Source/SIMPLib/DataContainers/DataContainer.cpp index d397df6434..3153303b7e 100644 --- a/Source/SIMPLib/DataContainers/DataContainer.cpp +++ b/Source/SIMPLib/DataContainers/DataContainer.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DataContainer.h" @@ -39,10 +39,12 @@ #include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/DataContainers/DataContainer.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" #include "SIMPLib/DataContainers/DataContainerProxy.h" #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/Geometry/EdgeGeom.h" +#include "SIMPLib/Geometry/GeometryHelpers.h" #include "SIMPLib/Geometry/HexahedralGeom.h" #include "SIMPLib/Geometry/IGeometry.h" #include "SIMPLib/Geometry/ImageGeom.h" @@ -52,8 +54,10 @@ #include "SIMPLib/Geometry/TriangleGeom.h" #include "SIMPLib/Geometry/VertexGeom.h" #include "SIMPLib/Utilities/SIMPLH5DataReaderRequirements.h" +#include "SIMPLib/Utilities/STLUtilities.hpp" #include "H5Support/H5ScopedSentinel.h" +#include "H5Support/QH5Lite.h" #include "H5Support/QH5Utilities.h" // ----------------------------------------------------------------------------- @@ -64,8 +68,8 @@ DataContainer::DataContainer() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataContainer::DataContainer(const QString &name) - : m_Name(name) +DataContainer::DataContainer(const QString& name) +: IDataStructureContainerNode(name) { } @@ -87,6 +91,19 @@ DataContainer::Pointer DataContainer::New(const QString& name) return sharedPtr; } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainer::Pointer DataContainer::New(const DataArrayPath& path) +{ + if(path.isEmpty()) + { + return DataContainer::NullPointer(); + } + DataContainer::Pointer sharedPtr(new DataContainer(path.getDataContainerName())); + return sharedPtr; +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -102,25 +119,21 @@ DataContainer::Pointer DataContainer::createNewDataContainer(const QString& name void DataContainer::ReadDataContainerStructure(hid_t dcArrayGroupId, DataContainerArrayProxy& proxy, SIMPLH5DataReaderRequirements* req, const QString& h5InternalPath) { QList dataContainers; - QH5Utilities::getGroupObjects(dcArrayGroupId, H5Utilities::H5Support_GROUP, dataContainers); - foreach(QString dataContainerName, dataContainers) + QH5Utilities::getGroupObjects(dcArrayGroupId, H5Utilities::CustomHDFDataTypes::Group, dataContainers); + for(QString dataContainerName : dataContainers) { - if(__SHOW_DEBUG_MSG__) - { - std::cout << "Data Container:" << dataContainerName.toStdString() << std::endl; - } hid_t containerGid = H5Gopen(dcArrayGroupId, dataContainerName.toLatin1().constData(), H5P_DEFAULT); if(containerGid < 0) { continue; } - H5ScopedGroupSentinel sentinel(&containerGid, false); + H5ScopedGroupSentinel sentinel(containerGid, false); DataContainerProxy dcProxy(dataContainerName); dcProxy.setName(dataContainerName); dcProxy.setFlag(Qt::Unchecked); - int32_t geometryType; + uint32_t geometryType; herr_t err = QH5Lite::readScalarAttribute(containerGid, SIMPL::Geometry::Geometry, SIMPL::Geometry::GeometryType, geometryType); if(err >= 0) { @@ -128,14 +141,12 @@ void DataContainer::ReadDataContainerStructure(hid_t dcArrayGroupId, DataContain if(req != nullptr) { IGeometry::Types geomTypes = req->getDCGeometryTypes(); - if(geomTypes.empty() || geomTypes.contains(static_cast(geometryType))) + if(geomTypes.empty() || SIMPL::contains(geomTypes, static_cast(geometryType))) { + dcProxy.setFlag(Qt::Checked); } - - dcProxy.setFlag(Qt::Checked); } } - QString h5Path = h5InternalPath + "/" + dataContainerName; // Read the Attribute Matricies for this Data Container AttributeMatrix::ReadAttributeMatrixStructure(containerGid, &dcProxy, req, h5Path); @@ -148,17 +159,9 @@ void DataContainer::ReadDataContainerStructure(hid_t dcArrayGroupId, DataContain // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainer::setName(const QString& name) -{ - m_Name = name; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString DataContainer::getName() +DataArrayPath DataContainer::getDataArrayPath() const { - return m_Name; + return DataArrayPath(getName(), "", ""); } // ----------------------------------------------------------------------------- @@ -172,7 +175,7 @@ void DataContainer::setGeometry(const IGeometry::Pointer& geometry) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IGeometry::Pointer DataContainer::getGeometry() +IGeometry::Pointer DataContainer::getGeometry() const { return m_Geometry; } @@ -180,87 +183,26 @@ IGeometry::Pointer DataContainer::getGeometry() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataContainer::AttributeMatrixMap_t& DataContainer::getAttributeMatrices() -{ - return m_AttributeMatrices; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -bool DataContainer::doesAttributeMatrixExist(const QString& name) -{ - return m_AttributeMatrices.contains(name); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -AttributeMatrix::Pointer DataContainer::createAndAddAttributeMatrix(const QVector& tDims, const QString& attrMatName, AttributeMatrix::Type attrType) +AttributeMatrix::Pointer DataContainer::createAndAddAttributeMatrix(const std::vector& tDims, const QString& attrMatName, AttributeMatrix::Type attrType) { AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tDims, attrMatName, attrType); - addAttributeMatrix(attrMatName, attrMat); + addOrReplaceAttributeMatrix(attrMat); return attrMat; // Return the shared pointer } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void DataContainer::addAttributeMatrix(const QString& name, const AttributeMatrix::Pointer& data) -{ - if(data->getName().compare(name) != 0) - { - qDebug() << "Adding Attribute Matrix with a different name than key name"; - qDebug() << "Key name: " << name; - qDebug() << "AttributeMatrix Name: " << data->getName(); - qDebug() << "This action is NOT typical of DREAM3D Usage. Are you sure you want to be doing this? We are forcing the name of the AttributeMatrix to be the same as the key"; - data->setName(name); - } - m_AttributeMatrices[name] = data; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -AttributeMatrix::Pointer DataContainer::getAttributeMatrix(const QString& name) -{ - QMap::iterator it; - it = m_AttributeMatrices.find(name); - if(it == m_AttributeMatrices.end()) - { - return AttributeMatrix::NullPointer(); - } - return it.value(); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -AttributeMatrix::Pointer DataContainer::getAttributeMatrix(const DataArrayPath& path) -{ - QMap::iterator it; - it = m_AttributeMatrices.find(path.getAttributeMatrixName()); - if(it == m_AttributeMatrices.end()) - { - return AttributeMatrix::NullPointer(); - } - return it.value(); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- AttributeMatrix::Pointer DataContainer::removeAttributeMatrix(const QString& name) { - QMap::iterator it; - it = m_AttributeMatrices.find(name); - if(it == m_AttributeMatrices.end()) + auto it = find(name); + if(it == end()) { - // DO NOT return a NullPointer for any reason other than "Attribute Matrix was not found" + // DO NOT return a NullPointer for any reason other than "AttributeMatrix was not found" return AttributeMatrix::NullPointer(); } - AttributeMatrix::Pointer p = it.value(); - m_AttributeMatrices.erase(it); + AttributeMatrix::Pointer p = (*it); + erase(it); return p; } @@ -269,32 +211,8 @@ AttributeMatrix::Pointer DataContainer::removeAttributeMatrix(const QString& nam // ----------------------------------------------------------------------------- bool DataContainer::renameAttributeMatrix(const QString& oldname, const QString& newname, bool overwrite) { - QMap::iterator it; - it = m_AttributeMatrices.find(oldname); - if(it == m_AttributeMatrices.end()) - { - return false; - } - AttributeMatrix::Pointer p = it.value(); - p->setName(newname); - removeAttributeMatrix(oldname); - - // Now check to make sure there isn't one with the same name - it = m_AttributeMatrices.find(newname); - if(it == m_AttributeMatrices.end()) // Didn't find another AttributeMatrix with the new name - { - addAttributeMatrix(newname, p); - } - else if(overwrite) // We are here because we found another attribute matrix with the new name - { - AttributeMatrix::Pointer removedAttributeMatrix = removeAttributeMatrix(newname); // Remove the existing one - addAttributeMatrix(newname, p); - } - else - { - return false; - } - return true; + auto am = getChildByName(oldname); + return am && am->setName(newname); } // ----------------------------------------------------------------------------- @@ -302,62 +220,50 @@ bool DataContainer::renameAttributeMatrix(const QString& oldname, const QString& // ----------------------------------------------------------------------------- void DataContainer::clearAttributeMatrices() { - m_AttributeMatrices.clear(); + clear(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QList DataContainer::getAttributeMatrixNames() +DataContainer::NameList DataContainer::getAttributeMatrixNames() const { - QList keys; - for(QMap::iterator iter = m_AttributeMatrices.begin(); iter != m_AttributeMatrices.end(); ++iter) - { - keys.push_back(iter.key()); - } - return keys; + return getNamesOfChildren(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int DataContainer::getNumAttributeMatrices() -{ - return static_cast(m_AttributeMatrices.size()); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -int DataContainer::writeAttributeMatricesToHDF5(hid_t parentId) +int DataContainer::writeAttributeMatricesToHDF5(hid_t parentId) const { int err; hid_t attributeMatrixId; - for(QMap::iterator iter = m_AttributeMatrices.begin(); iter != m_AttributeMatrices.end(); ++iter) + for(auto iter = begin(); iter != end(); ++iter) { - AttributeMatrix::Pointer attrMat = iter.value(); + auto attrMat = (*iter); + const QString amName = attrMat->getName(); - err = QH5Utilities::createGroupsFromPath(iter.key(), parentId); + err = QH5Utilities::createGroupsFromPath(amName, parentId); if(err < 0) { return err; } - attributeMatrixId = H5Gopen(parentId, iter.key().toLatin1().data(), H5P_DEFAULT); - H5ScopedGroupSentinel gSentinel(&attributeMatrixId, false); + attributeMatrixId = H5Gopen(parentId, attrMat->getName().toLatin1().data(), H5P_DEFAULT); + H5ScopedGroupSentinel gSentinel(attributeMatrixId, false); AttributeMatrix::EnumType attrMatType = static_cast(attrMat->getType()); - err = QH5Lite::writeScalarAttribute(parentId, iter.key(), SIMPL::StringConstants::AttributeMatrixType, attrMatType); + err = QH5Lite::writeScalarAttribute(parentId, amName, SIMPL::StringConstants::AttributeMatrixType, attrMatType); if(err < 0) { return err; } - hsize_t size = (*iter)->getTupleDimensions().size(); - err = QH5Lite::writePointerAttribute(parentId, iter.key(), SIMPL::HDF5::TupleDimensions, 1, &size, (*iter)->getTupleDimensions().data()); + hsize_t size = attrMat->getTupleDimensions().size(); + err = QH5Lite::writePointerAttribute(parentId, amName, SIMPL::HDF5::TupleDimensions, 1, &size, attrMat->getTupleDimensions().data()); if(err < 0) { return err; } - err = (*iter)->writeAttributeArraysToHDF5(attributeMatrixId); + err = attrMat->writeAttributeArraysToHDF5(attributeMatrixId); if(err < 0) { return err; @@ -372,7 +278,7 @@ int DataContainer::writeAttributeMatricesToHDF5(hid_t parentId) int DataContainer::readAttributeMatricesFromHDF5(bool preflight, hid_t dcGid, DataContainerProxy& dcProxy) { int err = 0; - QVector tDims; + std::vector tDims; DataContainerProxy::StorageType& attrMatsToRead = dcProxy.getAttributeMatricies(); AttributeMatrix::Type amType = AttributeMatrix::Type::Unknown; @@ -408,7 +314,7 @@ int DataContainer::readAttributeMatricesFromHDF5(bool preflight, hid_t dcGid, Da { amType = static_cast(amTypeTmp); AttributeMatrix::Pointer am = AttributeMatrix::New(tDims, amName, amType); - addAttributeMatrix(amName, am); + addOrReplaceAttributeMatrix(am); } AttributeMatrixProxy amProxy = iter.value(); @@ -428,7 +334,7 @@ int DataContainer::readAttributeMatricesFromHDF5(bool preflight, hid_t dcGid, Da // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataContainer::Pointer DataContainer::deepCopy(bool forceNoAllocate) +DataContainer::Pointer DataContainer::deepCopy(bool forceNoAllocate) const { DataContainer::Pointer dcCopy = DataContainer::New(getName()); dcCopy->setName(getName()); @@ -439,10 +345,11 @@ DataContainer::Pointer DataContainer::deepCopy(bool forceNoAllocate) dcCopy->setGeometry(geomCopy); } - for(auto & iter : getAttributeMatrices()) + const auto attrMatrices = getChildren(); + for(const auto& am : attrMatrices) { - AttributeMatrix::Pointer attrMat = iter->deepCopy(forceNoAllocate); - dcCopy->addAttributeMatrix(attrMat->getName(), attrMat); + AttributeMatrix::Pointer attrMat = am->deepCopy(forceNoAllocate); + dcCopy->addOrReplaceAttributeMatrix(attrMat); } return dcCopy; @@ -451,7 +358,7 @@ DataContainer::Pointer DataContainer::deepCopy(bool forceNoAllocate) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int DataContainer::writeMeshToHDF5(hid_t dcGid, bool writeXdmf) +int DataContainer::writeMeshToHDF5(hid_t dcGid, bool writeXdmf) const { int err; hid_t geometryId; @@ -465,7 +372,7 @@ int DataContainer::writeMeshToHDF5(hid_t dcGid, bool writeXdmf) { return -1; } - H5ScopedGroupSentinel gSentinel(&geometryId, false); + H5ScopedGroupSentinel gSentinel(geometryId, false); if(nullptr == m_Geometry.get()) { @@ -525,7 +432,7 @@ int DataContainer::writeMeshToHDF5(hid_t dcGid, bool writeXdmf) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int DataContainer::writeXdmf(QTextStream& out, const QString& hdfFileName) +int DataContainer::writeXdmf(QTextStream& out, const QString& hdfFileName) const { if(nullptr == m_Geometry.get()) { @@ -535,14 +442,12 @@ int DataContainer::writeXdmf(QTextStream& out, const QString& hdfFileName) m_Geometry->writeXdmf(out, getName(), hdfFileName); IGeometry::Type geomType = m_Geometry->getGeometryType(); - // Get all of our AttributeMatrices - AttributeMatrixMap_t amMap = getAttributeMatrices(); // Loop over each AttributeMatrix and write the meta data to the Xdmf file QString xdmfCenter = ""; - for(QMap::iterator iter = amMap.begin(); iter != amMap.end(); ++iter) + for(auto iter = begin(); iter != end(); ++iter) { xdmfCenter = ""; - AttributeMatrix::Pointer attrMat = iter.value(); + AttributeMatrix::Pointer attrMat = (*iter); AttributeMatrix::Type amType = attrMat->getType(); switch(geomType) { @@ -634,21 +539,21 @@ int DataContainer::writeXdmf(QTextStream& out, const QString& hdfFileName) case IGeometry::Type::Hexahedral: switch(amType) { - // FIXME: There are more AttributeMatrix Types that should be implemented - case AttributeMatrix::Type::Vertex: - xdmfCenter = SIMPL::XdmfCenterType::Node; - break; - case AttributeMatrix::Type::Edge: - xdmfCenter = SIMPL::XdmfCenterType::Cell; - break; - case AttributeMatrix::Type::Face: - xdmfCenter = SIMPL::XdmfCenterType::Cell; - break; - case AttributeMatrix::Type::Cell: - xdmfCenter = SIMPL::XdmfCenterType::Cell; - break; - default: - break; + // FIXME: There are more AttributeMatrix Types that should be implemented + case AttributeMatrix::Type::Vertex: + xdmfCenter = SIMPL::XdmfCenterType::Node; + break; + case AttributeMatrix::Type::Edge: + xdmfCenter = SIMPL::XdmfCenterType::Cell; + break; + case AttributeMatrix::Type::Face: + xdmfCenter = SIMPL::XdmfCenterType::Cell; + break; + case AttributeMatrix::Type::Cell: + xdmfCenter = SIMPL::XdmfCenterType::Cell; + break; + default: + break; } break; case IGeometry::Type::Image: @@ -712,7 +617,7 @@ int DataContainer::writeXdmf(QTextStream& out, const QString& hdfFileName) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainer::writeXdmfFooter(QTextStream& xdmf) +void DataContainer::writeXdmfFooter(QTextStream& xdmf) const { xdmf << " " << "\n"; @@ -739,7 +644,7 @@ int DataContainer::readMeshDataFromHDF5(hid_t dcGid, bool preflight) { return -1; } - H5ScopedGroupSentinel gSentinel(&geometryId, false); + H5ScopedGroupSentinel gSentinel(geometryId, false); IGeometry::Pointer geomPtr = IGeometry::NullPointer(); @@ -822,17 +727,16 @@ int DataContainer::readMeshDataFromHDF5(hid_t dcGid, bool preflight) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector DataContainer::getAllDataArrayPaths() +QVector DataContainer::getAllDataArrayPaths() const { - QVector paths; - for(QMap::iterator iter = m_AttributeMatrices.begin(); iter != m_AttributeMatrices.end(); ++iter) + const auto attributeMatrices = getChildren(); + for(const auto& am : attributeMatrices) { - AttributeMatrix::Pointer am = iter.value(); QString amName = am->getName(); - QList aaNames = am->getAttributeArrayNames(); + NameList aaNames = am->getAttributeArrayNames(); - foreach(QString aaName, aaNames) + for(QString aaName : aaNames) { DataArrayPath dap(getName(), amName, aaName); paths.push_back(dap); @@ -845,40 +749,42 @@ QVector DataContainer::getAllDataArrayPaths() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString DataContainer::getInfoString(SIMPL::InfoStringFormat format) +QString DataContainer::getInfoString(SIMPL::InfoStringFormat format) const { - QString info; - QTextStream ss(&info); if(format == SIMPL::HtmlFormat) { - ss << "\n"; - ss << "\n"; - ss << "\n"; - ss << "\n"; - ss << ""; + return getToolTipGenerator().generateHTML(); + } - ss << R"("; - ss << R"("; - ss << ""; - if(getGeometry().get() != nullptr) - { - ss << getGeometry()->getInfoString(SIMPL::HtmlFormat); - } + QString info; + QTextStream ss(&info); + ss << "Requested InfoStringFormat is not supported. " << format; + return info; +} - ss << "
Data Container Info
Name:)" << getName() << "
Attribute Matrix Count:)" << getNumAttributeMatrices() << "
\n"; - ss << ""; - } - else +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +ToolTipGenerator DataContainer::getToolTipGenerator() const +{ + ToolTipGenerator toolTipGen; + + toolTipGen.addTitle("Data Container Info"); + toolTipGen.addValue("Name", getName()); + toolTipGen.addValue("Attribute Matrix Count", QString::number(getNumAttributeMatrices())); + + if(getGeometry().get() != nullptr) { - ss << "Requested InfoStringFormat is not supported. " << format; + toolTipGen.append(getGeometry()->getToolTipGenerator()); } - return info; + + return toolTipGen; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrixShPtr DataContainer::getPrereqAttributeMatrix(AbstractFilter* filter, const QString& attributeMatrixName, int err) +AttributeMatrixShPtr DataContainer::getPrereqAttributeMatrix(AbstractFilter* filter, const QString& attributeMatrixName, int err) const { QString ss; AttributeMatrixShPtr attributeMatrix(nullptr); @@ -889,9 +795,8 @@ AttributeMatrixShPtr DataContainer::getPrereqAttributeMatrix(AbstractFilter* fil { if(filter != nullptr) { - filter->setErrorCondition(err * 1000); ss = QObject::tr("DataContainer:'%1' The name of the AttributeMatrix was empty. Please provide a name for this AttributeMatrix").arg(getName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(err * 1000, ss); } return attributeMatrix; } @@ -901,9 +806,8 @@ AttributeMatrixShPtr DataContainer::getPrereqAttributeMatrix(AbstractFilter* fil { if(filter != nullptr) { - filter->setErrorCondition(err * 1020); ss = QObject::tr("DataContainer:'%1' An AttributeMatrix with name '%2' does not exist and is required for this filter to execute.").arg(getName()).arg(attributeMatrixName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(err * 1020, ss); } return attributeMatrix; } @@ -911,9 +815,8 @@ AttributeMatrixShPtr DataContainer::getPrereqAttributeMatrix(AbstractFilter* fil { if(filter != nullptr) { - filter->setErrorCondition(err * 1030); ss = QObject::tr("DataContainer:'%1' AttributeMatrix: '%2' Attribute Matrix has Attribute Arrays with mismatched number of objects.").arg(getName()).arg(attributeMatrixName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(err * 1030, ss); } return attributeMatrix; } @@ -923,63 +826,92 @@ AttributeMatrixShPtr DataContainer::getPrereqAttributeMatrix(AbstractFilter* fil // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrixShPtr DataContainer::createNonPrereqAttributeMatrix(AbstractFilter* filter, const DataArrayPath& path, const QVector& tDims, AttributeMatrix::Type amType) +AttributeMatrixShPtr DataContainer::createNonPrereqAttributeMatrix(AbstractFilter* filter, const DataArrayPath& path, const std::vector& tDims, AttributeMatrix::Type amType, + RenameDataPath::DataID_t id) { - return createNonPrereqAttributeMatrix(filter, path.getAttributeMatrixName(), tDims, amType); + return createNonPrereqAttributeMatrix(filter, path.getAttributeMatrixName(), tDims, amType, id); } - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrixShPtr DataContainer::createNonPrereqAttributeMatrix(AbstractFilter* filter, const QString& attributeMatrixName, const QVector &tDims, AttributeMatrix::Type amType) +AttributeMatrixShPtr DataContainer::createNonPrereqAttributeMatrix(AbstractFilter* filter, const DataArrayPath& path, const SizeVec3Type& tDims, AttributeMatrix::Type amType, + RenameDataPath::DataID_t id) { - AttributeMatrixShPtr attributeMatrix(nullptr); + std::vector tupleDims; + for(const auto& value : tDims) + { + tupleDims.push_back(value); + } + return createNonPrereqAttributeMatrix(filter, path.getAttributeMatrixName(), tupleDims, amType, id); +} +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AttributeMatrixShPtr DataContainer::createNonPrereqAttributeMatrix(AbstractFilter* filter, const QString& attributeMatrixName, const std::vector& tDims, AttributeMatrix::Type amType, + RenameDataPath::DataID_t id) +{ QString ss; if(attributeMatrixName.isEmpty()) { if(filter != nullptr) { - filter->setErrorCondition(-10011); ss = QObject::tr("The name of the Attribute Matrix was empty. Please provide a name for this Attribute Matrix."); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10011, ss); } - return attributeMatrix; + return nullptr; } if(attributeMatrixName.contains('/')) { if(filter != nullptr) { - filter->setErrorCondition(-10012); ss = QObject::tr("The AttributeMatrix '%1' has forward slashes in its name").arg(attributeMatrixName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10012, ss); } - return attributeMatrix; + return nullptr; } if(attributeMatrixName.compare(SIMPL::Geometry::Geometry) == 0) { if(filter != nullptr) { - filter->setErrorCondition(-10013); ss = QObject::tr("%1 is a protected name. Please provide a different name for this Attribute Matrix.").arg(SIMPL::Geometry::Geometry); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10013, ss); } - return attributeMatrix; + return nullptr; } - attributeMatrix = getAttributeMatrix(attributeMatrixName); + AttributeMatrixShPtr attributeMatrix = getAttributeMatrix(attributeMatrixName); if(nullptr == attributeMatrix.get()) { attributeMatrix = createAndAddAttributeMatrix(tDims, attributeMatrixName, amType); + // Check if path was renamed + RenameDataPath::AlertFilterCreatedPath(filter, id, DataArrayPath(getName(), attributeMatrixName, "")); return attributeMatrix; } if(filter != nullptr) // If the filter object is NOT null (is valid) then set the error condition and send an error message { - filter->setErrorCondition(-10014); ss = QObject::tr("An Attribute Matrix already exists with the name %1.").arg(attributeMatrixName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-10014, ss); } return attributeMatrix; } + +// ----------------------------------------------------------------------------- +DataContainer::Pointer DataContainer::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString DataContainer::getNameOfClass() const +{ + return QString("DataContainer"); +} + +// ----------------------------------------------------------------------------- +QString DataContainer::ClassName() +{ + return QString("DataContainer"); +} diff --git a/Source/SIMPLib/DataContainers/DataContainer.h b/Source/SIMPLib/DataContainers/DataContainer.h old mode 100755 new mode 100644 index bafc1fd8b9..f81f39c4ae --- a/Source/SIMPLib/DataContainers/DataContainer.h +++ b/Source/SIMPLib/DataContainers/DataContainer.h @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,17 +35,27 @@ #pragma once +#include + #include #include #include +#include #include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Observable.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/Common/SIMPLArray.hpp" +#include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/DataContainers/IDataStructureContainerNode.hpp" +#include "SIMPLib/DataContainers/RenameDataPath.h" #include "SIMPLib/Geometry/IGeometry.h" -#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Utilities/ToolTipGenerator.h" + +class IDataArray; +using IDataArrayShPtrType = std::shared_ptr; class QTextStream; class DataArrayPath; @@ -60,32 +70,47 @@ using AttributeMatrixShPtr = std::shared_ptr; /** * @brief The DataContainer class */ -class SIMPLib_EXPORT DataContainer : public Observable +class SIMPLib_EXPORT DataContainer : public Observable, public IDataStructureContainerNode { // This line MUST be first when exposing a class and properties to Python // clang-format off - PYB11_CREATE_BINDINGS(DataContainer) - PYB11_STATIC_CREATION(New ARGS QString) - + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(DataContainer) + PYB11_SHARED_POINTERS(DataContainer) + PYB11_STATIC_CREATION(New OVERLOAD QString) + PYB11_STATIC_CREATION(New OVERLOAD DataArrayPath) PYB11_PROPERTY(QString Name READ getName WRITE setName) PYB11_PROPERTY(IGeometry Geometry READ getGeometry WRITE setGeometry) - PYB11_METHOD(QString getInfoString ARGS InfoStringFormat) - PYB11_METHOD(void addAttributeMatrix ARGS Name AttributeMatrix) - - PYB11_METHOD(AttributeMatrix::Pointer getAttributeMatrix OVERLOAD const.QString.&,Name) - PYB11_METHOD(AttributeMatrix::Pointer getAttributeMatrix OVERLOAD const.DataArrayPath.&,Path) - + PYB11_METHOD(bool addOrReplaceAttributeMatrix ARGS AttributeMatrix) + PYB11_METHOD(bool insertOrAssign ARGS AttributeMatrix) + PYB11_METHOD(AttributeMatrix::Pointer getAttributeMatrix OVERLOAD const.QString.&,Name CONST_METHOD) + PYB11_METHOD(AttributeMatrix::Pointer getAttributeMatrix OVERLOAD const.DataArrayPath.&,Path CONST_METHOD) PYB11_METHOD(AttributeMatrix removeAttributeMatrix ARGS Name) PYB11_METHOD(bool renameAttributeMatrix ARGS OldName NewName OverWrite) - PYB11_METHOD(bool doesAttributeMatrixExist ARGS Name) PYB11_METHOD(void setGeometry ARGS Geometry) + PYB11_CUSTOM() + PYB11_END_BINDINGS() + // End Python bindings declarations // clang-format on public: - SIMPL_SHARED_POINTERS(DataContainer) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DataContainer, Observable) + using Self = DataContainer; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for DataContainer + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for DataContainer + */ + static QString ClassName(); ~DataContainer() override; @@ -108,10 +133,12 @@ class SIMPLib_EXPORT DataContainer : public Observable using Types = QVector; + using Container_t = std::vector; + /** * @brief AttributeMatrixMap_t */ - using AttributeMatrixMap_t = QMap; + // using AttributeMatrixMap_t = QMap; /** * @brief Creates a new shared pointer instance of this class @@ -120,6 +147,13 @@ class SIMPLib_EXPORT DataContainer : public Observable */ static Pointer New(const QString& name); + /** + * @brief Creates a new shared pointer instance of this class + * @param name The name to give to the DataContainer and must NOT be empty. + * @return Shared Pointer to a DataContainer instance. + */ + static Pointer New(const DataArrayPath& name); + /** * @brief Creates a new data container */ @@ -134,64 +168,79 @@ class SIMPLib_EXPORT DataContainer : public Observable static void ReadDataContainerStructure(hid_t dcArrayGroupId, DataContainerArrayProxy& proxy, SIMPLH5DataReaderRequirements* req, const QString& h5InternalPath); /** - * @brief Sets the name of the data container - */ - virtual void setName(const QString& name); - - /** - * @brief Gets the name of the data container + * @brief Creates and returns a DataArrayPath for the DataContainer + * @return */ - virtual QString getName(); + DataArrayPath getDataArrayPath() const override; /** * @brief Sets the geometry of the data container * @param geometry */ - virtual void setGeometry(const IGeometry::Pointer &geometry); + virtual void setGeometry(const IGeometry::Pointer& geometry); /** * @brief Returns the geometry of the data container * @return */ - virtual IGeometry::Pointer getGeometry(); + virtual IGeometry::Pointer getGeometry() const; /** * @param format The format of the string to be returned. */ - virtual QString getInfoString(SIMPL::InfoStringFormat format); + virtual QString getInfoString(SIMPL::InfoStringFormat format) const; /** - * @brief Adds/overwrites the data for a named array - * @param name The name that the array will be known by - * @param data The IDataArray::Pointer that will hold the data + * @brief Returns a ToolTipGenerator for creating HTML tooltip tables + * with values populated to match the current DataContainer. + * @return */ - virtual void addAttributeMatrix(const QString& name, const AttributeMatrixShPtr& matrix); + virtual ToolTipGenerator getToolTipGenerator() const; + + /** + * @brief Adds the data for a named array. If an AttributeMatrix with the same + * name already exists in the DataContainer then the add will fail. + * @param matrix The IDataArrayShPtrType that will hold the data + * @return Bool TRUE if the addition was successful, FALSE Otherwise. + */ + bool addOrReplaceAttributeMatrix(const AttributeMatrixShPtr& matrix) + { + return insertOrAssign(matrix); + } /** * @brief Returns the array for a given named array or the equivelant to a * null pointer if the name does not exist. * @param name The name of the data array */ - virtual AttributeMatrixShPtr getAttributeMatrix(const QString& name); + AttributeMatrixShPtr getAttributeMatrix(const QString& name) const + { + return getChildByName(name); + } /** * @brief Returns the array for a given named array or the equivelant to a * null pointer if the name does not exist. * @param name The Name of the AttributeMatrix will be extracted from the DataArratPath object */ - virtual AttributeMatrixShPtr getAttributeMatrix(const DataArrayPath& path); - - /** - * @brief getAttributeMatrices - * @return - */ - AttributeMatrixMap_t& getAttributeMatrices(); + AttributeMatrixShPtr getAttributeMatrix(const DataArrayPath& path) const + { + // Could this be sped-up if we hashed DataArrayPath as well? + if(path.getDataContainerName() != getName()) + { + return nullptr; + } + return getChildByName(path.getAttributeMatrixName()); + } /** * @brief Returns bool of whether a named array exists * @param name The name of the data array */ - virtual bool doesAttributeMatrixExist(const QString& name); + bool doesAttributeMatrixExist(const QString& name) const + { + return contains(name); + } /** * @brief Removes the named data array from the Data Container and returns it to the calling @@ -212,24 +261,32 @@ class SIMPLib_EXPORT DataContainer : public Observable */ virtual void clearAttributeMatrices(); + Container_t getAttributeMatrices() const + { + return getChildren(); + } + /** * @brief Returns a list that contains the names of all the arrays currently stored in the * Cell (Formerly Cell) group * @return */ - virtual QList getAttributeMatrixNames(); + virtual NameList getAttributeMatrixNames() const; /** * @brief Returns the total number of arrays that are stored in the Cell group * @return */ - virtual int getNumAttributeMatrices(); + int getNumAttributeMatrices() const + { + return static_cast(size()); + } /** * @brief getAllDataArrayPaths * @return */ - virtual QVector getAllDataArrayPaths(); + virtual QVector getAllDataArrayPaths() const; /** * @brief This method will check for the existance of a named AttributeMatrix. If that AttributeMatrix with the @@ -240,7 +297,7 @@ class SIMPLib_EXPORT DataContainer : public Observable * @param err The unique error value to generate derived error values from. This helps debugging. * @return Shared Pointer to an AttributeMatrix object. */ - AttributeMatrixShPtr getPrereqAttributeMatrix(AbstractFilter* filter, const QString& attributeMatrixName, int err); + AttributeMatrixShPtr getPrereqAttributeMatrix(AbstractFilter* filter, const QString& attributeMatrixName, int err) const; /** * @brief createNonPrereqAttributeMatrix This method will create a new AttributeMatrix with the given tuple dimensions @@ -253,7 +310,19 @@ class SIMPLib_EXPORT DataContainer : public Observable * @param amType The Type of AttributeMatrix * @return A Shared Pointer to the AttributeMatrix */ - AttributeMatrixShPtr createNonPrereqAttributeMatrix(AbstractFilter* filter, const DataArrayPath& path, const QVector& tDims, AttributeMatrix::Type amType); + AttributeMatrixShPtr createNonPrereqAttributeMatrix(AbstractFilter* filter, const DataArrayPath& path, const std::vector& tDims, AttributeMatrix::Type amType, + RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID); + + /** + * @brief createNonPrereqAttributeMatrix + * @param filter + * @param path + * @param tDims + * @param amType + * @param id + * @return + */ + AttributeMatrixShPtr createNonPrereqAttributeMatrix(AbstractFilter* filter, const DataArrayPath& path, const SizeVec3Type& tDims, AttributeMatrix::Type amType, RenameDataPath::DataID_t id); /** * @brief createNonPrereqAttributeMatrix This method will create a new AttributeMatrix with the given tuple dimensions @@ -265,13 +334,15 @@ class SIMPLib_EXPORT DataContainer : public Observable * @param amType The Type of AttributeMatrix * @return A Shared Pointer to the AttributeMatrix */ - AttributeMatrixShPtr createNonPrereqAttributeMatrix(AbstractFilter* filter, const QString& attributeMatrixName, const QVector& tDims, AttributeMatrix::Type amType); + AttributeMatrixShPtr createNonPrereqAttributeMatrix(AbstractFilter* filter, const QString& attributeMatrixName, const std::vector& tDims, AttributeMatrix::Type amType, + RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID); /** * @brief Returns the geometry as the templated type * @return */ - template typename GeometryType::Pointer getGeometryAs() + template + typename GeometryType::Pointer getGeometryAs() const { typename GeometryType::Pointer geom = std::dynamic_pointer_cast(getGeometry()); return geom; @@ -282,7 +353,8 @@ class SIMPLib_EXPORT DataContainer : public Observable * @param filter * @return */ - template typename GeometryType::Pointer getPrereqGeometry(Filter* filter) + template + typename GeometryType::Pointer getPrereqGeometry(AbstractFilter* filter) const { typename GeometryType::Pointer geom = GeometryType::NullPointer(); IGeometry::Pointer igeom = getGeometry(); @@ -290,9 +362,8 @@ class SIMPLib_EXPORT DataContainer : public Observable { if(filter) { - filter->setErrorCondition(-385); QString ss = QObject::tr("Data Container Geometry is missing."); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-385, ss); } return geom; } @@ -301,9 +372,8 @@ class SIMPLib_EXPORT DataContainer : public Observable { if(filter) { - filter->setErrorCondition(-384); QString ss = QObject::tr("Data Container Geometry is not compatible. The selected Geometry type is %1").arg(igeom->getGeometryTypeAsString()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); + filter->setErrorCondition(-384, ss); } return geom; } @@ -319,13 +389,13 @@ class SIMPLib_EXPORT DataContainer : public Observable * @param attrType The Type of AttributeMatrix to create * @return */ - virtual AttributeMatrixShPtr createAndAddAttributeMatrix(const QVector& tDims, const QString& attrMatName, AttributeMatrix::Type attrType); + virtual AttributeMatrixShPtr createAndAddAttributeMatrix(const std::vector& tDims, const QString& attrMatName, AttributeMatrix::Type attrType); /** * @brief Writes all the Attribute Matrices to HDF5 file * @return */ - virtual int writeAttributeMatricesToHDF5(hid_t parentId); + virtual int writeAttributeMatricesToHDF5(hid_t parentId) const; /** * @brief Reads desired Attribute Matrices from HDF5 file @@ -337,14 +407,14 @@ class SIMPLib_EXPORT DataContainer : public Observable * @brief creates copy of dataContainer * @return */ - virtual DataContainer::Pointer deepCopy(bool forceNoAllocate = false); + virtual DataContainer::Pointer deepCopy(bool forceNoAllocate = false) const; /** * @brief writeMeshToHDF5 * @param dcGid * @return */ - virtual int writeMeshToHDF5(hid_t dcGid, bool writeXdmf); + virtual int writeMeshToHDF5(hid_t dcGid, bool writeXdmf) const; /** * @brief writeXdmf @@ -352,7 +422,7 @@ class SIMPLib_EXPORT DataContainer : public Observable * @param hdfFileName * @return */ - virtual int writeXdmf(QTextStream& out, const QString &hdfFileName); + virtual int writeXdmf(QTextStream& out, const QString& hdfFileName) const; /** * @brief readMeshDataFromHDF5 @@ -363,13 +433,11 @@ class SIMPLib_EXPORT DataContainer : public Observable virtual int readMeshDataFromHDF5(hid_t dcGid, bool preflight); protected: - virtual void writeXdmfFooter(QTextStream& xdmf); + virtual void writeXdmfFooter(QTextStream& xdmf) const; DataContainer(); explicit DataContainer(const QString& name); private: - AttributeMatrixMap_t m_AttributeMatrices; IGeometry::Pointer m_Geometry; - QString m_Name; }; diff --git a/Source/SIMPLib/DataContainers/DataContainerArray.cpp b/Source/SIMPLib/DataContainers/DataContainerArray.cpp index 30293b1e2c..7cbc3b63ad 100644 --- a/Source/SIMPLib/DataContainers/DataContainerArray.cpp +++ b/Source/SIMPLib/DataContainers/DataContainerArray.cpp @@ -1,41 +1,127 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + #include "DataContainerArray.h" +#include + +#include + +#include + +#include "SIMPLib/DataContainers/DataContainer.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" #include "SIMPLib/DataContainers/DataContainerProxy.h" +#include "SIMPLib/Filtering/AbstractFilter.h" +#include "SIMPLib/Montages/AbstractMontage.h" +#include "SIMPLib/Montages/GridMontage.h" + +namespace +{ +template +bool validateNumberOfTuplesImpl(const DataContainerArray& dca, AbstractFilter* filter, const Container& paths) +{ + static_assert(std::is_same_v); + + using size_type = typename Container::size_type; + + if(paths.size() <= 1) + { + return false; + } + QVector dataArrays; + bool valid = true; + QString ss; + if(!paths.at(0).isValid() && nullptr != filter) + { + ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2") + .arg(__LINE__) + .arg(paths.at(0).serialize()); + filter->setErrorCondition(-10000, ss); + valid = false; + return valid; + } + IDataArrayShPtrType array0 = dca.getPrereqIDataArrayFromPath(filter, paths.at(0)); + if(nullptr == array0.get() && nullptr != filter) + { + ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArray object was not available. The path is %2").arg(__LINE__).arg(paths.at(0).serialize()); + filter->setErrorCondition(-10100, ss); + valid = false; + return valid; + } + + dataArrays.push_back(array0); + for(size_type i = 1; i < paths.size(); i++) + { + if(!paths.at(i).isValid() && nullptr != filter) + { + ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2") + .arg(__LINE__) + .arg(paths.at(i).serialize()); + filter->setErrorCondition(-10000, ss); + valid = false; + return valid; + } + IDataArrayShPtrType nextArray = dca.getPrereqIDataArrayFromPath(filter, paths.at(i)); + if(nullptr == nextArray.get() && nullptr != filter) + { + ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArray object was not available. The path is %2").arg(__LINE__).arg(paths.at(i).serialize()); + filter->setErrorCondition(-10100, ss); + valid = false; + return valid; + } + + dataArrays.push_back(nextArray); + } + size_t numTuples = dataArrays[0]->getNumberOfTuples(); + for(int32_t i = 1; i < dataArrays.size(); i++) + { + if(numTuples != dataArrays[i]->getNumberOfTuples() && nullptr != filter) + { + ss = QObject::tr("The number of tuples for the DataArray %1 is %2 and for DataArray %3 is %4. The number of tuples must match.") + .arg(dataArrays[0]->getName()) + .arg(dataArrays[0]->getNumberOfTuples()) + .arg(dataArrays[i]->getName()) + .arg(dataArrays[i]->getNumberOfTuples()); + filter->setErrorCondition(-10200, ss); + valid = false; + } + } + return valid; +} +} // namespace // ----------------------------------------------------------------------------- // @@ -50,17 +136,17 @@ DataContainerArray::~DataContainerArray() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerArray::addDataContainer(DataContainer::Pointer f) +DataArrayPath DataContainerArray::getDataArrayPath() const { - m_Array.push_back(f); + return DataArrayPath(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int DataContainerArray::getNumDataContainers() +int DataContainerArray::getNumDataContainers() const { - return m_Array.size(); + return static_cast(size()); } // ----------------------------------------------------------------------------- @@ -68,7 +154,7 @@ int DataContainerArray::getNumDataContainers() // ----------------------------------------------------------------------------- void DataContainerArray::clearDataContainers() { - m_Array.clear(); + clear(); } #if 0 @@ -122,19 +208,15 @@ bool DataContainerArray::empty() DataContainer::Pointer DataContainerArray::removeDataContainer(const QString& name) { removeDataContainerFromBundles(name); - DataContainer::Pointer f = DataContainer::NullPointer(); - for(QList::iterator it = m_Array.begin(); it != m_Array.end(); ++it) + auto it = find(name); + if(it == end()) { - if((*it)->getName().compare(name) == 0) - { - f = *it; - m_Array.erase(it); - return f; - } + // DO NOT return a NullPointer for any reason other than "DataContainer was not found" + return DataContainer::NullPointer(); } - - // DO NOT return a NullPointer for any reason other than "DataContainer was not found" - return f; + DataContainer::Pointer p = (*it); + erase(it); + return p; } // ----------------------------------------------------------------------------- @@ -142,65 +224,31 @@ DataContainer::Pointer DataContainerArray::removeDataContainer(const QString& na // ----------------------------------------------------------------------------- bool DataContainerArray::renameDataContainer(const QString& oldName, const QString& newName) { - DataContainer::Pointer dc = DataContainer::NullPointer(); - - // Make sure we do not already have a DataContainer with the newname - for(const auto& iter : m_Array) - { - if(iter->getName().compare(newName) == 0) - { - dc = iter; - break; - } - } - - if(nullptr == dc) - { - // We did not find any data container that matches the new name so we can rename if we find one that matches - // the 'oldname' argument - // Now find the data container we want to rename - for(const auto& iter : m_Array) - { - if(iter->getName() == oldName) - { - // we have an existing DataContainer that matches our "oldname" that we want to rename so all is good. - dc = iter; - dc->setName(newName); - return true; - } - } - } - else if(nullptr != dc) - { - // We found an existing Data Container with the 'newname' but we do NOT want to over write it so just bail out now - return false; - } - - return false; // default (but we should just NEVER make it here) + DataContainer::Pointer dc = getChildByName(oldName); + return dc && dc->setName(newName); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataContainer::Pointer DataContainerArray::getDataContainer(const QString& name) +bool DataContainerArray::renameDataContainer(const DataArrayPath& oldName, const DataArrayPath& newName) { - DataContainer::Pointer f = DataContainer::NullPointer(); - for(const auto& dc : m_Array) - { - if(dc->getName().compare(name) == 0) - { - f = dc; - break; - } - } + DataContainer::Pointer dc = getChildByName(oldName.getDataContainerName()); + return dc && dc->setName(newName.getDataContainerName()); +} - return f; +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainer::Pointer DataContainerArray::getDataContainer(const QString& name) const +{ + return getChildByName(name); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataContainer::Pointer DataContainerArray::getDataContainer(const DataArrayPath& path) +DataContainer::Pointer DataContainerArray::getDataContainer(const DataArrayPath& path) const { QString dcName = path.getDataContainerName(); return getDataContainer(dcName); @@ -209,7 +257,7 @@ DataContainer::Pointer DataContainerArray::getDataContainer(const DataArrayPath& // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrix::Pointer DataContainerArray::getAttributeMatrix(const DataArrayPath& path) +AttributeMatrix::Pointer DataContainerArray::getAttributeMatrix(const DataArrayPath& path) const { DataContainer::Pointer dc = getDataContainer(path); if(nullptr == dc.get()) @@ -225,16 +273,7 @@ AttributeMatrix::Pointer DataContainerArray::getAttributeMatrix(const DataArrayP // ----------------------------------------------------------------------------- void DataContainerArray::duplicateDataContainer(const QString& name, const QString& newName) { - DataContainer::Pointer f = DataContainer::NullPointer(); - for(const auto& dc : m_Array) - { - if(dc->getName().compare(name) == 0) - { - f = dc; - break; - } - } - + DataContainer::Pointer f = getDataContainer(name); if(f == nullptr) { return; @@ -242,37 +281,33 @@ void DataContainerArray::duplicateDataContainer(const QString& name, const QStri DataContainer::Pointer new_f = f->deepCopy(false); new_f->setName(newName); - addDataContainer(new_f); + addOrReplaceDataContainer(new_f); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QList DataContainerArray::getDataContainerNames() +DataContainerArray::NameList DataContainerArray::getDataContainerNames() const { - QList names; - for(const auto& dc : m_Array) - { - names.push_back(dc->getName()); - } - return names; + return getNamesOfChildren(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QList& DataContainerArray::getDataContainers() +DataContainerArray::Container DataContainerArray::getDataContainers() const { - return m_Array; + return getChildren(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerArray::printDataContainerNames(QTextStream& out) +void DataContainerArray::printDataContainerNames(QTextStream& out) const { out << "---------------------------------------------------------------------"; - for(const auto& dc : m_Array) + Container dcArray = getDataContainers(); + for(DataContainer::Pointer dc : dcArray) { out << dc->getNameOfClass(); } @@ -301,12 +336,12 @@ int DataContainerArray::readDataContainersFromHDF5(bool preflight, hid_t dcaGid, QString ss = QObject::tr("A Data Container with name %1 already exists in Memory. Reading a Data Container with the same name would over write the one in memory. Currently this is not allowed.") .arg(dcProxy.getName()); - obs->notifyErrorMessage(getNameOfClass(), ss, -198745600); + obs->setErrorCondition(-198745600, ss); } return -198745600; } DataContainer::Pointer dc = DataContainer::New(dcProxy.getName()); - this->addDataContainer(dc); + this->addOrReplaceDataContainer(dc); // Now open the DataContainer Group in the HDF5 file hid_t dcGid = H5Gopen(dcaGid, dcProxy.getName().toLatin1().data(), H5P_DEFAULT); @@ -315,7 +350,7 @@ int DataContainerArray::readDataContainersFromHDF5(bool preflight, hid_t dcaGid, if(nullptr != obs) { QString ss = QObject::tr("Error opening Group '%1'").arg(dcProxy.getName()); - obs->notifyErrorMessage(getNameOfClass(), ss, -198745602); + obs->setErrorCondition(-198745602, ss); } return -198745602; } @@ -326,7 +361,7 @@ int DataContainerArray::readDataContainersFromHDF5(bool preflight, hid_t dcaGid, if(nullptr != obs) { QString ss = QObject::tr("Error reading Mesh Data from '%1'").arg(dcProxy.getName()); - obs->notifyErrorMessage(getNameOfClass(), ss, -198745603); + obs->setErrorCondition(-198745603, ss); } return -198745603; } @@ -336,7 +371,7 @@ int DataContainerArray::readDataContainersFromHDF5(bool preflight, hid_t dcaGid, if(nullptr != obs) { QString ss = QObject::tr("Error reading AttributeMatrix Data from '%1'").arg(dcProxy.getName()); - obs->notifyErrorMessage(getNameOfClass(), ss, -198745604); + obs->setErrorCondition(-198745604, ss); } return -198745604; } @@ -347,22 +382,23 @@ int DataContainerArray::readDataContainersFromHDF5(bool preflight, hid_t dcaGid, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool DataContainerArray::doesDataContainerExist(const QString& name) +bool DataContainerArray::doesDataContainerExist(const DataArrayPath& dap) const { - for(const auto& dc : m_Array) - { - if(dc->getName() == name) - { - return true; - } - } - return false; + return contains(dap.getDataContainerName()); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool DataContainerArray::doesAttributeMatrixExist(const DataArrayPath& path) +bool DataContainerArray::doesDataContainerExist(const QString& name) const +{ + return contains(name); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool DataContainerArray::doesAttributeMatrixExist(const DataArrayPath& path) const { if(!doesDataContainerExist(path.getDataContainerName())) { @@ -376,7 +412,7 @@ bool DataContainerArray::doesAttributeMatrixExist(const DataArrayPath& path) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool DataContainerArray::doesAttributeArrayExist(const DataArrayPath& path) +bool DataContainerArray::doesAttributeArrayExist(const DataArrayPath& path) const { if(!doesDataContainerExist(path.getDataContainerName())) { @@ -410,16 +446,15 @@ QMap& DataContainerArray::getDataContain // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IDataContainerBundle::Pointer DataContainerArray::getDataContainerBundle(const QString& name) +IDataContainerBundle::Pointer DataContainerArray::getDataContainerBundle(const QString& name) const { IDataContainerBundle::Pointer f = IDataContainerBundle::NullPointer(); - for(QMap::iterator it = m_DataContainerBundles.begin(); it != m_DataContainerBundles.end(); ++it) + + auto match = std::find_if(m_DataContainerBundles.cbegin(), m_DataContainerBundles.cend(), [&name](auto bundle) { return bundle->getName() == name; }); + + if(match != m_DataContainerBundles.cend()) { - if((*it)->getName().compare(name) == 0) - { - f = *it; - break; - } + f = *match; } return f; @@ -480,9 +515,9 @@ bool DataContainerArray::renameDataContainerBundle(const QString& oldName, const return false; } - m_DataContainerBundles.insert(newName, iter.value()); - iter.value()->setName(newName); - m_DataContainerBundles.remove(oldName); + m_DataContainerBundles.insert(newName, iter.value()); + iter.value()->setName(newName); + m_DataContainerBundles.remove(oldName); } return false; } @@ -490,43 +525,170 @@ bool DataContainerArray::renameDataContainerBundle(const QString& oldName, const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataContainerArray::Pointer DataContainerArray::deepCopy(bool forceNoAllocate) +DataContainerArray::MontageCollection DataContainerArray::getMontageCollection() const { - DataContainerArray::Pointer dcaCopy = DataContainerArray::New(); - QList dcs = getDataContainers(); - for(int i = 0; i < dcs.size(); i++) + return m_MontageCollection; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool DataContainerArray::addMontage(const AbstractMontageShPtr& montage) +{ + return m_MontageCollection.insert(montage); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataContainerArray::addOrReplaceMontage(const AbstractMontageShPtr& montage) +{ + m_MontageCollection.erase(montage->getName()); + m_MontageCollection.insert(montage); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataContainerArray::removeMontage(const QString& name) +{ + m_MontageCollection.erase(name); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AbstractMontageShPtr DataContainerArray::getMontage(const QString& name) const +{ + auto iter = m_MontageCollection.find(name); + if(m_MontageCollection.end() == iter) { - DataContainer::Pointer dcCopy = dcs[i]->deepCopy(forceNoAllocate); -#if 0 + return nullptr; + } + return (*iter); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QStringList DataContainerArray::getMontageNames() const +{ + QStringList names; + for(const auto& montage : m_MontageCollection) + { + names.push_back(montage->getName()); + } + + return names; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AbstractMontageShPtr DataContainerArray::getPrereqMontage(AbstractFilter* filter, const QString& name) +{ + AbstractMontageShPtr montage = getMontage(name); + if(nullptr == montage) + { + filter->setErrorCondition(-4950, "The prerequisite montage '" + name + "' could not be found."); + } + return montage; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +GridMontageShPtr DataContainerArray::createNonPrereqGridMontage(AbstractFilter* filter, const QString& montageName, SizeVec3Type size, const QStringList& dcNames, + GridMontage::CollectionMethod collectionMethod) +{ + GridMontage::Pointer montage = GridMontage::New(montageName, size[0], size[1], size[2]); + + if(nullptr == montage) + { + filter->setErrorCondition(-4965, "The montage '" + montageName + "' could not be instantiated"); + return nullptr; + } + + QStringListIterator dcNameIter(dcNames); - // Deep copy geometry if applicable - if(nullptr != dcs[i]->getGeometry().get()) + switch(collectionMethod) + { + case GridMontage::CollectionMethod::CombOrder: + for(size_t depth = 0; depth < size[2] && dcNameIter.hasNext(); depth++) { - dcCopy->setGeometry(dcs[i]->getGeometry()->deepCopy()); + for(size_t row = 0; row < size[0] && dcNameIter.hasNext(); row++) + { + for(size_t col = 0; col < size[1] && dcNameIter.hasNext(); col++) + { + setMontageTileFromDataContainerName(filter, row, col, depth, montage, dcNameIter.next()); + } + } } - - // Add AttributeMatrix copies - QMap ams = dcs[i]->getAttributeMatrices(); - for(QMap::Iterator iter = ams.begin(); iter != ams.end(); iter++) + break; + case GridMontage::CollectionMethod::SnakeOrder: + for(size_t depth = 0; depth < size[2] && dcNameIter.hasNext(); depth++) { - QVector dims = (*iter)->getTupleDimensions(); - AttributeMatrix::Pointer amCopy = AttributeMatrix::New(dims, (*iter)->getName(), (*iter)->getType()); - - // Add DataArray copies without allocating memory - QList daNames = (*iter)->getAttributeArrayNames(); - for(int i = 0; i < daNames.size(); i++) + for(size_t row = 0; row < size[0] && dcNameIter.hasNext(); row++) { - // Copy and add DataArray to AttributeMatrix copy without allocating memory - IDataArray::Pointer daCopy = (*iter)->getAttributeArray(daNames[i])->deepCopy(true); - amCopy->addAttributeArray(daNames[i], daCopy); + if(row % 2 == 0) + { + for(size_t col = 0; col < size[1] && dcNameIter.hasNext(); col++) + { + setMontageTileFromDataContainerName(filter, row, col, depth, montage, dcNameIter.next()); + } + } + else + { + for(int64_t col = static_cast(size[1] - 1); col >= 0 && dcNameIter.hasNext(); col--) + { + setMontageTileFromDataContainerName(filter, row, col, depth, montage, dcNameIter.next()); + } + } } - - // End add AttributeMatrix - dcCopy->addAttributeMatrix(amCopy->getName(), amCopy); } -#endif + break; + } + + if(!addMontage(montage)) + { + filter->setErrorCondition(-4960, "The montage '" + montageName + "' could not be added to the Data Structure"); + return nullptr; + } + + return montage; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataContainerArray::setMontageTileFromDataContainerName(AbstractFilter* filter, size_t row, size_t col, size_t depth, const GridMontage::Pointer& montage, const QString& dcName) +{ + GridTileIndex index = montage->getTileIndex(row, col, depth); + DataContainer::Pointer dc = getPrereqDataContainer(filter, dcName); + montage->setDataContainer(index, dc); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainerArray::Pointer DataContainerArray::deepCopy(bool forceNoAllocate) const +{ + DataContainerArray::Pointer dcaCopy = DataContainerArray::New(); + const Container dcs = getDataContainers(); + for(const auto& dc : dcs) + { + DataContainer::Pointer dcCopy = dc->deepCopy(forceNoAllocate); + // End add DataContainer - dcaCopy->addDataContainer(dcCopy); + dcaCopy->push_back(dcCopy); + } + + const MontageCollection montageCollection = getMontageCollection(); + MontageCollection mccopy = MontageCollection(); + for(const auto& montage : montageCollection) + { + AbstractMontage::Pointer montageCopy = montage->propagate(dcaCopy); + dcaCopy->addMontage(montageCopy); } return dcaCopy; @@ -565,3 +727,224 @@ void DataContainerArray::renameDataArrayPaths(DataArrayPath::RenameContainer ren } } } + +// ----------------------------------------------------------------------------- +DataContainerArray::Pointer DataContainerArray::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +DataContainerArray::Pointer DataContainerArray::New() +{ + Pointer sharedPtr(new(DataContainerArray)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString DataContainerArray::getNameOfClass() const +{ + return QString("DataContainerArray"); +} + +// ----------------------------------------------------------------------------- +QString DataContainerArray::ClassName() +{ + return QString("DataContainerArray"); +} + +// ----------------------------------------------------------------------------- +DataContainerShPtr DataContainerArray::getPrereqDataContainer(AbstractFilter* filter, const DataArrayPath& dap, bool createIfNotExists) +{ + return getPrereqDataContainer(filter, dap.getDataContainerName(), createIfNotExists); +} + +// ----------------------------------------------------------------------------- +DataContainerShPtr DataContainerArray::getPrereqDataContainer(AbstractFilter* filter, const QString& name, bool createIfNotExists) +{ + DataContainerShPtr dc = getDataContainer(name); + if(nullptr == dc.get() && !createIfNotExists) + { + if(filter) + { + QString ss = "The DataContainer Object with the specific name '" + name + "' was not available."; + filter->setErrorCondition(-999, ss); + } + return dc; + } + + if(nullptr != dc && createIfNotExists) + { + DataContainerShPtr dataContainer = DataContainer::New(name); // Create a new Data Container + addOrReplaceDataContainer(dataContainer); // Put the new DataContainer into the array + return dataContainer; // Return the wrapped pointer + } + // The DataContainer we asked for was present and NON Null so return that. + return dc; +} + +// ----------------------------------------------------------------------------- +DataContainerShPtr DataContainerArray::createNonPrereqDataContainer(AbstractFilter* filter, const DataArrayPath& dap, RenameDataPath::DataID_t id) +{ + return createNonPrereqDataContainer(filter, dap.getDataContainerName(), id); +} + +// ----------------------------------------------------------------------------- +DataContainerShPtr DataContainerArray::createNonPrereqDataContainer(AbstractFilter* filter, const QString& dataContainerName, RenameDataPath::DataID_t id) +{ + if(dataContainerName.isEmpty()) + { + if(filter) + { + QString ss = QObject::tr("The DataContainer Object must have a name to be created."); + filter->setErrorCondition(-887, ss); + return DataContainer::NullPointer(); + } + } + + if(dataContainerName.contains('/')) + { + if(filter) + { + QString ss = QObject::tr("The DataContainer Object has forward slashes in its name."); + filter->setErrorCondition(-888, ss); + return DataContainer::NullPointer(); + } + } + + DataContainerShPtr dataContainer = DataContainer::New(dataContainerName); + bool dcExists = !push_back(dataContainer); + if(dcExists) + { + if(filter) + { + QString ss = QObject::tr("The DataContainer Object with the specific name '%1' already exists.").arg(dataContainerName); + filter->setErrorCondition(-889, ss); + return DataContainer::NullPointer(); + } + } + + RenameDataPath::AlertFilterCreatedPath(filter, id, DataArrayPath(dataContainerName, "", "")); + return dataContainer; +} + +// ----------------------------------------------------------------------------- +AttributeMatrix::Pointer DataContainerArray::getPrereqAttributeMatrixFromPath(AbstractFilter* filter, const DataArrayPath& path, int err) +{ + // First try to get the Parent DataContainer. If an error occurs the error message will have been set + // so just return a nullptr shared pointer + DataContainerShPtr dc = getPrereqDataContainer(filter, path.getDataContainerName(), false); + if(nullptr == dc) + { + return AttributeMatrix::NullPointer(); + } + + // Now just return what ever the DataContainer gives us. if the AttributeMatrix was not available then an + // error message and code will have been set into the "filter" object if that object was non-null itself. + return dc->getPrereqAttributeMatrix(filter, path.getAttributeMatrixName(), err); +} + +// ----------------------------------------------------------------------------- +bool DataContainerArray::validateNumberOfTuples(AbstractFilter* filter, const QVector& paths) const +{ + return validateNumberOfTuplesImpl(*this, filter, paths); +} + +// ----------------------------------------------------------------------------- +bool DataContainerArray::validateNumberOfTuples(AbstractFilter* filter, const std::vector& paths) const +{ + return validateNumberOfTuplesImpl(*this, filter, paths); +} + +// ----------------------------------------------------------------------------- +bool DataContainerArray::validateNumberOfTuples(AbstractFilter* filter, QVector dataArrays) const +{ + if(dataArrays.size() <= 1) + { + return false; + } + bool valid = true; + QString ss; + for(const auto& dataArray : dataArrays) + { + if(nullptr == dataArray && nullptr != filter) + { + ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArray object was not available").arg(__LINE__); + filter->setErrorCondition(-10100, ss); + valid = false; + } + } + size_t numTuples = dataArrays[0]->getNumberOfTuples(); + for(int32_t i = 1; i < dataArrays.size(); i++) + { + if(numTuples != dataArrays[i]->getNumberOfTuples() && nullptr != filter) + { + ss = QObject::tr("The number of tuples for the DataArray %1 is %2 and for DataArray %3 is %4. The number of tuples must match.") + .arg(dataArrays[i - 1]->getName()) + .arg(dataArrays[i - 1]->getNumberOfTuples()) + .arg(dataArrays[i]->getName()) + .arg(dataArrays[i]->getNumberOfTuples()); + filter->setErrorCondition(-10200, ss); + valid = false; + } + } + return valid; +} + +// ----------------------------------------------------------------------------- +IDataArray::Pointer DataContainerArray::getPrereqIDataArrayFromPath(AbstractFilter* filter, const DataArrayPath& path) const +{ + QString ss; + IDataArray::Pointer dataArray = nullptr; + + if(path.isEmpty()) + { + if(filter) + { + ss = QObject::tr("DataContainerArray::getPrereqIDataArrayFromPath Error at line %1. The DataArrayPath object was empty").arg(__LINE__); + filter->setErrorCondition(-90000, ss); + } + return dataArray; + } + + if(!path.isValid()) + { + if(filter) + { + ss = QObject::tr("DataContainerArray::getPrereqIDataArrayFromPath Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2") + .arg(__LINE__) + .arg(path.serialize()); + filter->setErrorCondition(-90001, ss); + } + return dataArray; + } + + QString dcName = path.getDataContainerName(); + QString amName = path.getAttributeMatrixName(); + QString daName = path.getDataArrayName(); + + DataContainerShPtr dc = getDataContainer(dcName); + if(nullptr == dc.get()) + { + if(filter) + { + ss = QObject::tr("The DataContainer '%1' was not found in the DataContainerArray").arg(dcName); + filter->setErrorCondition(-999, ss); + } + return dataArray; + } + + AttributeMatrix::Pointer attrMat = dc->getAttributeMatrix(amName); + if(nullptr == attrMat.get()) + { + if(filter) + { + ss = QObject::tr("The AttributeMatrix '%1' was not found in the DataContainer '%2'").arg(amName).arg(dcName); + filter->setErrorCondition(-307020, ss); + } + return dataArray; + } + + dataArray = attrMat->getPrereqIDataArray(filter, daName, -90002); + return dataArray; +} diff --git a/Source/SIMPLib/DataContainers/DataContainerArray.h b/Source/SIMPLib/DataContainers/DataContainerArray.h old mode 100755 new mode 100644 index e3554dc618..d0f878fa3f --- a/Source/SIMPLib/DataContainers/DataContainerArray.h +++ b/Source/SIMPLib/DataContainers/DataContainerArray.h @@ -1,56 +1,66 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include // for nullptr +#include + +#include // for nullptr #include // for Q_OBJECT #include -#include +#include -#include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/DataContainers/IDataContainerBundle.h" +#include "SIMPLib/Common/NamedCollection.hpp" +#include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/DataContainers/DataArrayPath.h" - +#include "SIMPLib/DataContainers/IDataContainerBundle.h" +#include "SIMPLib/DataContainers/IDataStructureContainerNode.hpp" +#include "SIMPLib/DataContainers/RenameDataPath.h" +#include "SIMPLib/Filtering/AbstractFilter.h" +#include "SIMPLib/Montages/AbstractMontage.h" +#include "SIMPLib/Montages/GridMontage.h" class DataContainer; using DataContainerShPtr = std::shared_ptr; +class IDataArray; +using IDataArrayShPtrType = std::shared_ptr; + +class GridMontage; +using GridMontageShPtr = std::shared_ptr; + /** * @class DataContainerArray DataContainerArray.h DREAM3DLib/Common/DataContainerArray.h * @brief This class holds the list of filters that will be run. This should be @@ -60,80 +70,119 @@ using DataContainerShPtr = std::shared_ptr; * @date Sep 28, 2011 * @version 1.0 */ -class SIMPLib_EXPORT DataContainerArray : public QObject +class SIMPLib_EXPORT DataContainerArray : public QObject, public IDataStructureContainerNode { Q_OBJECT // clang-format off - PYB11_CREATE_BINDINGS(DataContainerArray) - - PYB11_METHOD(void addDataContainer ARGS data_container) - //PYB11_METHOD(DataContainer::Pointer getDataContainer ARGS name) - PYB11_METHOD(bool doesDataContainerExist ARGS name) - PYB11_METHOD(DataContainer::Pointer removeDataContainer ARGS name) - PYB11_METHOD(bool renameDataContainer ARGS oldName newName) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(DataContainerArray) + PYB11_SHARED_POINTERS(DataContainerArray) + PYB11_STATIC_NEW_MACRO(DataContainerArray) + PYB11_METHOD(bool addOrReplaceDataContainer ARGS DataContainer) + PYB11_METHOD(bool insertOrAssign ARGS DataContainer) + PYB11_METHOD(DataContainer::Pointer getDataContainer OVERLOAD const.QString.&,Name CONST_METHOD) + PYB11_METHOD(DataContainer::Pointer getDataContainer OVERLOAD const.DataArrayPath.&,Path CONST_METHOD) + PYB11_METHOD(bool doesDataContainerExist OVERLOAD const.QString.&,Name CONST_METHOD) + PYB11_METHOD(bool doesDataContainerExist OVERLOAD const.DataArrayPath.&,Path CONST_METHOD) + PYB11_METHOD(DataContainer::Pointer removeDataContainer ARGS Name) + PYB11_METHOD(bool renameDataContainer OVERLOAD const.QString.&,OldName const.QString.&,NewName) + PYB11_METHOD(bool renameDataContainer OVERLOAD const.DataArrayPath.&,OldPath const.DataArrayPath.&,NewPath ) PYB11_METHOD(void clearDataContainers) - //PYB11_METHOD(XXXX getDataContainerNames) PYB11_METHOD(int getNumDataContainers) - PYB11_METHOD(void duplicateDataContainer ARGS oldName, newName) - - PYB11_METHOD(AttributeMatrix::Pointer getAttributeMatrix ARGS dataArrayPath) - PYB11_METHOD(bool doesAttributeMatrixExist ARGS dataArrayPath) - - PYB11_METHOD(bool doesAttributeArrayExist ARGS dataArrayPath) + PYB11_METHOD(void duplicateDataContainer ARGS OldName NewName) + PYB11_METHOD(AttributeMatrix::Pointer getAttributeMatrix ARGS DataArrayPath) + PYB11_METHOD(bool doesAttributeMatrixExist ARGS DataArrayPath) + PYB11_METHOD(bool doesAttributeArrayExist ARGS DataArrayPath) + PYB11_CUSTOM() + PYB11_END_BINDINGS() + // End Python bindings declarations // clang-format on public: - SIMPL_SHARED_POINTERS(DataContainerArray) - SIMPL_STATIC_NEW_MACRO(DataContainerArray) - SIMPL_TYPE_MACRO(DataContainerArray) + using Self = DataContainerArray; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for DataContainerArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for DataContainerArray + */ + static QString ClassName(); + + using Container = ChildCollection; + using MontageCollection = NamedCollection; ~DataContainerArray() override; + /** + * @brief Creates and returns an empty DataArrayPath + * @return + */ + DataArrayPath getDataArrayPath() const override; + /** * @brief */ - virtual void addDataContainer(DataContainerShPtr f); + bool addOrReplaceDataContainer(const DataContainerShPtr& f) + { + return insertOrAssign(f); + } /** * @brief getDataContainer * @param path Uses the DataContainerName from the DataArrayPath to return a data container * @return */ - virtual DataContainerShPtr getDataContainer(const DataArrayPath& path); + virtual DataContainerShPtr getDataContainer(const DataArrayPath& path) const; /** * @brief getDataContainer * @param name * @return */ - virtual DataContainerShPtr getDataContainer(const QString& name); + virtual DataContainerShPtr getDataContainer(const QString& name) const; /** * @brief getDataContainers * @return */ - QList& getDataContainers(); + Container getDataContainers() const; /** * @brief Returns if a DataContainer with the give name is in the array * @param name The name of the DataContiner to find * @return */ - virtual bool doesDataContainerExist(const QString& name); + virtual bool doesDataContainerExist(const QString& name) const; + + /** + * @brief doesDataContainerExist + * @param dap + * @return + */ + virtual bool doesDataContainerExist(const DataArrayPath& dap) const; /** * @brief DataContainerArray::doesAttributeMatrixExist * @param path * @return */ - virtual bool doesAttributeMatrixExist(const DataArrayPath& path); + virtual bool doesAttributeMatrixExist(const DataArrayPath& path) const; /** * @brief doesAttributeArrayExist * @param path * @return */ - virtual bool doesAttributeArrayExist(const DataArrayPath& path); + virtual bool doesAttributeArrayExist(const DataArrayPath& path) const; /** * @brief @@ -148,6 +197,14 @@ class SIMPLib_EXPORT DataContainerArray : public QObject */ bool renameDataContainer(const QString& oldName, const QString& newName); + /** + * @brief renameDataContainer + * @param oldName + * @param newName + * @return + */ + bool renameDataContainer(const DataArrayPath& oldName, const DataArrayPath& newName); + /** * @brief Removes all DataContainers from this DataContainerArray */ @@ -157,13 +214,13 @@ class SIMPLib_EXPORT DataContainerArray : public QObject * @brief getDataContainerNames * @return */ - QList getDataContainerNames(); + NameList getDataContainerNames() const; /** * @brief Returns the number of DataContainers * @return */ - virtual int getNumDataContainers(); + virtual int getNumDataContainers() const; /** * @brief duplicateDataContainer @@ -178,13 +235,13 @@ class SIMPLib_EXPORT DataContainerArray : public QObject * @param path * @return */ - virtual AttributeMatrix::Pointer getAttributeMatrix(const DataArrayPath& path); + virtual AttributeMatrix::Pointer getAttributeMatrix(const DataArrayPath& path) const; /** * @brief printDataContainerNames * @param out */ - virtual void printDataContainerNames(QTextStream& out); + virtual void printDataContainerNames(QTextStream& out) const; /** * @brief Reads desired the DataContainers from HDF5 file @@ -213,536 +270,417 @@ class SIMPLib_EXPORT DataContainerArray : public QObject * @param name * @return */ - IDataContainerBundle::Pointer getDataContainerBundle(const QString& name); + IDataContainerBundle::Pointer getDataContainerBundle(const QString& name) const; - template typename BundleType::Pointer getDataContainerBundleAs(const QString& name) + template + typename BundleType::Pointer getDataContainerBundleAs(const QString& name) const { typename BundleType::Pointer dcb = std::dynamic_pointer_cast(getDataContainerBundle(name)); return dcb; } - /** - * @brief addDataContainerBundle - * @param dataContainer - */ - void addDataContainerBundle(IDataContainerBundle::Pointer dataContainerBundle); - - /** - * @brief removeDataContainerBundle - * @param name - * @return - */ - int removeDataContainerBundle(const QString& name); - - /** - * @brief renameDataContainerBundle - * @param oldName - * @param newName - */ - bool renameDataContainerBundle(const QString& oldName, const QString& newName); - - /** - * @brief removeDataContainerFromBundle - * @param name - */ - void removeDataContainerFromBundles(const QString& name); - - /** - * @brief renameDataArrayPaths - * @param renamePaths - */ - void renameDataArrayPaths(DataArrayPath::RenameContainer renamePaths); - - /** - * @brief getPrereqDataContainer - * @param name - * @param createIfNotExists - * @return - */ - template - DataContainerShPtr getPrereqDataContainer(Filter* filter, const QString& name, bool createIfNotExists = false) - { - DataContainerShPtr dc = getDataContainer(name); - if(nullptr == dc.get() && !createIfNotExists) - { - if (filter) - { - filter->setErrorCondition(-999); - QString ss = "The DataContainer Object with the specific name '" + name + "' was not available."; - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dc; - } - - if(nullptr != dc && createIfNotExists) - { - DataContainerShPtr dataContainer = DataContainer::New(name); // Create a new Data Container - addDataContainer(dataContainer); // Put the new DataContainer into the array - return dataContainer; // Return the wrapped pointer - } - // The DataContainer we asked for was present and NON Null so return that. - return dc; - } - - /** - * @brief This function will create a new DataContainer of type - * @param dataContainerName The name of the DataContainer. Must not be empty or this method will ASSERT() - * @return Valid DataContainer Object UNLESS the DataContainer with the given name already exists or the - * dataContainerName is empty in which case a Null DataContainer will be returned. - */ - template - DataContainerShPtr createNonPrereqDataContainer(Filter* filter, const QString& dataContainerName) - { - if(dataContainerName.isEmpty()) - { - if (filter) - { - filter->setErrorCondition(-887); - QString ss = QObject::tr("The DataContainer Object must have a name to be created."); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - return DataContainer::NullPointer(); - } - } + /** + * @brief addDataContainerBundle + * @param dataContainer + */ + void addDataContainerBundle(IDataContainerBundle::Pointer dataContainerBundle); - if (dataContainerName.contains('/')) - { - if (filter) - { - filter->setErrorCondition(-888); - QString ss = QObject::tr("The DataContainer Object has forward slashes in its name."); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - return DataContainer::NullPointer(); - } - } + /** + * @brief removeDataContainerBundle + * @param name + * @return + */ + int removeDataContainerBundle(const QString& name); - if(doesDataContainerExist(dataContainerName)) - { - if (filter) - { - filter->setErrorCondition(-889); - QString ss = QObject::tr("The DataContainer Object with the specific name '%1' already exists.").arg(dataContainerName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - return DataContainer::NullPointer(); - } - } - DataContainerShPtr dataContainer = DataContainer::New(dataContainerName); - addDataContainer(dataContainer); - return dataContainer; - } + /** + * @brief renameDataContainerBundle + * @param oldName + * @param newName + */ + bool renameDataContainerBundle(const QString& oldName, const QString& newName); + /** + * @brief removeDataContainerFromBundle + * @param name + */ + void removeDataContainerFromBundles(const QString& name); - /** - * @brief getPrereqGeometryFromDataContainer Returns an IGeometry object of the templated type - * if it is available for the given DataContainer - * @param filter - * @param dcName - * @return - */ - template - typename GeometryType::Pointer getPrereqGeometryFromDataContainer(Filter* filter, const QString& dcName) - { - typename GeometryType::Pointer geom = GeometryType::NullPointer(); - DataContainerShPtr dc = getPrereqDataContainer(filter, dcName, false); - if(nullptr == dc) { return geom; } + /** + * @brief Returns a copy of the Montage collection. + * @return + */ + MontageCollection getMontageCollection() const; - return dc->getPrereqGeometry(filter); - } + /** + * @brief Attempts to add the given montage to the collection. + * This will fail if a montage by the same name already exists in the collection. + * Returns true if it succeded. Returns false otherwise. + * @param montage + * @return + */ + bool addMontage(const AbstractMontageShPtr& montage); + /** + * @brief Adds the given montage to the collection if no montages of the same name exist yet. + * Otherwise, the current montage is replaced with the one provided. + * @param montage + */ + void addOrReplaceMontage(const AbstractMontageShPtr& montage); - /** - * @brief getPrereqAttributeMatrixFromPath This function will return an AttributeMatrix if it is availabe - * at the path - * @param filter An AbstractFilter or subclass where error messages and error codes can be sent - * @param path The DataArrayPath object that has the path to the AttributeMatrix - * @param err The error code to display to the user - * @return - */ - template - AttributeMatrix::Pointer getPrereqAttributeMatrixFromPath(Filter* filter, const DataArrayPath& path, int err) - { - // First try to get the Parent DataContainer. If an error occurs the error message will have been set - // so just return a nullptr shared pointer - DataContainerShPtr dc = getPrereqDataContainer(filter, path.getDataContainerName(), false); - if(nullptr == dc) { return AttributeMatrix::NullPointer(); } - - // Now just return what ever the DataContainer gives us. if the AttributeMatrix was not available then an - // error message and code will have been set into the "filter" object if that object was non-null itself. - return dc->getPrereqAttributeMatrix(filter, path.getAttributeMatrixName(), err); - } + /** + * @brief Removes any montage of the given name from the collection. + * @param name + */ + void removeMontage(const QString& name); - /** - * @brief getPrereqArrayFromPath - * @param filter Instance of an AbstractFilter. Can be nullptr - * @param path The path to the IDataArray - * @param cDims The component dimensions of the IDataArray subclass - * @return Valid or nullptr shared pointer based on availability of the array - */ - template - typename ArrayType::Pointer getPrereqArrayFromPath(Filter* filter, const DataArrayPath& path, QVector cDims) - { + /** + * @brief Finds and returns a shared pointer to a montage with the given name. + * If none are found, this returns nullptr. + * @param name + * @return + */ + AbstractMontageShPtr getMontage(const QString& name) const; - QString ss; - typename ArrayType::Pointer dataArray = ArrayType::NullPointer(); + /** + * @brief Returns a list of names for all montages in the collection. + * @return + */ + QStringList getMontageNames() const; - if(path.isEmpty()) - { - if(filter) - { - filter->setErrorCondition(-80000); - ss = QObject::tr("DataContainerArray::getPrereqArrayFromPath Error at line %1. The DataArrayPath object was empty").arg(__LINE__); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; - } + /** + * @brief createNonPrereqGridMontage + * @param filter + * @param montageName + * @param size + * @param dcNames + * @param collectionType + * @return + */ + GridMontageShPtr createNonPrereqGridMontage(AbstractFilter* filter, const QString& montageName, SizeVec3Type size, const QStringList& dcNames = QStringList(), + GridMontage::CollectionMethod collectionMethod = GridMontage::CollectionMethod::CombOrder); - if(!path.isValid()) - { - if(filter) - { - filter->setErrorCondition(-80001); - ss = QObject::tr("DataContainerArray::getPrereqArrayFromPath Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2").arg(__LINE__).arg(path.serialize()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; - } + /** + * @brief renameDataArrayPaths + * @param renamePaths + */ + void renameDataArrayPaths(DataArrayPath::RenameContainer renamePaths); - QString dcName = path.getDataContainerName(); - QString amName = path.getAttributeMatrixName(); - QString daName = path.getDataArrayName(); + DataContainerShPtr getPrereqDataContainer(AbstractFilter* filter, const DataArrayPath& dap, bool createIfNotExists = false); + /** + * @brief getPrereqMontage + * @param filter + * @param name + */ + AbstractMontageShPtr getPrereqMontage(AbstractFilter* filter, const QString& name); - DataContainerShPtr dc = getDataContainer(dcName); - if(nullptr == dc.get()) - { - if(filter) - { - filter->setErrorCondition(-80002); - ss = QObject::tr("The DataContainer '%1' was not found in the DataContainerArray").arg(dcName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; - } + /** + * @brief getPrereqDataContainer + * @param name + * @param createIfNotExists + * @return + */ + DataContainerShPtr getPrereqDataContainer(AbstractFilter* filter, const QString& name, bool createIfNotExists = false); - AttributeMatrix::Pointer attrMat = dc->getAttributeMatrix(amName); - if(nullptr == attrMat.get()) - { - if(filter) - { - filter->setErrorCondition(-80003); - ss = QObject::tr("The AttributeMatrix '%1' was not found in the DataContainer '%2'").arg(amName).arg(dcName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; - } + /** + * @brief createNonPrereqDataContainer + * @param filter + * @param dap + * @param id + * @return + */ + DataContainerShPtr createNonPrereqDataContainer(AbstractFilter* filter, const DataArrayPath& dap, RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID); - dataArray = attrMat->getPrereqArray(filter, daName, -80002, cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ - return dataArray; - } + /** + * @brief This function will create a new DataContainer of type + * @param dataContainerName The name of the DataContainer. Must not be empty or this method will ASSERT() + * @return Valid DataContainer Object UNLESS the DataContainer with the given name already exists or the + * dataContainerName is empty in which case a Null DataContainer will be returned. + */ + DataContainerShPtr createNonPrereqDataContainer(AbstractFilter* filter, const QString& dataContainerName, RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID); - /** - * @brief getPrereqIDataArrayFromPath - * @param filter - * @param path - * @return - */ - template - typename ArrayType::Pointer getPrereqIDataArrayFromPath(Filter* filter, const DataArrayPath& path) + /** + * @brief getPrereqGeometryFromDataContainer Returns an IGeometry object of the templated type + * if it is available for the given DataContainer + * @param filter + * @param dcName + * @return + */ + template + typename GeometryType::Pointer getPrereqGeometryFromDataContainer(AbstractFilter* filter, const QString& dcName) + { + typename GeometryType::Pointer geom = GeometryType::NullPointer(); + DataContainerShPtr dc = getPrereqDataContainer(filter, dcName, false); + if(nullptr == dc) { + return geom; + } - QString ss; - typename ArrayType::Pointer dataArray = ArrayType::NullPointer(); + return dc->getPrereqGeometry(filter); + } - if(path.isEmpty()) - { - if(filter) - { - filter->setErrorCondition(-90000); - ss = QObject::tr("DataContainerArray::getPrereqIDataArrayFromPath Error at line %1. The DataArrayPath object was empty").arg(__LINE__); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; - } + /** + * @brief getPrereqGeometryFromDataContainer Returns an IGeometry object of the templated type + * if it is available for the given DataContainer + * @param filter + * @param path + * @return + */ + template + typename GeometryType::Pointer getPrereqGeometryFromDataContainer(AbstractFilter* filter, const DataArrayPath& path) + { + typename GeometryType::Pointer geom = GeometryType::NullPointer(); + DataContainerShPtr dc = getPrereqDataContainer(filter, path.getDataContainerName(), false); + if(nullptr == dc) + { + return geom; + } - if(!path.isValid()) - { - if(filter) - { - filter->setErrorCondition(-90001); - ss = QObject::tr("DataContainerArray::getPrereqIDataArrayFromPath Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2").arg(__LINE__).arg(path.serialize()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; - } + return dc->getPrereqGeometry(filter); + } - QString dcName = path.getDataContainerName(); - QString amName = path.getAttributeMatrixName(); - QString daName = path.getDataArrayName(); + /** + * @brief getPrereqAttributeMatrixFromPath This function will return an AttributeMatrix if it is availabe + * at the path + * @param filter An AbstractFilter or subclass where error messages and error codes can be sent + * @param path The DataArrayPath object that has the path to the AttributeMatrix + * @param err The error code to display to the user + * @return + */ + AttributeMatrix::Pointer getPrereqAttributeMatrixFromPath(AbstractFilter* filter, const DataArrayPath& path, int err); + /** + * @brief getPrereqArrayFromPath + * @param filter Instance of an AbstractFilter. Can be nullptr + * @param path The path to the IDataArray + * @param cDims The component dimensions of the IDataArray subclass + * @return Valid or nullptr shared pointer based on availability of the array + */ + template + typename ArrayType::Pointer getPrereqArrayFromPath(AbstractFilter* filter, const DataArrayPath& path, const std::vector& cDims = {}) const + { + QString ss; + typename ArrayType::Pointer dataArray = ArrayType::NullPointer(); - DataContainerShPtr dc = getDataContainer(dcName); - if(nullptr == dc.get()) + if(path.isEmpty()) + { + if(filter) { - if(filter) - { - filter->setErrorCondition(-999); - ss = QObject::tr("The DataContainer '%1' was not found in the DataContainerArray").arg(dcName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; + ss = QObject::tr("DataContainerArray::getPrereqArrayFromPath Error at line %1. The DataArrayPath object was empty").arg(__LINE__); + filter->setErrorCondition(-80000, ss); } + return dataArray; + } - AttributeMatrix::Pointer attrMat = dc->getAttributeMatrix(amName); - if(nullptr == attrMat.get()) + if(!path.isValid()) + { + if(filter) { - if(filter) - { - filter->setErrorCondition(-307020); - ss = QObject::tr("The AttributeMatrix '%1' was not found in the DataContainer '%2'").arg(amName).arg(dcName); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; + ss = QObject::tr("DataContainerArray::getPrereqArrayFromPath Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2") + .arg(__LINE__) + .arg(path.serialize()); + filter->setErrorCondition(-80001, ss); } - - dataArray = attrMat->getPrereqIDataArray(filter, daName, -90002); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ return dataArray; } - /** - * @brief createNonPrereqArray This method will create a new DataArray in the AttributeMatrix. The conditions for this - * method to work properly include: a valid DataArrayPath is supplied, the name of the attribute array is not empty, - * and an array with the same name cannot already exist - * @param filter The instance of the filter the filter that is requesting the new array - * @param attributeArrayName The name of the AttributeArray to create - * @param initValue The initial value of all the elements of the array - * @param size The number of tuples in the Array - * @param dims The dimensions of the components of the AttributeArray - * @return A Shared Pointer to the newly created array - */ - template - typename ArrayType::Pointer createNonPrereqArrayFromPath(Filter* filter, - const DataArrayPath& path, - T initValue, - QVector compDims, - const QString& property = "") + QString dcName = path.getDataContainerName(); + QString amName = path.getAttributeMatrixName(); + QString daName = path.getDataArrayName(); + + DataContainerShPtr dc = getDataContainer(dcName); + if(nullptr == dc.get()) { - typename ArrayType::Pointer dataArray = ArrayType::NullPointer(); - QString ss; - if(!path.isValid()) + if(filter) { - if(filter) - { - filter->setErrorCondition(-80010); - ss = QObject::tr("Property '%1': The DataArrayPath is invalid because one of the elements was empty.\n DataContainer: %2\n AttributeMatrix: %3\n DataArray: %4").arg(property).arg(path.getDataContainerName()).arg(path.getAttributeMatrixName()).arg(path.getDataArrayName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; + ss = QObject::tr("The DataContainer '%1' was not found in the DataContainerArray").arg(dcName); + filter->setErrorCondition(-80002, ss); } + return dataArray; + } - if (path.getDataContainerName().contains('/')) + AttributeMatrix::Pointer attrMat = dc->getAttributeMatrix(amName); + if(nullptr == attrMat.get()) + { + if(filter) { - if (filter) - { - filter->setErrorCondition(-80005); - ss = QObject::tr("The DataContainer '%1' has forward slashes in its name").arg(path.getDataContainerName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; + ss = QObject::tr("The AttributeMatrix '%1' was not found in the DataContainer '%2'").arg(amName).arg(dcName); + filter->setErrorCondition(-80003, ss); } + return dataArray; + } - if (path.getAttributeMatrixName().contains('/')) - { - if (filter) - { - filter->setErrorCondition(-80006); - ss = QObject::tr("The AttributeMatrix '%1' has forward slashes in its name").arg(path.getAttributeMatrixName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; - } + dataArray = attrMat->getPrereqArray(filter, daName, -80002, cDims); + return dataArray; + } - if (path.getDataArrayName().contains('/')) - { - if (filter) - { - filter->setErrorCondition(-80007); - ss = QObject::tr("The DataArray '%1' has forward slashes in its name").arg(path.getDataArrayName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; - } + /** + * @brief getPrereqIDataArrayFromPath + * @param filter + * @param path + * @return + */ + IDataArray::Pointer getPrereqIDataArrayFromPath(AbstractFilter* filter, const DataArrayPath& path) const; - if (path.getDataContainerName().contains('/')) + /** + * @brief createNonPrereqArray This method will create a new DataArray in the AttributeMatrix. The conditions for this + * method to work properly include: a valid DataArrayPath is supplied, the name of the attribute array is not empty, + * and an array with the same name cannot already exist + * @param filter The instance of the filter the filter that is requesting the new array + * @param attributeArrayName The name of the AttributeArray to create + * @param initValue The initial value of all the elements of the array + * @param size The number of tuples in the Array + * @param dims The dimensions of the components of the AttributeArray + * @return A Shared Pointer to the newly created array + */ + template + typename ArrayType::Pointer createNonPrereqArrayFromPath(AbstractFilter* filter, const DataArrayPath& path, typename ArrayType::value_type initValue, const std::vector& compDims, + const QString& property = "", RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID) + { + typename ArrayType::Pointer dataArray = ArrayType::NullPointer(); + QString ss; + if(!path.isValid()) + { + if(filter) { - if (filter) - { - filter->setErrorCondition(-80004); - ss = QObject::tr("The DataContainer '%1' has forward slashes in its name").arg(path.getDataContainerName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; + ss = QObject::tr("Property '%1': The DataArrayPath is invalid because one of the elements was empty.\n DataContainer: %2\n AttributeMatrix: %3\n DataArray: %4") + .arg(property) + .arg(path.getDataContainerName()) + .arg(path.getAttributeMatrixName()) + .arg(path.getDataArrayName()); + filter->setErrorCondition(-80010, ss); } + return dataArray; + } - DataContainerShPtr dc = getDataContainer(path.getDataContainerName()); - if(nullptr == dc.get()) + if(path.getDataContainerName().contains('/')) + { + if(filter) { - if(filter) - { - filter->setErrorCondition(-80002); - ss = QObject::tr("The DataContainer '%1' was not found in the DataContainerArray").arg(path.getDataContainerName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; + ss = QObject::tr("The DataContainer '%1' has forward slashes in its name").arg(path.getDataContainerName()); + filter->setErrorCondition(-80005, ss); } + return dataArray; + } - AttributeMatrix::Pointer attrMat = dc->getAttributeMatrix(path.getAttributeMatrixName()); - if(nullptr == attrMat.get()) + if(path.getAttributeMatrixName().contains('/')) + { + if(filter) { - if(filter) - { - filter->setErrorCondition(-80003); - ss = QObject::tr("The AttributeMatrix '%1' was not found in the DataContainer '%2'").arg(path.getAttributeMatrixName()).arg(path.getDataContainerName()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - } - return dataArray; + ss = QObject::tr("The AttributeMatrix '%1' has forward slashes in its name").arg(path.getAttributeMatrixName()); + filter->setErrorCondition(-80006, ss); } - - // If something goes wrong at this point the error message will be directly set in the 'filter' object so we just - // simply return what ever is given to us. - dataArray = attrMat->createNonPrereqArray(filter, path.getDataArrayName(), initValue, compDims); return dataArray; } - /** - * @brief validateNumberOfTuples This method will validate that all of the DataArray - * paths supplied are valid, return non-nullptr DataArray pointers, and that all have the - * same number of tuples. It will return false if and any of the checks fail, or - * if the QVector of input paths has 0 or 1 element. - * @param filter The filter calling the validation - * @param paths The paths that should be checked - * @return bool Validation check - */ - template - bool validateNumberOfTuples(Filter* filter, const QVector& paths) + if(path.getDataArrayName().contains('/')) { - if (paths.size() <= 1) { return false; } - QVector dataArrays; - bool valid = true; - QString ss; - if (!paths.at(0).isValid() && nullptr != filter) + if(filter) { - filter->setErrorCondition(-10000); - ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2").arg(__LINE__).arg(paths.at(0).serialize()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - valid = false; - return valid; - } - IDataArray::Pointer array0 = getPrereqIDataArrayFromPath(filter, paths.at(0)); - if (nullptr == array0.get() && nullptr != filter) - { - filter->setErrorCondition(-10100); - ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArray object was not available. The path is %2").arg(__LINE__).arg(paths.at(0).serialize()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - valid = false; - return valid; + ss = QObject::tr("The DataArray '%1' has forward slashes in its name").arg(path.getDataArrayName()); + filter->setErrorCondition(-80007, ss); } + return dataArray; + } - dataArrays.push_back(array0); - for (int32_t i = 1; i < paths.size(); i++) - { - if (!paths.at(i).isValid() && nullptr != filter) - { - filter->setErrorCondition(-10000); - ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2").arg(__LINE__).arg(paths.at(i).serialize()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - valid = false; - return valid; - } - IDataArray::Pointer nextArray = getPrereqIDataArrayFromPath(filter, paths.at(i)); - if (nullptr == nextArray.get() && nullptr != filter) - { - filter->setErrorCondition(-10100); - ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArray object was not available. The path is %2").arg(__LINE__).arg(paths.at(i).serialize()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - valid = false; - return valid; - } - - dataArrays.push_back(nextArray); - } - size_t numTuples = dataArrays[0]->getNumberOfTuples(); - for (int32_t i = 1; i < dataArrays.size(); i++) + if(path.getDataContainerName().contains('/')) + { + if(filter) { - if (numTuples != dataArrays[i]->getNumberOfTuples() && nullptr != filter) - { - filter->setErrorCondition(-10200); - ss = QObject::tr("The number of tuples for the DataArray %1 is %2 and for DataArray %3 is %4. The number of tuples must match.") - .arg(dataArrays[0]->getName()).arg(dataArrays[0]->getNumberOfTuples()).arg(dataArrays[i]->getName()).arg(dataArrays[i]->getNumberOfTuples()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - valid = false; - } + ss = QObject::tr("The DataContainer '%1' has forward slashes in its name").arg(path.getDataContainerName()); + filter->setErrorCondition(-80004, ss); } - return valid; + return dataArray; } - /** - * @brief validateNumberOfTuples This method will validate that all of the DataArray - * objects supplied are non-nullptr and that all are have the same number of tuples. - * It will return false if and any of the checks fail, or - * if the QVector of input DataArray objects has 0 or 1 element. - * @param filter The filter calling the validation - * @param paths The paths that should be checked - * @return bool Validation check - */ - template - bool validateNumberOfTuples(Filter* filter, QVector dataArrays) + DataContainerShPtr dc = getDataContainer(path.getDataContainerName()); + if(nullptr == dc.get()) { - if (dataArrays.size() <= 1) { return false; } - bool valid = true; - QString ss; - for (const auto & dataArray : dataArrays) + if(filter) { - if (nullptr == dataArray && nullptr != filter) - { - filter->setErrorCondition(-10100); - ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArray object was not available").arg(__LINE__); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - valid = false; - } + ss = QObject::tr("The DataContainer '%1' was not found in the DataContainerArray").arg(path.getDataContainerName()); + filter->setErrorCondition(-80002, ss); } - size_t numTuples = dataArrays[0]->getNumberOfTuples(); - for (int32_t i = 1; i < dataArrays.size(); i++) + return dataArray; + } + + AttributeMatrix::Pointer attrMat = dc->getAttributeMatrix(path.getAttributeMatrixName()); + if(nullptr == attrMat.get()) + { + if(filter) { - if (numTuples != dataArrays[i]->getNumberOfTuples() && nullptr != filter) - { - filter->setErrorCondition(-10200); - ss = QObject::tr("The number of tuples for the DataArray %1 is %2 and for DataArray %3 is %4. The number of tuples must match.") - .arg(dataArrays[i - 1]->getName()).arg(dataArrays[i - 1]->getNumberOfTuples()).arg(dataArrays[i]->getName()).arg(dataArrays[i]->getNumberOfTuples()); - filter->notifyErrorMessage(filter->getHumanLabel(), ss, filter->getErrorCondition()); - valid = false; - } + ss = QObject::tr("The AttributeMatrix '%1' was not found in the DataContainer '%2'").arg(path.getAttributeMatrixName()).arg(path.getDataContainerName()); + filter->setErrorCondition(-80003, ss); } - return valid; + return dataArray; } - /** - * @brief deepCopy - * @param dca - * @return - */ - DataContainerArray::Pointer deepCopy(bool forceNoAllocate = false); - - protected: - DataContainerArray(); - - private: - QList m_Array; - QMap m_DataContainerBundles; - - public: - DataContainerArray(const DataContainerArray&) = delete; // Copy Constructor Not Implemented - DataContainerArray(DataContainerArray&&) = delete; // Move Constructor Not Implemented - DataContainerArray& operator=(const DataContainerArray&) = delete; // Copy Assignment Not Implemented - DataContainerArray& operator=(DataContainerArray&&) = delete; // Move Assignment Not Implemented -}; + // If something goes wrong at this point the error message will be directly set in the 'filter' object so we just + // simply return what ever is given to us. + dataArray = attrMat->createNonPrereqArray(filter, path.getDataArrayName(), initValue, compDims, id); + return dataArray; + } + /** + * @brief validateNumberOfTuples This method will validate that all of the DataArray + * paths supplied are valid, return non-nullptr DataArray pointers, and that all have the + * same number of tuples. It will return false if and any of the checks fail, or + * if the QVector of input paths has 0 or 1 element. + * @param filter The filter calling the validation + * @param paths The paths that should be checked + * @return bool Validation check + */ + bool validateNumberOfTuples(AbstractFilter* filter, const QVector& paths) const; + + /** + * @brief validateNumberOfTuples This method will validate that all of the DataArray + * paths supplied are valid, return non-nullptr DataArray pointers, and that all have the + * same number of tuples. It will return false if and any of the checks fail, or + * if the QVector of input paths has 0 or 1 element. + * @param filter The filter calling the validation + * @param paths The paths that should be checked + * @return bool Validation check + */ + bool validateNumberOfTuples(AbstractFilter* filter, const std::vector& paths) const; + /** + * @brief validateNumberOfTuples This method will validate that all of the DataArray + * objects supplied are non-nullptr and that all are have the same number of tuples. + * It will return false if and any of the checks fail, or + * if the QVector of input DataArray objects has 0 or 1 element. + * @param filter The filter calling the validation + * @param paths The paths that should be checked + * @return bool Validation check + */ + bool validateNumberOfTuples(AbstractFilter* filter, QVector dataArrays) const; + + /** + * @brief deepCopy + * @param dca + * @return + */ + DataContainerArray::Pointer deepCopy(bool forceNoAllocate = false) const; + +protected: + DataContainerArray(); + +private: + QMap m_DataContainerBundles; + MontageCollection m_MontageCollection; + + /** + * @brief setMontageTileFromDataContainerName + * @param row + * @param col + * @param depth + * @param dcName + */ + void setMontageTileFromDataContainerName(AbstractFilter* filter, size_t row, size_t col, size_t depth, const GridMontage::Pointer& montage, const QString& dcName); + +public: + DataContainerArray(const DataContainerArray&) = delete; // Copy Constructor Not Implemented + DataContainerArray(DataContainerArray&&) = delete; // Move Constructor Not Implemented + DataContainerArray& operator=(const DataContainerArray&) = delete; // Copy Assignment Not Implemented + DataContainerArray& operator=(DataContainerArray&&) = delete; // Move Assignment Not Implemented +}; +Q_DECLARE_METATYPE(DataContainerArray::Pointer); diff --git a/Source/SIMPLib/DataContainers/DataContainerArrayProxy.cpp b/Source/SIMPLib/DataContainers/DataContainerArrayProxy.cpp index 0af84df38b..bdc601a223 100644 --- a/Source/SIMPLib/DataContainers/DataContainerArrayProxy.cpp +++ b/Source/SIMPLib/DataContainers/DataContainerArrayProxy.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -37,6 +37,8 @@ #include +#include + #include "SIMPLib/DataArrays/IDataArray.h" #include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/DataContainers/DataArrayPath.h" @@ -69,10 +71,10 @@ DataContainerArrayProxy::DataContainerArrayProxy(DataContainerArray* dca) return; } - QList containers = dca->getDataContainers(); - for(const auto& container : containers) + DataContainerArray::Container containers = dca->getDataContainers(); + for(DataContainer::Pointer dataContainer : containers) // Loop on each Data Container { - IGeometry::Pointer geo = container->getGeometry(); + IGeometry::Pointer geo = dataContainer->getGeometry(); IGeometry::Type dcType; if(geo != IGeometry::NullPointer()) { @@ -82,25 +84,21 @@ DataContainerArrayProxy::DataContainerArrayProxy(DataContainerArray* dca) { dcType = IGeometry::Type::Unknown; } - DataContainerProxy dcProxy(container->getName(), Qt::Checked, dcType); // Create a new DataContainerProxy + DataContainerProxy dcProxy(dataContainer->getName(), Qt::Checked, dcType); // Create a new DataContainerProxy // Now loop over each AttributeMatrix in the data container that was selected - DataContainer::AttributeMatrixMap_t attrMats = container->getAttributeMatrices(); - QMapIterator iter(attrMats); - while(iter.hasNext()) + DataContainer::Container_t attrMats = dataContainer->getAttributeMatrices(); + for(auto iter = attrMats.begin(); iter != attrMats.end(); ++iter) { - iter.next(); - QString amName = iter.key(); - AttributeMatrix::Pointer attrMat = iter.value(); + AttributeMatrix::Pointer attrMat = *iter; + QString amName = attrMat->getName(); AttributeMatrixProxy amProxy(amName, Qt::Checked, attrMat->getType()); - QList attrArrayNames = attrMat->getAttributeArrayNames(); - QListIterator attrArrayNamesIter(attrArrayNames); - while(attrArrayNamesIter.hasNext()) + for(IDataArray::Pointer attrArray : attrMat->getAttributeArrays()) { - QString aaName = attrArrayNamesIter.next(); - QString daPath = container->getName() + "/" + amName + "/"; - IDataArray::Pointer attrArray = attrMat->getAttributeArray(aaName); + QString aaName = attrArray->getName(); + QString daPath = dataContainer->getName() + "/" + amName + "/"; + DataArrayProxy daProxy(daPath, aaName, Qt::Checked, attrArray->getTypeAsString(), attrArray->getClassVersion()); daProxy.setCompDims(attrArray->getComponentDimensions()); daProxy.setTupleDims(attrMat->getTupleDimensions()); @@ -522,7 +520,7 @@ QJsonArray DataContainerArrayProxy::writeMap(const QMap DataContainerArrayProxy::readMap(QJsonArray jsonArray) { QMap map; - for(const auto& val : jsonArray) + for(const auto val : jsonArray) { if(val.isObject()) { diff --git a/Source/SIMPLib/DataContainers/DataContainerArrayProxy.h b/Source/SIMPLib/DataContainers/DataContainerArrayProxy.h index d402e8bf94..dd01800f62 100644 --- a/Source/SIMPLib/DataContainers/DataContainerArrayProxy.h +++ b/Source/SIMPLib/DataContainers/DataContainerArrayProxy.h @@ -1,47 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include -#include #include #include -#include "SIMPLib/DataContainers/DataContainerProxy.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataContainers/DataContainerProxy.h" class DataContainerArray; @@ -50,10 +48,16 @@ class DataContainerArray; */ class SIMPLib_EXPORT DataContainerArrayProxy { - PYB11_CREATE_BINDINGS(DataContainerArrayProxy) + + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(DataContainerArrayProxy) PYB11_CREATION() PYB11_PROPERTY(StorageType DataContainers READ getDataContainers WRITE setDataContainers CONST_GET_OVERLOAD) PYB11_METHOD(DataContainerProxy.& getDataContainerProxy ARGS name RETURN_VALUE_POLICY py::return_value_policy::reference) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: using StorageType = QMap; diff --git a/Source/SIMPLib/DataContainers/DataContainerBundle.cpp b/Source/SIMPLib/DataContainers/DataContainerBundle.cpp index b30b0715b4..408f6c57a1 100644 --- a/Source/SIMPLib/DataContainers/DataContainerBundle.cpp +++ b/Source/SIMPLib/DataContainers/DataContainerBundle.cpp @@ -1,45 +1,49 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DataContainerBundle.h" -#include "H5Support/QH5Utilities.h" +#include + #include "H5Support/H5ScopedSentinel.h" +#include "H5Support/QH5Lite.h" +#include "H5Support/QH5Utilities.h" #include "SIMPLib/DataArrays/StringDataArray.h" #include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/DataContainers/DataContainer.h" // ----------------------------------------------------------------------------- // @@ -86,7 +90,7 @@ QVector DataContainerBundle::getDataContainerNames() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerBundle::addDataContainer(DataContainer::Pointer dc) +void DataContainerBundle::addOrReplaceDataContainer(DataContainer::Pointer dc) { m_DataContainers.append(dc); } @@ -191,7 +195,7 @@ QVector DataContainerBundle::findCommonDataArrayPaths(bool filter { DataArrayPath dc0Path = dc0Paths[i]; bool match = false; - foreach(DataArrayPath path, paths) + for(DataArrayPath path : paths) { // qDebug() << "Comparing " << dc0Path.serialize() << " TO " << path.serialize(); if(path.hasSameAttributeMatrix(dc0Path) && path.hasSameDataArray(dc0Path)) @@ -222,7 +226,7 @@ int DataContainerBundle::writeH5Data(hid_t groupId) { hid_t bundleId = QH5Utilities::createGroup(groupId, getName()); // This object will make sure the HDF5 Group id is closed when it goes out of scope. - H5GroupAutoCloser bundleIdClose(&bundleId); + H5GroupAutoCloser bundleIdClose(bundleId); size_t count = static_cast(m_DataContainers.size()); QStringList dcNameList; @@ -261,3 +265,45 @@ int DataContainerBundle::readH5Data(hid_t groupId) return err; } + +// ----------------------------------------------------------------------------- +DataContainerBundle::Pointer DataContainerBundle::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString DataContainerBundle::getNameOfClass() const +{ + return QString("DataContainerBundle"); +} + +// ----------------------------------------------------------------------------- +QString DataContainerBundle::ClassName() +{ + return QString("DataContainerBundle"); +} + +// ----------------------------------------------------------------------------- +void DataContainerBundle::setName(const QString& value) +{ + m_Name = value; +} + +// ----------------------------------------------------------------------------- +QString DataContainerBundle::getName() const +{ + return m_Name; +} + +// ----------------------------------------------------------------------------- +void DataContainerBundle::setMetaDataArrays(const QStringList& value) +{ + m_MetaDataArrays = value; +} + +// ----------------------------------------------------------------------------- +QStringList DataContainerBundle::getMetaDataArrays() const +{ + return m_MetaDataArrays; +} diff --git a/Source/SIMPLib/DataContainers/DataContainerBundle.h b/Source/SIMPLib/DataContainers/DataContainerBundle.h old mode 100755 new mode 100644 index 7ee508cda5..26bcd9648b --- a/Source/SIMPLib/DataContainers/DataContainerBundle.h +++ b/Source/SIMPLib/DataContainers/DataContainerBundle.h @@ -1,174 +1,203 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include -#include #include #include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataContainers/IDataContainerBundle.h" class SIMPLib_EXPORT DataContainerBundle : public IDataContainerBundle { - Q_OBJECT - public: - SIMPL_SHARED_POINTERS (DataContainerBundle) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DataContainerBundle, IDataContainerBundle) - - ~DataContainerBundle() override; - - /** - * @brief Creates a new DataContainerBundle - * @param name The Name of the Bundle - * @return - */ - static Pointer New(const QString& name) - { - Pointer sharedPtr (new DataContainerBundle); - sharedPtr->setName(name); - return sharedPtr; - } - - /** - * @brief GetMetaDataName - * @return Returns the name of the Meta Data AttributeMatrix name. This name should be used for any AttributeMatrix - * that is used in a DataContainer to hold the type of data that is used to group DataContainers into bundles. - */ - static QString GetMetaDataName(); - - /** - * @brief The name of this DataContainerBundle - */ - SIMPL_INSTANCE_STRING_PROPERTY_OVERRIDE(Name) - - /* - * @brief This is the list of array names that reside inside the "Meta Data" attribute matrix that are the - * pieces of data that define why the data containers were grouped into a bundle. For example, if you have a time - * series set of data where each Data Container is a step in "time" and there are several values for time: - * @li Time Value Real value of time - * @li Time Step Value Time Step value in the simulation - * @li Time Index The raw index of the data, i.e., this is the actual ordering that could also be used as then index - * into an array of data containers - */ - SIMPL_INSTANCE_PROPERTY(QStringList, MetaDataArrays) - - /** - * @brief Sets All the DataContainers for this bundle - * @param containers - */ - void setDataContainers(QVector& containers); - QVector getDataContainerNames() override; - - - /** - * @brief addDataContainer Adds a Data Container to the bundle - * @param dc - */ - void addDataContainer(DataContainer::Pointer dc) override; - - /** - * @brief removeDataContainer Removes a Data Container from the bundle by pointer - * @param dc - */ - void removeDataContainer(DataContainer::Pointer dc) override; - - /** - * @brief Removes a DataContainer by name from the bundle - * @param name - */ - void removeDataContainer(const QString& name) override; - - /** - * @brief Removes a Data Container by index - * @param i - */ - void removeDataContainer(qint32 i) override; - - /** - * @brief Returns the DataContainer at a given index - * @param index - * @return - */ - DataContainer::Pointer getDataContainer(qint32 index) override; - - /** - * @brief Returns the number of DataContainers held in the bundle - * @return - */ - qint32 count() override; - - /** - * @brief Removes all references to the DataContainers stored in the class. Count will = 0 - * after this operation - */ - void clear() override; - - /** - * @brief This function returns all the Data Arrays Path objects that all the - * DataContainers have in common with each other. - */ - QVector findCommonDataArrayPaths(bool filterMetaData = true); - - /** - * @brief writeH5Data Write this bundle out to an HDF5 File - * @param file_id The hdf5 file id or other group id where the bundle is going to be serialized to. - * @return - */ - int writeH5Data(hid_t groupId) override; - - /** - * @brief readH5Data Reads this bundle from an HDF5 file - * @param groupId - * @return - */ - int readH5Data(hid_t groupId) override; - - protected: - DataContainerBundle(); - - private: - QVector m_DataContainers; - QString m_MetaDataAMName; - - public: - DataContainerBundle(const DataContainerBundle&) = delete; // Copy Constructor Not Implemented - DataContainerBundle(DataContainerBundle&&) = delete; // Move Constructor Not Implemented - DataContainerBundle& operator=(const DataContainerBundle&) = delete; // Copy Assignment Not Implemented - DataContainerBundle& operator=(DataContainerBundle&&) = delete; // Move Assignment Not Implemented + Q_OBJECT +public: + using Self = DataContainerBundle; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for DataContainerBundle + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for DataContainerBundle + */ + static QString ClassName(); + + ~DataContainerBundle() override; + + /** + * @brief Creates a new DataContainerBundle + * @param name The Name of the Bundle + * @return + */ + static Pointer New(const QString& name) + { + Pointer sharedPtr(new DataContainerBundle); + sharedPtr->setName(name); + return sharedPtr; + } + + /** + * @brief GetMetaDataName + * @return Returns the name of the Meta Data AttributeMatrix name. This name should be used for any AttributeMatrix + * that is used in a DataContainer to hold the type of data that is used to group DataContainers into bundles. + */ + static QString GetMetaDataName(); + + /** + * @brief The name of this DataContainerBundle + */ + /** + * @brief Setter property for Name + */ + void setName(const QString& value) override; + /** + * @brief Getter property for Name + * @return Value of Name + */ + QString getName() const override; + + /* + * @brief This is the list of array names that reside inside the "Meta Data" attribute matrix that are the + * pieces of data that define why the data containers were grouped into a bundle. For example, if you have a time + * series set of data where each Data Container is a step in "time" and there are several values for time: + * @li Time Value Real value of time + * @li Time Step Value Time Step value in the simulation + * @li Time Index The raw index of the data, i.e., this is the actual ordering that could also be used as then index + * into an array of data containers + */ + /** + * @brief Setter property for MetaDataArrays + */ + void setMetaDataArrays(const QStringList& value); + /** + * @brief Getter property for MetaDataArrays + * @return Value of MetaDataArrays + */ + QStringList getMetaDataArrays() const; + + /** + * @brief Sets All the DataContainers for this bundle + * @param containers + */ + void setDataContainers(QVector& containers); + QVector getDataContainerNames() override; + + /** + * @brief addDataContainer Adds a Data Container to the bundle + * @param dc + */ + void addOrReplaceDataContainer(DataContainer::Pointer dc) override; + + /** + * @brief removeDataContainer Removes a Data Container from the bundle by pointer + * @param dc + */ + void removeDataContainer(DataContainer::Pointer dc) override; + + /** + * @brief Removes a DataContainer by name from the bundle + * @param name + */ + void removeDataContainer(const QString& name) override; + + /** + * @brief Removes a Data Container by index + * @param i + */ + void removeDataContainer(qint32 i) override; + + /** + * @brief Returns the DataContainer at a given index + * @param index + * @return + */ + DataContainer::Pointer getDataContainer(qint32 index) override; + + /** + * @brief Returns the number of DataContainers held in the bundle + * @return + */ + qint32 count() override; + + /** + * @brief Removes all references to the DataContainers stored in the class. Count will = 0 + * after this operation + */ + void clear() override; + + /** + * @brief This function returns all the Data Arrays Path objects that all the + * DataContainers have in common with each other. + */ + QVector findCommonDataArrayPaths(bool filterMetaData = true); + + /** + * @brief writeH5Data Write this bundle out to an HDF5 File + * @param file_id The hdf5 file id or other group id where the bundle is going to be serialized to. + * @return + */ + int writeH5Data(hid_t groupId) override; + + /** + * @brief readH5Data Reads this bundle from an HDF5 file + * @param groupId + * @return + */ + int readH5Data(hid_t groupId) override; + +protected: + DataContainerBundle(); + +private: + QString m_Name = {}; + QStringList m_MetaDataArrays = {}; + + QVector m_DataContainers; + QString m_MetaDataAMName; + +public: + DataContainerBundle(const DataContainerBundle&) = delete; // Copy Constructor Not Implemented + DataContainerBundle(DataContainerBundle&&) = delete; // Move Constructor Not Implemented + DataContainerBundle& operator=(const DataContainerBundle&) = delete; // Copy Assignment Not Implemented + DataContainerBundle& operator=(DataContainerBundle&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/DataContainers/DataContainerProxy.cpp b/Source/SIMPLib/DataContainers/DataContainerProxy.cpp index 8adc09fe58..345335d256 100644 --- a/Source/SIMPLib/DataContainers/DataContainerProxy.cpp +++ b/Source/SIMPLib/DataContainers/DataContainerProxy.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DataContainerProxy.h" @@ -47,7 +47,8 @@ DataContainerProxy::DataContainerProxy(const QString& dc_name, const uint8_t& re : m_Flag(read_dc) , m_Name(dc_name) , m_DCType(static_cast(dc_type)) -{} +{ +} // ----------------------------------------------------------------------------- // @@ -111,14 +112,14 @@ void DataContainerProxy::writeJson(QJsonObject& json) const // ----------------------------------------------------------------------------- bool DataContainerProxy::readJson(QJsonObject& json) { - if (json["Flag"].isDouble() && json["Name"].isString() && json["Type"].isDouble() && json["Attribute Matricies"].isArray()) + if(json["Flag"].isDouble() && json["Name"].isString() && json["Type"].isDouble() && json["Attribute Matricies"].isArray()) { - if (json["Flag"].toDouble() >= std::numeric_limits::min() && json["Flag"].toDouble() <= std::numeric_limits::max()) + if(json["Flag"].toDouble() >= std::numeric_limits::min() && json["Flag"].toDouble() <= std::numeric_limits::max()) { m_Flag = static_cast(json["Flag"].toDouble()); } m_Name = json["Name"].toString(); - if (json["Type"].toDouble() >= std::numeric_limits::min() && json["Type"].toDouble() <= std::numeric_limits::max()) + if(json["Type"].toDouble() >= std::numeric_limits::min() && json["Type"].toDouble() <= std::numeric_limits::max()) { m_DCType = static_cast(json["Type"].toDouble()); } @@ -149,9 +150,9 @@ QJsonArray DataContainerProxy::writeMap(const QMap DataContainerProxy::readMap(QJsonArray jsonArray) { QMap map; - foreach(QJsonValue val, jsonArray) + for(QJsonValue val : jsonArray) { - if (val.isObject()) + if(val.isObject()) { AttributeMatrixProxy am; QJsonObject obj = val.toObject(); @@ -167,48 +168,38 @@ QMap DataContainerProxy::readMap(QJsonArray jsonA // ----------------------------------------------------------------------------- DataContainerProxy::DCGeometryTypeFlag DataContainerProxy::GeometryTypeToFlag(IGeometry::Type geoType) { - switch (geoType) + switch(geoType) { - case IGeometry::Type::Any: - { - return Any_DCGeomType; - } - case IGeometry::Type::Edge: - { - return Edge_DCGeomType; - } - case IGeometry::Type::Image: - { - return Image_DCGeomType; - } - case IGeometry::Type::Quad: - { - return Quad_DCGeomType; - } - case IGeometry::Type::RectGrid: - { - return RectGrid_DCGeomType; - } - case IGeometry::Type::Tetrahedral: - { - return Tetrahedral_DCGeomType; - } - case IGeometry::Type::Triangle: - { - return Triangle_DCGeomType; - } - case IGeometry::Type::Vertex: - { - return Vertex_DCGeomType; - } - case IGeometry::Type::Hexahedral: - { - return Hexahedral_DCGeomType; - } - case IGeometry::Type::Unknown: - { - return Unknown_DCGeomType; - } + case IGeometry::Type::Any: { + return Any_DCGeomType; + } + case IGeometry::Type::Edge: { + return Edge_DCGeomType; + } + case IGeometry::Type::Image: { + return Image_DCGeomType; + } + case IGeometry::Type::Quad: { + return Quad_DCGeomType; + } + case IGeometry::Type::RectGrid: { + return RectGrid_DCGeomType; + } + case IGeometry::Type::Tetrahedral: { + return Tetrahedral_DCGeomType; + } + case IGeometry::Type::Triangle: { + return Triangle_DCGeomType; + } + case IGeometry::Type::Vertex: { + return Vertex_DCGeomType; + } + case IGeometry::Type::Hexahedral: { + return Hexahedral_DCGeomType; + } + case IGeometry::Type::Unknown: { + return Unknown_DCGeomType; + } } return Unknown_DCGeomType; @@ -225,7 +216,7 @@ void DataContainerProxy::setFlags(uint8_t flag, AttributeMatrixProxy::AMTypeFlag { AttributeMatrixProxy& amProxy = amIter.value(); AttributeMatrixProxy::AMTypeFlag amTypeFlag = AttributeMatrixProxy::AttributeMatrixTypeToFlag(static_cast(amProxy.getAMType())); - if ((amTypes & amTypeFlag) > 0 || amTypes == AttributeMatrixProxy::AMTypeFlag::Any_AMType) + if((amTypes & amTypeFlag) > 0 || amTypes == AttributeMatrixProxy::AMTypeFlag::Any_AMType) { amProxy.setFlags(flag, primitiveTypes, compDimsVector); } diff --git a/Source/SIMPLib/DataContainers/DataContainerProxy.h b/Source/SIMPLib/DataContainers/DataContainerProxy.h index 1461d4ce45..d8de0729c0 100644 --- a/Source/SIMPLib/DataContainers/DataContainerProxy.h +++ b/Source/SIMPLib/DataContainers/DataContainerProxy.h @@ -1,49 +1,48 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once #include #include -#include #include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataContainers/AttributeMatrixProxy.h" #include "SIMPLib/Geometry/IGeometry.h" -#include "SIMPLib/SIMPLib.h" /** * @brief The DataContainerProxy class @@ -51,13 +50,16 @@ class SIMPLib_EXPORT DataContainerProxy { - PYB11_CREATE_BINDINGS(DataContainerProxy) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(DataContainerProxy) PYB11_CREATION() PYB11_PROPERTY(StorageType AttributeMatricies READ getAttributeMatricies WRITE setAttributeMatricies CONST_GET_OVERLOAD) PYB11_PROPERTY(QString Name READ getName WRITE setName) PYB11_PROPERTY(uint8_t Flag READ getFlag WRITE setFlag) PYB11_METHOD(AttributeMatrixProxy getAttributeMatrixProxy ARGS name RETURN_VALUE_POLICY py::return_value_policy::reference) PYB11_METHOD(void toggleFlag) + PYB11_END_BINDINGS() + // End Python bindings declarations public: // This enumeration is not a class enumeration because it is not possible to diff --git a/Source/SIMPLib/DataContainers/DataStructureUtilities.cpp b/Source/SIMPLib/DataContainers/DataStructureUtilities.cpp new file mode 100644 index 0000000000..e95051c1b7 --- /dev/null +++ b/Source/SIMPLib/DataContainers/DataStructureUtilities.cpp @@ -0,0 +1,236 @@ +/* ============================================================================ + * Copyright (c) 2019-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5261 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "DataStructureUtilities.h" + +#include "SIMPLib/DataArrays/IDataArray.h" +#include "SIMPLib/DataContainers/AttributeMatrix.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" + +// ----------------------------------------------------------------------------- +DataStructureUtilities::DataStructureUtilities() = default; +// ----------------------------------------------------------------------------- +DataStructureUtilities::~DataStructureUtilities() = default; + +// ----------------------------------------------------------------------------- +DataContainerShPtr DataStructureUtilities::getPrereqDataContainer(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const DataArrayPath& dap, bool createIfNotExists) +{ + return getPrereqDataContainer(filter, dap.getDataContainerName(), createIfNotExists); +} + +// ----------------------------------------------------------------------------- +DataContainerShPtr DataStructureUtilities::getPrereqDataContainer(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const QString& name, bool createIfNotExists) +{ + DataContainerShPtr dc = getDataContainer(name); + if(nullptr == dc.get() && !createIfNotExists) + { + if(filter != nullptr) + { + QString ss = "The DataContainer Object with the specific name '" + name + "' was not available."; + filter->setErrorCondition(-999, ss); + } + return dc; + } + if(nullptr != dc && createIfNotExists) + { + DataContainerShPtr dataContainer = DataContainer::New(name); // Create a new Data Container + addOrReplaceDataContainer(dataContainer); // Put the new DataContainer into the array + return dataContainer; // Return the wrapped pointer + } + // The DataContainer we asked for was present and NON Null so return that. + return dc; +} + +// ----------------------------------------------------------------------------- +DataContainerShPtr DataStructureUtilities::createNonPrereqDataContainer(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const DataArrayPath& dap, RenameDataPath::DataID_t id) +{ + return createNonPrereqDataContainer(filter, dap.getDataContainerName(), id); +} + +// ----------------------------------------------------------------------------- +DataContainerShPtr DataStructureUtilities::createNonPrereqDataContainer(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const QString& dataContainerName, RenameDataPath::DataID_t id) +{ + if(dataContainerName.isEmpty()) + { + if(filter != nullptr) + { + QString ss = QObject::tr("The DataContainer Object must have a name to be created."); + filter->setErrorCondition(-887, ss); + return DataContainer::NullPointer(); + } + } + + if(dataContainerName.contains('/')) + { + if(filter != nullptr) + { + QString ss = QObject::tr("The DataContainer Object has forward slashes in its name."); + filter->setErrorCondition(-888, ss); + return DataContainer::NullPointer(); + } + } + + DataContainerShPtr dataContainer = DataContainer::New(dataContainerName); + bool dcExists = !push_back(dataContainer); + if(dcExists) + { + if(filter != nullptr) + { + QString ss = QObject::tr("The DataContainer Object with the specific name '%1' already exists.").arg(dataContainerName); + filter->setErrorCondition(-889, ss); + return DataContainer::NullPointer(); + } + } + + RenameDataPath::AlertFilterCreatedPath(filter, id, DataArrayPath(dataContainerName, "", "")); + return dataContainer; +} + +// ----------------------------------------------------------------------------- +AttributeMatrixShPtrType DataStructureUtilities::getPrereqAttributeMatrixFromPath(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const DataArrayPath& path, int err) +{ + // First try to get the Parent DataContainer. If an error occurs the error message will have been set + // so just return a nullptr shared pointer + DataContainerShPtr dc = getPrereqDataContainer(filter, path.getDataContainerName(), false); + if(nullptr == dc) + { + return AttributeMatrix::NullPointer(); + } + + // Now just return what ever the DataContainer gives us. if the AttributeMatrix was not available then an + // error message and code will have been set into the "filter" object if that object was non-null itself. + return dc->getPrereqAttributeMatrix(filter, path.getAttributeMatrixName(), err); +} + +// ----------------------------------------------------------------------------- +bool DataStructureUtilities::validateNumberOfTuples(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const std::vector& paths) +{ + if(paths.size() <= 1) + { + return false; + } + QVector dataArrays; + bool valid = true; + QString ss; + if(!paths.at(0).isValid() && nullptr != filter) + { + ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2") + .arg(__LINE__) + .arg(paths.at(0).serialize()); + filter->setErrorCondition(-10000, ss); + valid = false; + return valid; + } + IDataArray::Pointer array0 = getPrereqIDataArrayFromPath(filter, paths.at(0)); + if(nullptr == array0.get() && nullptr != filter) + { + ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArray object was not available. The path is %2").arg(__LINE__).arg(paths.at(0).serialize()); + filter->setErrorCondition(-10100, ss); + valid = false; + return valid; + } + + dataArrays.push_back(array0); + for(int32_t i = 1; i < paths.size(); i++) + { + if(!paths.at(i).isValid() && nullptr != filter) + { + ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2") + .arg(__LINE__) + .arg(paths.at(i).serialize()); + filter->setErrorCondition(-10000, ss); + valid = false; + return valid; + } + IDataArray::Pointer nextArray = getPrereqIDataArrayFromPath(filter, paths.at(i)); + if(nullptr == nextArray.get() && nullptr != filter) + { + ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArray object was not available. The path is %2").arg(__LINE__).arg(paths.at(i).serialize()); + filter->setErrorCondition(-10100, ss); + valid = false; + return valid; + } + + dataArrays.push_back(nextArray); + } + size_t numTuples = dataArrays[0]->getNumberOfTuples(); + for(int32_t i = 1; i < dataArrays.size(); i++) + { + if(numTuples != dataArrays[i]->getNumberOfTuples() && nullptr != filter) + { + ss = QObject::tr("The number of tuples for the DataArray %1 is %2 and for DataArray %3 is %4. The number of tuples must match.") + .arg(dataArrays[0]->getName()) + .arg(dataArrays[0]->getNumberOfTuples()) + .arg(dataArrays[i]->getName()) + .arg(dataArrays[i]->getNumberOfTuples()); + filter->setErrorCondition(-10200, ss); + valid = false; + } + } + return valid; +} + +// ----------------------------------------------------------------------------- +bool DataStructureUtilities::validateNumberOfTuples(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, std::vector& dataArrays) +{ + if(dataArrays.size() <= 1) + { + return false; + } + bool valid = true; + QString ss; + for(const auto& dataArray : dataArrays) + { + if(nullptr == dataArray && nullptr != filter) + { + ss = QObject::tr("DataContainerArray::validateNumberOfTuples Error at line %1. The DataArray object was not available").arg(__LINE__); + filter->setErrorCondition(-10100, ss); + valid = false; + } + } + size_t numTuples = dataArrays[0]->getNumberOfTuples(); + for(int32_t i = 1; i < dataArrays.size(); i++) + { + if(numTuples != dataArrays[i]->getNumberOfTuples() && nullptr != filter) + { + ss = QObject::tr("The number of tuples for the DataArray %1 is %2 and for DataArray %3 is %4. The number of tuples must match.") + .arg(dataArrays[i - 1]->getName()) + .arg(dataArrays[i - 1]->getNumberOfTuples()) + .arg(dataArrays[i]->getName()) + .arg(dataArrays[i]->getNumberOfTuples()); + filter->setErrorCondition(-10200, ss); + valid = false; + } + } + return valid; +} diff --git a/Source/SIMPLib/DataContainers/DataStructureUtilities.h b/Source/SIMPLib/DataContainers/DataStructureUtilities.h new file mode 100644 index 0000000000..b3778b1198 --- /dev/null +++ b/Source/SIMPLib/DataContainers/DataStructureUtilities.h @@ -0,0 +1,398 @@ +/* ============================================================================ + * Copyright (c) 2019-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5261 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#pragma once + +#include +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataContainers/DataArrayPath.h" + +class IDataArray; +using IDataArrayShPtrType = std::shared_ptr; + +class DataContainerArray; +using DataContainerArrayShPtrType = std::shared_ptr; + +class DataContainer; +using DataContainerShPtrType = std::shared_ptr; + +class AttributeMatrix; +using AttributeMatrixShPtrType = std::shared_ptr; + +class AbstractFilter; + +class SIMPLib_EXPORT DataStructureUtilities +{ +public: + DataStructureUtilities(); + ~DataStructureUtilities(); + + /** + * @brief getPrereqDataContainer + * @param filter + * @param dap + * @param createIfNotExists + * @return + */ + ADataContainerShPtrType getPrereqDataContainer(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const DataArrayPath& dap, bool createIfNotExists = false); + + /** + * @brief getPrereqDataContainer + * @param name + * @param createIfNotExists + * @return + */ + ADataContainerShPtrType getPrereqDataContainer(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const QString& name, bool createIfNotExists = false); + + /** + * @brief createNonPrereqDataContainer + * @param filter + * @param dap + * @param id + * @return + */ + ADataContainerShPtrType createNonPrereqDataContainer(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const DataArrayPath& dap, + RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID); + + /** + * @brief This function will create a new DataContainer of type + * @param dataContainerName The name of the DataContainer. Must not be empty or this method will ASSERT() + * @return Valid DataContainer Object UNLESS the DataContainer with the given name already exists or the + * dataContainerName is empty in which case a Null DataContainer will be returned. + */ + ADataContainerShPtrType createNonPrereqDataContainer(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const QString& dataContainerName, + RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID); + + /** + * @brief getPrereqGeometryFromDataContainer Returns an IGeometry object of the templated type + * if it is available for the given DataContainer + * @param filter + * @param dcName + * @return + */ + template + typename GeometryType::Pointer getPrereqGeometryFromDataContainer(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const QString& dcName) + { + typename GeometryType::Pointer geom = GeometryType::NullPointer(); + ADataContainerShPtrType dc = DataStructureUtilites::getPrereqDataContainer(filter, dcName, false); + if(nullptr == dc) + { + return geom; + } + + return dc->getPrereqGeometry(filter); + } + + /** + * @brief getPrereqGeometryFromDataContainer Returns an IGeometry object of the templated type + * if it is available for the given DataContainer + * @param filter + * @param path + * @return + */ + template + typename GeometryType::Pointer getPrereqGeometryFromDataContainer(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const DataArrayPath& path) + { + typename GeometryType::Pointer geom = GeometryType::NullPointer(); + ADataContainerShPtrType dc = DataStructureUtilites::getPrereqDataContainer(filter, path.getDataContainerName(), false); + if(nullptr == dc) + { + return geom; + } + + return dc->getPrereqGeometry(filter); + } + + /** + * @brief getPrereqAttributeMatrixFromPath This function will return an AttributeMatrix if it is availabe + * at the path + * @param filter An AbstractFilter or subclass where error messages and error codes can be sent + * @param path The DataArrayPath object that has the path to the AttributeMatrix + * @param err The error code to display to the user + * @return + */ + AttributeMatrixShPtrType getPrereqAttributeMatrixFromPath(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const DataArrayPath& path, int err); + + /** + * @brief getPrereqArrayFromPath + * @param filter Instance of an AbstractFilter. Can be nullptr + * @param path The path to the IDataArray + * @param cDims The component dimensions of the IDataArray subclass + * @return Valid or nullptr shared pointer based on availability of the array + */ + template + typename ArrayType::Pointer getPrereqArrayFromPath(const DataContainerArrayShPtrType& dca, Filter* filter, const DataArrayPath& path, std::vector cDims) + { + + QString ss; + typename ArrayType::Pointer dataArray = ArrayType::NullPointer(); + + if(path.isEmpty()) + { + if(filter) + { + ss = QObject::tr("DataContainerArray::getPrereqArrayFromPath Error at line %1. The DataArrayPath object was empty").arg(__LINE__); + filter->setErrorCondition(-80000, ss); + } + return dataArray; + } + + if(!path.isValid()) + { + if(filter) + { + ss = QObject::tr("DataContainerArray::getPrereqArrayFromPath Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2") + .arg(__LINE__) + .arg(path.serialize()); + filter->setErrorCondition(-80001, ss); + } + return dataArray; + } + + QString dcName = path.getDataContainerName(); + QString amName = path.getAttributeMatrixName(); + QString daName = path.getDataArrayName(); + + ADataContainerShPtrType dc = dca->getDataContainer(dcName); + if(nullptr == dc.get()) + { + if(filter) + { + ss = QObject::tr("The DataContainer '%1' was not found in the DataContainerArray").arg(dcName); + filter->setErrorCondition(-80002, ss); + } + return dataArray; + } + + AttributeMatrixShPtrType attrMat = dc->getAttributeMatrix(amName); + if(nullptr == attrMat.get()) + { + if(filter) + { + ss = QObject::tr("The AttributeMatrix '%1' was not found in the DataContainer '%2'").arg(amName).arg(dcName); + filter->setErrorCondition(-80003, ss); + } + return dataArray; + } + + dataArray = attrMat->getPrereqArray(filter, daName, -80002, cDims); + return dataArray; + } + + /** + * @brief getPrereqIDataArrayFromPath + * @param filter + * @param path + * @return + */ + template + typename ArrayType::Pointer getPrereqIDataArrayFromPath(const DataContainerArrayShPtrType& dca, Filter* filter, const DataArrayPath& path) + { + + QString ss; + typename ArrayType::Pointer dataArray = ArrayType::NullPointer(); + + if(path.isEmpty()) + { + if(filter) + { + ss = QObject::tr("DataContainerArray::getPrereqIDataArrayFromPath Error at line %1. The DataArrayPath object was empty").arg(__LINE__); + filter->setErrorCondition(-90000, ss); + } + return dataArray; + } + + if(!path.isValid()) + { + if(filter) + { + ss = QObject::tr("DataContainerArray::getPrereqIDataArrayFromPath Error at line %1. The DataArrayPath object was not valid meaning one of the strings in the object is empty. The path is %2") + .arg(__LINE__) + .arg(path.serialize()); + filter->setErrorCondition(-90001, ss); + } + return dataArray; + } + + QString dcName = path.getDataContainerName(); + QString amName = path.getAttributeMatrixName(); + QString daName = path.getDataArrayName(); + + ADataContainerShPtrType dc = getDataContainer(dcName); + if(nullptr == dc.get()) + { + if(filter) + { + ss = QObject::tr("The DataContainer '%1' was not found in the DataContainerArray").arg(dcName); + filter->setErrorCondition(-999, ss); + } + return dataArray; + } + + AttributeMatrixShPtrType attrMat = dc->getAttributeMatrix(amName); + if(nullptr == attrMat.get()) + { + if(filter) + { + ss = QObject::tr("The AttributeMatrix '%1' was not found in the DataContainer '%2'").arg(amName).arg(dcName); + filter->setErrorCondition(-307020, ss); + } + return dataArray; + } + + dataArray = std::dynamic_pointer_cast(attrMat->getPrereqIDataArray(filter, daName, -90002)); + return dataArray; + } + + /** + * @brief createNonPrereqArray This method will create a new DataArray in the AttributeMatrix. The conditions for this + * method to work properly include: a valid DataArrayPath is supplied, the name of the attribute array is not empty, + * and an array with the same name cannot already exist + * @param filter The instance of the filter the filter that is requesting the new array + * @param attributeArrayName The name of the AttributeArray to create + * @param initValue The initial value of all the elements of the array + * @param size The number of tuples in the Array + * @param dims The dimensions of the components of the AttributeArray + * @return A Shared Pointer to the newly created array + */ + template + typename ArrayType::Pointer createNonPrereqArrayFromPath(const DataContainerArrayShPtrType& dca, Filter* filter, const DataArrayPath& path, T initValue, std::vector compDims, + const QString& property = "", RenameDataPath::DataID_t id = RenameDataPath::k_Invalid_ID) + { + typename ArrayType::Pointer dataArray = ArrayType::NullPointer(); + QString ss; + if(!path.isValid()) + { + if(filter) + { + ss = QObject::tr("Property '%1': The DataArrayPath is invalid because one of the elements was empty.\n DataContainer: %2\n AttributeMatrix: %3\n DataArray: %4") + .arg(property) + .arg(path.getDataContainerName()) + .arg(path.getAttributeMatrixName()) + .arg(path.getDataArrayName()); + filter->setErrorCondition(-80010, ss); + } + return dataArray; + } + + if(path.getDataContainerName().contains('/')) + { + if(filter) + { + ss = QObject::tr("The DataContainer '%1' has forward slashes in its name").arg(path.getDataContainerName()); + filter->setErrorCondition(-80005, ss); + } + return dataArray; + } + + if(path.getAttributeMatrixName().contains('/')) + { + if(filter) + { + ss = QObject::tr("The AttributeMatrix '%1' has forward slashes in its name").arg(path.getAttributeMatrixName()); + filter->setErrorCondition(-80006, ss); + } + return dataArray; + } + + if(path.getDataArrayName().contains('/')) + { + if(filter) + { + ss = QObject::tr("The DataArray '%1' has forward slashes in its name").arg(path.getDataArrayName()); + filter->setErrorCondition(-80007, ss); + } + return dataArray; + } + + if(path.getDataContainerName().contains('/')) + { + if(filter) + { + ss = QObject::tr("The DataContainer '%1' has forward slashes in its name").arg(path.getDataContainerName()); + filter->setErrorCondition(-80004, ss); + } + return dataArray; + } + + ADataContainerShPtrType dc = getDataContainer(path.getDataContainerName()); + if(nullptr == dc.get()) + { + if(filter) + { + ss = QObject::tr("The DataContainer '%1' was not found in the DataContainerArray").arg(path.getDataContainerName()); + filter->setErrorCondition(-80002, ss); + } + return dataArray; + } + + AttributeMatrixShPtrType attrMat = dc->getAttributeMatrix(path.getAttributeMatrixName()); + if(nullptr == attrMat.get()) + { + if(filter) + { + ss = QObject::tr("The AttributeMatrix '%1' was not found in the DataContainer '%2'").arg(path.getAttributeMatrixName()).arg(path.getDataContainerName()); + filter->setErrorCondition(-80003, ss); + } + return dataArray; + } + + // If something goes wrong at this point the error message will be directly set in the 'filter' object so we just + // simply return what ever is given to us. + dataArray = attrMat->createNonPrereqArray(filter, path.getDataArrayName(), initValue, compDims, id); + return dataArray; + } + + /** + * @brief validateNumberOfTuples This method will validate that all of the DataArray + * paths supplied are valid, return non-nullptr DataArray pointers, and that all have the + * same number of tuples. It will return false if and any of the checks fail, or + * if the QVector of input paths has 0 or 1 element. + * @param filter The filter calling the validation + * @param paths The paths that should be checked + * @return bool Validation check + */ + bool validateNumberOfTuples(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const std::vector& paths); + + /** + * @brief validateNumberOfTuples This method will validate that all of the DataArray + * objects supplied are non-nullptr and that all are have the same number of tuples. + * It will return false if and any of the checks fail, or + * if the QVector of input DataArray objects has 0 or 1 element. + * @param filter The filter calling the validation + * @param paths The paths that should be checked + * @return bool Validation check + */ + bool validateNumberOfTuples(const DataContainerArrayShPtrType& dca, AbstractFilter* filter, const std::vector& dataArrays); +}; diff --git a/Source/SIMPLib/DataContainers/DsnIterators.h b/Source/SIMPLib/DataContainers/DsnIterators.h new file mode 100644 index 0000000000..8394174fe5 --- /dev/null +++ b/Source/SIMPLib/DataContainers/DsnIterators.h @@ -0,0 +1,474 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include +#include + +class IDataStructureNode; + +/** + * @brief The DsnIterator is a bidirectional iterator over data structure types + * belonging to the same level. DataContainerArray iterators only iterate over + * DataContainers. DataContainer iterators only iterate over their AttributeMatrices. + * AttributeMatrix iterators only iterate over their DataArrays. + * This was made constexpr for the sake of creating faster runtime operations. + */ +class DsnIterator : public std::iterator, size_t> // std::iterator_traits> +{ + using self_type = DsnIterator; + using difference_type = size_t; + using value_type = std::shared_ptr; + using pointer = IDataStructureNode*; + using reference = value_type&; + using collection_type = std::vector; + using iterator_category = std::random_access_iterator_tag; + +public: + /** + * @brief Default constructor creates an invalid iterator + */ + DsnIterator() = default; + + /** + * @brief Creates an iterator for the given collection and index + * @param collection + * @param index + */ + DsnIterator(const collection_type& collection, size_t index) + : m_Collection(collection) + , m_Index(index) + { + } + + /** + * @brief Copy iterator + * @param other + */ + DsnIterator(const self_type& other) + : m_Collection(other.m_Collection) + , m_Index(other.m_Index) + { + } + + /** + * @brief Destructor + */ + ~DsnIterator() = default; + + /** + * @brief Returns the iterator's index. + * @return + */ + constexpr difference_type position() const + { + return m_Index; + } + + /** + * @brief Returns the next iterator in the collection. + * @return + */ + constexpr self_type& operator++(int) + { + m_Index++; + return *this; + } + + /** + * @brief Returns the previous iterator in the collection. + * @return + */ + constexpr self_type& operator--(int) + { + m_Index--; + return *this; + } + + /** + * @brief Proceeds n positions. + * @param n + * @return + */ + constexpr self_type& operator+(difference_type n) + { + m_Index += n; + return *this; + } + + /** + * @brief Regresses n positions. + * @param n + * @return + */ + constexpr self_type& operator-(difference_type n) + { + if(n > m_Index) + { + throw std::out_of_range("Iterator out of range"); + } + m_Index -= n; + return *this; + } + + /** + * @brief Returns the difference in position with the given iterator. + * @param other + * @return + */ + constexpr difference_type operator-(const self_type& other) + { + return m_Index - other.m_Index; + } + + /** + * @brief Returns the stored value. + * @return + */ + constexpr reference operator*() + { + return m_Collection[m_Index]; + } + + /** + * @brief Returns the stored value. + * @return + */ + constexpr pointer operator->() + { + return m_Collection[m_Index].get(); + } + + /** + * @brief Returns true if the given iterator comes later in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator<(const self_type& other) const + { + return m_Index < other.m_Index; + } + + /** + * @brief Returns true if the given iterator comes later or equal to the iterator in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator<=(const self_type& other) const + { + return m_Index <= other.m_Index; + } + + /** + * @brief Returns true if the given iterator comes earlier in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator>(const self_type& other) const + { + return m_Index > other.m_Index; + } + + /** + * @brief Returns true if the given iterator comes earlier or equal to the iterator in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator>=(const self_type& other) const + { + return m_Index >= other.m_Index; + } + + /** + * @brief Returns true if other iterator points to the same index in same collection. + * @param rhs right hand side + * @return + */ + constexpr bool operator==(const self_type& rhs) const + { + return (m_Index == rhs.m_Index) && (m_Collection == rhs.m_Collection); + } + + /** + * @brief Returns true if the other iterator does not point to the same index and collection. + * @param rhs right hand side + * @return + */ + bool operator!=(const self_type& rhs) const + { + return !operator==(rhs); + } + + /** + * @brief Swaps values with the given iterator. + * @param other + */ + inline void swap(self_type& other) noexcept + { + const collection_type tempCollection = m_Collection; + m_Collection = other.m_Collection; + other.m_Collection = tempCollection; + + const difference_type tempIndex = m_Index; + m_Index = other.m_Index; + other.m_Index = tempIndex; + } + +private: + collection_type m_Collection; + difference_type m_Index; +}; + +/** + * @brief The DsnConstIterator is a bidirectional const iterator over data structure types + * belonging to the same level. DataContainerArray iterators only iterate over + * DataContainers. DataContainer iterators only iterate over their AttributeMatrices. + * AttributeMatrix iterators only iterate over their DataArrays. + * This was made constexpr for the sake of creating faster runtime operations. + */ +class DsnConstIterator : public std::iterator, size_t> // std::iterator_traits> +{ + using self_type = DsnConstIterator; + using difference_type = size_t; + using value_type = const std::shared_ptr; + using pointer = const IDataStructureNode*; + using reference = value_type&; + using collection_type = std::vector>; + using iterator_category = std::random_access_iterator_tag; + +public: + /** + * @brief Calling the default constructor will return an invalid iterator. + */ + DsnConstIterator() = default; + + /** + * @brief Constructor for the given collection and index + * @param collection + * @param index + */ + DsnConstIterator(const collection_type& collection, size_t index) + : m_Collection(collection) + , m_Index(index) + { + } + + /** + * @brief Copy constructor + * @param other + */ + DsnConstIterator(const self_type& other) + : m_Collection(other.m_Collection) + , m_Index(other.m_Index) + { + } + + /** + * @brief Destructor + */ + ~DsnConstIterator() = default; + + /** + * @brief Returns the iterator's index. + * @return + */ + constexpr difference_type position() const + { + return m_Index; + } + + /** + * @brief Returns the next iterator in the collection + * @return + */ + constexpr self_type& operator++() + { + m_Index++; + return *this; + } + + /** + * @brief Returns the previous iterator in the collection + * @return + */ + constexpr self_type& operator--(int) + { + m_Index--; + return *this; + } + + /** + * @brief Proceeds n positions. + * @param n + * @return + */ + constexpr self_type& operator+(difference_type n) + { + m_Index += n; + return *this; + } + + /** + * @brief Regresses n positions + * @param n + * @return + */ + constexpr self_type& operator-(difference_type n) + { + if(n > m_Index) + { + throw std::out_of_range("Iterator out of range"); + } + m_Index -= n; + return *this; + } + + /** + * @brief Returns the difference in position with the given iterator. + * @param other + * @return + */ + constexpr difference_type operator-(const self_type& other) + { + return m_Index - other.m_Index; + } + + /** + * @brief Returns a the stored value as const. + * @return + */ + constexpr reference operator*() const + { + return m_Collection[m_Index]; + } + + /** + * @brief Returns the value as const. + * @return + */ + constexpr pointer operator->() const + { + return m_Collection[m_Index].get(); + } + + /** + * @brief Returns true if the given iterator comes later in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator<(const self_type& other) const + { + return m_Index < other.m_Index; + } + + /** + * @brief Returns true if the given iterator comes later or equal to the iterator in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator<=(const self_type& other) const + { + return m_Index <= other.m_Index; + } + + /** + * @brief Returns true if the given iterator comes earlier in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator>(const self_type& other) const + { + return m_Index > other.m_Index; + } + + /** + * @brief Returns true if the given iterator comes earlier or equal to the iterator in the collection. + * Returns false otherwise. + * @param other + * @return + */ + constexpr bool operator>=(const self_type& other) const + { + return m_Index >= other.m_Index; + } + + /** + * @brief Returns true if the other iterator points to the same index and collection. + * Returns false otherwise. + * @param rhs right hand side + * @return + */ + constexpr bool operator==(const self_type& rhs) const + { + return (m_Index == rhs.m_Index) && (m_Collection == rhs.m_Collection); + } + + /** + * @brief Returns true if the other iterator does not point to the same index and collection. + * Returns false otherwise. + * @param rhs right hand side + * @return + */ + bool operator!=(const self_type& rhs) const + { + return !operator==(rhs); + } + + /** + * @brief Swaps values with the given iterator. + * @param other + */ + inline void swap(self_type& other) noexcept + { + const collection_type tempCollection = m_Collection; + m_Collection = other.m_Collection; + other.m_Collection = tempCollection; + + const difference_type tempIndex = m_Index; + m_Index = other.m_Index; + other.m_Index = tempIndex; + } + +private: + collection_type m_Collection; + size_t m_Index; +}; diff --git a/Source/SIMPLib/DataContainers/IDataContainerBundle.cpp b/Source/SIMPLib/DataContainers/IDataContainerBundle.cpp index b32ee4145a..37c5909c97 100644 --- a/Source/SIMPLib/DataContainers/IDataContainerBundle.cpp +++ b/Source/SIMPLib/DataContainers/IDataContainerBundle.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "IDataContainerBundle.h" // ----------------------------------------------------------------------------- @@ -43,3 +43,21 @@ IDataContainerBundle::IDataContainerBundle() = default; // // ----------------------------------------------------------------------------- IDataContainerBundle::~IDataContainerBundle() = default; + +// ----------------------------------------------------------------------------- +IDataContainerBundle::Pointer IDataContainerBundle::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString IDataContainerBundle::getNameOfClass() const +{ + return QString("IDataContainerBundle"); +} + +// ----------------------------------------------------------------------------- +QString IDataContainerBundle::ClassName() +{ + return QString("IDataContainerBundle"); +} diff --git a/Source/SIMPLib/DataContainers/IDataContainerBundle.h b/Source/SIMPLib/DataContainers/IDataContainerBundle.h old mode 100755 new mode 100644 index 9b1673a6fd..41954e7274 --- a/Source/SIMPLib/DataContainers/IDataContainerBundle.h +++ b/Source/SIMPLib/DataContainers/IDataContainerBundle.h @@ -1,86 +1,99 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include - #include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataContainers/DataContainer.h" class SIMPLib_EXPORT IDataContainerBundle : public QObject { - Q_OBJECT - public: - SIMPL_SHARED_POINTERS (IDataContainerBundle) - //SIMPL_STATIC_NEW_MACRO (IDataContainerBundle) - SIMPL_TYPE_MACRO(IDataContainerBundle) + Q_OBJECT +public: + using Self = IDataContainerBundle; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - ~IDataContainerBundle() override; + /** + * @brief Returns the name of the class for IDataContainerBundle + */ + virtual QString getNameOfClass() const; + /** + * @brief Returns the name of the class for IDataContainerBundle + */ + static QString ClassName(); - virtual void setName(const QString& getDataContainer) = 0; - virtual QString getName() const = 0; + ~IDataContainerBundle() override; - virtual QVector getDataContainerNames() = 0; + virtual void setName(const QString& getDataContainer) = 0; + virtual QString getName() const = 0; - virtual void addDataContainer(DataContainer::Pointer dc) = 0; + virtual QVector getDataContainerNames() = 0; - virtual void removeDataContainer(DataContainer::Pointer dc) = 0; - virtual void removeDataContainer(const QString& name) = 0; - virtual void removeDataContainer(qint32 i) = 0; + virtual void addOrReplaceDataContainer(DataContainer::Pointer dc) = 0; - virtual DataContainer::Pointer getDataContainer(qint32 index) = 0; + virtual void removeDataContainer(DataContainer::Pointer dc) = 0; + virtual void removeDataContainer(const QString& name) = 0; + virtual void removeDataContainer(qint32 i) = 0; - virtual qint32 count() = 0; + virtual DataContainer::Pointer getDataContainer(qint32 index) = 0; - virtual void clear() = 0; + virtual qint32 count() = 0; - virtual int writeH5Data(hid_t groupId) = 0; + virtual void clear() = 0; - virtual int readH5Data(hid_t groupId) = 0; + virtual int writeH5Data(hid_t groupId) = 0; - protected: - IDataContainerBundle(); + virtual int readH5Data(hid_t groupId) = 0; - public: - IDataContainerBundle(const IDataContainerBundle&) = delete; // Copy Constructor Not Implemented - IDataContainerBundle(IDataContainerBundle&&) = delete; // Move Constructor Not Implemented - IDataContainerBundle& operator=(const IDataContainerBundle&) = delete; // Copy Assignment Not Implemented - IDataContainerBundle& operator=(IDataContainerBundle&&) = delete; // Move Assignment Not Implemented -}; +protected: + IDataContainerBundle(); +public: + IDataContainerBundle(const IDataContainerBundle&) = delete; // Copy Constructor Not Implemented + IDataContainerBundle(IDataContainerBundle&&) = delete; // Move Constructor Not Implemented + IDataContainerBundle& operator=(const IDataContainerBundle&) = delete; // Copy Assignment Not Implemented + IDataContainerBundle& operator=(IDataContainerBundle&&) = delete; // Move Assignment Not Implemented + +private: +}; diff --git a/Source/SIMPLib/DataContainers/IDataStructureContainerNode.hpp b/Source/SIMPLib/DataContainers/IDataStructureContainerNode.hpp new file mode 100644 index 0000000000..ea3d2bc6ee --- /dev/null +++ b/Source/SIMPLib/DataContainers/IDataStructureContainerNode.hpp @@ -0,0 +1,460 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "IDataStructureNode.h" + +template +class IDataStructureContainerNode : public AbstractDataStructureContainer +{ +public: + using Self = IDataStructureContainerNode; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + using ChildShPtr = std::shared_ptr; + using ChildCollection = std::vector; + using iterator = typename ChildCollection::iterator; + using const_iterator = typename ChildCollection::const_iterator; + using NameList = QList; + +private: + ChildCollection m_ChildrenNodes; + +protected: +public: + IDataStructureContainerNode(const QString& name = "") + : AbstractDataStructureContainer(name) + { + } + IDataStructureContainerNode(ParentType* parent, const QString& name = "") + : AbstractDataStructureContainer(parent, name) + { + } + ~IDataStructureContainerNode() override + { + clear(); + } + + /** + * @brief Returns a copy of the children collection. + * @return + */ + constexpr const ChildCollection& getChildren() const + { + return m_ChildrenNodes; + } + + /** + * @brief Returns the names of all children nodes. + * @return + */ + NameList getNamesOfChildren() const + { + NameList names; + for(const auto& child : m_ChildrenNodes) + { + names.push_back(child->getName()); + } + return names; + } + + /** + * @brief Returns the DataArrayPaths of all descendants. + * @return + */ + DataArrayPathList getDescendantPaths() const + { + DataArrayPathList paths; + + for(const auto& child : m_ChildrenNodes) + { + paths.push_back(child->getDataArrayPath()); + // Check if child is a container node + auto childContainer = std::dynamic_pointer_cast(child); + if(nullptr != childContainer) + { + paths.merge(childContainer->getDescendantPaths()); + } + } + + return paths; + } + + /** + * @brief Returns a list of DataArrayPaths from both itself and all its descendants. + * @return + */ + DataArrayPathList getAllPaths() const + { + DataArrayPathList list = getDescendantPaths(); + list.push_front(getDataArrayPath()); + return list; + } + + /** + * @brief Returns an iterator pointing to the start of the children collection. + * @return + */ + constexpr iterator begin() noexcept + { + return m_ChildrenNodes.begin(); + } + + /** + * @brief Returns a const iterator pointing to the start of the children collection. + * @return + */ + constexpr const_iterator begin() const noexcept + { + return m_ChildrenNodes.begin(); + } + + /** + * @brief Returns a const iterator pointing to the start of the children collection. + * @return + */ + constexpr const_iterator cbegin() const noexcept + { + return m_ChildrenNodes.cbegin(); + } + + /** + * @brief Returns an iterator pointing past the end of the children collection. + * @return + */ + constexpr iterator end() noexcept + { + return m_ChildrenNodes.end(); + } + + /** + * @brief Returns a const iterator pointing past the end of the children collection. + * @return + */ + constexpr const_iterator end() const noexcept + { + return m_ChildrenNodes.end(); + } + + /** + * @brief Returns a const iterator pointing past the end of the children collection. + * @return + */ + constexpr const_iterator cend() const noexcept + { + return m_ChildrenNodes.cend(); + } + + /** + * @brief Returns true if the child collection is empty. Returns false otherwise. + * @return + */ + constexpr bool empty() const + { + return m_ChildrenNodes.empty(); + } + + /** + * @brief Returns the size of the children collection. + * @return + */ + constexpr size_t size() const + { + return m_ChildrenNodes.size(); + } + + /** + * @brief Clears the children collection. Items are not deleted unless this + * was the last shared_ptr referencing them. + */ + constexpr void clear() noexcept + { + auto children = getChildren(); + for(auto& child : children) + { + if(child != nullptr) + { + destroyParentConnection(child.get()); + } + } + m_ChildrenNodes.clear(); + } + + /** + * @brief Returns the child node with the given name. If no children nodes + * are found with the given name, return nullptr. + * @param name + * @return + */ + constexpr iterator find(const QString& name) + { + const auto hash = CreateStringHash(name); + for(auto iter = begin(); iter != end(); iter++) + { + if((*iter)->checkNameHash(hash)) + { + return iter; + } + } + + return end(); + } + + /** + * @brief Returns the child node with the given name. If no children nodes + * are found with the given name, return nullptr. + * @param name + * @return + */ + constexpr const_iterator find(const QString& name) const + { + const auto hash = CreateStringHash(name); + for(auto iter = begin(); iter != end(); iter++) + { + if((*iter)->checkNameHash(hash)) + { + return iter; + } + } + + return cend(); + } + + /** + * @brief Returns the child with the given name as a shared_ptr. + * If no child is found, return nullptr. + * @param name + * @return + */ + constexpr ChildShPtr getChildByName(const QString& name) const + { + HashType nameHash = CreateStringHash(name); + + const auto& children = getChildren(); + for(const auto& child : children) + { + if(child->checkNameHash(nameHash)) + { + return child; + } + } + return nullptr; + } + + /** + * @brief Returns true if the container has a child node with the given name. + * Returns false otherwise. + * @param name + * @return + */ + constexpr bool contains(const QString& name) const + { + return getChildByName(name) != nullptr; + } + + /** + * @brief Returns true if the given object is one of the container's children. + * Returns false otherwise. + * @param obj + * @return + */ + constexpr bool contains(const ChildShPtr& obj) const + { + const auto& children = getChildren(); + for(const auto& child : children) + { + if(child == obj) + { + return true; + } + } + return false; + } + + /** + * @brief Returns the index for the child with the given name. + * Returns -1 if there is no child with the given name. + * @param name + * @return + */ + constexpr int64_t getIndex(const QString& name) const + { + auto iter = find(name); + if(iter == cend()) + { + return -1; + } + return iter - begin(); + } + + /** + * @brief Returns the child node at the given index. If index is greater than + * the specified index, throw out_of_range exception. + * @param index + * @return + */ + constexpr ChildShPtr& operator[](size_t index) + { + if(index < 0 || index > m_ChildrenNodes.size()) + { + const char msg[] = "Index is out of range for the IDataStructureContainerNode's children collection."; + throw std::out_of_range(msg); + } + + return m_ChildrenNodes[index]; + } + + /** + * @brief Returns the child node with the given name. If no children nodes + * are found with the given name, return nullptr. + * @param name + * @return + */ + constexpr ChildShPtr& operator[](const QString& name) + { + return operator[](getIndex(name)); + } + + /** + * @brief Returns true if the container has a child by the given name. + * Returns false otherwise. + * @param name + * @return + */ + bool hasChildWithName(const QString& name) const override + { + return contains(name); + } + + /** + * @brief Attempts to append the given IDataStructureNode as a child. + * Returns true if the process succeeded. Returns false otherwise. + * @param value + * @return success + */ + bool push_back(const ChildShPtr& node) + { + if(node.get() == nullptr) + { + return false; + } + if(contains(node->getName())) + { + return false; + } + typename ChildCollection::size_type size = m_ChildrenNodes.size(); + m_ChildrenNodes.push_back(node); + + createParentConnection(node.get(), this); + return (size != m_ChildrenNodes.size()); + } + + /** + * @brief Sets the given IDataStructureNode as a child. If a child already + * exists with the given name, it is removed. + * @param node + * @return success + */ + bool insertOrAssign(const ChildShPtr& node) + { + // Can not insert a null IDataArray + if(node.get() == nullptr) + { + return false; + } + + auto iter = find(node->getName()); + if(iter != end()) + { + if((*iter) != node) + { + erase(iter); + } + else + { + return true; + } + } + + m_ChildrenNodes.push_back(node); + createParentConnection(node.get(), this); + return true; + } + + /** + * @brief Erases the child at the given iterator + * @param iter + */ + void erase(iterator iter) + { + ChildShPtr child = (*iter); + m_ChildrenNodes.erase(iter); + destroyParentConnection(child.get()); + } + + /** + * @brief Removes the given child from the children collection and returns its shared_ptr. + * @param child + * @return + */ + IDataStructureNode::Pointer removeChildNode(const IDataStructureNode* rmChild) override + { + if(rmChild == nullptr) + { + return NullPointer(); + } + + for(auto iter = m_ChildrenNodes.begin(); iter != m_ChildrenNodes.end(); ++iter) + { + if((*iter).get() == rmChild) + { + ChildShPtr ptr = *iter; + m_ChildrenNodes.erase(iter); + return ptr; + } + } + + return NullPointer(); + } +}; diff --git a/Source/SIMPLib/DataContainers/IDataStructureNode.cpp b/Source/SIMPLib/DataContainers/IDataStructureNode.cpp new file mode 100644 index 0000000000..0eab51262e --- /dev/null +++ b/Source/SIMPLib/DataContainers/IDataStructureNode.cpp @@ -0,0 +1,194 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "IDataStructureNode.h" + +#include +#include +#include + +//#include "SIMPLib/DataContainers/DsnIterators.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IDataStructureNode::HashType IDataStructureNode::CreateStringHash(const QString& string) +{ + std::hash hashFn; + std::string stdStr = std::string(string.toStdString()); + HashType hash = hashFn(stdStr); + return hash; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IDataStructureNode::IDataStructureNode(const QString& name) +: m_Name(name) +, m_Parent(nullptr) +{ + updateNameHash(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IDataStructureNode::IDataStructureNode(ParentType* parent, const QString& name) +: m_Name(name) +, m_Parent(parent) +{ + updateNameHash(); + + // Add to parent's children +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IDataStructureNode::~IDataStructureNode() +{ + if(m_Parent != nullptr) + { + m_Parent->removeChildNode(this); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void IDataStructureNode::updateNameHash() +{ + m_NameHash = CreateStringHash(getName()); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString IDataStructureNode::getName() const +{ + return m_Name; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool IDataStructureNode::setName(const QString& newName) +{ + if(nullptr == m_Parent) + { + m_Name = newName; + updateNameHash(); + return true; + } + else if(!m_Parent->hasChildWithName(newName)) + { + m_Name = newName; + updateNameHash(); + return true; + } + + return false; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IDataStructureNode::ParentType* IDataStructureNode::getParentNode() const +{ + return m_Parent; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void IDataStructureNode::setParentNode(ParentType* parent) +{ + if(parent == m_Parent) + { + return; + } + + // Remove from parent's children + if(nullptr != m_Parent) + { + m_Parent->removeChildNode(this); + } + + m_Parent = parent; +} + +// ----------------------------------------------------------------------------- +QString IDataStructureNode::getNameOfClass() const +{ + return QString("IDataStructureNode"); +} + +// ----------------------------------------------------------------------------- +QString IDataStructureNode::ClassName() +{ + return QString("IDataStructureNode"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataArrayPath IDataStructureNode::getParentPath() const +{ + if(!hasParent()) + { + return DataArrayPath(); + } + return getParentNode()->getDataArrayPath(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractDataStructureContainer::createParentConnection(IDataStructureNode* child, AbstractDataStructureContainer* parent) const +{ + child->setParentNode(parent); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractDataStructureContainer::destroyParentConnection(IDataStructureNode* child) const +{ + child->clearParentNode(); +} + +// ----------------------------------------------------------------------------- +IDataStructureNode::Pointer IDataStructureNode::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} diff --git a/Source/SIMPLib/DataContainers/IDataStructureNode.h b/Source/SIMPLib/DataContainers/IDataStructureNode.h new file mode 100644 index 0000000000..a25b7d1706 --- /dev/null +++ b/Source/SIMPLib/DataContainers/IDataStructureNode.h @@ -0,0 +1,227 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include +#include +#include +#include + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataContainers/DataArrayPath.h" + +class AbstractDataStructureContainer; + +/** + * @class IDataStructureNode IDataStructureNode.h SIMPLib/DataContainers/IDataStructureNode.h + * @brief the IDataStructureNode class serves as the base class for data + * structure classes from DataContainer to DataArray + */ +class SIMPLib_EXPORT IDataStructureNode +{ +public: + using Self = IDataStructureNode; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for AbstractMessage + */ + virtual QString getNameOfClass() const; + /** + * @brief Returns the name of the class for AbstractMessage + */ + static QString ClassName(); + + using ParentType = AbstractDataStructureContainer; + // using ParentWkPtr = std::weak_ptr; + // using parent_collection = std::vector; + using DataArrayPathList = std::list; + using HashType = size_t; + + friend AbstractDataStructureContainer; + +private: + QString m_Name; + ParentType* m_Parent = nullptr; + HashType m_NameHash = 0; + + /** + * @brief Updates the name hash variable based on the current name. + */ + void updateNameHash(); + + /** + * @brief Sets the raw parent pointer. As additional graph support is added, + * this will instead be replaced with addParentNode(const ParentType&) and + * removeParentNode(const ParentType&). This should only be called from + * IDataStructureContainerNode::push_back, insertOrAssign, or + * IDataStructureNode::clearParentNode. THIS DOES NOT ADD THE NODE TO THE TARGET PARENT! + * @param parent + */ + void setParentNode(ParentType* parent); + + /** + * @brief Clears the parent pointer and removes this from its parent constainer. + */ + void clearParentNode() + { + setParentNode(nullptr); + } + + // void addParentNode(const ParentType& newParent); + // bool removeParentNode(const ParentType& removedParent); + +protected: + /** + * @brief Method for creating hashes from QString values. + * @param string + * @return + */ + static HashType CreateStringHash(const QString& string); + +public: + IDataStructureNode(const QString& name = ""); + IDataStructureNode(ParentType* parent, const QString& name = ""); + + virtual ~IDataStructureNode(); + + /** + * @brief Checks the name hash for equality. Returns true if they are equal. + * Returns false otherwise. + * @param nameHash + * @return + */ + bool checkNameHash(size_t nameHash) const + { + return m_NameHash == nameHash; + } + + /** + * @brief Returns the node's name. + * @return + */ + QString getName() const; + + /** + * @brief Attempts to rename the container. Returns true if the operation succeeded. + * Returns false otherwise. + * @param newName + * @return + */ + bool setName(const QString& newName); + + /** + * @brief Returns the parent node. This currently only returns a single pointer, + * but as additional graph support is added, this will instead return a parent_collection. + * @return + */ + ParentType* getParentNode() const; + + /** + * @brief Returns the data structure node's DataArrayPath. + * @return + */ + virtual DataArrayPath getDataArrayPath() const = 0; + + /** + * @brief Returns the parent node's DataArrayPath. If no parent node exists, return an empty path; + * @return + */ + DataArrayPath getParentPath() const; + + /** + * @brief Returns true if a parent node exists. Returns false otherwise. + * @return + */ + bool hasParent() const + { + return m_Parent != nullptr; + } +}; + +/** + * @class AbstractDataStructureContainer IDataStructureNode.h SIMPLib/DataContainers/IDataStructureNode.h + * @brief The AbstractDataStructureContainer is an interface created so that IDataStructureNode can call required methods in IDataStructureContainerNode. + */ +class SIMPLib_EXPORT AbstractDataStructureContainer : public IDataStructureNode +{ +public: + AbstractDataStructureContainer(const QString& name = "") + : IDataStructureNode(name) + { + } + AbstractDataStructureContainer(ParentType* parent, const QString& name = "") + : IDataStructureNode(parent, name) + { + } + ~AbstractDataStructureContainer() override = default; + + /** + * @brief Returns true if the container has a child node with the given name. + * @param name + * @return + */ + virtual bool hasChildWithName(const QString& name) const = 0; + + /** + * @brief Removes the target node from the container's list of children. + * Returns the removed node as a shared pointer. + * @param rmChild + * @return + */ + virtual IDataStructureNode::Pointer removeChildNode(const IDataStructureNode* rmChild) = 0; + +protected: + /** + * @brief Sets the child's parent container. This does not add the child to the parent's collection. + * THIS METHOD IS ONLY USED BY IDataStructureNode AND SHOULD NOT BE USED BY ANY CLASS THAT DERIVES FROM IT. + * @param child + * @param parent + */ + void createParentConnection(IDataStructureNode* child, AbstractDataStructureContainer* parent) const; + + /** + * @brief Clears the child's parent pointer. This does not remove the child from the parent's collection. + * THIS METHOD IS ONLY USED BY IDataStructureNode AND SHOULD NOT BE USED BY ANY CLASS THAT DERIVES FROM IT. + * @param child + */ + void destroyParentConnection(IDataStructureNode* child) const; +}; diff --git a/Source/SIMPLib/DataContainers/RenameDataPath.cpp b/Source/SIMPLib/DataContainers/RenameDataPath.cpp new file mode 100644 index 0000000000..f60b5e3153 --- /dev/null +++ b/Source/SIMPLib/DataContainers/RenameDataPath.cpp @@ -0,0 +1,246 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "RenameDataPath.h" + +#include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void RenameDataPath::AlertFilterCreatedPath(AbstractFilter* filter, DataID_t id, const DataArrayPath& path) +{ + if(filter != nullptr) + { + filter->checkIfPathRenamed(id, path); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool RenameDataPath::CanReplaceRenamePath(const DataArrayPath::RenameType& originalPair, const DataArrayPath::RenameType& newPair) +{ + return originalPair.first == newPair.first && originalPair.second != newPair.second; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool RenameDataPath::CheckRenamePath(const DataContainerArrayShPtr& oldDca, const DataContainerArrayShPtr& newDca, const DataArrayPath& oldPath, const DataArrayPath& newPath) +{ + // If the paths are not possible renames, return false + if(!oldPath.possibleRename(newPath)) + { + return false; + } + + // Check that the DataArrayPath targets are compatibles + DataContainer::Pointer oldDc = oldDca->getDataContainer(oldPath.getDataContainerName()); + DataContainer::Pointer newDc = newDca->getDataContainer(newPath.getDataContainerName()); + + // Data Container required + if(oldDc && newDc) + { + IGeometry::Pointer oldGeom = oldDc->getGeometry(); + IGeometry::Pointer newGeom = newDc->getGeometry(); + + bool hasGeom = oldGeom && newGeom; + if((hasGeom && oldGeom->getGeometryType() == newGeom->getGeometryType()) || !hasGeom) + { + // No Attribute Matrix path + if(oldPath.getAttributeMatrixName().isEmpty() && newPath.getAttributeMatrixName().isEmpty()) + { + return true; + } + + AttributeMatrix::Pointer oldAm = oldDc->getAttributeMatrix(oldPath.getAttributeMatrixName()); + AttributeMatrix::Pointer newAm = newDc->getAttributeMatrix(newPath.getAttributeMatrixName()); + + bool hasAttributeMatrix = oldAm && newAm; + if(hasAttributeMatrix && oldAm->getType() == newAm->getType() && oldAm->getNumberOfTuples() == newAm->getNumberOfTuples()) + { + // No Data Array path + if(oldPath.getDataArrayName().isEmpty() && newPath.getDataArrayName().isEmpty()) + { + return true; + } + + IDataArray::Pointer oldDa = oldAm->getAttributeArray(oldPath.getDataArrayName()); + IDataArray::Pointer newDa = newAm->getAttributeArray(newPath.getDataArrayName()); + + bool hasDataArray = oldDa && newDa; + bool hasSameType = oldDa->getTypeAsString() == newDa->getTypeAsString(); + bool hasSameCompDims = oldDa->getComponentDimensions() == newDa->getComponentDimensions(); + bool isNeighborList = hasSameType && newDa->getTypeAsString().startsWith("NeighborList"); + if(hasDataArray && hasSameType && (hasSameCompDims || isNeighborList)) + { + return true; + } + } + } + } + + return false; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataArrayPath::RenameContainer RenameDataPath::CheckForRenamedPaths(const DataContainerArrayShPtr& oldDca, const DataContainerArrayShPtr& newDca, const std::list& oldPaths, + const std::list& newPaths) +{ + DataArrayPath::RenameContainer container; + std::list duplicatedPaths; + std::list usedNewPaths; + + // For each older path, check for any matching new paths. If only one new path matches, add it as a possibility + for(const DataArrayPath& oldPath : oldPaths) + { + // If the same path exists in both oldPaths and newPaths, it was not renamed + if(std::find(newPaths.begin(), newPaths.end(), oldPath) != newPaths.end()) + { + continue; + } + + // Find any potential renames in newPaths for the given oldPath + std::list matches; + for(const DataArrayPath& newPath : newPaths) + { + // If the same path exists in both oldPaths and newPaths, it was not renamed + if(std::find(oldPaths.begin(), oldPaths.end(), newPath) != oldPaths.end()) + { + continue; + } + + // Check that all geometries, AttributeMatrices, and DataArrays are compatible + if(CheckRenamePath(oldDca, newDca, oldPath, newPath)) + { + matches.push_back(newPath); + } + } + // If this path was already used, mark it as duplicate and move on + if(matches.size() == 1) + { + const DataArrayPath& newPath = matches.front(); + if(usedNewPaths.end() != std::find(usedNewPaths.begin(), usedNewPaths.end(), newPath)) + { + duplicatedPaths.push_back(newPath); + } + else + { + usedNewPaths.push_back(newPath); + container.push_back(std::make_pair(oldPath, newPath)); + } + } + } + + // Remove items with duplicated paths + for(auto iter = container.begin(); iter != container.end();) + { + const DataArrayPath& checkPath = std::get<1>(*iter); + if(duplicatedPaths.end() != std::find(duplicatedPaths.begin(), duplicatedPaths.end(), checkPath)) + { + iter = container.erase(iter); + } + else + { + iter++; + } + } + + return container; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void RenameDataPath::CalculateRenamedPaths(const AbstractFilterShPtr& filter, DataArrayPath::RenameContainer& renamedPaths) +{ + const DataArrayPath::RenameContainer origRenamedPaths = filter->getRenamedPaths(); + filter->preflight(); + // Check if an existing renamed path was created by this filter + std::list createdPaths = filter->getCreatedPaths(); + for(const auto& origRenamedPath : origRenamedPaths) + { + createdPaths.push_back(origRenamedPath.second); + } + for(const DataArrayPath& createdPath : createdPaths) + { + // Using iterator over range-based for to utilize std::list.erase(iterator) + for(auto iter = renamedPaths.begin(); iter != renamedPaths.end(); iter++) + { + const DataArrayPath& originalPath = (*iter).first; + if(originalPath == createdPath) + { + renamedPaths.erase(iter); + break; + } + } + } + + // Check for updated rename paths + MergeRenamedPaths(renamedPaths, origRenamedPaths); + const DataArrayPath::RenameContainer updatedRenamedPaths = filter->getRenamedPaths(); + MergeRenamedPaths(renamedPaths, updatedRenamedPaths); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void RenameDataPath::MergeRenamedPaths(RenameContainer& list, const RenameContainer& newRenames) +{ + for(const auto& newRename : newRenames) + { + bool added = false; + // Check if this updates an existing rename + for(auto iter = list.begin(); iter != list.end(); iter++) + { + const DataArrayPath::RenameType& renamedPath = *iter; + const auto& possibleRename = DataArrayPath::CreateLinkingRename(renamedPath, newRename); + if(possibleRename.first) + { + list.insert(iter, possibleRename.second); + added = true; + break; + } + } + // Path wasn't updated + if(!added) + { + list.push_back(newRename); + } + } +} diff --git a/Source/SIMPLib/DataContainers/RenameDataPath.h b/Source/SIMPLib/DataContainers/RenameDataPath.h new file mode 100644 index 0000000000..6a31f60b50 --- /dev/null +++ b/Source/SIMPLib/DataContainers/RenameDataPath.h @@ -0,0 +1,125 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include +#include + +#include "SIMPLib/SIMPLib.h" + +class AbstractFilter; +class DataArrayPath; +class DataContainerArray; + +using AbstractFilterShPtr = std::shared_ptr; +using DataContainerArrayShPtr = std::shared_ptr; + +/** + * @brief RenameDataPath is used by DataContainerArray, DataContainer, and AttributeMatrix + * to alert the specified AbstractFilter that a DataArrayPath has been created + * with the given DataID_t. This also serves as the declaration of the type alias, + * DataID_t so that all classes that require it have access to it without causing + * dependency issues. + */ +namespace RenameDataPath +{ +using RenamePathType = std::pair; +using RenameContainer = std::list; +using PossibleRename = std::pair; + +/** + * @brief DataID_t is used as the ID type when creating DataArrayPaths through + * createNonPrereq* methods inside AbstractFilter::dataCheck(). This ID is + * used for mapping created paths and performing quick lookups to detect rename + * operations far more quickly than previous implementations for rename + * operations. This forces filters to opt-in to rename functionality rather than + * provide it across all filters automatically. + */ +using DataID_t = size_t; +const DataID_t k_Invalid_ID = 0; + +/** + * @brief This function serves as the main hub for alerting the specified + * AbstractFilter that a DataArrayPath has been created with the given ID. + * The plus side of this is that AbstractFilter has a single friend function + * instead of having to declare DataContainerArray, DataContainer, and AttributeMatrix + * all as friend classes in order to achieve the same result. + * @param filter The filter creating the path + * @param id The local ID for the filter to perform rename checks on + * @param path The new DataArrayPath + */ +void SIMPLib_EXPORT AlertFilterCreatedPath(AbstractFilter* filter, DataID_t id, const DataArrayPath& path); + +/** + * @brief Checks if two rename values are compatible to be merged together. + * @param originalPair + * @param newPair + * @return + */ +bool SIMPLib_EXPORT CanReplaceRenamePath(const RenamePathType& originalPair, const RenamePathType& newPair); + +/** + * @brief checks if the targets of the old DataArrayPath and new DataArrayPath are compatible in their given DataContainerArrays + * @param oldDca + * @param newDca + * @param oldPath + * @param newPath + */ +bool SIMPLib_EXPORT CheckRenamePath(const DataContainerArrayShPtr& oldDca, const DataContainerArrayShPtr& newDca, const DataArrayPath& oldPath, const DataArrayPath& newPath); + +/** + * @brief checks for and returns any updated DataArrayPaths between two sets + * @param oldPaths + * @param newPaths + * @return + */ +RenameContainer SIMPLib_EXPORT CheckForRenamedPaths(const DataContainerArrayShPtr& oldDca, const DataContainerArrayShPtr& newDca, const std::list& oldPaths, + const std::list& newPaths); + +/** + * @brief Calculate the rename paths for the given filter and removes rename paths as required by created paths. + * The updated rename paths are added to the list parameter. + * @param filter + * @param renamePaths + */ +void SIMPLib_EXPORT CalculateRenamedPaths(const AbstractFilterShPtr& filter, RenameContainer& renamedPaths); + +/** + * @brief Merges a list of DataArrayPath renames into an existing list. + * @param list + * @param newRenames + */ +void SIMPLib_EXPORT MergeRenamedPaths(RenameContainer& list, const RenameContainer& newRenames); +} // namespace RenameDataPath diff --git a/Source/SIMPLib/DataContainers/SourceList.cmake b/Source/SIMPLib/DataContainers/SourceList.cmake index 1ef9dcf942..695709073a 100755 --- a/Source/SIMPLib/DataContainers/SourceList.cmake +++ b/Source/SIMPLib/DataContainers/SourceList.cmake @@ -26,7 +26,7 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -# The code contained herein was partially funded by the followig contracts: +# The code contained herein was partially funded by the following contracts: # United States Air Force Prime Contract FA8650-07-D-5800 # United States Air Force Prime Contract FA8650-10-D-5210 # United States Prime Contract Navy N00173-07-C-2068 @@ -57,6 +57,10 @@ set(SIMPLib_${SUBDIR_NAME}_HDRS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainer.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerArrayProxy.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerProxy.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DsnIterators.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IDataStructureContainerNode.hpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IDataStructureNode.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/RenameDataPath.h ) set(SIMPLib_${SUBDIR_NAME}_SRCS @@ -70,6 +74,8 @@ set(SIMPLib_${SUBDIR_NAME}_SRCS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerProxy.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerBundle.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IDataContainerBundle.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IDataStructureNode.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/RenameDataPath.cpp ) cmp_IDE_SOURCE_PROPERTIES( "${SUBDIR_NAME}" "${SIMPLib_${SUBDIR_NAME}_HDRS};${SIMPLib_${SUBDIR_NAME}_Moc_HDRS}" "${SIMPLib_${SUBDIR_NAME}_SRCS}" "${PROJECT_INSTALL_HEADERS}") diff --git a/Source/SIMPLib/DataContainers/Testing/Cxx/DataContainerBundleTest.cpp b/Source/SIMPLib/DataContainers/Testing/Cxx/DataContainerBundleTest.cpp index cfab4dfe84..ec91981bc3 100644 --- a/Source/SIMPLib/DataContainers/Testing/Cxx/DataContainerBundleTest.cpp +++ b/Source/SIMPLib/DataContainers/Testing/Cxx/DataContainerBundleTest.cpp @@ -1,41 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include #include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataArrays/IDataArray.h" @@ -43,8 +44,6 @@ #include "SIMPLib/DataContainers/DataContainer.h" #include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/DataContainers/DataContainerBundle.h" -#include "SIMPLib/SIMPLib.h" - #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -67,12 +66,13 @@ class DataContainerBundleTest // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- - template void AddDataArray(AttributeMatrix::Pointer am, const QString name, QVector& tDims, QVector& cDims) + template + void AddDataArray(AttributeMatrix::Pointer am, const QString name, std::vector& tDims, std::vector& cDims) { - typename DataArray::Pointer data = DataArray::CreateArray(tDims, cDims, name); + typename DataArray::Pointer data = DataArray::CreateArray(tDims, cDims, name, true); - am->addAttributeArray(data->getName(), data); + am->insertOrAssign(data); } // ----------------------------------------------------------------------------- @@ -81,11 +81,11 @@ class DataContainerBundleTest void TestDataBundleCommonPaths() { - QVector tDims(3, 0); + std::vector tDims(3, 0); tDims[0] = 10; tDims[1] = 20; tDims[2] = 30; - QVector cDims(2); + std::vector cDims(2); cDims[0] = 3; cDims[1] = 3; @@ -94,11 +94,11 @@ class DataContainerBundleTest AddDataArray(am, "Uint8 Array", tDims, cDims); AddDataArray(am, "Float Array", tDims, cDims); AddDataArray(am, "int32 Array", tDims, cDims); - dc0->addAttributeMatrix(am->getName(), am); + dc0->addOrReplaceAttributeMatrix(am); - QVector tupleDims(1, 1); + std::vector tupleDims(1, 1); AttributeMatrix::Pointer metaAm = AttributeMatrix::New(tupleDims, DataContainerBundle::GetMetaDataName(), AttributeMatrix::Type::MetaData); - dc0->addAttributeMatrix(metaAm->getName(), metaAm); + dc0->addOrReplaceAttributeMatrix(metaAm); DataContainer::Pointer dc1 = dc0->deepCopy(false); dc1->setName("DC 1"); @@ -109,14 +109,14 @@ class DataContainerBundleTest dc2->getAttributeMatrix("CellAttributeMatrix")->removeAttributeArray("Uint8 Array"); DataContainerArray::Pointer dca = DataContainerArray::New(); - dca->addDataContainer(dc0); - dca->addDataContainer(dc1); - dca->addDataContainer(dc2); + dca->addOrReplaceDataContainer(dc0); + dca->addOrReplaceDataContainer(dc1); + dca->addOrReplaceDataContainer(dc2); DataContainerBundle::Pointer bundle = DataContainerBundle::New("Bundle 1"); - bundle->addDataContainer(dc0); - bundle->addDataContainer(dc1); - bundle->addDataContainer(dc2); + bundle->addOrReplaceDataContainer(dc0); + bundle->addOrReplaceDataContainer(dc1); + bundle->addOrReplaceDataContainer(dc2); QVector paths = bundle->findCommonDataArrayPaths(); diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ApplyImageTransforms.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ApplyImageTransforms.md new file mode 100644 index 0000000000..42cef1823a --- /dev/null +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ApplyImageTransforms.md @@ -0,0 +1,36 @@ +# Apply Image Transforms # + +## Group (Subgroup) ## + +CoreFilters (Image) + +## Description ## + +This **Filter** updates the geometry of selected data containers by applying the transforms stored in each data container to the data container's origin. This is an experimental filter and is not yet ready for release to the public. It is only currently meant to be used to apply Affine 3x3 transforms from each data container's transform container to the data container's origin. + +## Parameters ## + +None. + +## Required Geometry ## + +Image + +## Required Objects ## + +| Kind | Default Name | Type | Component Dimensions | Description | +|------|--------------|-------------|---------|-----| +| **Image Data Containers** | N/A | Any | Any | The data containers whose stored transforms will be applied to the origin. | + +## Created Objects ## + +None. + +## License & Copyright ## + +Please see the description file distributed with this plugin. + +## DREAM3D Mailing Lists ## + +If you need more help with a filter, please consider asking your question on the DREAM3D Users mailing list: +https://groups.google.com/forum/?hl=en#!forum/dream3d-users \ No newline at end of file diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ArrayCalculator.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ArrayCalculator.md index 0d199ab27c..b6e3cc312d 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ArrayCalculator.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ArrayCalculator.md @@ -1,5 +1,5 @@ -Attribute Array Calculator -============= +# Attribute Array Calculator # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/Breakpoint.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/Breakpoint.md index 7272b8201b..1ea57aec54 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/Breakpoint.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/Breakpoint.md @@ -1,2 +1 @@ -Breakpoint -============= \ No newline at end of file +# Breakpoint # diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CombineAttributeArrays.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CombineAttributeArrays.md index e29a42737f..9791d430d1 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CombineAttributeArrays.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CombineAttributeArrays.md @@ -1,5 +1,5 @@ -Combine Attribute Arrays -============= +# Combine Attribute Arrays # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CombineAttributeMatrices.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CombineAttributeMatrices.md index 87ef3fcdca..05e844f722 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CombineAttributeMatrices.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CombineAttributeMatrices.md @@ -1,5 +1,5 @@ -Combine Feature/Ensemble Attribute Matrices -============= +# Combine Feature/Ensemble Attribute Matrices # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ConditionalSetValue.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ConditionalSetValue.md index 983d4b3f92..c165637d70 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ConditionalSetValue.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ConditionalSetValue.md @@ -1,5 +1,5 @@ -Replace Value in Array (Conditional) -============= +# Replace Value in Array (Conditional) # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ConvertColorToGrayScale.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ConvertColorToGrayScale.md index bf3f8df96b..d6b0657291 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ConvertColorToGrayScale.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ConvertColorToGrayScale.md @@ -1,5 +1,5 @@ -Color to GrayScale -============= +# Color to GrayScale # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ConvertData.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ConvertData.md index 09e667ce22..d2e49ef18c 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ConvertData.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ConvertData.md @@ -1,5 +1,5 @@ -Convert Attribute Data Type -============= +# Convert Attribute Data Type # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CopyFeatureArrayToElementArray.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CopyFeatureArrayToElementArray.md index f50f268cfe..6209d42f92 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CopyFeatureArrayToElementArray.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CopyFeatureArrayToElementArray.md @@ -1,5 +1,5 @@ -Create Element Array from Feature Array -============= +# Create Element Array from Feature Array # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CopyObject.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CopyObject.md index e2f5caf45b..fbcc68e236 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CopyObject.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CopyObject.md @@ -1,5 +1,5 @@ -Copy Object -============= +# Copy Object # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateAttributeMatrix.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateAttributeMatrix.md index ce017dd859..13382bacce 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateAttributeMatrix.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateAttributeMatrix.md @@ -1,5 +1,5 @@ -Create Attribute Matrix -============= +# Create Attribute Matrix # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateDataArray.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateDataArray.md index 5c700696aa..e270c20ebf 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateDataArray.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateDataArray.md @@ -1,16 +1,24 @@ -Create Data Array -============= +# Create Data Array # ## Group (Subgroup) ## Core (Generation) - ## Description ## -This **Filter** creates an **Attribute Array** of any primitive type with any number of components along a _single component dimension_. For example, a scalar as (1) or a 3-vector as (3), but _not_ a matrix as (3, 3). The array is initialized to a user define value. The primitive type of the array to create is set using an integer constant. Code listing 1 shows the values: +This **Filter** creates an **Attribute Array** of any primitive type with any number of components along a _single component dimension_. For example, a scalar as (1) or a 3-vector as (3), but _not_ a matrix as (3, 3). The array is initialized to a user define value or with random values within a specified range. + +When initializing a multicomponent array square bracket notation can be used to specify different initialization values for each component. For example say that I want to intialize a 2 component array where the first component is 0 and the second component is 1 we would use the following input string for the *Initialization Value* + + 0;1 + +We are using semicolons instead of commas or decimal points due to different international standards (European versus United States?). + +Another example is if you want to create a floating point array where each tuple has 10 components but you just want the value of 2.5 to be used for each, then simply use: -### Primitive Type Enumeration ### + 2.5 + +### Scalar Type Values ### static const int Int8 = 0; static const int UInt8 = 1; @@ -23,9 +31,8 @@ This **Filter** creates an **Attribute Array** of any primitive type with any nu static const int Float = 8; static const int Double = 9; static const int Bool = 10; - -### Primitive Data Types ## +### Primitive Data Type Valid Ranges ## | Type | Size | Range | |------------------|------|--------------------| @@ -49,7 +56,7 @@ must have a user entry or the default value _0_ will be used. | Name | Type | Description | |------------------|------|-------------| | Scalar Type | Enumeration | Primitive data type for created array | -| Number of Components | int32_t | Component size | +| Number of Components | int32_t | The number of components that each tuple contains. Matrix are row major form within SIMPL| | Initialization Value | float | Initialization value for array | ## Required Geometry ## @@ -66,11 +73,8 @@ None |------|--------------|-------------|---------|----------------| | Any **Attribute Array** | None | Any | Any | Created **Attribute Array** location and name | - ## Example Pipelines ## - - ## License & Copyright ## Please see the description file distributed with this **Plugin** @@ -78,4 +82,3 @@ Please see the description file distributed with this **Plugin** ## DREAM.3D Mailing Lists ## If you need more help with a **Filter**, please consider asking your question on the [DREAM.3D Users Google group!](https://groups.google.com/forum/?hl=en#!forum/dream3d-users) - diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateDataContainer.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateDataContainer.md index b92f83bebd..1a3f0c0c71 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateDataContainer.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateDataContainer.md @@ -1,5 +1,5 @@ -Create Data Container -============= +# Create Data Container # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateFeatureArrayFromElementArray.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateFeatureArrayFromElementArray.md index 02d25b8d93..1b0996a2f4 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateFeatureArrayFromElementArray.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateFeatureArrayFromElementArray.md @@ -1,5 +1,5 @@ -Create Feature Array From Element Array -============= +# Create Feature Array From Element Array # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateGeometry.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateGeometry.md index 77fdd9c940..057ca8516c 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateGeometry.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateGeometry.md @@ -1,5 +1,5 @@ -Create Geometry -============= +# Create Geometry # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateGridMontage.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateGridMontage.md new file mode 100644 index 0000000000..7cdbed8272 --- /dev/null +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateGridMontage.md @@ -0,0 +1,44 @@ +# Create Grid Montage # + + +## Group (Subgroup) ## + +Core (Generation) + +## Description ## + +This **Filter** creates a new **Grid Montage**. + +## Parameters ## + +| Kind | Default Name | Type | Component Dimensions | Description | +|------|--------------|-------------|---------|----------------| +| **Int Vec 3** | Dims | N/A | N/A | **Grid Montage** dimensions | +| **DataContainerGrid** | GridSelection | N/A | N/A | **Data Container** grid | + +## Required Geometry ## + +Not Applicable + +## Required Objects ## + +Not Applicable + +## Created Objects ## + +| Kind | Default Name | Type | Component Dimensions | Description | +|------|--------------|-------------|---------|----------------| +| **Grid Montage** | Grid Montage | N/A | N/A | Created **Grid Montage** name | + + +## Example Pipelines ## + + + +## License & Copyright ## + +Please see the description file distributed with this **Plugin** + +## DREAM.3D Mailing Lists ## + +If you need more help with a **Filter**, please consider asking your question on the [DREAM.3D Users Google group!](https://groups.google.com/forum/?hl=en#!forum/dream3d-users) diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateImageGeometry.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateImageGeometry.md index c13c7248d0..3c04e96e3e 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateImageGeometry.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateImageGeometry.md @@ -1,5 +1,5 @@ -Create Geometry (Image) -============= +# Create Geometry (Image) # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateStringArray.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateStringArray.md index c35a5d070d..318f15d436 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateStringArray.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CreateStringArray.md @@ -1,5 +1,5 @@ -Create String Array -============= +# Create String Array # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CropVertexGeometry.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CropVertexGeometry.md index 2a75b8df5b..46ab7c279d 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CropVertexGeometry.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/CropVertexGeometry.md @@ -1,5 +1,5 @@ -Crop Geometry (Vertex) -============= +# Crop Geometry (Vertex) # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/DataContainerReader.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/DataContainerReader.md index 18de70ac4c..5663c91928 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/DataContainerReader.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/DataContainerReader.md @@ -1,5 +1,5 @@ -Read DREAM.3D Data File -============= +# Read DREAM.3D Data File # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/DataContainerWriter.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/DataContainerWriter.md index f5baf9eb0c..196457d8a0 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/DataContainerWriter.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/DataContainerWriter.md @@ -1,5 +1,5 @@ -Write DREAM.3D Data File -============= +# Write DREAM.3D Data File # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ExecuteProcess.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ExecuteProcess.md index 0345993cf2..453cc60775 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ExecuteProcess.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ExecuteProcess.md @@ -1,5 +1,5 @@ -Execute Process -============= +# Execute Process # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ExtractAttributeArraysFromGeometry.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ExtractAttributeArraysFromGeometry.md index bc14248bd7..3758664b51 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ExtractAttributeArraysFromGeometry.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ExtractAttributeArraysFromGeometry.md @@ -1,5 +1,5 @@ -Extract Attribute Arrays from Geometry -============= +# Extract Attribute Arrays from Geometry # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ExtractComponentAsArray.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ExtractComponentAsArray.md index 3666a37cb4..b9de7271be 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ExtractComponentAsArray.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ExtractComponentAsArray.md @@ -1,5 +1,5 @@ -Extract Component as Attribute Array -============= +# Extract Component as Attribute Array # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/FeatureCountDecision.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/FeatureCountDecision.md index 949633ff58..c13373f427 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/FeatureCountDecision.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/FeatureCountDecision.md @@ -1,5 +1,5 @@ -Feature Count Decision -============= +# Feature Count Decision # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/FindDerivatives.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/FindDerivatives.md index d55c688a90..c4072d9066 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/FindDerivatives.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/FindDerivatives.md @@ -1,5 +1,5 @@ -Find Derivatives -===== +# Find Derivatives # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/GenerateColorTable.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/GenerateColorTable.md index 0abc73b114..fac6bf9b4f 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/GenerateColorTable.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/GenerateColorTable.md @@ -1,5 +1,5 @@ -GenerateColorTable -============= +# GenerateColorTable # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/GenerateTiltSeries.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/GenerateTiltSeries.md new file mode 100644 index 0000000000..cdb1ef1ed0 --- /dev/null +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/GenerateTiltSeries.md @@ -0,0 +1,52 @@ +# Generate Tilt Series # + +## Group (Subgroup) ## + +Core Filters (SIMPLib) + +## Description ## + +This **Filter** creates a series of slices through the Image Geometry where each slice is rotated around the axis selected by the user. + +![images/GenerateTiltSeries.](Images/GenerateTiltSeries.png) + +Each Slice is saved as a new DataContainer with a Cell Attribute Matrix. The user will select which Cell Level Data Array to resample using a simple nearest neighbor algorithm. The user can change the default rotation limits of 0.0 < 180.0 (increments of 10.0) degrees by setting the *Rotation Limits* input parameter. + +## Parameters ## + +| Name | Type | Description | +|------|------|------| +| Rotation Axis | Int | 0=<100>, 1=<010>, 2=<001> | +| Rotation Limits | Float Vec 3 | The minimum, maximum and increment angle in degrees | +| Resample Spacing | Float Vec 3 | The Spacing in the X, Y, Z direction for the resampling | +| Input Data Array Path | DataArrayPath | The path to the Cell level data array to resample | + +## Required Geometry ## + +Required Geometry Type: Image Geometry + +## Required Objects ## + +| Kind | Default Name | Type | Component Dimensions | Description | +|------|--------------|-------------|---------|-----| + + +## Created Objects ## + +| Kind | Default Name | Type | Component Dimensions | Description | +|------|--------------|------|----------------------|-------------| +| **Data Container** | Name suffixed with the rotation index | DataContainer | N/A | A new DataContainer for each rotation is created | + + +## Example Pipelines ## + +List the names of the example pipelines where this filter is used. + +## License & Copyright ## + +Please see the description file distributed with this plugin. + +## DREAM3D Mailing Lists ## + +If you need more help with a filter, please consider asking your question on the DREAM3D Users mailing list: +https://groups.google.com/forum/?hl=en#!forum/dream3d-users \ No newline at end of file diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/GenerateVertexCoordinates.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/GenerateVertexCoordinates.md new file mode 100644 index 0000000000..46e2110584 --- /dev/null +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/GenerateVertexCoordinates.md @@ -0,0 +1,49 @@ +# Generate Cell Centers # + +This filter will generate an Float Attribute Array that stores the center point of each voxel in an Image Geometry + +## Group (Subgroup) ## + +Core Filters (Conversion) + +## Description ## + +This filter will extract all the voxel centers of an Image Geometry or a RectilinearGrid geometry +into a new 3x1 Float Attribute Array. + +## Parameters ## + +| Name | Type | Description | +|------|------|------| +| SelectedDataContainerName | string | Name of the DataContainer that has the Image or RectGrid Geometry object | +| CoordinateArrayPath | string | Name of the newly created AttributeArray that holds the Voxel Center Values | + +## Required Geometry ## + +Required Geometry Type: **ImageGeom** or **RectilinearGrid** + +## Required Objects ## + +| Kind | Default Name | Type | Component Dimensions | Description | +|------|--------------|-------------|---------|-----| +| **Data Container** | | ImageGeom or RectGridGeom | N/A | Input DataContainer that holds the geometry to extract | + + +## Created Objects ## + +| Kind | Default Name | Type | Component Dimensions | Description | +|------|--------------|-------------|---------|-----| +| FloatArray | "Cell Centers" | | N/A | The newly created Voxel Cell Centers | + +## Example Pipelines ## + + + +## License & Copyright ## + +Please see the description file distributed with this plugin. + +## DREAM3D Mailing Lists ## + +If you need more help with a filter, please consider asking your question on the DREAM3D Users mailing list: +https://groups.google.com/forum/?hl=en#!forum/dream3d-users \ No newline at end of file diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/Images/GenerateTiltSeries.png b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/Images/GenerateTiltSeries.png new file mode 100644 index 0000000000..328ba891d0 Binary files /dev/null and b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/Images/GenerateTiltSeries.png differ diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/Images/RotateSampleRefFrame_1.png b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/Images/RotateSampleRefFrame_1.png new file mode 100644 index 0000000000..cb326849ef Binary files /dev/null and b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/Images/RotateSampleRefFrame_1.png differ diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ImportAsciDataArray.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ImportAsciDataArray.md index c4188feda9..63c2e9afd2 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ImportAsciDataArray.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ImportAsciDataArray.md @@ -1,5 +1,5 @@ -Import ASCII Attribute Array -============= +# Import ASCII Attribute Array # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ImportHDF5Dataset.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ImportHDF5Dataset.md index 079eb0a1fd..d95f0922f4 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ImportHDF5Dataset.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ImportHDF5Dataset.md @@ -1,5 +1,4 @@ -Import HDF5 Dataset -============= +# Import HDF5 Dataset # ## Group (Subgroup) ## @@ -10,33 +9,33 @@ Core (IO/Read) This **Filter** allows the user to import datasets from an HDF5 file and store them as attribute arrays in DREAM.3D. This filter supports importing datasets with any number of dimensions, as long as the created attribute array's total number of components and the tuple count of the destination attribute matrix multiply together to match the HDF5 dataset's total number of elements. The component dimensions are input as a comma-delimited list of dimensional values. For example: + 1. 3, 4 = 3x4 2. 5, 2, 1 = 5x2x1 3. 6 = 6 -### Examples ### +### Examples ### + 1. Suppose we have a 1D dataset in an HDF5 file with dimension **12,000**. We can input component dimensions of **5, 2, 2** and set the destination attribute matrix tuple dimensions to **35 x 5 x 2 x 2** - - The total number of elements for the HDF5 dataset is 12,000. - The total number of tuples in the destination attribute matrix is 35\*5\*2\*2 = 700. - The total number of components for the created attribute array is 5\*2\*2 = 20. - The total number of elements for the created attribute array will be 700\*20 = 14,000. - - 14,000 does not equal 12,000, so this will result in a preflight error. - -1. Suppose we have a 3D dataset in an HDF5 file with dimensions **1 x 16 x 1001 x 1001**. - - We can input component dimensions of **2** and set our destination attribute matrix tuple dimensions to **134 x 67**. - - The total number of elements for the HDF5 dataset is 1\*16\*1001\*1001 = 16,032,016. - The total number of tuples in the destination attribute matrix is 8\*1001\*1001 = 8,016,008. - The total number of components for the created attribute array is 2. - The total number of elements for the created attribute array will be 8,016,008\*2 = 16,032,016. - - The total number of elements of the created attribute array (16,032,016) equals the total number of elements of the HDF5 dataset (16,032,016), so we can import this dataset without errors (see below). - -![](Images/ImportHDF5Dataset_ui.png) + ++ The total number of elements for the HDF5 dataset is 12,000. ++ The total number of tuples in the destination attribute matrix is 35\*5\*2\*2 = 700. ++ The total number of components for the created attribute array is 5\*2\*2 = 20. ++ The total number of elements for the created attribute array will be 700\*20 = 14,000. + +14,000 does not equal 12,000, so this will result in a preflight error. + +2. Suppose we have a 3D dataset in an HDF5 file with dimensions **1 x 16 x 1001 x 1001**. +We can input component dimensions of **2** and set our destination attribute matrix tuple dimensions to **134 x 67**. + ++ The total number of elements for the HDF5 dataset is 1\*16\*1001\*1001 = 16,032,016. ++ The total number of tuples in the destination attribute matrix is 8\*1001\*1001 = 8,016,008. ++ The total number of components for the created attribute array is 2. ++ The total number of elements for the created attribute array will be 8,016,008\*2 = 16,032,016. ++ The total number of elements of the created attribute array (16,032,016) equals the total number of elements of the HDF5 dataset (16,032,016), so we can import this dataset without errors (see below). + +![Example Image](Images/ImportHDF5Dataset_ui.png) ## Parameters ## @@ -46,7 +45,6 @@ The component dimensions are input as a comma-delimited list of dimensional valu | Checked Datasets | N/A | The checked datasets in the file tree to import | | Component Dimensions | QString | The component dimensions that the imported dataset will have. This is a comma-delimited list of dimensional values | - ## Required Geometry ## Not Applicable @@ -65,11 +63,8 @@ Not Applicable ## Example Pipelines ## - - ## License & Copyright ## Please see the description file distributed with this **Plugin** ## DREAM.3D Mailing Lists ## - diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/InitializeData.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/InitializeData.md index 1aa64f764c..b5b2d8bfaa 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/InitializeData.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/InitializeData.md @@ -1,5 +1,5 @@ -Initialize Data -============= +# Initialize Data # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/LinkFeatureMapToElementArray.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/LinkFeatureMapToElementArray.md index ad4b6787c5..0426b2b28e 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/LinkFeatureMapToElementArray.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/LinkFeatureMapToElementArray.md @@ -1,5 +1,5 @@ -Link Feature Attribute Matrix to Element Attribute Array -============= +# Link Feature Attribute Matrix to Element Attribute Array # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MaskCountDecision.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MaskCountDecision.md index ba3cfea5b0..53980193dd 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MaskCountDecision.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MaskCountDecision.md @@ -1,5 +1,5 @@ -Mask Count Decision -============= +# Mask Count Decision # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MassCreateData.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MassCreateData.md new file mode 100644 index 0000000000..59fc8c04ff --- /dev/null +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MassCreateData.md @@ -0,0 +1,41 @@ +# Mass Create Data Containers # + + +## Group (Subgroup) ## + +Core (Generation) + + +## Description ## + +This **Filter** creates 4,000 **Data Containers** starting with a given name with an index number tacked on at the end. This filter was created for testing rename operation timings. + +## Parameters ## + +| Name | Type | Description | +|------------------|------|-------------| +| Data Container Name | string | Base DataContainer name | + +## Required Geometry ## + +Not Applicable + +## Required Objects ## + +None + +## Created Objects ## + +| Kind | Default Name | Description | +|------|--------------|-------------|---------|----------------| +| **Data Container** | None | Created **Data Container** location and name | + + +## Example Pipelines ## + + + +## License & Copyright ## + +Please see the description file distributed with this **Plugin** + diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MoveData.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MoveData.md index 58827ad54f..77f9ca507c 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MoveData.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MoveData.md @@ -1,5 +1,5 @@ -Move Data -============= +# Move Data # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MoveMultiData.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MoveMultiData.md index 8207b8dffe..f33a99b2e4 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MoveMultiData.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MoveMultiData.md @@ -1,5 +1,5 @@ -Move Multi Data -============= +# Move Multi Data # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MultiThresholdObjects.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MultiThresholdObjects.md index bbf3221ebb..9b47d343d9 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MultiThresholdObjects.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MultiThresholdObjects.md @@ -1,5 +1,5 @@ -Threshold Objects -============= +# Threshold Objects # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MultiThresholdObjects2.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MultiThresholdObjects2.md index 52f5e65de9..23556b75cb 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MultiThresholdObjects2.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/MultiThresholdObjects2.md @@ -1,5 +1,5 @@ -Threshold Objects 2 -============= +# Threshold Objects 2 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/PipelineAnnotation.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/PipelineAnnotation.md index 3f1dbcecd8..9cb418e0c1 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/PipelineAnnotation.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/PipelineAnnotation.md @@ -1,5 +1,5 @@ -Pipeline Annotation -============= +# Pipeline Annotation # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/PostSlackMessage.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/PostSlackMessage.md index c646be9a71..c6c1d0419c 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/PostSlackMessage.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/PostSlackMessage.md @@ -1,5 +1,5 @@ -Post Slack Message -============= +# Post Slack Message # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RawBinaryReader.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RawBinaryReader.md index d633bf96c1..8dc7a3906b 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RawBinaryReader.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RawBinaryReader.md @@ -1,5 +1,5 @@ -Raw Binary Reader -============= +# Raw Binary Reader # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ReadASCIIData.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ReadASCIIData.md index 3a7431d5c4..ca9989b01e 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ReadASCIIData.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ReadASCIIData.md @@ -1,5 +1,5 @@ -Import ASCII Data -============= +# Import ASCII Data # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RemoveArrays.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RemoveArrays.md index 3d84b1a813..66b52ba497 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RemoveArrays.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RemoveArrays.md @@ -1,5 +1,5 @@ -Delete Data -============= +# Delete Data # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RemoveComponentFromArray.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RemoveComponentFromArray.md index 355a6d825c..d6168d4e5e 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RemoveComponentFromArray.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RemoveComponentFromArray.md @@ -1,5 +1,5 @@ -Remove Component From Array -============= +# Remove Component From Array # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RenameAttributeArray.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RenameAttributeArray.md index a3cce8e519..b9db60e7c9 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RenameAttributeArray.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RenameAttributeArray.md @@ -1,5 +1,5 @@ -Rename Attribute Array -============= +# Rename Attribute Array # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RenameAttributeMatrix.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RenameAttributeMatrix.md index 6ee3d67f28..c7d89ba35d 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RenameAttributeMatrix.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RenameAttributeMatrix.md @@ -1,5 +1,5 @@ -Rename Attribute Matrix -============= +# Rename Attribute Matrix # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RenameDataContainer.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RenameDataContainer.md index 4b9ada91ca..f154acd9c9 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RenameDataContainer.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RenameDataContainer.md @@ -1,5 +1,5 @@ -Rename Data Container -============= +# Rename Data Container # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ReplaceValueInArray.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ReplaceValueInArray.md index 2b8d5f4871..25a848ca70 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ReplaceValueInArray.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/ReplaceValueInArray.md @@ -1,5 +1,5 @@ -Replace Value in Array -============= +# Replace Value in Array # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RequiredZThickness.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RequiredZThickness.md index aff1dfec37..3a672f4768 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RequiredZThickness.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RequiredZThickness.md @@ -1,5 +1,5 @@ -RequiredZThickness -===== +# RequiredZThickness # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RotateSampleRefFrame.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RotateSampleRefFrame.md new file mode 100644 index 0000000000..7cb03d7272 --- /dev/null +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/RotateSampleRefFrame.md @@ -0,0 +1,63 @@ +# Rotate Sample Reference Frame # + +## Group (Subgroup) ## + +Sampling (Rotating/Transforming) + +## Description ## + +This **Filter** will rotate the *spatial reference frame* around a user defined axis, by a user defined angle. The **Filter** will modify the (X, Y, Z) positions of each **Cell** to correctly represent where the **Cell** sits in the newly defined reference frame. For example, if a user selected a *rotation angle* of 90o and a *rotation axis* of (001), then a **Cell** sitting at (10, 0, 0) would be transformed to (0, -10, 0), since the new *reference frame* would have x'=y and y'=-x. + +The equivalent rotation matrix for the above rotation would be the following: + +| | | | +| - | - | - | +| 0 | -1 | 0 | +| 1 | 0 | 0 | +| 0 | 0 | 1 | + +## Example ## + +When importing EBSD data from EDAX typically the user will need to rotate the sample reference frame about the <010> (Y) axis. This results in the image comparison below. Note that in the original image the origin of the data is at (0, 0) microns but after rotation the origin now becomes (-189, 0) microns. If you need to reset the origin back to (0,0) then the filter "Set Origin & Spacing" can be run. + +![Imported EBSD Data Rotated about the <010> axis](Images/RotateSampleREfFrame_1.png) + +## Parameters ## + +| Name | Type | Description | +|------|------|-------------| +| Rotation Representation | Enumeration | Which form used to represent rotation (**axis angle** or **rotation matrix)** | +| Rotation Axis (ijk) | float (3x) | Axis in sample reference frame to rotate about (if **axis angle**) | +| Rotation Angle (Degrees) | float | Magnitude of rotation (in degrees) about the rotation axis (if **axis angle**) | +| Rotation Matrix | float (3x3) | Axis in sample reference frame to rotate about (if **rotation matrix**) | + +## Required Geometry ## + +Image + +## Required Objects ## + +| Kind | Default Name | Type | Component Dimensions | Description | +|------|--------------|------|----------------------|-------------| +| **Attribute Matrix** | CellData | Cell | N/A | **Cell Attribute Matrix** that holds the data to rotate | + +## Created Objects ## + +None + +## Example Pipelines ## + ++ INL Export ++ Export Small IN100 ODF Data (StatsGenerator) ++ TxCopper_Exposed ++ TxCopper_Unexposed ++ Edax IPF Colors ++ Confidence Index Histogram + +## License & Copyright ## + +Please see the description file distributed with this **Plugin** + +## DREAM.3D Mailing Lists ## + +If you need more help with a **Filter**, please consider asking your question on the [DREAM.3D Users Google group!](https://groups.google.com/forum/?hl=en#!forum/dream3d-users) diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/SetOriginResolutionImageGeom.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/SetOriginResolutionImageGeom.md index 4666f56600..6f5dd24a79 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/SetOriginResolutionImageGeom.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/SetOriginResolutionImageGeom.md @@ -1,5 +1,5 @@ -Set Origin & Resolution (Image) -============= +# Set Origin & Resolution (Image) # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/SplitAttributeArray.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/SplitAttributeArray.md index 5b10a059f1..e5f7ffa8a4 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/SplitAttributeArray.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/SplitAttributeArray.md @@ -1,5 +1,5 @@ -Split Multicomponent Attribute Array -============= +# Split Multicomponent Attribute Array # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/WriteTriangleGeometry.md b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/WriteTriangleGeometry.md index 44eebcb24d..e0005ac294 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/WriteTriangleGeometry.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/CoreFilters/WriteTriangleGeometry.md @@ -1,5 +1,5 @@ -Export Triangle Geometry -====== +# Export Triangle Geometry # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/ArraySelectionExample.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/ArraySelectionExample.md index a66c43e414..e4e59a2854 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/ArraySelectionExample.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/ArraySelectionExample.md @@ -1,5 +1,5 @@ -DataContainerArrayProxy Example -===== +# DataContainerArrayProxy Example # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/DynamicTableExample.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/DynamicTableExample.md index f61875a46b..546272cc9a 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/DynamicTableExample.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/DynamicTableExample.md @@ -1,5 +1,5 @@ -Dynamic Table Example -===== +# Dynamic Table Example # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/ErrorWarningFilter.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/ErrorWarningFilter.md index d9a790f840..b9e7a60f89 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/ErrorWarningFilter.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/ErrorWarningFilter.md @@ -1,5 +1,5 @@ -ErrorWarningFilter -============= +# ErrorWarningFilter # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup01.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup01.md index d04c85a646..fa134be744 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup01.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup01.md @@ -1,5 +1,5 @@ -FilterGroup01 -============= +# FilterGroup01 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup02.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup02.md index fa11f98cf1..13a865f7b7 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup02.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup02.md @@ -1,5 +1,5 @@ -FilterGroup02 -============= +# FilterGroup02 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup03.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup03.md index fc2b60f6c5..2896312add 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup03.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup03.md @@ -1,5 +1,5 @@ -FilterGroup03 -============= +# FilterGroup03 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup04.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup04.md index d46c4682de..31dd20e54f 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup04.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup04.md @@ -1,5 +1,5 @@ -FilterGroup04 -============= +# FilterGroup04 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup05.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup05.md index 9b6dc04d14..1bab101fdf 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup05.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup05.md @@ -1,5 +1,5 @@ -FilterGroup05 -============= +# FilterGroup05 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup06.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup06.md index 50540ba14f..b510e835e0 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup06.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup06.md @@ -1,5 +1,5 @@ -FilterGroup06 -============= +# FilterGroup06 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup07.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup07.md index 03c53b2815..e300373a1d 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup07.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup07.md @@ -1,5 +1,5 @@ -FilterGroup07 -============= +# FilterGroup07 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup08.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup08.md index 430f677dc8..3e9ca23b5f 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup08.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup08.md @@ -1,5 +1,5 @@ -FilterGroup08 -============= +# FilterGroup08 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup09.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup09.md index 1429b86509..7e83b8dca6 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup09.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup09.md @@ -1,5 +1,5 @@ -FilterGroup09 -============= +# FilterGroup09 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup10.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup10.md index 23b49e402e..710fc60f99 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup10.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup10.md @@ -1,5 +1,5 @@ -FilterGroup10 -============= +# FilterGroup10 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup11.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup11.md index e377f13db8..d0696431c3 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup11.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup11.md @@ -1,5 +1,5 @@ -FilterGroup11 -============= +# FilterGroup11 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup12.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup12.md index bd3d642615..0b480cfbb3 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup12.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup12.md @@ -1,5 +1,5 @@ -FilterGroup12 -============= +# FilterGroup12 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup13.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup13.md index d450845452..acb6d9c3c3 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup13.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup13.md @@ -1,5 +1,5 @@ -FilterGroup13 -============= +# FilterGroup13 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup14.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup14.md index 96dec60dee..1106914097 100644 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup14.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/FilterGroup14.md @@ -1,5 +1,5 @@ -FilterGroup14 -============= +# FilterGroup14 # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/GenericExample.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/GenericExample.md index 3599725dec..017446049b 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/GenericExample.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/GenericExample.md @@ -1,5 +1,5 @@ -Generic Example -===== +# Generic Example # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/MakeDataContainer.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/MakeDataContainer.md index ddffbd9f3d..b4cc72c7ec 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/MakeDataContainer.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/MakeDataContainer.md @@ -1,5 +1,5 @@ -Make DataContainer -===== +# Make DataContainer # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/TestFilters.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/TestFilters.md index 5346a7d489..dccb0e43a4 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/TestFilters.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/TestFilters.md @@ -1,5 +1,5 @@ -TestFilter -===== +# TestFilter # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/ThresholdExample.md b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/ThresholdExample.md index 86f8051ebe..97ce03f5c1 100755 --- a/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/ThresholdExample.md +++ b/Source/SIMPLib/Documentation/SIMPLibFilters/TestFilters/ThresholdExample.md @@ -1,5 +1,5 @@ -Threshold Example -===== +# Threshold Example # + ## Group (Subgroup) ## diff --git a/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.cpp b/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.cpp index 173a1ed079..dd2f451494 100644 --- a/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.cpp +++ b/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.cpp @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "AbstractFilterParametersReader.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -48,7 +50,7 @@ AbstractFilterParametersReader::~AbstractFilterParametersReader() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString AbstractFilterParametersReader::readString(const QString name, QString value) +QString AbstractFilterParametersReader::readString(const QString& name, QString value) { Q_UNUSED(name) Q_UNUSED(value) @@ -60,7 +62,7 @@ QString AbstractFilterParametersReader::readString(const QString name, QString v // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector AbstractFilterParametersReader::readStrings(const QString name, QVector value) +QVector AbstractFilterParametersReader::readStrings(const QString& name, QVector value) { Q_UNUSED(name) Q_UNUSED(value) @@ -72,7 +74,7 @@ QVector AbstractFilterParametersReader::readStrings(const QString name, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QStringList AbstractFilterParametersReader::readStringList(const QString name, QStringList value) +QStringList AbstractFilterParametersReader::readStringList(const QString& name, QStringList value) { Q_UNUSED(name) Q_UNUSED(value) @@ -84,7 +86,7 @@ QStringList AbstractFilterParametersReader::readStringList(const QString name, Q // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int8_t AbstractFilterParametersReader::readValue(const QString name, int8_t value) +int8_t AbstractFilterParametersReader::readValue(const QString& name, int8_t value) { Q_UNUSED(name) Q_UNUSED(value) @@ -96,7 +98,7 @@ int8_t AbstractFilterParametersReader::readValue(const QString name, int8_t valu // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int16_t AbstractFilterParametersReader::readValue(const QString name, int16_t value) +int16_t AbstractFilterParametersReader::readValue(const QString& name, int16_t value) { Q_UNUSED(name) Q_UNUSED(value) @@ -108,7 +110,7 @@ int16_t AbstractFilterParametersReader::readValue(const QString name, int16_t va // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int32_t AbstractFilterParametersReader::readValue(const QString name, int32_t value) +int32_t AbstractFilterParametersReader::readValue(const QString& name, int32_t value) { Q_UNUSED(name) Q_UNUSED(value) @@ -120,7 +122,7 @@ int32_t AbstractFilterParametersReader::readValue(const QString name, int32_t va // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int64_t AbstractFilterParametersReader::readValue(const QString name, int64_t value) +int64_t AbstractFilterParametersReader::readValue(const QString& name, int64_t value) { Q_UNUSED(name) Q_UNUSED(value) @@ -132,7 +134,7 @@ int64_t AbstractFilterParametersReader::readValue(const QString name, int64_t va // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -uint8_t AbstractFilterParametersReader::readValue(const QString name, uint8_t value) +uint8_t AbstractFilterParametersReader::readValue(const QString& name, uint8_t value) { Q_UNUSED(name) Q_UNUSED(value) @@ -144,7 +146,7 @@ uint8_t AbstractFilterParametersReader::readValue(const QString name, uint8_t va // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -uint16_t AbstractFilterParametersReader::readValue(const QString name, uint16_t value) +uint16_t AbstractFilterParametersReader::readValue(const QString& name, uint16_t value) { Q_UNUSED(name) Q_UNUSED(value) @@ -156,7 +158,7 @@ uint16_t AbstractFilterParametersReader::readValue(const QString name, uint16_t // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -uint32_t AbstractFilterParametersReader::readValue(const QString name, uint32_t value) +uint32_t AbstractFilterParametersReader::readValue(const QString& name, uint32_t value) { Q_UNUSED(name) Q_UNUSED(value) @@ -168,7 +170,7 @@ uint32_t AbstractFilterParametersReader::readValue(const QString name, uint32_t // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -uint64_t AbstractFilterParametersReader::readValue(const QString name, uint64_t value) +uint64_t AbstractFilterParametersReader::readValue(const QString& name, uint64_t value) { Q_UNUSED(name) Q_UNUSED(value) @@ -180,7 +182,7 @@ uint64_t AbstractFilterParametersReader::readValue(const QString name, uint64_t // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -float AbstractFilterParametersReader::readValue(const QString name, float value) +float AbstractFilterParametersReader::readValue(const QString& name, float value) { Q_UNUSED(name) Q_UNUSED(value) @@ -192,7 +194,7 @@ float AbstractFilterParametersReader::readValue(const QString name, float value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -double AbstractFilterParametersReader::readValue(const QString name, double value) +double AbstractFilterParametersReader::readValue(const QString& name, double value) { Q_UNUSED(name) Q_UNUSED(value) @@ -204,7 +206,7 @@ double AbstractFilterParametersReader::readValue(const QString name, double valu // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool AbstractFilterParametersReader::readValue(const QString name, bool value) +bool AbstractFilterParametersReader::readValue(const QString& name, bool value) { Q_UNUSED(name) Q_UNUSED(value) @@ -216,7 +218,7 @@ bool AbstractFilterParametersReader::readValue(const QString name, bool value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrix::Type AbstractFilterParametersReader::readValue(const QString name, AttributeMatrix::Type value) +AttributeMatrix::Type AbstractFilterParametersReader::readValue(const QString& name, AttributeMatrix::Type value) { Q_UNUSED(name) Q_UNUSED(value) @@ -228,7 +230,7 @@ AttributeMatrix::Type AbstractFilterParametersReader::readValue(const QString na // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector AbstractFilterParametersReader::readArray(const QString name, QVector value) +QVector AbstractFilterParametersReader::readArray(const QString& name, QVector value) { Q_UNUSED(name) Q_UNUSED(value) @@ -240,7 +242,7 @@ QVector AbstractFilterParametersReader::readArray(const QString name, QV // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector AbstractFilterParametersReader::readArray(const QString name, QVector value) +QVector AbstractFilterParametersReader::readArray(const QString& name, QVector value) { Q_UNUSED(name) Q_UNUSED(value) @@ -252,7 +254,7 @@ QVector AbstractFilterParametersReader::readArray(const QString name, Q // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector AbstractFilterParametersReader::readArray(const QString name, QVector value) +QVector AbstractFilterParametersReader::readArray(const QString& name, QVector value) { Q_UNUSED(name) Q_UNUSED(value) @@ -264,7 +266,7 @@ QVector AbstractFilterParametersReader::readArray(const QString name, Q // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector AbstractFilterParametersReader::readArray(const QString name, QVector value) +QVector AbstractFilterParametersReader::readArray(const QString& name, QVector value) { Q_UNUSED(name) Q_UNUSED(value) @@ -276,7 +278,7 @@ QVector AbstractFilterParametersReader::readArray(const QString name, Q // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector AbstractFilterParametersReader::readArray(const QString name, QVector value) +QVector AbstractFilterParametersReader::readArray(const QString& name, QVector value) { Q_UNUSED(name) Q_UNUSED(value) @@ -288,7 +290,7 @@ QVector AbstractFilterParametersReader::readArray(const QString name, Q // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector AbstractFilterParametersReader::readArray(const QString name, QVector value) +QVector AbstractFilterParametersReader::readArray(const QString& name, QVector value) { Q_UNUSED(name) Q_UNUSED(value) @@ -300,7 +302,7 @@ QVector AbstractFilterParametersReader::readArray(const QString name, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector AbstractFilterParametersReader::readArray(const QString name, QVector value) +QVector AbstractFilterParametersReader::readArray(const QString& name, QVector value) { Q_UNUSED(name) Q_UNUSED(value) @@ -312,7 +314,7 @@ QVector AbstractFilterParametersReader::readArray(const QString name, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector AbstractFilterParametersReader::readArray(const QString name, QVector value) +QVector AbstractFilterParametersReader::readArray(const QString& name, QVector value) { Q_UNUSED(name) Q_UNUSED(value) @@ -324,7 +326,7 @@ QVector AbstractFilterParametersReader::readArray(const QString name, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector AbstractFilterParametersReader::readArray(const QString name, QVector value) +QVector AbstractFilterParametersReader::readArray(const QString& name, QVector value) { Q_UNUSED(name) Q_UNUSED(value) @@ -336,7 +338,7 @@ QVector AbstractFilterParametersReader::readArray(const QString name, QVe // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector AbstractFilterParametersReader::readArray(const QString name, QVector value) +QVector AbstractFilterParametersReader::readArray(const QString& name, QVector value) { Q_UNUSED(name) Q_UNUSED(value) @@ -348,43 +350,43 @@ QVector AbstractFilterParametersReader::readArray(const QString name, QV // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IntVec3_t AbstractFilterParametersReader::readIntVec3(const QString name, IntVec3_t defaultValue) +IntVec3Type AbstractFilterParametersReader::readIntVec3(const QString& name, IntVec3Type defaultValue) { Q_UNUSED(name) Q_UNUSED(defaultValue) // This should never be executed - return IntVec3_t(); + return IntVec3Type(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatVec3_t AbstractFilterParametersReader::readFloatVec3(const QString name, FloatVec3_t defaultValue) +FloatVec3Type AbstractFilterParametersReader::readFloatVec3(const QString& name, FloatVec3Type defaultValue) { Q_UNUSED(name) Q_UNUSED(defaultValue) // This should never be executed - return FloatVec3_t(); + return FloatVec3Type(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -Float2ndOrderPoly_t AbstractFilterParametersReader::readFloat2ndOrderPoly(const QString name, Float2ndOrderPoly_t defaultValue) +Float2ndOrderPolynomial AbstractFilterParametersReader::readFloat2ndOrderPoly(const QString& name, Float2ndOrderPolynomial defaultValue) { Q_UNUSED(name) Q_UNUSED(defaultValue) // This should never be executed - return Float2ndOrderPoly_t(); + return Float2ndOrderPolynomial(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -Float3rdOrderPoly_t AbstractFilterParametersReader::readFloat3rdOrderPoly(const QString name, Float3rdOrderPoly_t defaultValue) +Float3rdOrderPoly_t AbstractFilterParametersReader::readFloat3rdOrderPoly(const QString& name, Float3rdOrderPoly_t defaultValue) { Q_UNUSED(name) Q_UNUSED(defaultValue) @@ -396,31 +398,31 @@ Float3rdOrderPoly_t AbstractFilterParametersReader::readFloat3rdOrderPoly(const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -Float4thOrderPoly_t AbstractFilterParametersReader::readFloat4thOrderPoly(const QString name, Float4thOrderPoly_t defaultValue) +Float4thOrderPolynomial AbstractFilterParametersReader::readFloat4thOrderPoly(const QString& name, Float4thOrderPolynomial defaultValue) { Q_UNUSED(name) Q_UNUSED(defaultValue) // This should never be executed - return Float4thOrderPoly_t(); + return Float4thOrderPolynomial(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FileListInfo_t AbstractFilterParametersReader::readFileListInfo(const QString name, FileListInfo_t defaultValue) +StackFileListInfo AbstractFilterParametersReader::readFileListInfo(const QString& name, StackFileListInfo defaultValue) { Q_UNUSED(name) Q_UNUSED(defaultValue) // This should never be executed - return FileListInfo_t(); + return StackFileListInfo(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ComparisonInput_t AbstractFilterParametersReader::readComparisonInput(const QString name, ComparisonInput_t defaultValue, int vectorPos) +ComparisonInput_t AbstractFilterParametersReader::readComparisonInput(const QString& name, ComparisonInput_t defaultValue, int vectorPos) { Q_UNUSED(name) Q_UNUSED(defaultValue) @@ -433,7 +435,7 @@ ComparisonInput_t AbstractFilterParametersReader::readComparisonInput(const QStr // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ComparisonInputs AbstractFilterParametersReader::readComparisonInputs(const QString name, ComparisonInputs defValue) +ComparisonInputs AbstractFilterParametersReader::readComparisonInputs(const QString& name, ComparisonInputs defValue) { Q_UNUSED(name) Q_UNUSED(defValue) @@ -445,7 +447,7 @@ ComparisonInputs AbstractFilterParametersReader::readComparisonInputs(const QStr // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ComparisonInputsAdvanced AbstractFilterParametersReader::readComparisonInputsAdvanced(const QString name, ComparisonInputsAdvanced defValue) +ComparisonInputsAdvanced AbstractFilterParametersReader::readComparisonInputsAdvanced(const QString& name, ComparisonInputsAdvanced defValue) { Q_UNUSED(name) Q_UNUSED(defValue) @@ -457,32 +459,32 @@ ComparisonInputsAdvanced AbstractFilterParametersReader::readComparisonInputsAdv // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AxisAngleInput_t AbstractFilterParametersReader::readAxisAngle(const QString name, AxisAngleInput_t v, int vectorPos) +AxisAngleInput AbstractFilterParametersReader::readAxisAngle(const QString& name, AxisAngleInput v, int vectorPos) { Q_UNUSED(name) Q_UNUSED(v) Q_UNUSED(vectorPos) // This should never be executed - return AxisAngleInput_t(); + return AxisAngleInput(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector AbstractFilterParametersReader::readAxisAngles(const QString name, QVector v) +QVector AbstractFilterParametersReader::readAxisAngles(const QString& name, QVector v) { Q_UNUSED(name) Q_UNUSED(v) // This should never be executed - return QVector(); + return QVector(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QSet AbstractFilterParametersReader::readArraySelections(const QString name, QSet v) +QSet AbstractFilterParametersReader::readArraySelections(const QString& name, QSet v) { Q_UNUSED(name) Q_UNUSED(v) @@ -542,11 +544,23 @@ DynamicTableData AbstractFilterParametersReader::readDynamicTableData(const QStr // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QPair AbstractFilterParametersReader::readPairOfDoubles(const QString& name, QPair v) +FPRangePair AbstractFilterParametersReader::readPairOfDoubles(const QString& name, const FPRangePair& v) { Q_UNUSED(name) Q_UNUSED(v) // This should never be executed - return QPair(); + return {}; +} + +// ----------------------------------------------------------------------------- +QString AbstractFilterParametersReader::getNameOfClass() const +{ + return QString("AbstractFilterParametersReader"); +} + +// ----------------------------------------------------------------------------- +QString AbstractFilterParametersReader::ClassName() +{ + return QString("AbstractFilterParametersReader"); } diff --git a/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.h b/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.h index e945de0d6d..035edaef6d 100644 --- a/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.h +++ b/Source/SIMPLib/FilterParameters/AbstractFilterParametersReader.h @@ -1,65 +1,61 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once #include #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLArray.hpp" #include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" -#include "SIMPLib/FilterParameters/AxisAngleFilterParameter.h" +#include "SIMPLib/FilterParameters/AxisAngleInput.h" #include "SIMPLib/FilterParameters/DynamicTableData.h" -#include "SIMPLib/FilterParameters/FileListInfoFilterParameter.h" -#include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" -#include "SIMPLib/FilterParameters/FourthOrderPolynomialFilterParameter.h" -#include "SIMPLib/FilterParameters/IntVec3FilterParameter.h" -#include "SIMPLib/FilterParameters/SecondOrderPolynomialFilterParameter.h" -#include "SIMPLib/FilterParameters/ThirdOrderPolynomialFilterParameter.h" +#include "SIMPLib/FilterParameters/Float2ndOrderPolynomial.h" +#include "SIMPLib/FilterParameters/Float4thOrderPolynomial.h" +#include "SIMPLib/FilterParameters/RangeFilterParameter.h" +#include "SIMPLib/FilterParameters/StackFileListInfo.h" +#include "SIMPLib/FilterParameters/ThirdOrderPolynomial.h" #include "SIMPLib/Filtering/ComparisonInputs.h" #include "SIMPLib/Filtering/ComparisonInputsAdvanced.h" -#include "SIMPLib/SIMPLib.h" class AbstractFilter; -#define READ_ARRAY_SELECTION_PARAMETER(Name)\ - setSelected##Name##Arrays( reader->readArraySelections(#Name, getSelected##Name##Arrays() ) ); - - +#define READ_ARRAY_SELECTION_PARAMETER(Name) setSelected##Name##Arrays(reader->readArraySelections(#Name, getSelected##Name##Arrays())); /** * @class AbstractFilterParametersReader AbstractFilterParametersReader.h DREAM3DLib/Common/AbstractFilterParametersReader.h @@ -70,75 +66,79 @@ class AbstractFilter; */ class SIMPLib_EXPORT AbstractFilterParametersReader { - public: - - SIMPL_TYPE_MACRO(AbstractFilterParametersReader) - - - virtual ~AbstractFilterParametersReader(); - - virtual int openFilterGroup(AbstractFilter* filter, int index) = 0; - virtual int closeFilterGroup() = 0; - - - virtual QString readString(const QString name, QString value); - virtual QVector readStrings(const QString name, QVector value); - virtual QStringList readStringList(const QString name, QStringList value); - - virtual int8_t readValue(const QString name, int8_t value); - virtual int16_t readValue(const QString name, int16_t value); - virtual int32_t readValue(const QString name, int32_t value); - virtual int64_t readValue(const QString name, int64_t value); - virtual uint8_t readValue(const QString name, uint8_t value); - virtual uint16_t readValue(const QString name, uint16_t value); - virtual uint32_t readValue(const QString name, uint32_t value); - virtual uint64_t readValue(const QString name, uint64_t value); - virtual float readValue(const QString name, float value); - virtual double readValue(const QString name, double value); - virtual bool readValue(const QString name, bool value); - virtual AttributeMatrix::Type readValue(const QString name, AttributeMatrix::Type value); - - virtual QVector readArray(const QString name, QVector value); - virtual QVector readArray(const QString name, QVector value); - virtual QVector readArray(const QString name, QVector value); - virtual QVector readArray(const QString name, QVector value); - virtual QVector readArray(const QString name, QVector value); - virtual QVector readArray(const QString name, QVector value); - virtual QVector readArray(const QString name, QVector value); - virtual QVector readArray(const QString name, QVector value); - virtual QVector readArray(const QString name, QVector value); - virtual QVector readArray(const QString name, QVector value); - - virtual IntVec3_t readIntVec3(const QString name, IntVec3_t v); - virtual FloatVec3_t readFloatVec3(const QString name, FloatVec3_t v); - virtual Float2ndOrderPoly_t readFloat2ndOrderPoly(const QString name, Float2ndOrderPoly_t v); - virtual Float3rdOrderPoly_t readFloat3rdOrderPoly(const QString name, Float3rdOrderPoly_t v); - virtual Float4thOrderPoly_t readFloat4thOrderPoly(const QString name, Float4thOrderPoly_t v); - virtual FileListInfo_t readFileListInfo(const QString name, FileListInfo_t v); - virtual ComparisonInput_t readComparisonInput(const QString name, ComparisonInput_t v, int vectorPos); - virtual ComparisonInputs readComparisonInputs(const QString name, ComparisonInputs v); - virtual ComparisonInputsAdvanced readComparisonInputsAdvanced(const QString name, ComparisonInputsAdvanced v); - virtual AxisAngleInput_t readAxisAngle(const QString name, AxisAngleInput_t v, int vectorPos); - virtual QVector readAxisAngles(const QString name, QVector v); - virtual QSet readArraySelections(const QString name, QSet v); - - virtual DataContainerArrayProxy readDataContainerArrayProxy(const QString& name, DataContainerArrayProxy v); - - virtual DataArrayPath readDataArrayPath(const QString& name, DataArrayPath v); - virtual QVector readDataArrayPathVector(const QString& name, QVector v); - - virtual DynamicTableData readDynamicTableData(const QString& name, DynamicTableData v); - - virtual QPair readPairOfDoubles(const QString& name, QPair v); - - protected: - AbstractFilterParametersReader(); - - public: - AbstractFilterParametersReader(const AbstractFilterParametersReader&) = delete; // Copy Constructor Not Implemented - AbstractFilterParametersReader(AbstractFilterParametersReader&&) = delete; // Move Constructor Not Implemented - AbstractFilterParametersReader& operator=(const AbstractFilterParametersReader&) = delete; // Copy Assignment Not Implemented - AbstractFilterParametersReader& operator=(AbstractFilterParametersReader&&) = delete; // Move Assignment Not Implemented +public: + /** + * @brief Returns the name of the class for AbstractFilterParametersReader + */ + virtual QString getNameOfClass() const; + /** + * @brief Returns the name of the class for AbstractFilterParametersReader + */ + static QString ClassName(); + + virtual ~AbstractFilterParametersReader(); + + virtual int openFilterGroup(AbstractFilter* filter, int index) = 0; + virtual int closeFilterGroup() = 0; + + virtual QString readString(const QString& name, QString value); + virtual QVector readStrings(const QString& name, QVector value); + virtual QStringList readStringList(const QString& name, QStringList value); + + virtual int8_t readValue(const QString& name, int8_t value); + virtual int16_t readValue(const QString& name, int16_t value); + virtual int32_t readValue(const QString& name, int32_t value); + virtual int64_t readValue(const QString& name, int64_t value); + virtual uint8_t readValue(const QString& name, uint8_t value); + virtual uint16_t readValue(const QString& name, uint16_t value); + virtual uint32_t readValue(const QString& name, uint32_t value); + virtual uint64_t readValue(const QString& name, uint64_t value); + virtual float readValue(const QString& name, float value); + virtual double readValue(const QString& name, double value); + virtual bool readValue(const QString& name, bool value); + virtual AttributeMatrix::Type readValue(const QString& name, AttributeMatrix::Type value); + + virtual QVector readArray(const QString& name, QVector value); + virtual QVector readArray(const QString& name, QVector value); + virtual QVector readArray(const QString& name, QVector value); + virtual QVector readArray(const QString& name, QVector value); + virtual QVector readArray(const QString& name, QVector value); + virtual QVector readArray(const QString& name, QVector value); + virtual QVector readArray(const QString& name, QVector value); + virtual QVector readArray(const QString& name, QVector value); + virtual QVector readArray(const QString& name, QVector value); + virtual QVector readArray(const QString& name, QVector value); + + virtual IntVec3Type readIntVec3(const QString& name, IntVec3Type v); + virtual FloatVec3Type readFloatVec3(const QString& name, FloatVec3Type v); + virtual Float2ndOrderPolynomial readFloat2ndOrderPoly(const QString& name, Float2ndOrderPolynomial v); + virtual Float3rdOrderPoly_t readFloat3rdOrderPoly(const QString& name, Float3rdOrderPoly_t v); + virtual Float4thOrderPolynomial readFloat4thOrderPoly(const QString& name, Float4thOrderPolynomial v); + virtual StackFileListInfo readFileListInfo(const QString& name, StackFileListInfo v); + virtual ComparisonInput_t readComparisonInput(const QString& name, ComparisonInput_t v, int vectorPos); + virtual ComparisonInputs readComparisonInputs(const QString& name, ComparisonInputs v); + virtual ComparisonInputsAdvanced readComparisonInputsAdvanced(const QString& name, ComparisonInputsAdvanced v); + virtual AxisAngleInput readAxisAngle(const QString& name, AxisAngleInput v, int vectorPos); + virtual QVector readAxisAngles(const QString& name, QVector v); + virtual QSet readArraySelections(const QString& name, QSet v); + + virtual DataContainerArrayProxy readDataContainerArrayProxy(const QString& name, DataContainerArrayProxy v); + + virtual DataArrayPath readDataArrayPath(const QString& name, DataArrayPath v); + virtual QVector readDataArrayPathVector(const QString& name, QVector v); + + virtual DynamicTableData readDynamicTableData(const QString& name, DynamicTableData v); + + virtual FPRangePair readPairOfDoubles(const QString& name, const FPRangePair& v); + +protected: + AbstractFilterParametersReader(); + +public: + AbstractFilterParametersReader(const AbstractFilterParametersReader&) = delete; // Copy Constructor Not Implemented + AbstractFilterParametersReader(AbstractFilterParametersReader&&) = delete; // Move Constructor Not Implemented + AbstractFilterParametersReader& operator=(const AbstractFilterParametersReader&) = delete; // Copy Assignment Not Implemented + AbstractFilterParametersReader& operator=(AbstractFilterParametersReader&&) = delete; // Move Assignment Not Implemented + +private: }; - - diff --git a/Source/SIMPLib/FilterParameters/AbstractFilterParametersWriter.cpp b/Source/SIMPLib/FilterParameters/AbstractFilterParametersWriter.cpp index 9f4f3a11b7..4a39f0b373 100644 --- a/Source/SIMPLib/FilterParameters/AbstractFilterParametersWriter.cpp +++ b/Source/SIMPLib/FilterParameters/AbstractFilterParametersWriter.cpp @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "AbstractFilterParametersWriter.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -324,7 +326,7 @@ int AbstractFilterParametersWriter::writeValue(const QString& name, QVector v) +int AbstractFilterParametersWriter::writeValue(const QString& name, QVector v) { Q_UNUSED(name) Q_UNUSED(v) @@ -524,3 +526,15 @@ int AbstractFilterParametersWriter::writeValue(const QString& name, const QPair< // This should never be executed return -1; } + +// ----------------------------------------------------------------------------- +QString AbstractFilterParametersWriter::getNameOfClass() const +{ + return QString("AbstractFilterParametersWriter"); +} + +// ----------------------------------------------------------------------------- +QString AbstractFilterParametersWriter::ClassName() +{ + return QString("AbstractFilterParametersWriter"); +} diff --git a/Source/SIMPLib/FilterParameters/AbstractFilterParametersWriter.h b/Source/SIMPLib/FilterParameters/AbstractFilterParametersWriter.h index 2af54fad22..aca57df93c 100644 --- a/Source/SIMPLib/FilterParameters/AbstractFilterParametersWriter.h +++ b/Source/SIMPLib/FilterParameters/AbstractFilterParametersWriter.h @@ -1,38 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once @@ -40,7 +39,7 @@ #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" #include "SIMPLib/FilterParameters/AxisAngleFilterParameter.h" @@ -53,14 +52,10 @@ #include "SIMPLib/FilterParameters/ThirdOrderPolynomialFilterParameter.h" #include "SIMPLib/Filtering/ComparisonInputs.h" #include "SIMPLib/Filtering/FilterPipeline.h" -#include "SIMPLib/SIMPLib.h" class AbstractFilter; -#define WRITE_ARRAY_SELECTION_PARAMETER(Name)\ - writer->writeArraySelections( #Name, getSelected##Name##Arrays() ); - - +#define WRITE_ARRAY_SELECTION_PARAMETER(Name) writer->writeArraySelections(#Name, getSelected##Name##Arrays()); /** * @class AbstractFilterParametersWriter AbstractFilterParametersWriter.h DREAM3DLib/Common/AbstractFilterParametersWriter.h @@ -71,81 +66,85 @@ class AbstractFilter; */ class SIMPLib_EXPORT AbstractFilterParametersWriter { - public: -// SIMPL_SHARED_POINTERS(AbstractFilterParametersWriter) - // SIMPL_STATIC_NEW_MACRO(AbstractFilterParametersWriter) - SIMPL_TYPE_MACRO(AbstractFilterParametersWriter) +public: + /** + * @brief Returns the name of the class for AbstractFilterParametersWriter + */ + virtual QString getNameOfClass() const; + /** + * @brief Returns the name of the class for AbstractFilterParametersWriter + */ + static QString ClassName(); + virtual ~AbstractFilterParametersWriter(); - virtual ~AbstractFilterParametersWriter(); + virtual int openFilterGroup(AbstractFilter* filter, int index) = 0; + virtual int closeFilterGroup() = 0; - virtual int openFilterGroup(AbstractFilter* filter, int index) = 0; - virtual int closeFilterGroup() = 0; + virtual int writePipelineToFile(FilterPipeline::Pointer pipeline, QString filePath, QString pipelineName, bool expandPipeline, QList obs = QList()) = 0; - virtual int writePipelineToFile(FilterPipeline::Pointer pipeline, QString filePath, QString pipelineName, QList obs = QList()) = 0; + virtual int writeValue(const QString& name, const QString& value); + virtual int writeValue(const QString& name, const QVector& value); + virtual int writeValue(const QString& name, const QStringList& value); - virtual int writeValue(const QString& name, const QString& value); - virtual int writeValue(const QString& name, const QVector& value); - virtual int writeValue(const QString& name, const QStringList& value); + virtual int writeValue(const QString& name, int8_t value); + virtual int writeValue(const QString& name, int16_t value); + virtual int writeValue(const QString& name, int32_t value); + virtual int writeValue(const QString& name, int64_t value); + virtual int writeValue(const QString& name, uint8_t value); + virtual int writeValue(const QString& name, uint16_t value); + virtual int writeValue(const QString& name, uint32_t value); + virtual int writeValue(const QString& name, uint64_t value); + virtual int writeValue(const QString& name, float value); + virtual int writeValue(const QString& name, double value); - virtual int writeValue(const QString& name, int8_t value); - virtual int writeValue(const QString& name, int16_t value); - virtual int writeValue(const QString& name, int32_t value); - virtual int writeValue(const QString& name, int64_t value); - virtual int writeValue(const QString& name, uint8_t value); - virtual int writeValue(const QString& name, uint16_t value); - virtual int writeValue(const QString& name, uint32_t value); - virtual int writeValue(const QString& name, uint64_t value); - virtual int writeValue(const QString& name, float value); - virtual int writeValue(const QString& name, double value); + virtual int writeValue(const QString& name, QVector value); + virtual int writeValue(const QString& name, QVector value); + virtual int writeValue(const QString& name, QVector value); + virtual int writeValue(const QString& name, QVector value); + virtual int writeValue(const QString& name, QVector value); + virtual int writeValue(const QString& name, QVector value); + virtual int writeValue(const QString& name, QVector value); + virtual int writeValue(const QString& name, QVector value); + virtual int writeValue(const QString& name, QVector value); + virtual int writeValue(const QString& name, QVector value); - virtual int writeValue(const QString& name, QVector value); - virtual int writeValue(const QString& name, QVector value); - virtual int writeValue(const QString& name, QVector value); - virtual int writeValue(const QString& name, QVector value); - virtual int writeValue(const QString& name, QVector value); - virtual int writeValue(const QString& name, QVector value); - virtual int writeValue(const QString& name, QVector value); - virtual int writeValue(const QString& name, QVector value); - virtual int writeValue(const QString& name, QVector value); - virtual int writeValue(const QString& name, QVector value); + virtual int writeValue(const QString& name, IntVec3Type v); + virtual int writeValue(const QString& name, FloatVec3Type v); + virtual int writeValue(const QString& name, Float2ndOrderPolynomial v); + virtual int writeValue(const QString& name, Float3rdOrderPoly_t v); + virtual int writeValue(const QString& name, Float4thOrderPolynomial v); + virtual int writeValue(const QString& name, StackFileListInfo v); - virtual int writeValue(const QString& name, IntVec3_t v); - virtual int writeValue(const QString& name, FloatVec3_t v); - virtual int writeValue(const QString& name, Float2ndOrderPoly_t v); - virtual int writeValue(const QString& name, Float3rdOrderPoly_t v); - virtual int writeValue(const QString& name, Float4thOrderPoly_t v); - virtual int writeValue(const QString& name, FileListInfo_t v); + virtual int writeValue(const QString& name, ComparisonInput_t v); + virtual int writeValue(const QString& name, ComparisonInputs v); - virtual int writeValue(const QString& name, ComparisonInput_t v); - virtual int writeValue(const QString& name, ComparisonInputs v); + virtual int writeValue(const QString& name, QVector v); - virtual int writeValue(const QString& name, QVector v); + virtual int writeArraySelections(const QString& name, QSet v); - virtual int writeArraySelections(const QString& name, QSet v); + virtual int writeValue(const QString& name, DataContainerArrayProxy& dcaProxy); - virtual int writeValue(const QString& name, DataContainerArrayProxy& dcaProxy); + virtual int writeValue(const QString& name, AxisAngleInput v); - virtual int writeValue(const QString& name, AxisAngleInput_t v); + virtual int writeValue(const QString& name, const DataArrayPath& path); - virtual int writeValue(const QString& name, const DataArrayPath& path); + virtual int writeValue(const QString& name, const QVector& path); - virtual int writeValue(const QString& name, const QVector& path); + virtual int writeValue(const QString& name, const DynamicTableData& v); - virtual int writeValue(const QString& name, const DynamicTableData& v); + virtual int writeValue(const QString& name, const QPair& v); - virtual int writeValue(const QString& name, const QPair& v); +protected: + AbstractFilterParametersWriter(); - protected: - AbstractFilterParametersWriter(); + virtual int writeValue(const QString& name, AxisAngleInput v, int vectorPos); - virtual int writeValue(const QString& name, AxisAngleInput_t v, int vectorPos); +public: + AbstractFilterParametersWriter(const AbstractFilterParametersWriter&) = delete; // Copy Constructor Not Implemented + AbstractFilterParametersWriter(AbstractFilterParametersWriter&&) = delete; // Move Constructor Not Implemented + AbstractFilterParametersWriter& operator=(const AbstractFilterParametersWriter&) = delete; // Copy Assignment Not Implemented + AbstractFilterParametersWriter& operator=(AbstractFilterParametersWriter&&) = delete; // Move Assignment Not Implemented - public: - AbstractFilterParametersWriter(const AbstractFilterParametersWriter&) = delete; // Copy Constructor Not Implemented - AbstractFilterParametersWriter(AbstractFilterParametersWriter&&) = delete; // Move Constructor Not Implemented - AbstractFilterParametersWriter& operator=(const AbstractFilterParametersWriter&) = delete; // Copy Assignment Not Implemented - AbstractFilterParametersWriter& operator=(AbstractFilterParametersWriter&&) = delete; // Move Assignment Not Implemented +private: }; - - diff --git a/Source/SIMPLib/FilterParameters/AbstractIOFilterParameter.cpp b/Source/SIMPLib/FilterParameters/AbstractIOFilterParameter.cpp new file mode 100644 index 0000000000..ed1252f0a5 --- /dev/null +++ b/Source/SIMPLib/FilterParameters/AbstractIOFilterParameter.cpp @@ -0,0 +1,85 @@ +/* ============================================================================ + * Copyright (c) 2021 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "SIMPLib/FilterParameters/AbstractIOFilterParameter.h" + +#include + +// ----------------------------------------------------------------------------- +AbstractIOFilterParameter::AbstractIOFilterParameter() = default; + +// ----------------------------------------------------------------------------- +void AbstractIOFilterParameter::readJson(const QJsonObject& json) +{ + QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } + if(!jsonValue.isUndefined() && m_SetterCallback) + { + m_SetterCallback(jsonValue.toString("")); + } +} + +// ----------------------------------------------------------------------------- +void AbstractIOFilterParameter::writeJson(QJsonObject& json) const +{ + if(m_GetterCallback) + { + json[getPropertyName()] = m_GetterCallback(); + } +} + +// ----------------------------------------------------------------------------- +void AbstractIOFilterParameter::setSetterCallback(const SetterCallbackType& setter) +{ + m_SetterCallback = setter; +} + +// ----------------------------------------------------------------------------- +void AbstractIOFilterParameter::setGetterCallback(const GetterCallbackType& getter) +{ + m_GetterCallback = getter; +} + +// ----------------------------------------------------------------------------- +AbstractIOFilterParameter::SetterCallbackType AbstractIOFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +AbstractIOFilterParameter::GetterCallbackType AbstractIOFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/AbstractIOFilterParameter.h b/Source/SIMPLib/FilterParameters/AbstractIOFilterParameter.h new file mode 100644 index 0000000000..2a88cc4ce0 --- /dev/null +++ b/Source/SIMPLib/FilterParameters/AbstractIOFilterParameter.h @@ -0,0 +1,98 @@ +/* ============================================================================ + * Copyright (c) 2021 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include "SIMPLib/FilterParameters/FilterParameter.h" + +/** + * @class AbstractIOFilterParameter AbstractIOFilterParameter.h SIMPLib/FilterParameters/AbstractIOFilterParameter.h + * @brief Base class for file/path input/output filter parameters + */ +class SIMPLib_EXPORT AbstractIOFilterParameter : public FilterParameter +{ +public: + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + ~AbstractIOFilterParameter() override = default; + + AbstractIOFilterParameter(const AbstractIOFilterParameter&) = delete; + AbstractIOFilterParameter(AbstractIOFilterParameter&&) = delete; + AbstractIOFilterParameter& operator=(const AbstractIOFilterParameter&) = delete; + AbstractIOFilterParameter& operator=(AbstractIOFilterParameter&&) = delete; + + /** + * @brief readJson + * @return + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson + * @return + */ + void writeJson(QJsonObject& json) const override; + + /** + * @brief Sets setter + * @param setter + * @return + */ + void setSetterCallback(const SetterCallbackType& setter); + + /** + * @brief Sets getter + * @param getter + * @return + */ + void setGetterCallback(const GetterCallbackType& getter); + + /** + * @brief Returns setter + * @return + */ + SetterCallbackType getSetterCallback() const; + + /** + * @brief Returns getter + * @return + */ + GetterCallbackType getGetterCallback() const; + +protected: + AbstractIOFilterParameter(); + +private: + SetterCallbackType m_SetterCallback; + GetterCallbackType m_GetterCallback; +}; diff --git a/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.cpp b/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.cpp index bf917932e4..6426b9edea 100644 --- a/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.cpp @@ -1,39 +1,40 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "AttributeMatrixCreationFilterParameter.h" +#include "SIMPLib/Filtering/AbstractFilter.h" // ----------------------------------------------------------------------------- // @@ -48,9 +49,9 @@ AttributeMatrixCreationFilterParameter::~AttributeMatrixCreationFilterParameter( // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrixCreationFilterParameter::Pointer AttributeMatrixCreationFilterParameter::New(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, - Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex) +AttributeMatrixCreationFilterParameter::Pointer AttributeMatrixCreationFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, + Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + const RequirementType& req, int groupIndex) { AttributeMatrixCreationFilterParameter::Pointer ptr = AttributeMatrixCreationFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -81,6 +82,10 @@ QString AttributeMatrixCreationFilterParameter::getWidgetType() const void AttributeMatrixCreationFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonObject obj = jsonValue.toObject(); @@ -93,9 +98,9 @@ void AttributeMatrixCreationFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AttributeMatrixCreationFilterParameter::writeJson(QJsonObject& json) +void AttributeMatrixCreationFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { DataArrayPath dap = m_GetterCallback(); QJsonObject obj; @@ -103,3 +108,84 @@ void AttributeMatrixCreationFilterParameter::writeJson(QJsonObject& json) json[getPropertyName()] = obj; } } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AttributeMatrixCreationFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + QVariant var = filter->property(qPrintable(getPropertyName())); + if(var.isValid() && var.canConvert()) + { + DataArrayPath path = var.value(); + if(path.updatePath(renamePath)) + { + if(m_SetterCallback) + { + m_SetterCallback(path); + } + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); + } + } +} + +// ----------------------------------------------------------------------------- +AttributeMatrixCreationFilterParameter::Pointer AttributeMatrixCreationFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +AttributeMatrixCreationFilterParameter::Pointer AttributeMatrixCreationFilterParameter::New() +{ + Pointer sharedPtr(new(AttributeMatrixCreationFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString AttributeMatrixCreationFilterParameter::getNameOfClass() const +{ + return QString("AttributeMatrixCreationFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString AttributeMatrixCreationFilterParameter::ClassName() +{ + return QString("AttributeMatrixCreationFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void AttributeMatrixCreationFilterParameter::setDefaultGeometryTypes(const IGeometry::Types& value) +{ + m_DefaultGeometryTypes = value; +} + +// ----------------------------------------------------------------------------- +IGeometry::Types AttributeMatrixCreationFilterParameter::getDefaultGeometryTypes() const +{ + return m_DefaultGeometryTypes; +} + +// ----------------------------------------------------------------------------- +void AttributeMatrixCreationFilterParameter::setSetterCallback(const AttributeMatrixCreationFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +AttributeMatrixCreationFilterParameter::SetterCallbackType AttributeMatrixCreationFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void AttributeMatrixCreationFilterParameter::setGetterCallback(const AttributeMatrixCreationFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +AttributeMatrixCreationFilterParameter::GetterCallbackType AttributeMatrixCreationFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.h b/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.h old mode 100755 new mode 100644 index 3761d5940e..98472bf378 --- a/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/AttributeMatrixCreationFilterParameter.h @@ -1,47 +1,50 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Geometry/IGeometry.h" +class AbstractFilter; + /** * @brief SIMPL_NEW_AM_CREATION_FP This macro is a short-form way of instantiating an instance of * AttributeMatrixCreationFilterParameter. There are 5 required parameters and 1 optional parameter @@ -53,12 +56,10 @@ * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): * AttributeMatrixCreationFilterParameter::RequirementType req; - * SIMPL_NEW_AM_CREATION_FP("Created Attribute Matrix", CreatedAttributeMatrix, FilterParameter::CreatedArray, GenericExample, req); + * SIMPL_NEW_AM_CREATION_FP("Created Attribute Matrix", CreatedAttributeMatrix, FilterParameter::Category::CreatedArray, GenericExample, req); */ -#define SIMPL_NEW_AM_CREATION_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (AttributeMatrixCreationFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_AM_CREATION_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(AttributeMatrixCreationFilterParameter, __VA_ARGS__)) /** * @brief The AttributeMatrixCreationFilterParameter class is used by filters to instantiate an AttributeMatrixCreationWidget. By instantiating an instance of @@ -66,97 +67,151 @@ */ class SIMPLib_EXPORT AttributeMatrixCreationFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(AttributeMatrixCreationFilterParameter) - SIMPL_STATIC_NEW_MACRO(AttributeMatrixCreationFilterParameter) - SIMPL_TYPE_MACRO(AttributeMatrixCreationFilterParameter) - - // Typedefs for this class's callback functions - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - typedef struct - { - IGeometry::Types dcGeometryTypes; - } RequirementType; - - /** - * @brief New This function instantiates an instance of the AttributeMatrixCreationFilterParameter. Specifying a RequirementType will - * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. - * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the - * SIMPL_NEW_AM_CREATION_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D - * user interface. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const DataArrayPath& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex = -1); - - ~AttributeMatrixCreationFilterParameter() override; - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param DefaultGeometryTypes Default geometry types required for Data Container selections - * @return - */ - SIMPL_INSTANCE_PROPERTY(IGeometry::Types, DefaultGeometryTypes) - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @return The SetterCallback - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief AttributeMatrixCreationFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - AttributeMatrixCreationFilterParameter(); - - public: - AttributeMatrixCreationFilterParameter(const AttributeMatrixCreationFilterParameter&) = delete; // Copy Constructor Not Implemented - AttributeMatrixCreationFilterParameter(AttributeMatrixCreationFilterParameter&&) = delete; // Move Constructor Not Implemented - AttributeMatrixCreationFilterParameter& operator=(const AttributeMatrixCreationFilterParameter&) = delete; // Copy Assignment Not Implemented - AttributeMatrixCreationFilterParameter& operator=(AttributeMatrixCreationFilterParameter&&) = delete; // Move Assignment Not Implemented + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(AttributeMatrixCreationFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(AttributeMatrixCreationFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_CUSTOM() + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = AttributeMatrixCreationFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for AttributeMatrixCreationFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for AttributeMatrixCreationFilterParameter + */ + static QString ClassName(); + + // Typedefs for this class's callback functions + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + struct RequirementType + { + IGeometry::Types dcGeometryTypes; + }; + + /** + * @brief New This function instantiates an instance of the AttributeMatrixCreationFilterParameter. Specifying a RequirementType will + * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. + * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the + * SIMPL_NEW_AM_CREATION_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D + * user interface. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const RequirementType& req, int groupIndex = -1); + + ~AttributeMatrixCreationFilterParameter() override; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param DefaultGeometryTypes Default geometry types required for Data Container selections + * @return + */ + /** + * @brief Setter property for DefaultGeometryTypes + */ + void setDefaultGeometryTypes(const IGeometry::Types& value); + /** + * @brief Getter property for DefaultGeometryTypes + * @return Value of DefaultGeometryTypes + */ + IGeometry::Types getDefaultGeometryTypes() const; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const AttributeMatrixCreationFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + AttributeMatrixCreationFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const AttributeMatrixCreationFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + AttributeMatrixCreationFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handle DataArrayPath changes if necessary + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief AttributeMatrixCreationFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + AttributeMatrixCreationFilterParameter(); + +public: + AttributeMatrixCreationFilterParameter(const AttributeMatrixCreationFilterParameter&) = delete; // Copy Constructor Not Implemented + AttributeMatrixCreationFilterParameter(AttributeMatrixCreationFilterParameter&&) = delete; // Move Constructor Not Implemented + AttributeMatrixCreationFilterParameter& operator=(const AttributeMatrixCreationFilterParameter&) = delete; // Copy Assignment Not Implemented + AttributeMatrixCreationFilterParameter& operator=(AttributeMatrixCreationFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + IGeometry::Types m_DefaultGeometryTypes = {}; + AttributeMatrixCreationFilterParameter::SetterCallbackType m_SetterCallback = {}; + AttributeMatrixCreationFilterParameter::GetterCallbackType m_GetterCallback = {}; }; - diff --git a/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.cpp index 2bd7f205b8..34628b9b19 100644 --- a/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "AttributeMatrixSelectionFilterParameter.h" @@ -52,9 +52,9 @@ AttributeMatrixSelectionFilterParameter::~AttributeMatrixSelectionFilterParamete // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrixSelectionFilterParameter::Pointer AttributeMatrixSelectionFilterParameter::New(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, - Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex) +AttributeMatrixSelectionFilterParameter::Pointer AttributeMatrixSelectionFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, + Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + const RequirementType& req, int groupIndex) { AttributeMatrixSelectionFilterParameter::Pointer ptr = AttributeMatrixSelectionFilterParameter::New(); @@ -122,7 +122,7 @@ AttributeMatrixSelectionFilterParameter::RequirementType AttributeMatrixSelectio AttributeMatrixSelectionFilterParameter::RequirementType req; if(AttributeMatrix::Type::Any != attributeMatrixType) { - req.amTypes = QVector(1, attributeMatrixType); + req.amTypes = AttributeMatrix::Types(1, attributeMatrixType); } if(IGeometry::Type::Any != geometryType) { @@ -137,6 +137,10 @@ AttributeMatrixSelectionFilterParameter::RequirementType AttributeMatrixSelectio void AttributeMatrixSelectionFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonObject obj = jsonValue.toObject(); @@ -149,9 +153,9 @@ void AttributeMatrixSelectionFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AttributeMatrixSelectionFilterParameter::writeJson(QJsonObject& json) +void AttributeMatrixSelectionFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { DataArrayPath dap = m_GetterCallback(); QJsonObject obj; @@ -171,3 +175,96 @@ AttributeMatrixSelectionFilterParameter::RequirementType AttributeMatrixSelectio return reqs; } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AttributeMatrixSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + QVariant var = filter->property(qPrintable(getPropertyName())); + if(var.isValid() && var.canConvert()) + { + DataArrayPath path = var.value(); + if(path.updatePath(renamePath)) + { + if(m_SetterCallback) + { + m_SetterCallback(path); + } + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); + } + } +} + +// ----------------------------------------------------------------------------- +AttributeMatrixSelectionFilterParameter::Pointer AttributeMatrixSelectionFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +AttributeMatrixSelectionFilterParameter::Pointer AttributeMatrixSelectionFilterParameter::New() +{ + Pointer sharedPtr(new(AttributeMatrixSelectionFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString AttributeMatrixSelectionFilterParameter::getNameOfClass() const +{ + return QString("AttributeMatrixSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString AttributeMatrixSelectionFilterParameter::ClassName() +{ + return QString("AttributeMatrixSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void AttributeMatrixSelectionFilterParameter::setDefaultGeometryTypes(const IGeometry::Types& value) +{ + m_DefaultGeometryTypes = value; +} + +// ----------------------------------------------------------------------------- +IGeometry::Types AttributeMatrixSelectionFilterParameter::getDefaultGeometryTypes() const +{ + return m_DefaultGeometryTypes; +} + +// ----------------------------------------------------------------------------- +void AttributeMatrixSelectionFilterParameter::setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value) +{ + m_DefaultAttributeMatrixTypes = value; +} + +// ----------------------------------------------------------------------------- +AttributeMatrix::Types AttributeMatrixSelectionFilterParameter::getDefaultAttributeMatrixTypes() const +{ + return m_DefaultAttributeMatrixTypes; +} + +// ----------------------------------------------------------------------------- +void AttributeMatrixSelectionFilterParameter::setSetterCallback(const AttributeMatrixSelectionFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +AttributeMatrixSelectionFilterParameter::SetterCallbackType AttributeMatrixSelectionFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void AttributeMatrixSelectionFilterParameter::setGetterCallback(const AttributeMatrixSelectionFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +AttributeMatrixSelectionFilterParameter::GetterCallbackType AttributeMatrixSelectionFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h old mode 100755 new mode 100644 index 8457a752af..8cd1e02120 --- a/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/AttributeMatrixSelectionFilterParameter.h @@ -1,45 +1,47 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" -#include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/DataContainers/AttributeMatrix.h" +#include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Geometry/IGeometry.h" /** @@ -53,12 +55,10 @@ * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): * AttributeMatrixSelectionFilterParameter::RequirementType req; - * SIMPL_NEW_AM_SELECTION_FP("Attribute Matrix", AttributeMatrixPath, FilterParameter::Parameter, GenericExample, req); + * SIMPL_NEW_AM_SELECTION_FP("Attribute Matrix", AttributeMatrixPath, FilterParameter::Category::Parameter, GenericExample, req); */ -#define SIMPL_NEW_AM_SELECTION_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (AttributeMatrixSelectionFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_AM_SELECTION_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(AttributeMatrixSelectionFilterParameter, __VA_ARGS__)) /** * @brief The AttributeMatrixSelectionFilterParameter class is used by filters to instantiate an AttributeMatrixSelectionWidget. By instantiating an instance of @@ -66,125 +66,187 @@ */ class SIMPLib_EXPORT AttributeMatrixSelectionFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(AttributeMatrixSelectionFilterParameter) - SIMPL_STATIC_NEW_MACRO(AttributeMatrixSelectionFilterParameter) - SIMPL_TYPE_MACRO(AttributeMatrixSelectionFilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - typedef struct - { - IGeometry::Types dcGeometryTypes; - AttributeMatrix::Types amTypes; - } RequirementType; - - /** - * @brief New This function instantiates an instance of the AttributeMatrixSelectionFilterParameter. Specifying a RequirementType will - * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. - * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the - * SIMPL_NEW_AM_SELECTION_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D - * user interface. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const DataArrayPath& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex = -1); - - ~AttributeMatrixSelectionFilterParameter() override; - - /** - * @brief CreateRequirement - * @param attributeMatrixType - * @return - */ - static RequirementType CreateRequirement(AttributeMatrix::Category attributeMatrixObjectType); - - /** - * @brief CreateRequirement - * @param attributeMatrixType - * @param geometryType - * @return - */ - static RequirementType CreateRequirement(AttributeMatrix::Type attributeMatrixType, - IGeometry::Type geometryType); - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @brief Returns the RequirementType for the filter parameter - * @return - */ - RequirementType getRequirements(); - - /** - * @param DefaultGeometryTypes Default geometry types required for Data Container selections - * @return - */ - SIMPL_INSTANCE_PROPERTY(IGeometry::Types, DefaultGeometryTypes) - - /** - * @param DefaultAttributeMatrixTypes Default attribute matrix types required for Attribute Matrix selections - * @return - */ - SIMPL_INSTANCE_PROPERTY(QVector, DefaultAttributeMatrixTypes) - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief AttributeMatrixSelectionFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - AttributeMatrixSelectionFilterParameter(); - - public: - AttributeMatrixSelectionFilterParameter(const AttributeMatrixSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented - AttributeMatrixSelectionFilterParameter(AttributeMatrixSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented - AttributeMatrixSelectionFilterParameter& operator=(const AttributeMatrixSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented - AttributeMatrixSelectionFilterParameter& operator=(AttributeMatrixSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(AttributeMatrixSelectionFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(AttributeMatrixSelectionFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_CUSTOM() + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = AttributeMatrixSelectionFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for AttributeMatrixSelectionFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for AttributeMatrixSelectionFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + struct RequirementType + { + IGeometry::Types dcGeometryTypes; + AttributeMatrix::Types amTypes; + }; + + /** + * @brief New This function instantiates an instance of the AttributeMatrixSelectionFilterParameter. Specifying a RequirementType will + * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. + * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the + * SIMPL_NEW_AM_SELECTION_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D + * user interface. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const RequirementType& req, int groupIndex = -1); + + ~AttributeMatrixSelectionFilterParameter() override; + + /** + * @brief CreateRequirement + * @param attributeMatrixType + * @return + */ + static RequirementType CreateRequirement(AttributeMatrix::Category attributeMatrixObjectType); + + /** + * @brief CreateRequirement + * @param attributeMatrixType + * @param geometryType + * @return + */ + static RequirementType CreateRequirement(AttributeMatrix::Type attributeMatrixType, IGeometry::Type geometryType); + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @brief Returns the RequirementType for the filter parameter + * @return + */ + RequirementType getRequirements(); + + /** + * @param DefaultGeometryTypes Default geometry types required for Data Container selections + * @return + */ + /** + * @brief Setter property for DefaultGeometryTypes + */ + void setDefaultGeometryTypes(const IGeometry::Types& value); + /** + * @brief Getter property for DefaultGeometryTypes + * @return Value of DefaultGeometryTypes + */ + IGeometry::Types getDefaultGeometryTypes() const; + + /** + * @param DefaultAttributeMatrixTypes Default attribute matrix types required for Attribute Matrix selections + * @return + */ + /** + * @brief Setter property for DefaultAttributeMatrixTypes + */ + void setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value); + /** + * @brief Getter property for DefaultAttributeMatrixTypes + * @return Value of DefaultAttributeMatrixTypes + */ + AttributeMatrix::Types getDefaultAttributeMatrixTypes() const; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const AttributeMatrixSelectionFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + AttributeMatrixSelectionFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const AttributeMatrixSelectionFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + AttributeMatrixSelectionFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handle DataArrayPath changes if necessary + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief AttributeMatrixSelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + AttributeMatrixSelectionFilterParameter(); + +public: + AttributeMatrixSelectionFilterParameter(const AttributeMatrixSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + AttributeMatrixSelectionFilterParameter(AttributeMatrixSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + AttributeMatrixSelectionFilterParameter& operator=(const AttributeMatrixSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented + AttributeMatrixSelectionFilterParameter& operator=(AttributeMatrixSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + IGeometry::Types m_DefaultGeometryTypes = {}; + AttributeMatrix::Types m_DefaultAttributeMatrixTypes = {}; + AttributeMatrixSelectionFilterParameter::SetterCallbackType m_SetterCallback = {}; + AttributeMatrixSelectionFilterParameter::GetterCallbackType m_GetterCallback = {}; }; - diff --git a/Source/SIMPLib/FilterParameters/AxisAngleFilterParameter.cpp b/Source/SIMPLib/FilterParameters/AxisAngleFilterParameter.cpp index deb27eab0b..5630f29f86 100644 --- a/Source/SIMPLib/FilterParameters/AxisAngleFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/AxisAngleFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "AxisAngleFilterParameter.h" @@ -48,8 +48,8 @@ AxisAngleFilterParameter::~AxisAngleFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AxisAngleFilterParameter::Pointer AxisAngleFilterParameter::New(const QString& humanLabel, const QString& propertyName, const AxisAngleInput_t& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) +AxisAngleFilterParameter::Pointer AxisAngleFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const AxisAngleInput& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { AxisAngleFilterParameter::Pointer ptr = AxisAngleFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -79,10 +79,14 @@ QString AxisAngleFilterParameter::getWidgetType() const void AxisAngleFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonObject axisObj = jsonValue.toObject(); - AxisAngleInput_t axisAngle; + AxisAngleInput axisAngle; axisAngle.readJson(axisObj); m_SetterCallback(axisAngle); } @@ -91,13 +95,62 @@ void AxisAngleFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AxisAngleFilterParameter::writeJson(QJsonObject& json) +void AxisAngleFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { QJsonObject axisObj; - AxisAngleInput_t axisAngle = m_GetterCallback(); + AxisAngleInput axisAngle = m_GetterCallback(); axisAngle.writeJson(axisObj); json[getPropertyName()] = axisObj; } } + +// ----------------------------------------------------------------------------- +AxisAngleFilterParameter::Pointer AxisAngleFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +AxisAngleFilterParameter::Pointer AxisAngleFilterParameter::New() +{ + Pointer sharedPtr(new(AxisAngleFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString AxisAngleFilterParameter::getNameOfClass() const +{ + return QString("AxisAngleFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString AxisAngleFilterParameter::ClassName() +{ + return QString("AxisAngleFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void AxisAngleFilterParameter::setSetterCallback(const AxisAngleFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +AxisAngleFilterParameter::SetterCallbackType AxisAngleFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void AxisAngleFilterParameter::setGetterCallback(const AxisAngleFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +AxisAngleFilterParameter::GetterCallbackType AxisAngleFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/AxisAngleFilterParameter.h b/Source/SIMPLib/FilterParameters/AxisAngleFilterParameter.h old mode 100755 new mode 100644 index d30175685c..56bd712986 --- a/Source/SIMPLib/FilterParameters/AxisAngleFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/AxisAngleFilterParameter.h @@ -1,45 +1,46 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/FilterParameters/AxisAngleInput.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" /** * @brief SIMPL_NEW_AXISANGLE_FP This macro is a short-form way of instantiating an @@ -51,12 +52,10 @@ * SIMPL_NEW_AXISANGLE_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): - * SIMPL_NEW_AXISANGLE_FP("Crystal Rotations", CrystalSymmetryRotations, FilterParameter::Parameter, GenericExample, 2); + * SIMPL_NEW_AXISANGLE_FP("Crystal Rotations", CrystalSymmetryRotations, FilterParameter::Category::Parameter, GenericExample, 2); */ -#define SIMPL_NEW_AXISANGLE_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (AxisAngleFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_AXISANGLE_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(AxisAngleFilterParameter, __VA_ARGS__)) /** * @brief The AxisAngleFilterParameter class is used by filters to instantiate an AxisAngleWidget. By instantiating an instance of @@ -64,81 +63,120 @@ */ class SIMPLib_EXPORT AxisAngleFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(AxisAngleFilterParameter) - SIMPL_STATIC_NEW_MACRO(AxisAngleFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(AxisAngleFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the AxisAngleFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_AXISANGLE_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const AxisAngleInput_t& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - int groupIndex = -1); - - ~AxisAngleFilterParameter() override; - - /** + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(AxisAngleFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(AxisAngleFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = AxisAngleFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for AxisAngleFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for AxisAngleFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the AxisAngleFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_AXISANGLE_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const AxisAngleInput& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~AxisAngleFilterParameter() override; + + /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief AxisAngleFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - AxisAngleFilterParameter(); - - public: - AxisAngleFilterParameter(const AxisAngleFilterParameter&) = delete; // Copy Constructor Not Implemented - AxisAngleFilterParameter(AxisAngleFilterParameter&&) = delete; // Move Constructor Not Implemented - AxisAngleFilterParameter& operator=(const AxisAngleFilterParameter&) = delete; // Copy Assignment Not Implemented - AxisAngleFilterParameter& operator=(AxisAngleFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + QString getWidgetType() const override; + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const AxisAngleFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + AxisAngleFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const AxisAngleFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + AxisAngleFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief AxisAngleFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + AxisAngleFilterParameter(); + +public: + AxisAngleFilterParameter(const AxisAngleFilterParameter&) = delete; // Copy Constructor Not Implemented + AxisAngleFilterParameter(AxisAngleFilterParameter&&) = delete; // Move Constructor Not Implemented + AxisAngleFilterParameter& operator=(const AxisAngleFilterParameter&) = delete; // Copy Assignment Not Implemented + AxisAngleFilterParameter& operator=(AxisAngleFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + AxisAngleFilterParameter::SetterCallbackType m_SetterCallback = {}; + AxisAngleFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/FloatVec3.h b/Source/SIMPLib/FilterParameters/AxisAngleInput.cpp similarity index 63% rename from Source/SIMPLib/FilterParameters/FloatVec3.h rename to Source/SIMPLib/FilterParameters/AxisAngleInput.cpp index 2121e9e2f7..f9a69e98ea 100644 --- a/Source/SIMPLib/FilterParameters/FloatVec3.h +++ b/Source/SIMPLib/FilterParameters/AxisAngleInput.cpp @@ -1,5 +1,5 @@ /* ============================================================================ - * Copyright (c) 2019 BlueQuartz Software, LLC + * Copyright (c) 2021-2021 BlueQuartz Software, LLC * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -26,49 +26,38 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#pragma once +#include "AxisAngleInput.h" -#include +AxisAngleInput::AxisAngleInput() = default; +AxisAngleInput::~AxisAngleInput() = default; -typedef struct +AxisAngleInput::AxisAngleInput(float h, float k, float l, float angle) +: h(h) +, k(k) +, l(l) +, angle(angle) { - float x; - float y; - float z; - void FloatVec3(const float& xx, const float& yy, const float& zz) - { - x = xx; - y = yy; - z = zz; - } - - void writeJson(QJsonObject& json) - { - json["x"] = static_cast(x); - json["y"] = static_cast(y); - json["z"] = static_cast(z); - } - - bool readJson(QJsonObject& json) - { - if(json["x"].isDouble() && json["y"].isDouble() && json["z"].isDouble()) - { - x = static_cast(json["x"].toDouble()); - y = static_cast(json["y"].toDouble()); - z = static_cast(json["z"].toDouble()); - return true; - } - return false; - } +} +void AxisAngleInput::writeJson(QJsonObject& json) const +{ + json["angle"] = angle; + json["h"] = h; + json["k"] = k; + json["l"] = l; +} - void normalize() +bool AxisAngleInput::readJson(const QJsonObject& json) +{ + if(json["angle"].isDouble() && json["h"].isDouble() && json["k"].isDouble() && json["l"].isDouble()) { - float denom = std::sqrt(x * x + y * y + z * z); - x = x / denom; - y = y / denom; - z = z / denom; + angle = static_cast(json["angle"].toDouble()); + h = static_cast(json["h"].toDouble()); + k = static_cast(json["k"].toDouble()); + l = static_cast(json["l"].toDouble()); + return true; } -} FloatVec3_t; - -Q_DECLARE_METATYPE(FloatVec3_t) \ No newline at end of file + return false; +} diff --git a/Source/SIMPLib/FilterParameters/AxisAngleInput.h b/Source/SIMPLib/FilterParameters/AxisAngleInput.h index 0ee5e12e60..6c704aa6df 100644 --- a/Source/SIMPLib/FilterParameters/AxisAngleInput.h +++ b/Source/SIMPLib/FilterParameters/AxisAngleInput.h @@ -27,45 +27,57 @@ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + #pragma once #include +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLPythonMacros.h" /** -* @brief -*/ -typedef struct + * @brief + */ +class SIMPLib_EXPORT AxisAngleInput { - float angle; - float h; - float k; - float l; - - void writeJson(QJsonObject& json) - { - json["angle"] = angle; - json["h"] = h; - json["k"] = k; - json["l"] = l; - } + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(AxisAngleInput) + PYB11_CREATION(float float float float) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations - bool readJson(QJsonObject& json) - { - if (json["angle"].isDouble() && json["h"].isDouble() && json["k"].isDouble() && json["l"].isDouble()) - { - angle = static_cast(json["angle"].toDouble()); - h = static_cast(json["h"].toDouble()); - k = static_cast(json["k"].toDouble()); - l = static_cast(json["l"].toDouble()); - return true; - } - return false; - } +public: + AxisAngleInput(); + ~AxisAngleInput(); -} AxisAngleInput_t; + AxisAngleInput(float h, float k, float l, float angle); -Q_DECLARE_METATYPE(AxisAngleInput_t) + float h = 0.0f; + float k = 0.0f; + float l = 0.0f; + float angle = 0.0f; + /** + * @brief writeJson + * @param json + */ + void writeJson(QJsonObject& json) const; + /** + * @brief readJson + * @param json + * @return + */ + bool readJson(const QJsonObject& json); +public: + AxisAngleInput(const AxisAngleInput&) = default; + AxisAngleInput(AxisAngleInput&&) = default; + AxisAngleInput& operator=(const AxisAngleInput&) = default; + AxisAngleInput& operator=(AxisAngleInput&&) = default; +}; +Q_DECLARE_METATYPE(AxisAngleInput) diff --git a/Source/SIMPLib/FilterParameters/BooleanFilterParameter.cpp b/Source/SIMPLib/FilterParameters/BooleanFilterParameter.cpp index 8201216dc5..7daa5dd5b0 100644 --- a/Source/SIMPLib/FilterParameters/BooleanFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/BooleanFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "BooleanFilterParameter.h" @@ -48,8 +48,8 @@ BooleanFilterParameter::~BooleanFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -BooleanFilterParameter::Pointer BooleanFilterParameter::New(const QString& humanLabel, const QString& propertyName, const bool& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex) +BooleanFilterParameter::Pointer BooleanFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const bool& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { BooleanFilterParameter::Pointer ptr = BooleanFilterParameter::New(); @@ -78,6 +78,10 @@ QString BooleanFilterParameter::getWidgetType() const void BooleanFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { m_SetterCallback(static_cast(jsonValue.toInt())); @@ -87,10 +91,59 @@ void BooleanFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void BooleanFilterParameter::writeJson(QJsonObject& json) +void BooleanFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { json[getPropertyName()] = static_cast(m_GetterCallback()); } } + +// ----------------------------------------------------------------------------- +BooleanFilterParameter::Pointer BooleanFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +BooleanFilterParameter::Pointer BooleanFilterParameter::New() +{ + Pointer sharedPtr(new(BooleanFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString BooleanFilterParameter::getNameOfClass() const +{ + return QString("BooleanFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString BooleanFilterParameter::ClassName() +{ + return QString("BooleanFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void BooleanFilterParameter::setSetterCallback(const BooleanFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +BooleanFilterParameter::SetterCallbackType BooleanFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void BooleanFilterParameter::setGetterCallback(const BooleanFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +BooleanFilterParameter::GetterCallbackType BooleanFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/BooleanFilterParameter.h b/Source/SIMPLib/FilterParameters/BooleanFilterParameter.h old mode 100755 new mode 100644 index 0615c396c7..d03e523b74 --- a/Source/SIMPLib/FilterParameters/BooleanFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/BooleanFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" @@ -49,12 +51,10 @@ * SIMPL_NEW_BOOL_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): - * SIMPL_NEW_BOOL_FP("Write Alignment Shift File", WriteAlignmentShifts, FilterParameter::Parameter, GenericExample); + * SIMPL_NEW_BOOL_FP("Write Alignment Shift File", WriteAlignmentShifts, FilterParameter::Category::Parameter, GenericExample); */ -#define SIMPL_NEW_BOOL_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (BooleanFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_BOOL_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(BooleanFilterParameter, __VA_ARGS__)) /** * @brief The BooleanFilterParameter class is used by filters to instantiate an BooleanWidget. By instantiating an instance of @@ -62,80 +62,120 @@ */ class SIMPLib_EXPORT BooleanFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(BooleanFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(BooleanFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(BooleanFilterParameter) - SIMPL_STATIC_NEW_MACRO(BooleanFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(BooleanFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the BooleanFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_BOOL_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const bool& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); - - ~BooleanFilterParameter() override; - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + using Self = BooleanFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for BooleanFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for BooleanFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the BooleanFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_BOOL_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const bool& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~BooleanFilterParameter() override; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const BooleanFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + BooleanFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const BooleanFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + BooleanFilterParameter::GetterCallbackType getGetterCallback() const; protected: - /** - * @brief BooleanFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + /** + * @brief BooleanFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ BooleanFilterParameter(); public: - BooleanFilterParameter(const BooleanFilterParameter&) = delete; // Copy Constructor Not Implemented - BooleanFilterParameter(BooleanFilterParameter&&) = delete; // Move Constructor Not Implemented + BooleanFilterParameter(const BooleanFilterParameter&) = delete; // Copy Constructor Not Implemented + BooleanFilterParameter(BooleanFilterParameter&&) = delete; // Move Constructor Not Implemented BooleanFilterParameter& operator=(const BooleanFilterParameter&) = delete; // Copy Assignment Not Implemented BooleanFilterParameter& operator=(BooleanFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +private: + BooleanFilterParameter::SetterCallbackType m_SetterCallback = {}; + BooleanFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.cpp b/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.cpp index ceced77422..0f73f204cb 100644 --- a/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.cpp @@ -1,42 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CalculatorFilterParameter.h" -#include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/CoreFilters/ArrayCalculator.h" +#include "SIMPLib/Filtering/AbstractFilter.h" // ----------------------------------------------------------------------------- // @@ -51,8 +51,8 @@ CalculatorFilterParameter::~CalculatorFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -CalculatorFilterParameter::Pointer CalculatorFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) +CalculatorFilterParameter::Pointer CalculatorFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { CalculatorFilterParameter::Pointer ptr = CalculatorFilterParameter::New(); @@ -81,6 +81,10 @@ QString CalculatorFilterParameter::getWidgetType() const void CalculatorFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { m_SetterCallback(jsonValue.toString("")); @@ -90,7 +94,7 @@ void CalculatorFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void CalculatorFilterParameter::writeJson(QJsonObject& json) +void CalculatorFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { @@ -101,7 +105,7 @@ void CalculatorFilterParameter::writeJson(QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void CalculatorFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void CalculatorFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; @@ -126,7 +130,56 @@ void CalculatorFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, Dat inputStr.replace(oldPath.getDataArrayName(), newPath.getDataArrayName()); m_SetterCallback(inputStr); - emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); } } } + +// ----------------------------------------------------------------------------- +CalculatorFilterParameter::Pointer CalculatorFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +CalculatorFilterParameter::Pointer CalculatorFilterParameter::New() +{ + Pointer sharedPtr(new(CalculatorFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString CalculatorFilterParameter::getNameOfClass() const +{ + return QString("CalculatorFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString CalculatorFilterParameter::ClassName() +{ + return QString("CalculatorFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void CalculatorFilterParameter::setSetterCallback(const CalculatorFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +CalculatorFilterParameter::SetterCallbackType CalculatorFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void CalculatorFilterParameter::setGetterCallback(const CalculatorFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +CalculatorFilterParameter::GetterCallbackType CalculatorFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.h b/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.h index 3988a8ecde..07b3ad502f 100644 --- a/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/CalculatorFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2015 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2015 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" @@ -49,12 +51,10 @@ * SIMPL_NEW_CALC_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): - * SIMPL_NEW_CALC_FP("Calculator Expression", CalcExpression, FilterParameter::Parameter, GenericExample); + * SIMPL_NEW_CALC_FP("Calculator Expression", CalcExpression, FilterParameter::Category::Parameter, GenericExample); */ -#define SIMPL_NEW_CALC_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (CalculatorFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_CALC_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(CalculatorFilterParameter, __VA_ARGS__)) /** * @brief The CalculatorFilterParameter class is used by filters to instantiate an CalculatorWidget. By instantiating an instance of @@ -62,87 +62,127 @@ */ class SIMPLib_EXPORT CalculatorFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(CalculatorFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(CalculatorFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(CalculatorFilterParameter) - SIMPL_STATIC_NEW_MACRO(CalculatorFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(CalculatorFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the CalculatorFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_CALC_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex = -1); - - ~CalculatorFilterParameter() override; + using Self = CalculatorFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for CalculatorFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for CalculatorFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the CalculatorFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_CALC_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~CalculatorFilterParameter() override; /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @return The SetterCallback - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - /** - * @brief Handles DataArrayPath changes wwith the assumption that the DataContainer and AttributeMatrix both match the input - * @param filter - * @param renamePath - */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; - - protected: - /** - * @brief CalculatorFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const CalculatorFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + CalculatorFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const CalculatorFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + CalculatorFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handles DataArrayPath changes wwith the assumption that the DataContainer and AttributeMatrix both match the input + * @param filter + * @param renamePath + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief CalculatorFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ CalculatorFilterParameter(); public: - CalculatorFilterParameter(const CalculatorFilterParameter&) = delete; // Copy Constructor Not Implemented - CalculatorFilterParameter(CalculatorFilterParameter&&) = delete; // Move Constructor Not Implemented + CalculatorFilterParameter(const CalculatorFilterParameter&) = delete; // Copy Constructor Not Implemented + CalculatorFilterParameter(CalculatorFilterParameter&&) = delete; // Move Constructor Not Implemented CalculatorFilterParameter& operator=(const CalculatorFilterParameter&) = delete; // Copy Assignment Not Implemented CalculatorFilterParameter& operator=(CalculatorFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +private: + CalculatorFilterParameter::SetterCallbackType m_SetterCallback = {}; + CalculatorFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/ChoiceFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ChoiceFilterParameter.cpp index b0ab478351..9027132878 100644 --- a/Source/SIMPLib/FilterParameters/ChoiceFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/ChoiceFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ChoiceFilterParameter.h" @@ -51,8 +51,8 @@ ChoiceFilterParameter::~ChoiceFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ChoiceFilterParameter::Pointer ChoiceFilterParameter::New(const QString& humanLabel, const QString& propertyName, const int& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, QVector choices, bool editable, int groupIndex) +ChoiceFilterParameter::Pointer ChoiceFilterParameter::Create(const QString& humanLabel, const QString& propertyName, int defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const std::vector& choices, bool editable, int groupIndex) { ChoiceFilterParameter::Pointer ptr = ChoiceFilterParameter::New(); @@ -83,6 +83,10 @@ QString ChoiceFilterParameter::getWidgetType() const void ChoiceFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { m_SetterCallback(jsonValue.toInt(0.0)); @@ -92,10 +96,83 @@ void ChoiceFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ChoiceFilterParameter::writeJson(QJsonObject& json) +void ChoiceFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { json[getPropertyName()] = m_GetterCallback(); } } + +// ----------------------------------------------------------------------------- +ChoiceFilterParameter::Pointer ChoiceFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +ChoiceFilterParameter::Pointer ChoiceFilterParameter::New() +{ + Pointer sharedPtr(new(ChoiceFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString ChoiceFilterParameter::getNameOfClass() const +{ + return QString("ChoiceFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString ChoiceFilterParameter::ClassName() +{ + return QString("ChoiceFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void ChoiceFilterParameter::setChoices(const std::vector& value) +{ + m_Choices = value; +} + +// ----------------------------------------------------------------------------- +std::vector ChoiceFilterParameter::getChoices() const +{ + return m_Choices; +} + +// ----------------------------------------------------------------------------- +void ChoiceFilterParameter::setEditable(bool value) +{ + m_Editable = value; +} + +// ----------------------------------------------------------------------------- +bool ChoiceFilterParameter::getEditable() const +{ + return m_Editable; +} + +// ----------------------------------------------------------------------------- +void ChoiceFilterParameter::setSetterCallback(const ChoiceFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ChoiceFilterParameter::SetterCallbackType ChoiceFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void ChoiceFilterParameter::setGetterCallback(const ChoiceFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ChoiceFilterParameter::GetterCallbackType ChoiceFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/ChoiceFilterParameter.h b/Source/SIMPLib/FilterParameters/ChoiceFilterParameter.h old mode 100755 new mode 100644 index 0461ea00b6..dc8f0b22f5 --- a/Source/SIMPLib/FilterParameters/ChoiceFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ChoiceFilterParameter.h @@ -1,40 +1,43 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" @@ -49,12 +52,10 @@ * SIMPL_NEW_CHOICE_FP("HumanLabel", PropertyName, Category, FilterName, Choices, Editable, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): - * SIMPL_NEW_CHOICE_FP("Size Distribution Fit Type", SizeDistributionFitType, FilterParameter::Parameter, GenericExample, choices, false); + * SIMPL_NEW_CHOICE_FP("Size Distribution Fit Type", SizeDistributionFitType, FilterParameter::Category::Parameter, GenericExample, choices, false); */ -#define SIMPL_NEW_CHOICE_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (ChoiceFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_CHOICE_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(ChoiceFilterParameter, __VA_ARGS__)) /** * @brief The ChoiceFilterParameter class is used by filters to instantiate an ChoiceWidget. By instantiating an instance of @@ -62,87 +63,144 @@ */ class SIMPLib_EXPORT ChoiceFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(ChoiceFilterParameter) - SIMPL_STATIC_NEW_MACRO(ChoiceFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ChoiceFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the ChoiceFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_CHOICE_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param choices The selections to choose from in the ChoiceWidget. - * @param editable Boolean that determines whether the choices are editable or not. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const int& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - QVector choices, bool editable, - int groupIndex = -1); - - ~ChoiceFilterParameter() override; - - SIMPL_INSTANCE_PROPERTY(QVector, Choices) - SIMPL_INSTANCE_PROPERTY(bool, Editable) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief ChoiceFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - ChoiceFilterParameter(); - - public: - ChoiceFilterParameter(const ChoiceFilterParameter&) = delete; // Copy Constructor Not Implemented - ChoiceFilterParameter(ChoiceFilterParameter&&) = delete; // Move Constructor Not Implemented - ChoiceFilterParameter& operator=(const ChoiceFilterParameter&) = delete; // Copy Assignment Not Implemented - ChoiceFilterParameter& operator=(ChoiceFilterParameter&&) = delete; // Move Assignment Not Implemented + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(ChoiceFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(ChoiceFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = ChoiceFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for ChoiceFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ChoiceFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the ChoiceFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_CHOICE_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param choices The selections to choose from in the ChoiceWidget. + * @param editable Boolean that determines whether the choices are editable or not. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, int defaultValue, Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + const std::vector& choices, bool editable, int groupIndex = -1); + + ~ChoiceFilterParameter() override; + + /** + * @brief Setter property for Choices + */ + void setChoices(const std::vector& value); + /** + * @brief Getter property for Choices + * @return Value of Choices + */ + std::vector getChoices() const; + + /** + * @brief Setter property for Editable + */ + void setEditable(bool value); + /** + * @brief Getter property for Editable + * @return Value of Editable + */ + bool getEditable() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const ChoiceFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + ChoiceFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const ChoiceFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + ChoiceFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief ChoiceFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + ChoiceFilterParameter(); + +public: + ChoiceFilterParameter(const ChoiceFilterParameter&) = delete; // Copy Constructor Not Implemented + ChoiceFilterParameter(ChoiceFilterParameter&&) = delete; // Move Constructor Not Implemented + ChoiceFilterParameter& operator=(const ChoiceFilterParameter&) = delete; // Copy Assignment Not Implemented + ChoiceFilterParameter& operator=(ChoiceFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + std::vector m_Choices = {}; + bool m_Editable = {}; + ChoiceFilterParameter::SetterCallbackType m_SetterCallback = {}; + ChoiceFilterParameter::GetterCallbackType m_GetterCallback = {}; }; - diff --git a/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.cpp index 219d79bc9d..dd5a44f0ac 100644 --- a/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.cpp @@ -1,42 +1,40 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ComparisonSelectionAdvancedFilterParameter.h" -#include - #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/Filtering/ComparisonValue.h" @@ -56,9 +54,10 @@ ComparisonSelectionAdvancedFilterParameter::~ComparisonSelectionAdvancedFilterPa // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ComparisonSelectionAdvancedFilterParameter::Pointer ComparisonSelectionAdvancedFilterParameter::New(const QString& humanLabel, const QString& propertyName, ComparisonInputsAdvanced defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, QVector choices, bool showOperators, - int groupIndex) +ComparisonSelectionAdvancedFilterParameter::Pointer ComparisonSelectionAdvancedFilterParameter::Create(const QString& humanLabel, const QString& propertyName, ComparisonInputsAdvanced defaultValue, + Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const std::vector& choices, + bool showOperators, int groupIndex) { ComparisonSelectionAdvancedFilterParameter::Pointer ptr = ComparisonSelectionAdvancedFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -90,6 +89,10 @@ QString ComparisonSelectionAdvancedFilterParameter::getWidgetType() const void ComparisonSelectionAdvancedFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonObject jsonObject = jsonValue.toObject(); @@ -104,9 +107,9 @@ void ComparisonSelectionAdvancedFilterParameter::readJson(const QJsonObject& jso // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ComparisonSelectionAdvancedFilterParameter::writeJson(QJsonObject& json) +void ComparisonSelectionAdvancedFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { ComparisonInputsAdvanced inputs = m_GetterCallback(); @@ -120,7 +123,7 @@ void ComparisonSelectionAdvancedFilterParameter::writeJson(QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ComparisonSelectionAdvancedFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void ComparisonSelectionAdvancedFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; @@ -153,10 +156,107 @@ void ComparisonSelectionAdvancedFilterParameter::dataArrayPathRenamed(AbstractFi { hasChanges |= comparison->renameDataArrayPath(renamePath); } - + if(hasChanges) { m_SetterCallback(inputs); - emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); } } + +// ----------------------------------------------------------------------------- +ComparisonSelectionAdvancedFilterParameter::Pointer ComparisonSelectionAdvancedFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +ComparisonSelectionAdvancedFilterParameter::Pointer ComparisonSelectionAdvancedFilterParameter::New() +{ + Pointer sharedPtr(new(ComparisonSelectionAdvancedFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString ComparisonSelectionAdvancedFilterParameter::getNameOfClass() const +{ + return QString("ComparisonSelectionAdvancedFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString ComparisonSelectionAdvancedFilterParameter::ClassName() +{ + return QString("ComparisonSelectionAdvancedFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void ComparisonSelectionAdvancedFilterParameter::setChoices(const std::vector& value) +{ + m_Choices = value; +} + +// ----------------------------------------------------------------------------- +std::vector ComparisonSelectionAdvancedFilterParameter::getChoices() const +{ + return m_Choices; +} + +// ----------------------------------------------------------------------------- +void ComparisonSelectionAdvancedFilterParameter::setShowOperators(bool value) +{ + m_ShowOperators = value; +} + +// ----------------------------------------------------------------------------- +bool ComparisonSelectionAdvancedFilterParameter::getShowOperators() const +{ + return m_ShowOperators; +} + +// ----------------------------------------------------------------------------- +void ComparisonSelectionAdvancedFilterParameter::setDefaultGeometryTypes(const IGeometry::Types& value) +{ + m_DefaultGeometryTypes = value; +} + +// ----------------------------------------------------------------------------- +IGeometry::Types ComparisonSelectionAdvancedFilterParameter::getDefaultGeometryTypes() const +{ + return m_DefaultGeometryTypes; +} + +// ----------------------------------------------------------------------------- +void ComparisonSelectionAdvancedFilterParameter::setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value) +{ + m_DefaultAttributeMatrixTypes = value; +} + +// ----------------------------------------------------------------------------- +AttributeMatrix::Types ComparisonSelectionAdvancedFilterParameter::getDefaultAttributeMatrixTypes() const +{ + return m_DefaultAttributeMatrixTypes; +} + +// ----------------------------------------------------------------------------- +void ComparisonSelectionAdvancedFilterParameter::setSetterCallback(const ComparisonSelectionAdvancedFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ComparisonSelectionAdvancedFilterParameter::SetterCallbackType ComparisonSelectionAdvancedFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void ComparisonSelectionAdvancedFilterParameter::setGetterCallback(const ComparisonSelectionAdvancedFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ComparisonSelectionAdvancedFilterParameter::GetterCallbackType ComparisonSelectionAdvancedFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.h b/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.h index 37a838cc21..6a5488e34e 100644 --- a/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ComparisonSelectionAdvancedFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/DataContainers/AttributeMatrix.h" @@ -53,12 +55,10 @@ * SIMPL_NEW_COMP_SEL_ADV_FP("HumanLabel", PropertyName, Category, FilterName, Choices, ShowOperators, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): - * SIMPL_NEW_COMP_SEL_ADV_FP("Select Arrays to Threshold", SelectedThresholds, FilterParameter::Parameter, GenericExample, choices, true); + * SIMPL_NEW_COMP_SEL_ADV_FP("Select Arrays to Threshold", SelectedThresholds, FilterParameter::Category::Parameter, GenericExample, choices, true); */ -#define SIMPL_NEW_COMP_SEL_ADV_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (ComparisonSelectionAdvancedFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_COMP_SEL_ADV_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(ComparisonSelectionAdvancedFilterParameter, __VA_ARGS__)) /** * @brief The ComparisonSelectionAdvancedFilterParameter class is used by filters to instantiate an ComparisonSelectionAdvancedWidget. By instantiating an instance of @@ -66,96 +66,173 @@ */ class SIMPLib_EXPORT ComparisonSelectionAdvancedFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(ComparisonSelectionAdvancedFilterParameter) - SIMPL_STATIC_NEW_MACRO(ComparisonSelectionAdvancedFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ComparisonSelectionAdvancedFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the ComparisonSelectionAdvancedFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_COMP_SEL_ADV_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param choices The selections to choose from in the ComparisonSelectionAdvancedWidget. - * @param showOperators Boolean that determines whether to display the operators or not. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - ComparisonInputsAdvanced defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, QVector choices, - bool showOperators, int groupIndex = -1); - - ~ComparisonSelectionAdvancedFilterParameter() override; - - SIMPL_INSTANCE_PROPERTY(QVector, Choices) - SIMPL_INSTANCE_PROPERTY(bool, ShowOperators) - - SIMPL_INSTANCE_PROPERTY(IGeometry::Types, DefaultGeometryTypes) - SIMPL_INSTANCE_PROPERTY(AttributeMatrix::Types, DefaultAttributeMatrixTypes) - - /** + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(ComparisonSelectionAdvancedFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(ComparisonSelectionAdvancedFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = ComparisonSelectionAdvancedFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for ComparisonSelectionAdvancedFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ComparisonSelectionAdvancedFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the ComparisonSelectionAdvancedFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_COMP_SEL_ADV_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param choices The selections to choose from in the ComparisonSelectionAdvancedWidget. + * @param showOperators Boolean that determines whether to display the operators or not. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, ComparisonInputsAdvanced defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const std::vector& choices, bool showOperators, int groupIndex = -1); + + ~ComparisonSelectionAdvancedFilterParameter() override; + + /** + * @brief Setter property for Choices + */ + void setChoices(const std::vector& value); + /** + * @brief Getter property for Choices + * @return Value of Choices + */ + std::vector getChoices() const; + + /** + * @brief Setter property for ShowOperators + */ + void setShowOperators(bool value); + /** + * @brief Getter property for ShowOperators + * @return Value of ShowOperators + */ + bool getShowOperators() const; + + /** + * @brief Setter property for DefaultGeometryTypes + */ + void setDefaultGeometryTypes(const IGeometry::Types& value); + /** + * @brief Getter property for DefaultGeometryTypes + * @return Value of DefaultGeometryTypes + */ + IGeometry::Types getDefaultGeometryTypes() const; + + /** + * @brief Setter property for DefaultAttributeMatrixTypes + */ + void setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value); + /** + * @brief Getter property for DefaultAttributeMatrixTypes + * @return Value of DefaultAttributeMatrixTypes + */ + AttributeMatrix::Types getDefaultAttributeMatrixTypes() const; + + /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - /** - * @brief Handle DataArrayPath changes if necessary - * @param filter - * @param renamePath - */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; - - protected: - /** - * @brief ComparisonSelectionAdvancedFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - ComparisonSelectionAdvancedFilterParameter(); - - public: - ComparisonSelectionAdvancedFilterParameter(const ComparisonSelectionAdvancedFilterParameter&) = delete; // Copy Constructor Not Implemented - ComparisonSelectionAdvancedFilterParameter(ComparisonSelectionAdvancedFilterParameter&&) = delete; // Move Constructor Not Implemented - ComparisonSelectionAdvancedFilterParameter& operator=(const ComparisonSelectionAdvancedFilterParameter&) = delete; // Copy Assignment Not Implemented - ComparisonSelectionAdvancedFilterParameter& operator=(ComparisonSelectionAdvancedFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + QString getWidgetType() const override; + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const ComparisonSelectionAdvancedFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + ComparisonSelectionAdvancedFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const ComparisonSelectionAdvancedFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + ComparisonSelectionAdvancedFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handle DataArrayPath changes if necessary + * @param filter + * @param renamePath + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief ComparisonSelectionAdvancedFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + ComparisonSelectionAdvancedFilterParameter(); + +public: + ComparisonSelectionAdvancedFilterParameter(const ComparisonSelectionAdvancedFilterParameter&) = delete; // Copy Constructor Not Implemented + ComparisonSelectionAdvancedFilterParameter(ComparisonSelectionAdvancedFilterParameter&&) = delete; // Move Constructor Not Implemented + ComparisonSelectionAdvancedFilterParameter& operator=(const ComparisonSelectionAdvancedFilterParameter&) = delete; // Copy Assignment Not Implemented + ComparisonSelectionAdvancedFilterParameter& operator=(ComparisonSelectionAdvancedFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + std::vector m_Choices = {}; + bool m_ShowOperators = {}; + IGeometry::Types m_DefaultGeometryTypes = {}; + AttributeMatrix::Types m_DefaultAttributeMatrixTypes = {}; + ComparisonSelectionAdvancedFilterParameter::SetterCallbackType m_SetterCallback = {}; + ComparisonSelectionAdvancedFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.cpp index 53a098dc14..da5426ae58 100644 --- a/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ComparisonSelectionFilterParameter.h" @@ -55,9 +55,9 @@ ComparisonSelectionFilterParameter::~ComparisonSelectionFilterParameter() = defa // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ComparisonSelectionFilterParameter::Pointer ComparisonSelectionFilterParameter::New(const QString& humanLabel, const QString& propertyName, ComparisonInputs defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, QVector choices, bool showOperators, - int groupIndex) +ComparisonSelectionFilterParameter::Pointer ComparisonSelectionFilterParameter::Create(const QString& humanLabel, const QString& propertyName, ComparisonInputs defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + const std::vector& choices, bool showOperators, int groupIndex) { ComparisonSelectionFilterParameter::Pointer ptr = ComparisonSelectionFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -89,6 +89,10 @@ QString ComparisonSelectionFilterParameter::getWidgetType() const void ComparisonSelectionFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonArray jsonArray = jsonValue.toArray(); @@ -109,9 +113,9 @@ void ComparisonSelectionFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ComparisonSelectionFilterParameter::writeJson(QJsonObject& json) +void ComparisonSelectionFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { QJsonArray inputsArray; @@ -131,7 +135,7 @@ void ComparisonSelectionFilterParameter::writeJson(QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ComparisonSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void ComparisonSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; @@ -171,6 +175,103 @@ void ComparisonSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* fi if(hasChanges) { m_SetterCallback(inputs); - emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); } } + +// ----------------------------------------------------------------------------- +ComparisonSelectionFilterParameter::Pointer ComparisonSelectionFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +ComparisonSelectionFilterParameter::Pointer ComparisonSelectionFilterParameter::New() +{ + Pointer sharedPtr(new(ComparisonSelectionFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString ComparisonSelectionFilterParameter::getNameOfClass() const +{ + return QString("ComparisonSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString ComparisonSelectionFilterParameter::ClassName() +{ + return QString("ComparisonSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void ComparisonSelectionFilterParameter::setChoices(const std::vector& value) +{ + m_Choices = value; +} + +// ----------------------------------------------------------------------------- +std::vector ComparisonSelectionFilterParameter::getChoices() const +{ + return m_Choices; +} + +// ----------------------------------------------------------------------------- +void ComparisonSelectionFilterParameter::setShowOperators(bool value) +{ + m_ShowOperators = value; +} + +// ----------------------------------------------------------------------------- +bool ComparisonSelectionFilterParameter::getShowOperators() const +{ + return m_ShowOperators; +} + +// ----------------------------------------------------------------------------- +void ComparisonSelectionFilterParameter::setDefaultGeometryTypes(const IGeometry::Types& value) +{ + m_DefaultGeometryTypes = value; +} + +// ----------------------------------------------------------------------------- +IGeometry::Types ComparisonSelectionFilterParameter::getDefaultGeometryTypes() const +{ + return m_DefaultGeometryTypes; +} + +// ----------------------------------------------------------------------------- +void ComparisonSelectionFilterParameter::setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value) +{ + m_DefaultAttributeMatrixTypes = value; +} + +// ----------------------------------------------------------------------------- +AttributeMatrix::Types ComparisonSelectionFilterParameter::getDefaultAttributeMatrixTypes() const +{ + return m_DefaultAttributeMatrixTypes; +} + +// ----------------------------------------------------------------------------- +void ComparisonSelectionFilterParameter::setSetterCallback(const ComparisonSelectionFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ComparisonSelectionFilterParameter::SetterCallbackType ComparisonSelectionFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void ComparisonSelectionFilterParameter::setGetterCallback(const ComparisonSelectionFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ComparisonSelectionFilterParameter::GetterCallbackType ComparisonSelectionFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.h old mode 100755 new mode 100644 index a51894b632..c3a4325ce8 --- a/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ComparisonSelectionFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/DataContainers/AttributeMatrix.h" @@ -52,12 +54,10 @@ * SIMPL_NEW_COMP_SEL_FP("HumanLabel", PropertyName, Category, FilterName, Choices, ShowOperators, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): - * SIMPL_NEW_COMP_SEL_FP("Select Arrays to Threshold", SelectedThresholds, FilterParameter::Parameter, GenericExample, choices, true); + * SIMPL_NEW_COMP_SEL_FP("Select Arrays to Threshold", SelectedThresholds, FilterParameter::Category::Parameter, GenericExample, choices, true); */ -#define SIMPL_NEW_COMP_SEL_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (ComparisonSelectionFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_COMP_SEL_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(ComparisonSelectionFilterParameter, __VA_ARGS__)) /** * @brief The ComparisonSelectionFilterParameter class is used by filters to instantiate an ComparisonSelectionWidget. By instantiating an instance of @@ -65,96 +65,173 @@ */ class SIMPLib_EXPORT ComparisonSelectionFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(ComparisonSelectionFilterParameter) - SIMPL_STATIC_NEW_MACRO(ComparisonSelectionFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ComparisonSelectionFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the ComparisonSelectionFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_COMP_SEL_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param choices The selections to choose from in the ComparisonSelectionWidget. - * @param showOperators Boolean that determines whether to display the operators or not. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - ComparisonInputs defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, QVector choices, - bool showOperators, int groupIndex = -1); - - ~ComparisonSelectionFilterParameter() override; - - SIMPL_INSTANCE_PROPERTY(QVector, Choices) - SIMPL_INSTANCE_PROPERTY(bool, ShowOperators) - - SIMPL_INSTANCE_PROPERTY(IGeometry::Types, DefaultGeometryTypes) - SIMPL_INSTANCE_PROPERTY(AttributeMatrix::Types, DefaultAttributeMatrixTypes) - - /** + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(ComparisonSelectionFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(ComparisonSelectionFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = ComparisonSelectionFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for ComparisonSelectionFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ComparisonSelectionFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the ComparisonSelectionFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_COMP_SEL_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param choices The selections to choose from in the ComparisonSelectionWidget. + * @param showOperators Boolean that determines whether to display the operators or not. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, ComparisonInputs defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const std::vector& choices, bool showOperators, int groupIndex = -1); + + ~ComparisonSelectionFilterParameter() override; + + /** + * @brief Setter property for Choices + */ + void setChoices(const std::vector& value); + /** + * @brief Getter property for Choices + * @return Value of Choices + */ + std::vector getChoices() const; + + /** + * @brief Setter property for ShowOperators + */ + void setShowOperators(bool value); + /** + * @brief Getter property for ShowOperators + * @return Value of ShowOperators + */ + bool getShowOperators() const; + + /** + * @brief Setter property for DefaultGeometryTypes + */ + void setDefaultGeometryTypes(const IGeometry::Types& value); + /** + * @brief Getter property for DefaultGeometryTypes + * @return Value of DefaultGeometryTypes + */ + IGeometry::Types getDefaultGeometryTypes() const; + + /** + * @brief Setter property for DefaultAttributeMatrixTypes + */ + void setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value); + /** + * @brief Getter property for DefaultAttributeMatrixTypes + * @return Value of DefaultAttributeMatrixTypes + */ + AttributeMatrix::Types getDefaultAttributeMatrixTypes() const; + + /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - /** - * @brief Handle DataArrayPath changes if necessary - * @param filter - * @param renamePath - */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; - - protected: - /** - * @brief ComparisonSelectionFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - ComparisonSelectionFilterParameter(); - - public: - ComparisonSelectionFilterParameter(const ComparisonSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented - ComparisonSelectionFilterParameter(ComparisonSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented - ComparisonSelectionFilterParameter& operator=(const ComparisonSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented - ComparisonSelectionFilterParameter& operator=(ComparisonSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + QString getWidgetType() const override; + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const ComparisonSelectionFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + ComparisonSelectionFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const ComparisonSelectionFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + ComparisonSelectionFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handle DataArrayPath changes if necessary + * @param filter + * @param renamePath + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief ComparisonSelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + ComparisonSelectionFilterParameter(); + +public: + ComparisonSelectionFilterParameter(const ComparisonSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + ComparisonSelectionFilterParameter(ComparisonSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + ComparisonSelectionFilterParameter& operator=(const ComparisonSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented + ComparisonSelectionFilterParameter& operator=(ComparisonSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + std::vector m_Choices = {}; + bool m_ShowOperators = {}; + IGeometry::Types m_DefaultGeometryTypes = {}; + AttributeMatrix::Types m_DefaultAttributeMatrixTypes = {}; + ComparisonSelectionFilterParameter::SetterCallbackType m_SetterCallback = {}; + ComparisonSelectionFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/ConstrainedDoubleFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ConstrainedDoubleFilterParameter.cpp index 2c02ecaf8b..1f35ea4b9f 100644 --- a/Source/SIMPLib/FilterParameters/ConstrainedDoubleFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/ConstrainedDoubleFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ConstrainedDoubleFilterParameter.h" @@ -48,8 +48,9 @@ ConstrainedDoubleFilterParameter::~ConstrainedDoubleFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ConstrainedDoubleFilterParameter::Pointer ConstrainedDoubleFilterParameter::New(const QString& humanLabel, const QString& propertyName, - const double& defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) +ConstrainedDoubleFilterParameter::Pointer ConstrainedDoubleFilterParameter::Create(const QString& humanLabel, const QString& propertyName, double min, double max, double defaultValue, + Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + int groupIndex) { ConstrainedDoubleFilterParameter::Pointer ptr = ConstrainedDoubleFilterParameter::New(); @@ -60,6 +61,8 @@ ConstrainedDoubleFilterParameter::Pointer ConstrainedDoubleFilterParameter::New( ptr->setGroupIndex(groupIndex); ptr->setSetterCallback(setterCallback); ptr->setGetterCallback(getterCallback); + ptr->setMinimum(min); + ptr->setMaximum(max); return ptr; } @@ -75,7 +78,7 @@ QString ConstrainedDoubleFilterParameter::getWidgetType() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ConstrainedDoubleFilterParameter::readJson(const QJsonObject &json) +void ConstrainedDoubleFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; if(!jsonValue.isUndefined() && m_SetterCallback) @@ -87,11 +90,59 @@ void ConstrainedDoubleFilterParameter::readJson(const QJsonObject &json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ConstrainedDoubleFilterParameter::writeJson(QJsonObject &json) +void ConstrainedDoubleFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { json[getPropertyName()] = m_GetterCallback(); } } +// ----------------------------------------------------------------------------- +ConstrainedDoubleFilterParameter::Pointer ConstrainedDoubleFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +ConstrainedDoubleFilterParameter::Pointer ConstrainedDoubleFilterParameter::New() +{ + Pointer sharedPtr(new(ConstrainedDoubleFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString ConstrainedDoubleFilterParameter::getNameOfClass() const +{ + return QString("ConstrainedDoubleFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString ConstrainedDoubleFilterParameter::ClassName() +{ + return QString("ConstrainedDoubleFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void ConstrainedDoubleFilterParameter::setSetterCallback(const ConstrainedDoubleFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ConstrainedDoubleFilterParameter::SetterCallbackType ConstrainedDoubleFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void ConstrainedDoubleFilterParameter::setGetterCallback(const ConstrainedDoubleFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ConstrainedDoubleFilterParameter::GetterCallbackType ConstrainedDoubleFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/ConstrainedDoubleFilterParameter.h b/Source/SIMPLib/FilterParameters/ConstrainedDoubleFilterParameter.h old mode 100755 new mode 100644 index 296809b64b..0b3cb683f8 --- a/Source/SIMPLib/FilterParameters/ConstrainedDoubleFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ConstrainedDoubleFilterParameter.h @@ -1,43 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" +#include "SIMPLib/FilterParameters/ConstrainedFilterParameter.h" /** * @brief SIMPL_NEW_DOUBLE_FP This macro is a short-form way of instantiating an instance of @@ -49,95 +51,133 @@ * SIMPL_NEW_DOUBLE_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): - * SIMPL_NEW_DOUBLE_FP("Double 2", Double2, FilterParameter::Parameter, GenericExample); + * SIMPL_NEW_DOUBLE_FP("Double 2", Double2, FilterParameter::Category::Parameter, GenericExample); */ -#define SIMPL_NEW_CONSTRAINED_DOUBLE_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (ConstrainedDoubleFilterParameter, __VA_ARGS__)) - +#define SIMPL_NEW_CONSTRAINED_DOUBLE_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(ConstrainedDoubleFilterParameter, __VA_ARGS__)) /** * @brief The ConstrainedDoubleFilterParameter class is used by filters to instantiate an DoubleWidget. By instantiating an instance of * this class in a filter's setupFilterParameters() method, a DoubleWidget will appear in the filter's "filter input" section in the DREAM3D GUI. */ -class SIMPLib_EXPORT ConstrainedDoubleFilterParameter : public FilterParameter +class SIMPLib_EXPORT ConstrainedDoubleFilterParameter : public ConstrainedFilterParameter { - public: - SIMPL_SHARED_POINTERS(ConstrainedDoubleFilterParameter) - SIMPL_STATIC_NEW_MACRO(ConstrainedDoubleFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ConstrainedDoubleFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the ConstrainedDoubleFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DOUBLE_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const double& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); - - ~ConstrainedDoubleFilterParameter() override; - - /** + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(ConstrainedDoubleFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(ConstrainedDoubleFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = ConstrainedDoubleFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for ConstrainedDoubleFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ConstrainedDoubleFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the ConstrainedDoubleFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DOUBLE_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param min value + * @param max value + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, double min, double max, double defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~ConstrainedDoubleFilterParameter() override; + + /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief ConstrainedDoubleFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - ConstrainedDoubleFilterParameter(); - - public: - ConstrainedDoubleFilterParameter(const ConstrainedDoubleFilterParameter&) = delete; // Copy Constructor Not Implemented - ConstrainedDoubleFilterParameter(ConstrainedDoubleFilterParameter&&) = delete; // Move Constructor Not Implemented - ConstrainedDoubleFilterParameter& operator=(const ConstrainedDoubleFilterParameter&) = delete; // Copy Assignment Not Implemented - ConstrainedDoubleFilterParameter& operator=(ConstrainedDoubleFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + QString getWidgetType() const override; + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const ConstrainedDoubleFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + ConstrainedDoubleFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const ConstrainedDoubleFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + ConstrainedDoubleFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief ConstrainedDoubleFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + ConstrainedDoubleFilterParameter(); + +public: + ConstrainedDoubleFilterParameter(const ConstrainedDoubleFilterParameter&) = delete; // Copy Constructor Not Implemented + ConstrainedDoubleFilterParameter(ConstrainedDoubleFilterParameter&&) = delete; // Move Constructor Not Implemented + ConstrainedDoubleFilterParameter& operator=(const ConstrainedDoubleFilterParameter&) = delete; // Copy Assignment Not Implemented + ConstrainedDoubleFilterParameter& operator=(ConstrainedDoubleFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + ConstrainedDoubleFilterParameter::SetterCallbackType m_SetterCallback = {}; + ConstrainedDoubleFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/ConstrainedFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ConstrainedFilterParameter.cpp deleted file mode 100644 index c090a1e838..0000000000 --- a/Source/SIMPLib/FilterParameters/ConstrainedFilterParameter.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include "ConstrainedFilterParameter.h" diff --git a/Source/SIMPLib/FilterParameters/ConstrainedFilterParameter.h b/Source/SIMPLib/FilterParameters/ConstrainedFilterParameter.h old mode 100755 new mode 100644 index 91d78b3429..a5faee86fc --- a/Source/SIMPLib/FilterParameters/ConstrainedFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ConstrainedFilterParameter.h @@ -1,69 +1,143 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include +#include + #include "SIMPLib/FilterParameters/FilterParameter.h" -template +template class SIMPLib_EXPORT ConstrainedFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(ConstrainedFilterParameter) - SIMPL_STATIC_NEW_MACRO(ConstrainedFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ConstrainedFilterParameter, FilterParameter) + // Start Python bindings declarations + // clang-format off +// PYB11_BEGIN_BINDINGS(ConstrainedFilterParameter SUPERCLASS FilterParameter) +// PYB11_SHARED_POINTERS(ConstrainedFilterParameter) +// PYB11_STATIC_CREATION(Create) +// PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = ConstrainedFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer() + { + return Pointer(static_cast(nullptr)); + } - virtual ~ConstrainedFilterParameter() {} + static Pointer New() + { + Pointer sharedPtr(new(ConstrainedFilterParameter)); + return sharedPtr; + } - SIMPL_INSTANCE_PROPERTY(T, Minimum) - SIMPL_INSTANCE_PROPERTY(T, Maximum) + /** + * @brief Returns the name of the class for ConstrainedFilterParameter + */ + QString getNameOfClass() const override + { + return QString("ConstrainedFilterParameter"); + } + /** + * @brief Returns the name of the class for ConstrainedFilterParameter + */ + static QString ClassName() + { + return "ConstrainedFilterParameter"; + } - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; + virtual ~ConstrainedFilterParameter() = default; - protected: - ConstrainedFilterParameter() {} + /** + * @brief Setter property for Minimum + */ + void setMinimum(const T& value) + { + m_Minimum = value; + } + /** + * @brief Getter property for Minimum + * @return Value of Minimum + */ + T getMinimum() const + { + return m_Minimum; + } - public: - ConstrainedFilterParameter(const ConstrainedFilterParameter&) = delete; // Copy Constructor Not Implemented - ConstrainedFilterParameter(ConstrainedFilterParameter&&) = delete; // Move Constructor Not Implemented - ConstrainedFilterParameter& operator=(const ConstrainedFilterParameter&) = delete; // Copy Assignment Not Implemented - ConstrainedFilterParameter& operator=(ConstrainedFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + /** + * @brief Setter property for Maximum + */ + void setMaximum(const T& value) + { + m_Maximum = value; + } + /** + * @brief Getter property for Maximum + * @return Value of Maximum + */ + T getMaximum() const + { + return m_Maximum; + } + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override + { + return "SUBCLASS IMPLEMENTS THIS METHOD"; + } +protected: + ConstrainedFilterParameter() = default; + +public: + ConstrainedFilterParameter(const ConstrainedFilterParameter&) = delete; // Copy Constructor Not Implemented + ConstrainedFilterParameter(ConstrainedFilterParameter&&) = delete; // Move Constructor Not Implemented + ConstrainedFilterParameter& operator=(const ConstrainedFilterParameter&) = delete; // Copy Assignment Not Implemented + ConstrainedFilterParameter& operator=(ConstrainedFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + T m_Minimum = std::numeric_limits::min(); + T m_Maximum = std::numeric_limits::max(); + ; +}; diff --git a/Source/SIMPLib/FilterParameters/ConstrainedIntFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ConstrainedIntFilterParameter.cpp index b2faaa322c..66d572f93a 100644 --- a/Source/SIMPLib/FilterParameters/ConstrainedIntFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/ConstrainedIntFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ConstrainedIntFilterParameter.h" @@ -48,9 +48,8 @@ ConstrainedIntFilterParameter::~ConstrainedIntFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ConstrainedIntFilterParameter::Pointer ConstrainedIntFilterParameter::New(const QString& humanLabel, const QString& propertyName, - const int& defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, - int groupIndex) +ConstrainedIntFilterParameter::Pointer ConstrainedIntFilterParameter::Create(const QString& humanLabel, const QString& propertyName, int32_t min, int32_t max, int32_t defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { ConstrainedIntFilterParameter::Pointer ptr = ConstrainedIntFilterParameter::New(); @@ -61,6 +60,8 @@ ConstrainedIntFilterParameter::Pointer ConstrainedIntFilterParameter::New(const ptr->setGroupIndex(groupIndex); ptr->setSetterCallback(setterCallback); ptr->setGetterCallback(getterCallback); + ptr->setMinimum(min); + ptr->setMaximum(max); return ptr; } @@ -76,7 +77,7 @@ QString ConstrainedIntFilterParameter::getWidgetType() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ConstrainedIntFilterParameter::readJson(const QJsonObject &json) +void ConstrainedIntFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; if(!jsonValue.isUndefined() && m_SetterCallback) @@ -88,11 +89,59 @@ void ConstrainedIntFilterParameter::readJson(const QJsonObject &json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ConstrainedIntFilterParameter::writeJson(QJsonObject &json) +void ConstrainedIntFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { json[getPropertyName()] = m_GetterCallback(); } } +// ----------------------------------------------------------------------------- +ConstrainedIntFilterParameter::Pointer ConstrainedIntFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +ConstrainedIntFilterParameter::Pointer ConstrainedIntFilterParameter::New() +{ + Pointer sharedPtr(new(ConstrainedIntFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString ConstrainedIntFilterParameter::getNameOfClass() const +{ + return QString("ConstrainedIntFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString ConstrainedIntFilterParameter::ClassName() +{ + return QString("ConstrainedIntFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void ConstrainedIntFilterParameter::setSetterCallback(const ConstrainedIntFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ConstrainedIntFilterParameter::SetterCallbackType ConstrainedIntFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void ConstrainedIntFilterParameter::setGetterCallback(const ConstrainedIntFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ConstrainedIntFilterParameter::GetterCallbackType ConstrainedIntFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/ConstrainedIntFilterParameter.h b/Source/SIMPLib/FilterParameters/ConstrainedIntFilterParameter.h old mode 100755 new mode 100644 index 5e1b58c456..569f595328 --- a/Source/SIMPLib/FilterParameters/ConstrainedIntFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ConstrainedIntFilterParameter.h @@ -1,42 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include +#include "SIMPLib/FilterParameters/ConstrainedFilterParameter.h" #include "SIMPLib/FilterParameters/FilterParameter.h" /** @@ -49,94 +52,133 @@ * SIMPL_NEW_INTEGER_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): - * SIMPL_NEW_INTEGER_FP("Max Iterations", MaxIterations, FilterParameter::Parameter, GenericExample, 0); + * SIMPL_NEW_INTEGER_FP("Max Iterations", MaxIterations, FilterParameter::Category::Parameter, GenericExample, 0); */ -#define SIMPL_NEW_CONSTRAINED_INT_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (ConstrainedIntFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_CONSTRAINED_INT_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(ConstrainedIntFilterParameter, __VA_ARGS__)) /** * @brief The ConstrainedIntFilterParameter class is used by filters to instantiate an IntWidget. By instantiating an instance of * this class in a filter's setupFilterParameters() method, an IntWidget will appear in the filter's "filter input" section in the DREAM3D GUI. */ -class SIMPLib_EXPORT ConstrainedIntFilterParameter : public FilterParameter +class SIMPLib_EXPORT ConstrainedIntFilterParameter : public ConstrainedFilterParameter { - public: - SIMPL_SHARED_POINTERS(ConstrainedIntFilterParameter) - SIMPL_STATIC_NEW_MACRO(ConstrainedIntFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ConstrainedIntFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the ConstrainedIntFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_INTEGER_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const int& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); - - ~ConstrainedIntFilterParameter() override; - - /** + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(ConstrainedIntFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(ConstrainedIntFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = ConstrainedIntFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for ConstrainedIntFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ConstrainedIntFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the ConstrainedIntFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_INTEGER_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param min + * @param max + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, int min, int max, int defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~ConstrainedIntFilterParameter() override; + + /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief ConstrainedIntFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - ConstrainedIntFilterParameter(); - - public: - ConstrainedIntFilterParameter(const ConstrainedIntFilterParameter&) = delete; // Copy Constructor Not Implemented - ConstrainedIntFilterParameter(ConstrainedIntFilterParameter&&) = delete; // Move Constructor Not Implemented - ConstrainedIntFilterParameter& operator=(const ConstrainedIntFilterParameter&) = delete; // Copy Assignment Not Implemented - ConstrainedIntFilterParameter& operator=(ConstrainedIntFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + QString getWidgetType() const override; + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const ConstrainedIntFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + ConstrainedIntFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const ConstrainedIntFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + ConstrainedIntFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief ConstrainedIntFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + ConstrainedIntFilterParameter(); + +public: + ConstrainedIntFilterParameter(const ConstrainedIntFilterParameter&) = delete; // Copy Constructor Not Implemented + ConstrainedIntFilterParameter(ConstrainedIntFilterParameter&&) = delete; // Move Constructor Not Implemented + ConstrainedIntFilterParameter& operator=(const ConstrainedIntFilterParameter&) = delete; // Copy Assignment Not Implemented + ConstrainedIntFilterParameter& operator=(ConstrainedIntFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + ConstrainedIntFilterParameter::SetterCallbackType m_SetterCallback = {}; + ConstrainedIntFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.cpp index 22941d8c5a..74a3ef29cc 100644 --- a/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.cpp @@ -1,42 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DataArrayCreationFilterParameter.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataContainers/AttributeMatrix.h" - +#include "SIMPLib/Filtering/AbstractFilter.h" // ----------------------------------------------------------------------------- // @@ -51,8 +51,9 @@ DataArrayCreationFilterParameter::~DataArrayCreationFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataArrayCreationFilterParameter::Pointer DataArrayCreationFilterParameter::New(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, const RequirementType req, int groupIndex) +DataArrayCreationFilterParameter::Pointer DataArrayCreationFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, RequirementType req, + int groupIndex) { DataArrayCreationFilterParameter::Pointer ptr = DataArrayCreationFilterParameter::New(); @@ -120,7 +121,7 @@ DataArrayCreationFilterParameter::RequirementType DataArrayCreationFilterParamet DataArrayCreationFilterParameter::RequirementType req; if(AttributeMatrix::Type::Any != attributeMatrixType) { - req.amTypes = QVector(1, attributeMatrixType); + req.amTypes = AttributeMatrix::Types(1, attributeMatrixType); } if(IGeometry::Type::Any != geometryType) { @@ -135,6 +136,10 @@ DataArrayCreationFilterParameter::RequirementType DataArrayCreationFilterParamet void DataArrayCreationFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonObject obj = jsonValue.toObject(); @@ -147,9 +152,9 @@ void DataArrayCreationFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataArrayCreationFilterParameter::writeJson(QJsonObject& json) +void DataArrayCreationFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { DataArrayPath dap = m_GetterCallback(); QJsonObject obj; @@ -157,3 +162,96 @@ void DataArrayCreationFilterParameter::writeJson(QJsonObject& json) json[getPropertyName()] = obj; } } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataArrayCreationFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + QVariant var = filter->property(qPrintable(getPropertyName())); + if(var.isValid() && var.canConvert()) + { + DataArrayPath path = var.value(); + if(path.updatePath(renamePath)) + { + if(m_SetterCallback) + { + m_SetterCallback(path); + } + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); + } + } +} + +// ----------------------------------------------------------------------------- +DataArrayCreationFilterParameter::Pointer DataArrayCreationFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +DataArrayCreationFilterParameter::Pointer DataArrayCreationFilterParameter::New() +{ + Pointer sharedPtr(new(DataArrayCreationFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString DataArrayCreationFilterParameter::getNameOfClass() const +{ + return QString("DataArrayCreationFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString DataArrayCreationFilterParameter::ClassName() +{ + return QString("DataArrayCreationFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void DataArrayCreationFilterParameter::setDefaultGeometryTypes(const IGeometry::Types& value) +{ + m_DefaultGeometryTypes = value; +} + +// ----------------------------------------------------------------------------- +IGeometry::Types DataArrayCreationFilterParameter::getDefaultGeometryTypes() const +{ + return m_DefaultGeometryTypes; +} + +// ----------------------------------------------------------------------------- +void DataArrayCreationFilterParameter::setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value) +{ + m_DefaultAttributeMatrixTypes = value; +} + +// ----------------------------------------------------------------------------- +AttributeMatrix::Types DataArrayCreationFilterParameter::getDefaultAttributeMatrixTypes() const +{ + return m_DefaultAttributeMatrixTypes; +} + +// ----------------------------------------------------------------------------- +void DataArrayCreationFilterParameter::setSetterCallback(const DataArrayCreationFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DataArrayCreationFilterParameter::SetterCallbackType DataArrayCreationFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void DataArrayCreationFilterParameter::setGetterCallback(const DataArrayCreationFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DataArrayCreationFilterParameter::GetterCallbackType DataArrayCreationFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h b/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h old mode 100755 new mode 100644 index 8b0c690b58..746ad6da1d --- a/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/DataArrayCreationFilterParameter.h @@ -1,47 +1,51 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" -#include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/DataContainers/AttributeMatrix.h" +#include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Geometry/IGeometry.h" +class AbstractFilter; + /** * @brief SIMPL_NEW_DA_CREATION_FP This macro is a short-form way of instantiating an instance of * DataArrayCreationFilterParameter. There are 5 required parameters and 1 optional parameter @@ -53,12 +57,10 @@ * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): * DataArrayCreationFilterParameter::RequirementType req; - * SIMPL_NEW_DA_CREATION_FP("Created Data Array", CreatedDataArray, FilterParameter::Parameter, GenericExample, req, 0); + * SIMPL_NEW_DA_CREATION_FP("Created Data Array", CreatedDataArray, FilterParameter::Category::Parameter, GenericExample, req, 0); */ -#define SIMPL_NEW_DA_CREATION_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (DataArrayCreationFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_DA_CREATION_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(DataArrayCreationFilterParameter, __VA_ARGS__)) /** * @brief The DataArrayCreationFilterParameter class is used by filters to instantiate an DataArrayCreationWidget. By instantiating an instance of @@ -66,121 +68,181 @@ */ class SIMPLib_EXPORT DataArrayCreationFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(DataArrayCreationFilterParameter) - SIMPL_STATIC_NEW_MACRO(DataArrayCreationFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DataArrayCreationFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - typedef struct - { - IGeometry::Types dcGeometryTypes; - AttributeMatrix::Types amTypes; - } RequirementType; - - /** - * @brief New This function instantiates an instance of the DataArrayCreationFilterParameter. Specifying a RequirementType will - * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. - * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the - * SIMPL_NEW_DA_CREATION_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D - * user interface. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const DataArrayPath& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex = -1); - - ~DataArrayCreationFilterParameter() override; - - /** - * @brief CreateRequirement - * @param attributeMatrixType - * @return - */ - static RequirementType CreateRequirement(AttributeMatrix::Category attributeMatrixObjectType); - - /** - * @brief CreateRequirement - * @param attributeMatrixType - * @param geometryType - * @return - */ - static RequirementType CreateRequirement(AttributeMatrix::Type attributeMatrixType, - IGeometry::Type geometryType); - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param DefaultGeometryTypes Default geometry types required for Data Container selections - * @return - */ - SIMPL_INSTANCE_PROPERTY(IGeometry::Types, DefaultGeometryTypes) - - /** - * @param DefaultAttributeMatrixTypes Default attribute matrix types required for Attribute Matrix selections - * @return - */ - SIMPL_INSTANCE_PROPERTY(QVector, DefaultAttributeMatrixTypes) - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief DataArrayCreationFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - DataArrayCreationFilterParameter(); - - public: - DataArrayCreationFilterParameter(const DataArrayCreationFilterParameter&) = delete; // Copy Constructor Not Implemented - DataArrayCreationFilterParameter(DataArrayCreationFilterParameter&&) = delete; // Move Constructor Not Implemented - DataArrayCreationFilterParameter& operator=(const DataArrayCreationFilterParameter&) = delete; // Copy Assignment Not Implemented - DataArrayCreationFilterParameter& operator=(DataArrayCreationFilterParameter&&) = delete; // Move Assignment Not Implemented + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(DataArrayCreationFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(DataArrayCreationFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_CUSTOM() + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = DataArrayCreationFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for DataArrayCreationFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for DataArrayCreationFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + struct RequirementType + { + IGeometry::Types dcGeometryTypes; + AttributeMatrix::Types amTypes; + }; + + /** + * @brief New This function instantiates an instance of the DataArrayCreationFilterParameter. Specifying a RequirementType will + * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. + * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the + * SIMPL_NEW_DA_CREATION_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D + * user interface. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, RequirementType req, int groupIndex = -1); + + ~DataArrayCreationFilterParameter() override; + + /** + * @brief CreateRequirement + * @param attributeMatrixType + * @return + */ + static RequirementType CreateRequirement(AttributeMatrix::Category attributeMatrixObjectType); + + /** + * @brief CreateRequirement + * @param attributeMatrixType + * @param geometryType + * @return + */ + static RequirementType CreateRequirement(AttributeMatrix::Type attributeMatrixType, IGeometry::Type geometryType); + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param DefaultGeometryTypes Default geometry types required for Data Container selections + * @return + */ + /** + * @brief Setter property for DefaultGeometryTypes + */ + void setDefaultGeometryTypes(const IGeometry::Types& value); + /** + * @brief Getter property for DefaultGeometryTypes + * @return Value of DefaultGeometryTypes + */ + IGeometry::Types getDefaultGeometryTypes() const; + + /** + * @param DefaultAttributeMatrixTypes Default attribute matrix types required for Attribute Matrix selections + * @return + */ + /** + * @brief Setter property for DefaultAttributeMatrixTypes + */ + void setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value); + /** + * @brief Getter property for DefaultAttributeMatrixTypes + * @return Value of DefaultAttributeMatrixTypes + */ + AttributeMatrix::Types getDefaultAttributeMatrixTypes() const; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const DataArrayCreationFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + DataArrayCreationFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const DataArrayCreationFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + DataArrayCreationFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handle DataArrayPath changes if necessary + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief DataArrayCreationFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + DataArrayCreationFilterParameter(); + +public: + DataArrayCreationFilterParameter(const DataArrayCreationFilterParameter&) = delete; // Copy Constructor Not Implemented + DataArrayCreationFilterParameter(DataArrayCreationFilterParameter&&) = delete; // Move Constructor Not Implemented + DataArrayCreationFilterParameter& operator=(const DataArrayCreationFilterParameter&) = delete; // Copy Assignment Not Implemented + DataArrayCreationFilterParameter& operator=(DataArrayCreationFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + IGeometry::Types m_DefaultGeometryTypes = {}; + AttributeMatrix::Types m_DefaultAttributeMatrixTypes = {}; + DataArrayCreationFilterParameter::SetterCallbackType m_SetterCallback = {}; + DataArrayCreationFilterParameter::GetterCallbackType m_GetterCallback = {}; }; - - - diff --git a/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.cpp index 824f244c9b..4089565413 100644 --- a/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DataArraySelectionFilterParameter.h" #include "SIMPLib/Common/Constants.h" @@ -50,14 +50,9 @@ DataArraySelectionFilterParameter::~DataArraySelectionFilterParameter() = defaul // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataArraySelectionFilterParameter::Pointer DataArraySelectionFilterParameter::New(const QString& humanLabel, - const QString& propertyName, - const DataArrayPath& defaultValue, - Category category, - SetterCallbackType setterCallback, - GetterCallbackType getterCallback, - const RequirementType req, - int groupIndex) +DataArraySelectionFilterParameter::Pointer DataArraySelectionFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, RequirementType req, + int groupIndex) { DataArraySelectionFilterParameter::Pointer ptr = DataArraySelectionFilterParameter::New(); @@ -89,11 +84,10 @@ QString DataArraySelectionFilterParameter::getWidgetType() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataArraySelectionFilterParameter::RequirementType DataArraySelectionFilterParameter::CreateCategoryRequirement(const QString& primitiveType, - size_t allowedCompDim, +DataArraySelectionFilterParameter::RequirementType DataArraySelectionFilterParameter::CreateCategoryRequirement(const QString& primitiveType, size_t allowedCompDim, AttributeMatrix::Category attributeMatrixCategory) { - typedef QVector QVectorOfSizeType; + using SizeTVectorType = std::vector; DataArraySelectionFilterParameter::RequirementType req; AttributeMatrix::Types amTypes; if(attributeMatrixCategory == AttributeMatrix::Category::Element) @@ -120,11 +114,11 @@ DataArraySelectionFilterParameter::RequirementType DataArraySelectionFilterParam req.amTypes = amTypes; if(primitiveType.compare(SIMPL::Defaults::AnyPrimitive) != 0) { - req.daTypes = QVector(1, primitiveType); + req.daTypes = std::vector(1, primitiveType); } if(SIMPL::Defaults::AnyComponentSize != allowedCompDim) { - req.componentDimensions = QVector(1, QVectorOfSizeType(1, allowedCompDim)); + req.componentDimensions = std::vector(1, SizeTVectorType(1, allowedCompDim)); } // if(IGeometry::Type::Unknown != geometryType) // { @@ -136,24 +130,55 @@ DataArraySelectionFilterParameter::RequirementType DataArraySelectionFilterParam // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataArraySelectionFilterParameter::RequirementType DataArraySelectionFilterParameter::CreateRequirement(const QString& primitiveType, - size_t allowedCompDim, - AttributeMatrix::Type attributeMatrixType, +DataArraySelectionFilterParameter::RequirementType DataArraySelectionFilterParameter::CreateRequirement(const QString& primitiveType, size_t allowedCompDim, AttributeMatrix::Type attributeMatrixType, IGeometry::Type geometryType) { - typedef QVector QVectorOfSizeType; + using SizeTVectorType = std::vector; DataArraySelectionFilterParameter::RequirementType req; if(primitiveType.compare(SIMPL::Defaults::AnyPrimitive) != 0) { - req.daTypes = QVector(1, primitiveType); + req.daTypes = std::vector(1, primitiveType); } if(SIMPL::Defaults::AnyComponentSize != allowedCompDim) { - req.componentDimensions = QVector(1, QVectorOfSizeType(1, allowedCompDim)); + req.componentDimensions = std::vector(1, SizeTVectorType(1, allowedCompDim)); } if(AttributeMatrix::Type::Any != attributeMatrixType) { - QVector amTypes(1, attributeMatrixType); + AttributeMatrix::Types amTypes(1, attributeMatrixType); + req.amTypes = amTypes; + } + if(IGeometry::Type::Any != geometryType) + { + req.dcGeometryTypes = IGeometry::Types(1, geometryType); + } + return req; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataArraySelectionFilterParameter::RequirementType DataArraySelectionFilterParameter::CreateRequirement(const QVector& primitiveTypes, size_t allowedCompDim, + AttributeMatrix::Type attributeMatrixType, IGeometry::Type geometryType) +{ + using SizeTVectorType = std::vector; + DataArraySelectionFilterParameter::RequirementType req; + + for(const auto& type : primitiveTypes) + { + if(type.compare(SIMPL::Defaults::AnyPrimitive) != 0) + { + req.daTypes.push_back(type); + } + } + + if(SIMPL::Defaults::AnyComponentSize != allowedCompDim) + { + req.componentDimensions = std::vector(1, SizeTVectorType(1, allowedCompDim)); + } + if(AttributeMatrix::Type::Any != attributeMatrixType) + { + AttributeMatrix::Types amTypes(1, attributeMatrixType); req.amTypes = amTypes; } if(IGeometry::Type::Any != geometryType) @@ -169,6 +194,10 @@ DataArraySelectionFilterParameter::RequirementType DataArraySelectionFilterParam void DataArraySelectionFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonObject obj = jsonValue.toObject(); @@ -181,9 +210,9 @@ void DataArraySelectionFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataArraySelectionFilterParameter::writeJson(QJsonObject& json) +void DataArraySelectionFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { DataArrayPath dap = m_GetterCallback(); QJsonObject obj; @@ -205,3 +234,120 @@ DataArraySelectionFilterParameter::RequirementType DataArraySelectionFilterParam return reqs; } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataArraySelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + QVariant var = filter->property(qPrintable(getPropertyName())); + if(var.isValid() && var.canConvert()) + { + DataArrayPath path = var.value(); + if(path.updatePath(renamePath)) + { + if(m_SetterCallback) + { + m_SetterCallback(path); + } + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); + } + } +} + +// ----------------------------------------------------------------------------- +DataArraySelectionFilterParameter::Pointer DataArraySelectionFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +DataArraySelectionFilterParameter::Pointer DataArraySelectionFilterParameter::New() +{ + Pointer sharedPtr(new(DataArraySelectionFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString DataArraySelectionFilterParameter::getNameOfClass() const +{ + return QString("DataArraySelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString DataArraySelectionFilterParameter::ClassName() +{ + return QString("DataArraySelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void DataArraySelectionFilterParameter::setDefaultGeometryTypes(const IGeometry::Types& value) +{ + m_DefaultGeometryTypes = value; +} + +// ----------------------------------------------------------------------------- +IGeometry::Types DataArraySelectionFilterParameter::getDefaultGeometryTypes() const +{ + return m_DefaultGeometryTypes; +} + +// ----------------------------------------------------------------------------- +void DataArraySelectionFilterParameter::setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value) +{ + m_DefaultAttributeMatrixTypes = value; +} + +// ----------------------------------------------------------------------------- +AttributeMatrix::Types DataArraySelectionFilterParameter::getDefaultAttributeMatrixTypes() const +{ + return m_DefaultAttributeMatrixTypes; +} + +// ----------------------------------------------------------------------------- +void DataArraySelectionFilterParameter::setDefaultAttributeArrayTypes(const std::vector& value) +{ + m_DefaultAttributeArrayTypes = value; +} + +// ----------------------------------------------------------------------------- +std::vector DataArraySelectionFilterParameter::getDefaultAttributeArrayTypes() const +{ + return m_DefaultAttributeArrayTypes; +} + +// ----------------------------------------------------------------------------- +void DataArraySelectionFilterParameter::setDefaultComponentDimensions(const std::vector>& value) +{ + m_DefaultComponentDimensions = value; +} + +// ----------------------------------------------------------------------------- +std::vector> DataArraySelectionFilterParameter::getDefaultComponentDimensions() const +{ + return m_DefaultComponentDimensions; +} + +// ----------------------------------------------------------------------------- +void DataArraySelectionFilterParameter::setSetterCallback(const DataArraySelectionFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DataArraySelectionFilterParameter::SetterCallbackType DataArraySelectionFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void DataArraySelectionFilterParameter::setGetterCallback(const DataArraySelectionFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DataArraySelectionFilterParameter::GetterCallbackType DataArraySelectionFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h old mode 100755 new mode 100644 index 208c144fc5..24dcd8d8b1 --- a/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/DataArraySelectionFilterParameter.h @@ -1,47 +1,52 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Geometry/IGeometry.h" +class AbstractFilter; + /** * @brief SIMPL_NEW_DA_SELECTION_FP This macro is a short-form way of instantiating an instance of * DataArraySelectionFilterParameter. There are 5 required parameters and 1 optional parameter @@ -53,12 +58,10 @@ * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): * DataArraySelectionFilterParameter::RequirementType req; - * SIMPL_NEW_DA_SELECTION_FP("Feature Ids", FeatureIdsArrayPath, FilterParameter::Parameter, GenericExample, req); + * SIMPL_NEW_DA_SELECTION_FP("Feature Ids", FeatureIdsArrayPath, FilterParameter::Category::Parameter, GenericExample, req); */ -#define SIMPL_NEW_DA_SELECTION_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (DataArraySelectionFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_DA_SELECTION_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(DataArraySelectionFilterParameter, __VA_ARGS__)) /** * @brief The DataArraySelectionFilterParameter class is used by filters to instantiate an DataArraySelectionWidget. By instantiating an instance of @@ -66,149 +69,233 @@ */ class SIMPLib_EXPORT DataArraySelectionFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(DataArraySelectionFilterParameter) - SIMPL_STATIC_NEW_MACRO(DataArraySelectionFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DataArraySelectionFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - typedef struct - { - IGeometry::Types dcGeometryTypes; - AttributeMatrix::Types amTypes; - QVector daTypes; - QVector< QVector > componentDimensions; - } RequirementType; - - /** - * @brief New This function instantiates an instance of the DataArraySelectionFilterParameter. Specifying a RequirementType will - * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. - * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the - * SIMPL_NEW_DA_SELECTION_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D - * user interface. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const DataArrayPath& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex = -1); - - ~DataArraySelectionFilterParameter() override; - - /** - * @brief CreateRequirement - * @param primitiveType - * @param allowedCompDim - * @param attributeMatrixCategory - * @return - */ - static RequirementType CreateCategoryRequirement(const QString& primitiveType, - size_t allowedCompDim, - AttributeMatrix::Category attributeMatrixCategory); - - /** - * @brief CreateRequirement - * @param primitiveType - * @param allowedCompDim - * @param attributeMatrixType - * @param geometryType - * @return - */ - static RequirementType CreateRequirement(const QString& primitiveType, - size_t allowedCompDim, - AttributeMatrix::Type attributeMatrixType, - IGeometry::Type geometryType); - - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @brief Returns the RequirementType for the filter parameter - * @return - */ - RequirementType getRequirements(); - - /** - * @param DefaultGeometryTypes Default geometry types required for Data Container selections - * @return - */ - SIMPL_INSTANCE_PROPERTY(IGeometry::Types, DefaultGeometryTypes) - - /** - * @param DefaultAttributeMatrixTypes Default attribute matrix types required for Attribute Matrix selections - * @return - */ - SIMPL_INSTANCE_PROPERTY(QVector, DefaultAttributeMatrixTypes) - - /** - * @param DefaultAttributeArrayTypes Default attribute array types required for Attribute Array selections - * @return - */ - SIMPL_INSTANCE_PROPERTY(QVector, DefaultAttributeArrayTypes) - - /** - * @param DefaultComponentDimensions Default component dimensions required for Attribute Array selections - * @return - */ - SIMPL_INSTANCE_PROPERTY(QVector< QVector >, DefaultComponentDimensions) - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief DataArraySelectionFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - DataArraySelectionFilterParameter(); - - public: - DataArraySelectionFilterParameter(const DataArraySelectionFilterParameter&) = delete; // Copy Constructor Not Implemented - DataArraySelectionFilterParameter(DataArraySelectionFilterParameter&&) = delete; // Move Constructor Not Implemented - DataArraySelectionFilterParameter& operator=(const DataArraySelectionFilterParameter&) = delete; // Copy Assignment Not Implemented - DataArraySelectionFilterParameter& operator=(DataArraySelectionFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(DataArraySelectionFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(DataArraySelectionFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_CUSTOM() + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = DataArraySelectionFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for DataArraySelectionFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for DataArraySelectionFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + struct RequirementType + { + IGeometry::Types dcGeometryTypes; + AttributeMatrix::Types amTypes; + std::vector daTypes; + std::vector> componentDimensions; + }; + + /** + * @brief New This function instantiates an instance of the DataArraySelectionFilterParameter. Specifying a RequirementType will + * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. + * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the + * SIMPL_NEW_DA_SELECTION_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D + * user interface. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, RequirementType req, int groupIndex = -1); + ~DataArraySelectionFilterParameter() override; + /** + * @brief CreateRequirement + * @param primitiveType + * @param allowedCompDim + * @param attributeMatrixCategory + * @return + */ + static RequirementType CreateCategoryRequirement(const QString& primitiveType, size_t allowedCompDim, AttributeMatrix::Category attributeMatrixCategory); + + /** + * @brief CreateRequirement + * @param primitiveType + * @param allowedCompDim + * @param attributeMatrixType + * @param geometryType + * @return + */ + static RequirementType CreateRequirement(const QString& primitiveType, size_t allowedCompDim, AttributeMatrix::Type attributeMatrixType, IGeometry::Type geometryType); + + /** + * @brief CreateRequirement + * @param primitiveTypes + * @param allowedCompDim + * @param attributeMatrixType + * @param geometryType + * @return + */ + static RequirementType CreateRequirement(const QVector& primitiveTypes, size_t allowedCompDim, AttributeMatrix::Type attributeMatrixType, IGeometry::Type geometryType); + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @brief Returns the RequirementType for the filter parameter + * @return + */ + RequirementType getRequirements(); + + /** + * @param DefaultGeometryTypes Default geometry types required for Data Container selections + * @return + */ + /** + * @brief Setter property for DefaultGeometryTypes + */ + void setDefaultGeometryTypes(const IGeometry::Types& value); + /** + * @brief Getter property for DefaultGeometryTypes + * @return Value of DefaultGeometryTypes + */ + IGeometry::Types getDefaultGeometryTypes() const; + + /** + * @param DefaultAttributeMatrixTypes Default attribute matrix types required for Attribute Matrix selections + * @return + */ + /** + * @brief Setter property for DefaultAttributeMatrixTypes + */ + void setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value); + /** + * @brief Getter property for DefaultAttributeMatrixTypes + * @return Value of DefaultAttributeMatrixTypes + */ + AttributeMatrix::Types getDefaultAttributeMatrixTypes() const; + + /** + * @param DefaultAttributeArrayTypes Default attribute array types required for Attribute Array selections + * @return + */ + /** + * @brief Setter property for DefaultAttributeArrayTypes + */ + void setDefaultAttributeArrayTypes(const std::vector& value); + /** + * @brief Getter property for DefaultAttributeArrayTypes + * @return Value of DefaultAttributeArrayTypes + */ + std::vector getDefaultAttributeArrayTypes() const; + + /** + * @param DefaultComponentDimensions Default component dimensions required for Attribute Array selections + * @return + */ + /** + * @brief Setter property for DefaultComponentDimensions + */ + void setDefaultComponentDimensions(const std::vector>& value); + /** + * @brief Getter property for DefaultComponentDimensions + * @return Value of DefaultComponentDimensions + */ + std::vector> getDefaultComponentDimensions() const; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const DataArraySelectionFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + DataArraySelectionFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const DataArraySelectionFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + DataArraySelectionFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handle DataArrayPath changes if necessary + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief DataArraySelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + DataArraySelectionFilterParameter(); + +public: + DataArraySelectionFilterParameter(const DataArraySelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + DataArraySelectionFilterParameter(DataArraySelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + DataArraySelectionFilterParameter& operator=(const DataArraySelectionFilterParameter&) = delete; // Copy Assignment Not Implemented + DataArraySelectionFilterParameter& operator=(DataArraySelectionFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + IGeometry::Types m_DefaultGeometryTypes = {}; + AttributeMatrix::Types m_DefaultAttributeMatrixTypes = {}; + std::vector m_DefaultAttributeArrayTypes = {}; + std::vector> m_DefaultComponentDimensions = {}; + DataArraySelectionFilterParameter::SetterCallbackType m_SetterCallback = {}; + DataArraySelectionFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.cpp index 90d1c98404..5d023a823d 100644 --- a/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DataContainerArrayProxyFilterParameter.h" @@ -53,9 +53,9 @@ DataContainerArrayProxyFilterParameter::~DataContainerArrayProxyFilterParameter( // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataContainerArrayProxyFilterParameter::Pointer DataContainerArrayProxyFilterParameter::New(const QString& humanLabel, const QString& propertyName, DataContainerArrayProxy defaultValue, - Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, - DataContainerArrayProxy proxy, Qt::CheckState defValue, int groupIndex) +DataContainerArrayProxyFilterParameter::Pointer DataContainerArrayProxyFilterParameter::Create(const QString& humanLabel, const QString& propertyName, DataContainerArrayProxy defaultValue, + Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + DataContainerArrayProxy proxy, Qt::CheckState defValue, int groupIndex) { DataContainerArrayProxyFilterParameter::Pointer ptr = DataContainerArrayProxyFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -87,6 +87,10 @@ QString DataContainerArrayProxyFilterParameter::getWidgetType() const void DataContainerArrayProxyFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonObject jsonObject = jsonValue.toObject(); @@ -99,9 +103,9 @@ void DataContainerArrayProxyFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerArrayProxyFilterParameter::writeJson(QJsonObject& json) +void DataContainerArrayProxyFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { DataContainerArrayProxy proxy = m_GetterCallback(); QJsonObject obj; @@ -113,12 +117,88 @@ void DataContainerArrayProxyFilterParameter::writeJson(QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerArrayProxyFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void DataContainerArrayProxyFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { QVariant var = filter->property(qPrintable(getPropertyName())); DataContainerArrayProxy dcaProxy = var.value(); dcaProxy.updatePath(renamePath); var.setValue(dcaProxy); - filter->setProperty(qPrintable(getPropertyName()), var); - emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + if(m_SetterCallback) + { + m_SetterCallback(dcaProxy); + } + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); +} + +// ----------------------------------------------------------------------------- +DataContainerArrayProxyFilterParameter::Pointer DataContainerArrayProxyFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +DataContainerArrayProxyFilterParameter::Pointer DataContainerArrayProxyFilterParameter::New() +{ + Pointer sharedPtr(new(DataContainerArrayProxyFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString DataContainerArrayProxyFilterParameter::getNameOfClass() const +{ + return QString("DataContainerArrayProxyFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString DataContainerArrayProxyFilterParameter::ClassName() +{ + return QString("DataContainerArrayProxyFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void DataContainerArrayProxyFilterParameter::setDataContainerArrayProxy(const DataContainerArrayProxy& value) +{ + m_DataContainerArrayProxy = value; +} + +// ----------------------------------------------------------------------------- +DataContainerArrayProxy DataContainerArrayProxyFilterParameter::getDataContainerArrayProxy() const +{ + return m_DataContainerArrayProxy; +} + +// ----------------------------------------------------------------------------- +void DataContainerArrayProxyFilterParameter::setDefaultFlagValue(const Qt::CheckState& value) +{ + m_DefaultFlagValue = value; +} + +// ----------------------------------------------------------------------------- +Qt::CheckState DataContainerArrayProxyFilterParameter::getDefaultFlagValue() const +{ + return m_DefaultFlagValue; +} + +// ----------------------------------------------------------------------------- +void DataContainerArrayProxyFilterParameter::setSetterCallback(const DataContainerArrayProxyFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DataContainerArrayProxyFilterParameter::SetterCallbackType DataContainerArrayProxyFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void DataContainerArrayProxyFilterParameter::setGetterCallback(const DataContainerArrayProxyFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DataContainerArrayProxyFilterParameter::GetterCallbackType DataContainerArrayProxyFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; } diff --git a/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.h b/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.h old mode 100755 new mode 100644 index 9203534486..21a979ba87 --- a/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/DataContainerArrayProxyFilterParameter.h @@ -1,44 +1,46 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" /** * @brief SIMPL_NEW_DCA_PROXY_FP This macro is a short-form way of instantiating an instance of @@ -51,12 +53,10 @@ * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): * DataContainerArrayProxy proxy; - * SIMPL_NEW_DCA_PROXY_FP("Array to Select", DcaProxy, FilterParameter::Parameter, GenericExample, proxy, Qt::Checked); + * SIMPL_NEW_DCA_PROXY_FP("Array to Select", DcaProxy, FilterParameter::Category::Parameter, GenericExample, proxy, Qt::Checked); */ -#define SIMPL_NEW_DCA_PROXY_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (DataContainerArrayProxyFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_DCA_PROXY_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(DataContainerArrayProxyFilterParameter, __VA_ARGS__)) /** * @brief The DataContainerArrayProxyFilterParameter class is used by filters to instantiate an DataContainerArrayProxyWidget. By instantiating an instance of @@ -64,91 +64,149 @@ */ class SIMPLib_EXPORT DataContainerArrayProxyFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(DataContainerArrayProxyFilterParameter) - SIMPL_STATIC_NEW_MACRO(DataContainerArrayProxyFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DataContainerArrayProxyFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the DataContainerArrayProxyFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DCA_PROXY_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param proxy - * @param defState Default check-state of the items in the DataContainerArrayProxyWidget. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - DataContainerArrayProxy defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, DataContainerArrayProxy proxy, - Qt::CheckState defState, int groupIndex = -1); - - ~DataContainerArrayProxyFilterParameter() override; - - SIMPL_INSTANCE_PROPERTY(DataContainerArrayProxy, DataContainerArrayProxy) - SIMPL_INSTANCE_PROPERTY(Qt::CheckState, DefaultFlagValue) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - /** - * @brief Handle DataArrayPath changes if necessary - */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; - - protected: - /** - * @brief DataContainerArrayProxyFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - DataContainerArrayProxyFilterParameter(); - - public: - DataContainerArrayProxyFilterParameter(const DataContainerArrayProxyFilterParameter&) = delete; // Copy Constructor Not Implemented - DataContainerArrayProxyFilterParameter(DataContainerArrayProxyFilterParameter&&) = delete; // Move Constructor Not Implemented - DataContainerArrayProxyFilterParameter& operator=(const DataContainerArrayProxyFilterParameter&) = delete; // Copy Assignment Not Implemented - DataContainerArrayProxyFilterParameter& operator=(DataContainerArrayProxyFilterParameter&&) = delete; // Move Assignment Not Implemented + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(DataContainerArrayProxyFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(DataContainerArrayProxyFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = DataContainerArrayProxyFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for DataContainerArrayProxyFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for DataContainerArrayProxyFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the DataContainerArrayProxyFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DCA_PROXY_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param proxy + * @param defState Default check-state of the items in the DataContainerArrayProxyWidget. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, DataContainerArrayProxy defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, DataContainerArrayProxy proxy, Qt::CheckState defState, int groupIndex = -1); + + ~DataContainerArrayProxyFilterParameter() override; + + /** + * @brief Setter property for DataContainerArrayProxy + */ + void setDataContainerArrayProxy(const DataContainerArrayProxy& value); + /** + * @brief Getter property for DataContainerArrayProxy + * @return Value of DataContainerArrayProxy + */ + DataContainerArrayProxy getDataContainerArrayProxy() const; + + /** + * @brief Setter property for DefaultFlagValue + */ + void setDefaultFlagValue(const Qt::CheckState& value); + /** + * @brief Getter property for DefaultFlagValue + * @return Value of DefaultFlagValue + */ + Qt::CheckState getDefaultFlagValue() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const DataContainerArrayProxyFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + DataContainerArrayProxyFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const DataContainerArrayProxyFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + DataContainerArrayProxyFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handle DataArrayPath changes if necessary + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief DataContainerArrayProxyFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + DataContainerArrayProxyFilterParameter(); + +public: + DataContainerArrayProxyFilterParameter(const DataContainerArrayProxyFilterParameter&) = delete; // Copy Constructor Not Implemented + DataContainerArrayProxyFilterParameter(DataContainerArrayProxyFilterParameter&&) = delete; // Move Constructor Not Implemented + DataContainerArrayProxyFilterParameter& operator=(const DataContainerArrayProxyFilterParameter&) = delete; // Copy Assignment Not Implemented + DataContainerArrayProxyFilterParameter& operator=(DataContainerArrayProxyFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + DataContainerArrayProxy m_DataContainerArrayProxy = {}; + Qt::CheckState m_DefaultFlagValue = {}; + DataContainerArrayProxyFilterParameter::SetterCallbackType m_SetterCallback = {}; + DataContainerArrayProxyFilterParameter::GetterCallbackType m_GetterCallback = {}; }; - diff --git a/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.cpp index aee34d78c5..1a9775c2be 100644 --- a/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.cpp @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DataContainerCreationFilterParameter.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -48,14 +50,16 @@ DataContainerCreationFilterParameter::~DataContainerCreationFilterParameter() = // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataContainerCreationFilterParameter::Pointer DataContainerCreationFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) +DataContainerCreationFilterParameter::Pointer DataContainerCreationFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { DataContainerCreationFilterParameter::Pointer ptr = DataContainerCreationFilterParameter::New(); ptr->setHumanLabel(humanLabel); ptr->setPropertyName(propertyName); - ptr->setDefaultValue(defaultValue); + QVariant v; + v.setValue(defaultValue); + ptr->setDefaultValue(v); ptr->setCategory(category); ptr->setGroupIndex(groupIndex); ptr->setSetterCallback(setterCallback); @@ -78,19 +82,102 @@ QString DataContainerCreationFilterParameter::getWidgetType() const void DataContainerCreationFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { - m_SetterCallback(jsonValue.toString("")); + QJsonObject obj = jsonValue.toObject(); + DataArrayPath dap; + if(dap.readJson(obj)) + { + m_SetterCallback(dap); + } + else // this is in here for historical where we used to save the value as a string + { + QString dcName = jsonValue.toString(""); + DataArrayPath dap(dcName, "", ""); + m_SetterCallback(dap); + } } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerCreationFilterParameter::writeJson(QJsonObject& json) +void DataContainerCreationFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { - json[getPropertyName()] = m_GetterCallback(); + DataArrayPath dap = m_GetterCallback(); + QJsonObject obj; + dap.writeJson(obj); + json[getPropertyName()] = obj; + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataContainerCreationFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + DataArrayPath oldPath; + DataArrayPath newPath; + std::tie(oldPath, newPath) = renamePath; + + if(oldPath == m_GetterCallback() && oldPath.getDataContainerName() != newPath.getDataContainerName()) + { + m_SetterCallback(newPath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); } } + +// ----------------------------------------------------------------------------- +DataContainerCreationFilterParameter::Pointer DataContainerCreationFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +DataContainerCreationFilterParameter::Pointer DataContainerCreationFilterParameter::New() +{ + Pointer sharedPtr(new(DataContainerCreationFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString DataContainerCreationFilterParameter::getNameOfClass() const +{ + return QString("DataContainerCreationFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString DataContainerCreationFilterParameter::ClassName() +{ + return QString("DataContainerCreationFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void DataContainerCreationFilterParameter::setSetterCallback(const DataContainerCreationFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DataContainerCreationFilterParameter::SetterCallbackType DataContainerCreationFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void DataContainerCreationFilterParameter::setGetterCallback(const DataContainerCreationFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DataContainerCreationFilterParameter::GetterCallbackType DataContainerCreationFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h b/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h old mode 100755 new mode 100644 index 0e36ec16e7..60006b6737 --- a/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/DataContainerCreationFilterParameter.h @@ -1,42 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include +#include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/FilterParameters/FilterParameter.h" /** @@ -49,12 +52,10 @@ * SIMPL_NEW_DC_CREATION_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): - * SIMPL_NEW_DC_CREATION_FP("Created Data Container", CreatedDataContainer, FilterParameter::CreatedArray, GenericExample); + * SIMPL_NEW_DC_CREATION_FP("Created Data Container", CreatedDataContainer, FilterParameter::Category::CreatedArray, GenericExample); */ -#define SIMPL_NEW_DC_CREATION_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (DataContainerCreationFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_DC_CREATION_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(DataContainerCreationFilterParameter, __VA_ARGS__)) /** * @brief The DataContainerCreationFilterParameter class is used by filters to instantiate an DataContainerCreationWidget. By instantiating an instance of @@ -62,80 +63,127 @@ */ class SIMPLib_EXPORT DataContainerCreationFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(DataContainerCreationFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(DataContainerCreationFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(DataContainerCreationFilterParameter) - SIMPL_STATIC_NEW_MACRO(DataContainerCreationFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DataContainerCreationFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the DataContainerCreationFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DC_CREATION_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); - - ~DataContainerCreationFilterParameter() override; + using Self = DataContainerCreationFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for DataContainerCreationFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for DataContainerCreationFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the DataContainerCreationFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DC_CREATION_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~DataContainerCreationFilterParameter() override; /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @return The SetterCallback - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief DataContainerCreationFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const DataContainerCreationFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + DataContainerCreationFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const DataContainerCreationFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + DataContainerCreationFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handles changes to the DataArrayPath + * @param filter + * @param renamePath + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief DataContainerCreationFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ DataContainerCreationFilterParameter(); public: - DataContainerCreationFilterParameter(const DataContainerCreationFilterParameter&) = delete; // Copy Constructor Not Implemented - DataContainerCreationFilterParameter(DataContainerCreationFilterParameter&&) = delete; // Move Constructor Not Implemented + DataContainerCreationFilterParameter(const DataContainerCreationFilterParameter&) = delete; // Copy Constructor Not Implemented + DataContainerCreationFilterParameter(DataContainerCreationFilterParameter&&) = delete; // Move Constructor Not Implemented DataContainerCreationFilterParameter& operator=(const DataContainerCreationFilterParameter&) = delete; // Copy Assignment Not Implemented DataContainerCreationFilterParameter& operator=(DataContainerCreationFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +private: + DataContainerCreationFilterParameter::SetterCallbackType m_SetterCallback = {}; + DataContainerCreationFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/DataContainerGridSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DataContainerGridSelectionFilterParameter.cpp new file mode 100644 index 0000000000..a5b5621fa1 --- /dev/null +++ b/Source/SIMPLib/FilterParameters/DataContainerGridSelectionFilterParameter.cpp @@ -0,0 +1,215 @@ +/* ============================================================================ + * Copyright (c) 2019-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "DataContainerGridSelectionFilterParameter.h" + +#include "SIMPLib/Filtering/AbstractFilter.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainerGridSelectionFilterParameter::DataContainerGridSelectionFilterParameter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainerGridSelectionFilterParameter::~DataContainerGridSelectionFilterParameter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainerGridSelectionFilterParameter::Pointer DataContainerGridSelectionFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const DataContainerGrid& defaultValue, + Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, + int groupIndex) +{ + DataContainerGridSelectionFilterParameter::Pointer ptr = DataContainerGridSelectionFilterParameter::New(); + ptr->setHumanLabel(humanLabel); + ptr->setPropertyName(propertyName); + QVariant v; + v.setValue(defaultValue); + ptr->setDefaultValue(v); + ptr->setCategory(category); + ptr->setGroupIndex(groupIndex); + ptr->setSetterCallback(setterCallback); + ptr->setGetterCallback(getterCallback); + + return ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString DataContainerGridSelectionFilterParameter::getWidgetType() const +{ + return QString("DataContainerGridSelectionWidget"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataContainerGridSelectionFilterParameter::readJson(const QJsonObject& json) +{ + QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } + if(!jsonValue.isUndefined() && m_SetterCallback) + { + QJsonObject obj = jsonValue.toObject(); + DataArrayPath dap; + if(dap.readJson(obj)) + { + // m_SetterCallback(dap); + } + else // this is in here for historical where we used to save the value as a string + { + QString dcName = jsonValue.toString(""); + DataArrayPath dap(dcName, "", ""); + // m_SetterCallback(dap); + } + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataContainerGridSelectionFilterParameter::writeJson(QJsonObject& json) const +{ + if(m_GetterCallback) + { + /* + DataArrayPath dap = m_GetterCallback(); + QJsonObject obj; + dap.writeJson(obj); + json[getPropertyName()] = obj; + */ + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataContainerGridSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + DataArrayPath oldPath; + DataArrayPath newPath; + std::tie(oldPath, newPath) = renamePath; + + /* + if(oldPath == m_GetterCallback() && oldPath.getDataContainerName() != newPath.getDataContainerName()) + { + m_SetterCallback(newPath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); + } + */ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainerGridSelectionFilterParameter::Pointer DataContainerGridSelectionFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainerGridSelectionFilterParameter::Pointer DataContainerGridSelectionFilterParameter::New() +{ + return Pointer(new DataContainerGridSelectionFilterParameter()); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString DataContainerGridSelectionFilterParameter::getNameOfClass() const +{ + return "DataContainerGridSelectionFilterParameter"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString DataContainerGridSelectionFilterParameter::ClassName() +{ + return "DataContainerGridSelectionFilterParameter"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IGeometry::Types DataContainerGridSelectionFilterParameter::getDefaultGeometryTypes() const +{ + return m_DefaultGeometryTypes; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataContainerGridSelectionFilterParameter::setDefaultGeometryTypes(IGeometry::Types value) +{ + m_DefaultGeometryTypes = value; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainerGridSelectionFilterParameter::SetterCallbackType DataContainerGridSelectionFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataContainerGridSelectionFilterParameter::setSetterCallback(const SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainerGridSelectionFilterParameter::GetterCallbackType DataContainerGridSelectionFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void DataContainerGridSelectionFilterParameter::setGetterCallback(const GetterCallbackType& value) +{ + m_GetterCallback = value; +} diff --git a/Source/SIMPLib/FilterParameters/DataContainerGridSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/DataContainerGridSelectionFilterParameter.h new file mode 100644 index 0000000000..e8ab37e4c6 --- /dev/null +++ b/Source/SIMPLib/FilterParameters/DataContainerGridSelectionFilterParameter.h @@ -0,0 +1,193 @@ +/* ============================================================================ + * Copyright (c) 2019-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include + +#include + +#include "SIMPLib/Common/SIMPLArray.hpp" +#include "SIMPLib/FilterParameters/FilterParameter.h" +#include "SIMPLib/Geometry/IGeometry.h" +#include "SIMPLib/Montages/DataContainerGrid.h" + +/** + * @brief SIMPL_NEW_DC_GRID_SELECTION_FP This macro is a short-form way of instantiating an instance of + * DataContainerGridSelectionFilterParameter. There are 5 required parameters and 1 optional parameter + * that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, + * FilterName (class name), RequirementType, GroupIndex (optional). + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_DC_GRID_SELECTION_FP("HumanLabel", PropertyName, Category, FilterName, RequirementType, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): + * DataContainerGridSelectionFilterParameter::RequirementType req; + * SIMPL_NEW_DC_GRID_SELECTION_FP("Data Container", DataContainerName, FilterParameter::Category::Parameter, GenericExample, req, 2); + */ +#define SIMPL_NEW_DC_GRID_SELECTION_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(DataContainerGridSelectionFilterParameter, __VA_ARGS__)) + +/** + * @brief The DataContainerGridSelectionFilterParameter class is used by filters to instantiate an DataContainerSelectionWidget. By instantiating an instance of + * this class in a filter's setupFilterParameters() method, a DataContainerSelectionWidget will appear in the filter's "filter input" section in the DREAM3D GUI. + */ +class SIMPLib_EXPORT DataContainerGridSelectionFilterParameter : public FilterParameter +{ + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(DataContainerGridSelectionFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(DataContainerGridSelectionFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = DataContainerGridSelectionFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for StatsDataArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for StatsDataArray + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the DataContainerGridSelectionFilterParameter. Specifying a RequirementType will + * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. + * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the + * SIMPL_NEW_DC_GRID_SELECTION_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D + * user interface. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const DataContainerGrid& defaultValue, Category category, SetterCallbackType setterCallback, + GetterCallbackType getterCallback, int groupIndex = -1); + + ~DataContainerGridSelectionFilterParameter() override; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @brief Getter property for DefaultGeometryTypes + * @return + */ + IGeometry::Types getDefaultGeometryTypes() const; + + /** + * @brief Setter property for DefaultGeometryTypes + * @param value + */ + void setDefaultGeometryTypes(IGeometry::Types value); + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + SetterCallbackType getSetterCallback() const; + void setSetterCallback(const SetterCallbackType& value); + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + GetterCallbackType getGetterCallback() const; + void setGetterCallback(const GetterCallbackType& value); + + /** + * @brief Handles changes to the DataArrayPath + * @param filter + * @param renamePath + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief DataContainerGridSelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + DataContainerGridSelectionFilterParameter(); + +private: + IGeometry::Types m_DefaultGeometryTypes; + SetterCallbackType m_SetterCallback; + GetterCallbackType m_GetterCallback; + +public: + DataContainerGridSelectionFilterParameter(const DataContainerGridSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + DataContainerGridSelectionFilterParameter(DataContainerGridSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + DataContainerGridSelectionFilterParameter& operator=(const DataContainerGridSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented + DataContainerGridSelectionFilterParameter& operator=(DataContainerGridSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/FilterParameters/DataContainerReaderFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DataContainerReaderFilterParameter.cpp index ec29609a5e..de213b43c2 100644 --- a/Source/SIMPLib/FilterParameters/DataContainerReaderFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DataContainerReaderFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DataContainerReaderFilterParameter.h" @@ -53,8 +53,8 @@ DataContainerReaderFilterParameter::~DataContainerReaderFilterParameter() = defa // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataContainerReaderFilterParameter::Pointer DataContainerReaderFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - DataContainerReader* filter, int groupIndex) +DataContainerReaderFilterParameter::Pointer DataContainerReaderFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, + DataContainerReader* filter, int groupIndex) { DataContainerReaderFilterParameter::Pointer ptr = DataContainerReaderFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -83,6 +83,10 @@ QString DataContainerReaderFilterParameter::getWidgetType() const void DataContainerReaderFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined()) { QJsonObject jsonObject = jsonValue.toObject(); @@ -97,7 +101,7 @@ void DataContainerReaderFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // THIS IS A SPECIAL CASE AND IS NOT STANDARD. DO NOT COPY THIS CODE. // ----------------------------------------------------------------------------- -void DataContainerReaderFilterParameter::writeJson(QJsonObject& json) +void DataContainerReaderFilterParameter::writeJson(QJsonObject& json) const { DataContainerArrayProxy proxy = m_Filter->getInputFileDataContainerArrayProxy(); QJsonObject obj; @@ -105,3 +109,88 @@ void DataContainerReaderFilterParameter::writeJson(QJsonObject& json) json[getPropertyName()] = obj; json["InputFile"] = m_Filter->getInputFile(); } + +// ----------------------------------------------------------------------------- +DataContainerReaderFilterParameter::Pointer DataContainerReaderFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +DataContainerReaderFilterParameter::Pointer DataContainerReaderFilterParameter::New() +{ + Pointer sharedPtr(new(DataContainerReaderFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString DataContainerReaderFilterParameter::getNameOfClass() const +{ + return QString("DataContainerReaderFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString DataContainerReaderFilterParameter::ClassName() +{ + return QString("DataContainerReaderFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void DataContainerReaderFilterParameter::setDefaultFlagValue(const Qt::CheckState& value) +{ + m_DefaultFlagValue = value; +} + +// ----------------------------------------------------------------------------- +Qt::CheckState DataContainerReaderFilterParameter::getDefaultFlagValue() const +{ + return m_DefaultFlagValue; +} + +// ----------------------------------------------------------------------------- +void DataContainerReaderFilterParameter::setInputFileProperty(const QString& value) +{ + m_InputFileProperty = value; +} + +// ----------------------------------------------------------------------------- +QString DataContainerReaderFilterParameter::getInputFileProperty() const +{ + return m_InputFileProperty; +} + +// ----------------------------------------------------------------------------- +void DataContainerReaderFilterParameter::setFileExtension(const QString& value) +{ + m_FileExtension = value; +} + +// ----------------------------------------------------------------------------- +QString DataContainerReaderFilterParameter::getFileExtension() const +{ + return m_FileExtension; +} + +// ----------------------------------------------------------------------------- +void DataContainerReaderFilterParameter::setFileType(const QString& value) +{ + m_FileType = value; +} + +// ----------------------------------------------------------------------------- +QString DataContainerReaderFilterParameter::getFileType() const +{ + return m_FileType; +} + +// ----------------------------------------------------------------------------- +void DataContainerReaderFilterParameter::setFilter(DataContainerReader* value) +{ + m_Filter = value; +} + +// ----------------------------------------------------------------------------- +DataContainerReader* DataContainerReaderFilterParameter::getFilter() const +{ + return m_Filter; +} diff --git a/Source/SIMPLib/FilterParameters/DataContainerReaderFilterParameter.h b/Source/SIMPLib/FilterParameters/DataContainerReaderFilterParameter.h old mode 100755 new mode 100644 index 2a12544e94..fe6bbe86b4 --- a/Source/SIMPLib/FilterParameters/DataContainerReaderFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/DataContainerReaderFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/CoreFilters/DataContainerReader.h" @@ -47,64 +49,135 @@ */ class SIMPLib_EXPORT DataContainerReaderFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(DataContainerReaderFilterParameter) - SIMPL_STATIC_NEW_MACRO(DataContainerReaderFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DataContainerReaderFilterParameter, FilterParameter) - - /** - * @brief New This function instantiates an instance of the DataContainerCreationFilterParameter. - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param filter The corresponding filter that sets all its values into the DataContainerReaderWidget. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, DataContainerReader* filter, - int groupIndex = -1); - - ~DataContainerReaderFilterParameter() override; - - SIMPL_INSTANCE_PROPERTY(Qt::CheckState, DefaultFlagValue) - SIMPL_INSTANCE_PROPERTY(QString, InputFileProperty) - SIMPL_INSTANCE_PROPERTY(QString, FileExtension) - SIMPL_INSTANCE_PROPERTY(QString, FileType) - SIMPL_POINTER_PROPERTY(DataContainerReader, Filter) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - protected: - /** - * @brief DataContainerReaderFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - DataContainerReaderFilterParameter(); - - public: - DataContainerReaderFilterParameter(const DataContainerReaderFilterParameter&) = delete; // Copy Constructor Not Implemented - DataContainerReaderFilterParameter(DataContainerReaderFilterParameter&&) = delete; // Move Constructor Not Implemented - DataContainerReaderFilterParameter& operator=(const DataContainerReaderFilterParameter&) = delete; // Copy Assignment Not Implemented - DataContainerReaderFilterParameter& operator=(DataContainerReaderFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(DataContainerReaderFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(DataContainerReaderFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = DataContainerReaderFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for DataContainerReaderFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for DataContainerReaderFilterParameter + */ + static QString ClassName(); + + /** + * @brief New This function instantiates an instance of the DataContainerCreationFilterParameter. + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param filter The corresponding filter that sets all its values into the DataContainerReaderWidget. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, DataContainerReader* filter, int groupIndex = -1); + + ~DataContainerReaderFilterParameter() override; + + /** + * @brief Setter property for DefaultFlagValue + */ + void setDefaultFlagValue(const Qt::CheckState& value); + /** + * @brief Getter property for DefaultFlagValue + * @return Value of DefaultFlagValue + */ + Qt::CheckState getDefaultFlagValue() const; + + /** + * @brief Setter property for InputFileProperty + */ + void setInputFileProperty(const QString& value); + /** + * @brief Getter property for InputFileProperty + * @return Value of InputFileProperty + */ + QString getInputFileProperty() const; + + /** + * @brief Setter property for FileExtension + */ + void setFileExtension(const QString& value); + /** + * @brief Getter property for FileExtension + * @return Value of FileExtension + */ + QString getFileExtension() const; + /** + * @brief Setter property for FileType + */ + void setFileType(const QString& value); + /** + * @brief Getter property for FileType + * @return Value of FileType + */ + QString getFileType() const; + + /** + * @brief Setter property for Filter + */ + void setFilter(DataContainerReader* value); + /** + * @brief Getter property for Filter + * @return Value of Filter + */ + DataContainerReader* getFilter() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + +protected: + /** + * @brief DataContainerReaderFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + DataContainerReaderFilterParameter(); + +public: + DataContainerReaderFilterParameter(const DataContainerReaderFilterParameter&) = delete; // Copy Constructor Not Implemented + DataContainerReaderFilterParameter(DataContainerReaderFilterParameter&&) = delete; // Move Constructor Not Implemented + DataContainerReaderFilterParameter& operator=(const DataContainerReaderFilterParameter&) = delete; // Copy Assignment Not Implemented + DataContainerReaderFilterParameter& operator=(DataContainerReaderFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + DataContainerReader* m_Filter = nullptr; + + Qt::CheckState m_DefaultFlagValue = {}; + QString m_InputFileProperty = {}; + QString m_FileExtension = {}; + QString m_FileType = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.cpp index 0230d9b5b9..4891c1b82a 100644 --- a/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DataContainerSelectionFilterParameter.h" @@ -50,9 +50,9 @@ DataContainerSelectionFilterParameter::~DataContainerSelectionFilterParameter() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DataContainerSelectionFilterParameter::Pointer DataContainerSelectionFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, const RequirementType req, - int groupIndex) +DataContainerSelectionFilterParameter::Pointer DataContainerSelectionFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, + Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + const RequirementType& req, int groupIndex) { DataContainerSelectionFilterParameter::Pointer ptr = DataContainerSelectionFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -83,36 +83,54 @@ QString DataContainerSelectionFilterParameter::getWidgetType() const void DataContainerSelectionFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { - m_SetterCallback(jsonValue.toString("")); + QJsonObject obj = jsonValue.toObject(); + DataArrayPath dap; + if(dap.readJson(obj)) + { + m_SetterCallback(dap); + } + else // this is in here for historical where we used to save the value as a string + { + QString dcName = jsonValue.toString(""); + DataArrayPath dap(dcName, "", ""); + m_SetterCallback(dap); + } } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerSelectionFilterParameter::writeJson(QJsonObject& json) +void DataContainerSelectionFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { - json[getPropertyName()] = m_GetterCallback(); + DataArrayPath dap = m_GetterCallback(); + QJsonObject obj; + dap.writeJson(obj); + json[getPropertyName()] = obj; } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DataContainerSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void DataContainerSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; std::tie(oldPath, newPath) = renamePath; - if(oldPath.getDataContainerName() == m_GetterCallback() && oldPath.getDataContainerName() != newPath.getDataContainerName()) + if(oldPath == m_GetterCallback() && oldPath.getDataContainerName() != newPath.getDataContainerName()) { - m_SetterCallback(newPath.getDataContainerName()); - emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + m_SetterCallback(newPath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); } } @@ -126,3 +144,64 @@ DataContainerSelectionFilterParameter::RequirementType DataContainerSelectionFil return reqs; } + +// ----------------------------------------------------------------------------- +DataContainerSelectionFilterParameter::Pointer DataContainerSelectionFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +DataContainerSelectionFilterParameter::Pointer DataContainerSelectionFilterParameter::New() +{ + Pointer sharedPtr(new(DataContainerSelectionFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString DataContainerSelectionFilterParameter::getNameOfClass() const +{ + return QString("DataContainerSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString DataContainerSelectionFilterParameter::ClassName() +{ + return QString("DataContainerSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void DataContainerSelectionFilterParameter::setDefaultGeometryTypes(const IGeometry::Types& value) +{ + m_DefaultGeometryTypes = value; +} + +// ----------------------------------------------------------------------------- +IGeometry::Types DataContainerSelectionFilterParameter::getDefaultGeometryTypes() const +{ + return m_DefaultGeometryTypes; +} + +// ----------------------------------------------------------------------------- +void DataContainerSelectionFilterParameter::setSetterCallback(const DataContainerSelectionFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DataContainerSelectionFilterParameter::SetterCallbackType DataContainerSelectionFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void DataContainerSelectionFilterParameter::setGetterCallback(const DataContainerSelectionFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DataContainerSelectionFilterParameter::GetterCallbackType DataContainerSelectionFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h old mode 100755 new mode 100644 index 37310785cf..84509b40a5 --- a/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/DataContainerSelectionFilterParameter.h @@ -1,42 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include +#include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Geometry/IGeometry.h" @@ -51,12 +54,10 @@ * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): * DataContainerSelectionFilterParameter::RequirementType req; - * SIMPL_NEW_DC_SELECTION_FP("Data Container", DataContainerName, FilterParameter::Parameter, GenericExample, req, 2); + * SIMPL_NEW_DC_SELECTION_FP("Data Container", DataContainerName, FilterParameter::Category::Parameter, GenericExample, req, 2); */ -#define SIMPL_NEW_DC_SELECTION_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (DataContainerSelectionFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_DC_SELECTION_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(DataContainerSelectionFilterParameter, __VA_ARGS__)) /** * @brief The DataContainerSelectionFilterParameter class is used by filters to instantiate an DataContainerSelectionWidget. By instantiating an instance of @@ -64,105 +65,154 @@ */ class SIMPLib_EXPORT DataContainerSelectionFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(DataContainerSelectionFilterParameter) - SIMPL_STATIC_NEW_MACRO(DataContainerSelectionFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DataContainerSelectionFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - typedef struct - { - IGeometry::Types dcGeometryTypes; - } RequirementType; - - /** - * @brief New This function instantiates an instance of the DataContainerSelectionFilterParameter. Specifying a RequirementType will - * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. - * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the - * SIMPL_NEW_DC_SELECTION_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D - * user interface. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex = -1); - - ~DataContainerSelectionFilterParameter() override; - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @brief Returns the RequirementType for the filter parameter - * @return - */ - RequirementType getRequirements(); - - SIMPL_INSTANCE_PROPERTY(IGeometry::Types, DefaultGeometryTypes) - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - /** - * @brief Handles changes to the DataArrayPath - * @param filter - * @param renamePath - */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; - - protected: - /** - * @brief DataContainerSelectionFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - DataContainerSelectionFilterParameter(); - - public: - DataContainerSelectionFilterParameter(const DataContainerSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented - DataContainerSelectionFilterParameter(DataContainerSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented - DataContainerSelectionFilterParameter& operator=(const DataContainerSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented - DataContainerSelectionFilterParameter& operator=(DataContainerSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(DataContainerSelectionFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(DataContainerSelectionFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_CUSTOM() + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = DataContainerSelectionFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for DataContainerSelectionFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for DataContainerSelectionFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + struct RequirementType + { + IGeometry::Types dcGeometryTypes; + }; + + /** + * @brief New This function instantiates an instance of the DataContainerSelectionFilterParameter. Specifying a RequirementType will + * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. + * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the + * SIMPL_NEW_DC_SELECTION_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D + * user interface. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const RequirementType& req, int groupIndex = -1); + + ~DataContainerSelectionFilterParameter() override; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @brief Returns the RequirementType for the filter parameter + * @return + */ + RequirementType getRequirements(); + + /** + * @brief Setter property for DefaultGeometryTypes + */ + void setDefaultGeometryTypes(const IGeometry::Types& value); + /** + * @brief Getter property for DefaultGeometryTypes + * @return Value of DefaultGeometryTypes + */ + IGeometry::Types getDefaultGeometryTypes() const; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const DataContainerSelectionFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + DataContainerSelectionFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const DataContainerSelectionFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + DataContainerSelectionFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handles changes to the DataArrayPath + * @param filter + * @param renamePath + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief DataContainerSelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + DataContainerSelectionFilterParameter(); + +public: + DataContainerSelectionFilterParameter(const DataContainerSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + DataContainerSelectionFilterParameter(DataContainerSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + DataContainerSelectionFilterParameter& operator=(const DataContainerSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented + DataContainerSelectionFilterParameter& operator=(DataContainerSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + IGeometry::Types m_DefaultGeometryTypes = {}; + DataContainerSelectionFilterParameter::SetterCallbackType m_SetterCallback = {}; + DataContainerSelectionFilterParameter::GetterCallbackType m_GetterCallback = {}; }; - diff --git a/Source/SIMPLib/FilterParameters/DoubleFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DoubleFilterParameter.cpp index b7299d8833..0d04e707bd 100644 --- a/Source/SIMPLib/FilterParameters/DoubleFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DoubleFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DoubleFilterParameter.h" @@ -48,9 +48,8 @@ DoubleFilterParameter::~DoubleFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DoubleFilterParameter::Pointer DoubleFilterParameter::New(const QString& humanLabel, const QString& propertyName, - const double& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex) +DoubleFilterParameter::Pointer DoubleFilterParameter::Create(const QString& humanLabel, const QString& propertyName, double defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex) { DoubleFilterParameter::Pointer ptr = DoubleFilterParameter::New(); @@ -65,28 +64,6 @@ DoubleFilterParameter::Pointer DoubleFilterParameter::New(const QString& humanLa return ptr; } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -DoubleFilterParameter::Pointer DoubleFilterParameter::New(const QString& humanLabel, const QString& propertyName, - const float& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex) -{ - - DoubleFilterParameter::Pointer ptr = DoubleFilterParameter::New(); - ptr->setHumanLabel(humanLabel); - ptr->setPropertyName(propertyName); - ptr->setDefaultValue(defaultValue); - ptr->setCategory(category); - ptr->setGroupIndex(groupIndex); - ptr->setSetterCallback(setterCallback); - ptr->setGetterCallback(getterCallback); - - return ptr; -} - - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -101,6 +78,10 @@ QString DoubleFilterParameter::getWidgetType() const void DoubleFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { m_SetterCallback(jsonValue.toDouble()); @@ -110,10 +91,59 @@ void DoubleFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DoubleFilterParameter::writeJson(QJsonObject& json) +void DoubleFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { json[getPropertyName()] = m_GetterCallback(); } } + +// ----------------------------------------------------------------------------- +DoubleFilterParameter::Pointer DoubleFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +DoubleFilterParameter::Pointer DoubleFilterParameter::New() +{ + Pointer sharedPtr(new(DoubleFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString DoubleFilterParameter::getNameOfClass() const +{ + return QString("DoubleFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString DoubleFilterParameter::ClassName() +{ + return QString("DoubleFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void DoubleFilterParameter::setSetterCallback(const DoubleFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DoubleFilterParameter::SetterCallbackType DoubleFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void DoubleFilterParameter::setGetterCallback(const DoubleFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DoubleFilterParameter::GetterCallbackType DoubleFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/DoubleFilterParameter.h b/Source/SIMPLib/FilterParameters/DoubleFilterParameter.h old mode 100755 new mode 100644 index f7690b77d2..31207dc36d --- a/Source/SIMPLib/FilterParameters/DoubleFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/DoubleFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" @@ -49,13 +51,10 @@ * SIMPL_NEW_DOUBLE_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): - * SIMPL_NEW_DOUBLE_FP("Double 2", Double2, FilterParameter::Parameter, GenericExample); + * SIMPL_NEW_DOUBLE_FP("Double 2", Double2, FilterParameter::Category::Parameter, GenericExample); */ -#define SIMPL_NEW_DOUBLE_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (DoubleFilterParameter, __VA_ARGS__)) - +#define SIMPL_NEW_DOUBLE_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(DoubleFilterParameter, __VA_ARGS__)) /** * @brief The DoubleFilterParameter class is used by filters to instantiate an DoubleWidget. By instantiating an instance of @@ -63,101 +62,120 @@ */ class SIMPLib_EXPORT DoubleFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(DoubleFilterParameter) - SIMPL_STATIC_NEW_MACRO(DoubleFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DoubleFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the DoubleFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DOUBLE_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const double& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); - - /** - * @brief New This function instantiates an instance of the DoubleFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DOUBLE_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const float& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); - - ~DoubleFilterParameter() override; - - /** + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(DoubleFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(DoubleFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = DoubleFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for DoubleFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for DoubleFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the DoubleFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DOUBLE_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, double defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~DoubleFilterParameter() override; + + /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief DoubleFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - DoubleFilterParameter(); - - public: - DoubleFilterParameter(const DoubleFilterParameter&) = delete; // Copy Constructor Not Implemented - DoubleFilterParameter(DoubleFilterParameter&&) = delete; // Move Constructor Not Implemented - DoubleFilterParameter& operator=(const DoubleFilterParameter&) = delete; // Copy Assignment Not Implemented - DoubleFilterParameter& operator=(DoubleFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + QString getWidgetType() const override; + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const DoubleFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + DoubleFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const DoubleFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + DoubleFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief DoubleFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + DoubleFilterParameter(); + +public: + DoubleFilterParameter(const DoubleFilterParameter&) = delete; // Copy Constructor Not Implemented + DoubleFilterParameter(DoubleFilterParameter&&) = delete; // Move Constructor Not Implemented + DoubleFilterParameter& operator=(const DoubleFilterParameter&) = delete; // Copy Assignment Not Implemented + DoubleFilterParameter& operator=(DoubleFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + DoubleFilterParameter::SetterCallbackType m_SetterCallback = {}; + DoubleFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/DynamicChoiceFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DynamicChoiceFilterParameter.cpp index f627851c5e..ef4e0ba3d1 100644 --- a/Source/SIMPLib/FilterParameters/DynamicChoiceFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DynamicChoiceFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DynamicChoiceFilterParameter.h" @@ -48,8 +48,9 @@ DynamicChoiceFilterParameter::~DynamicChoiceFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DynamicChoiceFilterParameter::Pointer DynamicChoiceFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, const QString& listProperty, int groupIndex) +DynamicChoiceFilterParameter::Pointer DynamicChoiceFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, const QString& listProperty, + int groupIndex) { DynamicChoiceFilterParameter::Pointer ptr = DynamicChoiceFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -77,6 +78,10 @@ QString DynamicChoiceFilterParameter::getWidgetType() const void DynamicChoiceFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { m_SetterCallback(jsonValue.toString("")); @@ -86,10 +91,83 @@ void DynamicChoiceFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DynamicChoiceFilterParameter::writeJson(QJsonObject& json) +void DynamicChoiceFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { json[getPropertyName()] = m_GetterCallback(); } } + +// ----------------------------------------------------------------------------- +DynamicChoiceFilterParameter::Pointer DynamicChoiceFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +DynamicChoiceFilterParameter::Pointer DynamicChoiceFilterParameter::New() +{ + Pointer sharedPtr(new(DynamicChoiceFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString DynamicChoiceFilterParameter::getNameOfClass() const +{ + return QString("DynamicChoiceFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString DynamicChoiceFilterParameter::ClassName() +{ + return QString("DynamicChoiceFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void DynamicChoiceFilterParameter::setListProperty(const QString& value) +{ + m_ListProperty = value; +} + +// ----------------------------------------------------------------------------- +QString DynamicChoiceFilterParameter::getListProperty() const +{ + return m_ListProperty; +} + +// ----------------------------------------------------------------------------- +void DynamicChoiceFilterParameter::setUnits(const QString& value) +{ + m_Units = value; +} + +// ----------------------------------------------------------------------------- +QString DynamicChoiceFilterParameter::getUnits() const +{ + return m_Units; +} + +// ----------------------------------------------------------------------------- +void DynamicChoiceFilterParameter::setSetterCallback(const DynamicChoiceFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DynamicChoiceFilterParameter::SetterCallbackType DynamicChoiceFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void DynamicChoiceFilterParameter::setGetterCallback(const DynamicChoiceFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DynamicChoiceFilterParameter::GetterCallbackType DynamicChoiceFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/DynamicChoiceFilterParameter.h b/Source/SIMPLib/FilterParameters/DynamicChoiceFilterParameter.h old mode 100755 new mode 100644 index dfc8d7ec85..c7665d509b --- a/Source/SIMPLib/FilterParameters/DynamicChoiceFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/DynamicChoiceFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" @@ -49,12 +51,10 @@ * SIMPL_NEW_DYN_CHOICE_FP("HumanLabel", PropertyName, Category, FilterName, ListProperty, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): - * SIMPL_NEW_DYN_CHOICE_FP("X Coordinate Array", SelectedXCoordArrayName, FilterParameter::CreatedArray, GenericExample, "DataArrayList"); + * SIMPL_NEW_DYN_CHOICE_FP("X Coordinate Array", SelectedXCoordArrayName, FilterParameter::Category::CreatedArray, GenericExample, "DataArrayList"); */ -#define SIMPL_NEW_DYN_CHOICE_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (DynamicChoiceFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_DYN_CHOICE_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(DynamicChoiceFilterParameter, __VA_ARGS__)) /** * @brief The DynamicChoiceFilterParameter class is used by filters to instantiate an DynamicChoiceWidget. By instantiating an instance of @@ -62,87 +62,143 @@ */ class SIMPLib_EXPORT DynamicChoiceFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(DynamicChoiceFilterParameter) - SIMPL_STATIC_NEW_MACRO(DynamicChoiceFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DynamicChoiceFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the DynamicChoiceFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DYN_CHOICE_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param listProperty The name of the property that stores the selections to choose from in the DynamicChoiceWidget - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const QString& listProperty, int groupIndex = -1); - - ~DynamicChoiceFilterParameter() override; - - - SIMPL_INSTANCE_STRING_PROPERTY(ListProperty) - SIMPL_INSTANCE_STRING_PROPERTY(Units) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief DynamicChoiceFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - DynamicChoiceFilterParameter(); - - public: - DynamicChoiceFilterParameter(const DynamicChoiceFilterParameter&) = delete; // Copy Constructor Not Implemented - DynamicChoiceFilterParameter(DynamicChoiceFilterParameter&&) = delete; // Move Constructor Not Implemented - DynamicChoiceFilterParameter& operator=(const DynamicChoiceFilterParameter&) = delete; // Copy Assignment Not Implemented - DynamicChoiceFilterParameter& operator=(DynamicChoiceFilterParameter&&) = delete; // Move Assignment Not Implemented + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(DynamicChoiceFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(DynamicChoiceFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = DynamicChoiceFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for DynamicChoiceFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for DynamicChoiceFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the DynamicChoiceFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DYN_CHOICE_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param listProperty The name of the property that stores the selections to choose from in the DynamicChoiceWidget + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const QString& listProperty, int groupIndex = -1); + + ~DynamicChoiceFilterParameter() override; + + /** + * @brief Setter property for ListProperty + */ + void setListProperty(const QString& value); + /** + * @brief Getter property for ListProperty + * @return Value of ListProperty + */ + QString getListProperty() const; + + /** + * @brief Setter property for Units + */ + void setUnits(const QString& value); + /** + * @brief Getter property for Units + * @return Value of Units + */ + QString getUnits() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const DynamicChoiceFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + DynamicChoiceFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const DynamicChoiceFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + DynamicChoiceFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief DynamicChoiceFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + DynamicChoiceFilterParameter(); + +public: + DynamicChoiceFilterParameter(const DynamicChoiceFilterParameter&) = delete; // Copy Constructor Not Implemented + DynamicChoiceFilterParameter(DynamicChoiceFilterParameter&&) = delete; // Move Constructor Not Implemented + DynamicChoiceFilterParameter& operator=(const DynamicChoiceFilterParameter&) = delete; // Copy Assignment Not Implemented + DynamicChoiceFilterParameter& operator=(DynamicChoiceFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + QString m_ListProperty = {}; + QString m_Units = {}; + DynamicChoiceFilterParameter::SetterCallbackType m_SetterCallback = {}; + DynamicChoiceFilterParameter::GetterCallbackType m_GetterCallback = {}; }; - diff --git a/Source/SIMPLib/FilterParameters/DynamicTableData.cpp b/Source/SIMPLib/FilterParameters/DynamicTableData.cpp index eccfc9e828..e3ce862da3 100644 --- a/Source/SIMPLib/FilterParameters/DynamicTableData.cpp +++ b/Source/SIMPLib/FilterParameters/DynamicTableData.cpp @@ -1,66 +1,68 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DynamicTableData.h" #include #include +#include +#include // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DynamicTableData::DynamicTableData() : - m_DynamicRows(false), - m_DynamicCols(false), - m_MinRows(0), - m_MinCols(0), - m_DefaultRowCount(0), - m_DefaultColCount(0) +DynamicTableData::DynamicTableData() +: m_DynamicRows(false) +, m_DynamicCols(false) +, m_MinRows(0) +, m_MinCols(0) +, m_DefaultRowCount(0) +, m_DefaultColCount(0) { } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DynamicTableData::DynamicTableData(int nRows, int nCols) : - m_DynamicRows(false), - m_DynamicCols(false), - m_MinRows(0), - m_MinCols(0), - m_DefaultRowCount(0), - m_DefaultColCount(0) +DynamicTableData::DynamicTableData(int nRows, int nCols) +: m_DynamicRows(false) +, m_DynamicCols(false) +, m_MinRows(0) +, m_MinCols(0) +, m_DefaultRowCount(0) +, m_DefaultColCount(0) { std::vector> data(nRows, std::vector(nCols, 0)); m_TableData = data; @@ -84,13 +86,13 @@ DynamicTableData::DynamicTableData(int nRows, int nCols) : // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DynamicTableData::DynamicTableData(int nRows, int nCols, const QStringList &rHeaders, const QStringList &cHeaders) : - m_DynamicRows(false), - m_DynamicCols(false), - m_MinRows(0), - m_MinCols(0), - m_DefaultRowCount(0), - m_DefaultColCount(0) +DynamicTableData::DynamicTableData(int nRows, int nCols, const QStringList& rHeaders, const QStringList& cHeaders) +: m_DynamicRows(false) +, m_DynamicCols(false) +, m_MinRows(0) +, m_MinCols(0) +, m_DefaultRowCount(0) +, m_DefaultColCount(0) { std::vector> data(nRows, std::vector(nCols, 0)); m_TableData = data; @@ -105,15 +107,13 @@ DynamicTableData::DynamicTableData(int nRows, int nCols, const QStringList &rHe // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DynamicTableData::DynamicTableData(const std::vector>& data, - const QStringList& rHeaders, - const QStringList& cHeaders) : - m_DynamicRows(false), - m_DynamicCols(false), - m_MinRows(0), - m_MinCols(0), - m_DefaultRowCount(0), - m_DefaultColCount(0) +DynamicTableData::DynamicTableData(const std::vector>& data, const QStringList& rHeaders, const QStringList& cHeaders) +: m_DynamicRows(false) +, m_DynamicCols(false) +, m_MinRows(0) +, m_MinCols(0) +, m_DefaultRowCount(0) +, m_DefaultColCount(0) { m_TableData = data; m_RowHeaders = rHeaders; @@ -126,9 +126,7 @@ DynamicTableData::DynamicTableData(const std::vector>& data, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DynamicTableData DynamicTableData::Create(const std::vector>& dims, - const std::list& rHeaders, - const std::list& cHeaders) +DynamicTableData DynamicTableData::Create(const std::vector>& dims, const std::list& rHeaders, const std::list& cHeaders) { QStringList rowHdrs; for(const auto& rowHdr : rHeaders) @@ -174,29 +172,29 @@ void DynamicTableData::checkAndAdjustDimensions() return; } - /* The header dimensions do not equal the data dimensions. - The data dimensions will be used and will overwrite the current header dimensions. - This may result in data loss. - */ - int nRows = dataSize.width(); - int nCols = dataSize.height(); + /* The header dimensions do not equal the data dimensions. + The data dimensions will be used and will overwrite the current header dimensions. + This may result in data loss. + */ + int nRows = dataSize.width(); + int nCols = dataSize.height(); - // If row header dimension is greater than default row dimension, remove the extra headers - if(m_RowHeaders.size() > nRows) + // If row header dimension is greater than default row dimension, remove the extra headers + if(m_RowHeaders.size() > nRows) + { + while(m_RowHeaders.size() > nRows) { - while(m_RowHeaders.size() > nRows) - { - m_RowHeaders.pop_back(); - } + m_RowHeaders.pop_back(); } - // If column header dimension is greater than default column dimension, remove the extra headers - if(m_ColHeaders.size() > nCols) + } + // If column header dimension is greater than default column dimension, remove the extra headers + if(m_ColHeaders.size() > nCols) + { + while(m_ColHeaders.size() > nCols) { - while(m_ColHeaders.size() > nCols) - { - m_ColHeaders.pop_back(); - } + m_ColHeaders.pop_back(); } + } } // ----------------------------------------------------------------------------- @@ -339,7 +337,7 @@ QVector DynamicTableData::flattenData() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector> DynamicTableData::ExpandData(std::vector orig, int nRows, int nCols) +std::vector> DynamicTableData::ExpandData(std::vector orig, size_t nRows, size_t nCols) { std::vector> expand(nRows, std::vector(nCols)); @@ -349,9 +347,9 @@ std::vector> DynamicTableData::ExpandData(std::vector vector, m_TableData) + for(const std::vector& vector : m_TableData) { QJsonArray cols; - foreach(double val, vector) + for(double val : vector) { cols.push_back(val); } @@ -489,7 +487,7 @@ std::vector> DynamicTableData::readData(QJsonObject object) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector> DynamicTableData::getTableData() +std::vector> DynamicTableData::getTableData() const { return m_TableData; } @@ -563,9 +561,8 @@ DynamicTableData& DynamicTableData::operator=(const DynamicTableData& rhs) // ----------------------------------------------------------------------------- bool DynamicTableData::operator==(const DynamicTableData& rhs) const { - if(m_RowHeaders == rhs.m_RowHeaders && m_ColHeaders == rhs.m_ColHeaders && m_DynamicRows == rhs.m_DynamicRows - && m_DynamicCols == rhs.m_DynamicCols && m_MinRows == rhs.m_MinRows && m_MinCols == rhs.m_MinCols - && m_DefaultRowCount == rhs.m_DefaultRowCount && m_DefaultColCount == rhs.m_DefaultColCount) + if(m_RowHeaders == rhs.m_RowHeaders && m_ColHeaders == rhs.m_ColHeaders && m_DynamicRows == rhs.m_DynamicRows && m_DynamicCols == rhs.m_DynamicCols && m_MinRows == rhs.m_MinRows && + m_MinCols == rhs.m_MinCols && m_DefaultRowCount == rhs.m_DefaultRowCount && m_DefaultColCount == rhs.m_DefaultColCount) { for(int i = 0; i < m_TableData.size(); i++) { @@ -588,9 +585,8 @@ bool DynamicTableData::operator==(const DynamicTableData& rhs) const // ----------------------------------------------------------------------------- bool DynamicTableData::operator!=(const DynamicTableData& rhs) const { - if(m_RowHeaders == rhs.m_RowHeaders && m_ColHeaders == rhs.m_ColHeaders && m_DynamicRows == rhs.m_DynamicRows - && m_DynamicCols == rhs.m_DynamicCols && m_MinRows == rhs.m_MinRows && m_MinCols == rhs.m_MinCols - && m_DefaultRowCount == rhs.m_DefaultRowCount && m_DefaultColCount == rhs.m_DefaultColCount) + if(m_RowHeaders == rhs.m_RowHeaders && m_ColHeaders == rhs.m_ColHeaders && m_DynamicRows == rhs.m_DynamicRows && m_DynamicCols == rhs.m_DynamicCols && m_MinRows == rhs.m_MinRows && + m_MinCols == rhs.m_MinCols && m_DefaultRowCount == rhs.m_DefaultRowCount && m_DefaultColCount == rhs.m_DefaultColCount) { for(int i = 0; i < m_TableData.size(); i++) { @@ -610,3 +606,99 @@ bool DynamicTableData::operator!=(const DynamicTableData& rhs) const return false; } + +// ----------------------------------------------------------------------------- +void DynamicTableData::setColHeaders(const QStringList& value) +{ + m_ColHeaders = value; +} + +// ----------------------------------------------------------------------------- +QStringList DynamicTableData::getColHeaders() const +{ + return m_ColHeaders; +} + +// ----------------------------------------------------------------------------- +void DynamicTableData::setRowHeaders(const QStringList& value) +{ + m_RowHeaders = value; +} + +// ----------------------------------------------------------------------------- +QStringList DynamicTableData::getRowHeaders() const +{ + return m_RowHeaders; +} + +// ----------------------------------------------------------------------------- +void DynamicTableData::setDynamicRows(bool value) +{ + m_DynamicRows = value; +} + +// ----------------------------------------------------------------------------- +bool DynamicTableData::getDynamicRows() const +{ + return m_DynamicRows; +} + +// ----------------------------------------------------------------------------- +void DynamicTableData::setDynamicCols(bool value) +{ + m_DynamicCols = value; +} + +// ----------------------------------------------------------------------------- +bool DynamicTableData::getDynamicCols() const +{ + return m_DynamicCols; +} + +// ----------------------------------------------------------------------------- +void DynamicTableData::setMinRows(int value) +{ + m_MinRows = value; +} + +// ----------------------------------------------------------------------------- +int DynamicTableData::getMinRows() const +{ + return m_MinRows; +} + +// ----------------------------------------------------------------------------- +void DynamicTableData::setMinCols(int value) +{ + m_MinCols = value; +} + +// ----------------------------------------------------------------------------- +int DynamicTableData::getMinCols() const +{ + return m_MinCols; +} + +// ----------------------------------------------------------------------------- +void DynamicTableData::setDefaultRowCount(int value) +{ + m_DefaultRowCount = value; +} + +// ----------------------------------------------------------------------------- +int DynamicTableData::getDefaultRowCount() const +{ + return m_DefaultRowCount; +} + +// ----------------------------------------------------------------------------- +void DynamicTableData::setDefaultColCount(int value) +{ + m_DefaultColCount = value; +} + +// ----------------------------------------------------------------------------- +int DynamicTableData::getDefaultColCount() const +{ + return m_DefaultColCount; +} diff --git a/Source/SIMPLib/FilterParameters/DynamicTableData.h b/Source/SIMPLib/FilterParameters/DynamicTableData.h old mode 100755 new mode 100644 index 8ceff94aa0..56539d68c8 --- a/Source/SIMPLib/FilterParameters/DynamicTableData.h +++ b/Source/SIMPLib/FilterParameters/DynamicTableData.h @@ -1,183 +1,257 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once - #include -#include -#include - -#include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Filtering/AbstractFilter.h" /** -* @brief -* @author -* @version -*/ + * @brief + * @author + * @version + */ class SIMPLib_EXPORT DynamicTableData : public QObject { - Q_OBJECT - PYB11_CREATE_BINDINGS(DynamicTableData) - PYB11_STATIC_CREATION(Create ARGS std::vector> std::list std::list) - PYB11_PROPERTY(QStringList ColHeaders READ getColHeaders WRITE setColHeaders) - PYB11_PROPERTY(QStringList RowHeaders READ getRowHeaders WRITE setRowHeaders) - PYB11_PROPERTY(std::vector> TableData READ getTableData WRITE setTableData) - - public: - DynamicTableData(); - DynamicTableData(int nRows, int nCols); - DynamicTableData(int nRows, int nCols, const QStringList &rHeaders, const QStringList &cHeaders); - DynamicTableData(const std::vector > &data, - const QStringList &rHeaders = QStringList(), - const QStringList &cHeaders = QStringList()); - - ~DynamicTableData() override; - - static DynamicTableData Create(const std::vector>& dims, - const std::list& rHeaders, - const std::list& cHeaders); - - SIMPL_INSTANCE_PROPERTY(QStringList, ColHeaders) - SIMPL_INSTANCE_PROPERTY(QStringList, RowHeaders) - SIMPL_INSTANCE_PROPERTY(bool, DynamicRows) - SIMPL_INSTANCE_PROPERTY(bool, DynamicCols) - SIMPL_INSTANCE_PROPERTY(int, MinRows) - SIMPL_INSTANCE_PROPERTY(int, MinCols) - SIMPL_INSTANCE_PROPERTY(int, DefaultRowCount) - SIMPL_INSTANCE_PROPERTY(int, DefaultColCount) - - /** - * @brief This deserializes a string of data and returns the original 2D array. - */ - static std::vector > DeserializeData(QString dataStr, int nRows, int nCols, char delimiter); - - /** - * @brief This does the reverse of the flattenData function. It expands the data back into a 2D array. - */ - static std::vector > ExpandData(std::vector orig, int nRows, int nCols); - - /** - * @brief This deserializes a string of headers and returns the original QStringList. - */ - static QStringList DeserializeHeaders(QString headersStr, char delimiter); - - /** - * @brief This returns a serialized string of the data, iterating through columns first. - */ - QString serializeData(char delimiter) const; - - /** - * @brief This returns a serialized string of the row headers list. - */ - QString serializeRowHeaders(char delimiter) const; - - /** - * @brief This returns a serialized string of the column headers list. - */ - QString serializeColumnHeaders(char delimiter) const; - - /** - * @brief This returns a flattened vector of the data. - */ - QVector flattenData() const; - - /** - * @brief Writes the contents of the proxy to the json object 'json' - * @param json - * @return - */ - void writeJson(QJsonObject& json) const; - - /** - * @brief Reads the contents of the json object 'json' into the proxy - * @param json - * @return - */ - bool readJson(QJsonObject& json); - - /** - * @brief Table data getter and setter - */ - std::vector> getTableData(); - void setTableData(const std::vector>& data); - - /** - * @brief Calculates and returns the number of rows - */ - int getNumRows() const; - - /** - * @brief Calculates and returns the number of columns - */ - int getNumCols() const; - - /** - * @brief Checks if the DynamicTableData object is empty. - */ - bool isEmpty(); - - DynamicTableData(const DynamicTableData& rhs); - DynamicTableData& operator=(const DynamicTableData& rhs); - bool operator==(const DynamicTableData& rhs) const; - bool operator!=(const DynamicTableData& rhs) const; - - private: - std::vector > m_TableData; - - /** - * @brief Writes the contents of the data to a QJsonObject - * @param data - * @return QJsonArray - */ - void writeData(QJsonObject &object) const; - - /** - * @brief Reads the contents of the QJsonObject into a 2D array - * @param object - * @return 2D array - */ - std::vector > readData(QJsonObject object); - - /** - * @brief Checks that the dimensions between all variables are the same. If not, adjusts dimensions - * to match numRows and numCols. - */ - void checkAndAdjustDimensions(); + Q_OBJECT + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(DynamicTableData) + PYB11_STATIC_CREATION(Create ARGS std::vector> std::list std::list) + PYB11_PROPERTY(QStringList ColHeaders READ getColHeaders WRITE setColHeaders) + PYB11_PROPERTY(QStringList RowHeaders READ getRowHeaders WRITE setRowHeaders) + PYB11_PROPERTY(std::vector> TableData READ getTableData WRITE setTableData) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + DynamicTableData(); + DynamicTableData(int nRows, int nCols); + DynamicTableData(int nRows, int nCols, const QStringList& rHeaders, const QStringList& cHeaders); + DynamicTableData(const std::vector>& data, const QStringList& rHeaders = QStringList(), const QStringList& cHeaders = QStringList()); + + ~DynamicTableData() override; + + static DynamicTableData Create(const std::vector>& dims, const std::list& rHeaders, const std::list& cHeaders); + + /** + * @brief Setter property for ColHeaders + */ + void setColHeaders(const QStringList& value); + /** + * @brief Getter property for ColHeaders + * @return Value of ColHeaders + */ + QStringList getColHeaders() const; + + /** + * @brief Setter property for RowHeaders + */ + void setRowHeaders(const QStringList& value); + /** + * @brief Getter property for RowHeaders + * @return Value of RowHeaders + */ + QStringList getRowHeaders() const; + + /** + * @brief Setter property for DynamicRows + */ + void setDynamicRows(bool value); + /** + * @brief Getter property for DynamicRows + * @return Value of DynamicRows + */ + bool getDynamicRows() const; + + /** + * @brief Setter property for DynamicCols + */ + void setDynamicCols(bool value); + /** + * @brief Getter property for DynamicCols + * @return Value of DynamicCols + */ + bool getDynamicCols() const; + + /** + * @brief Setter property for MinRows + */ + void setMinRows(int value); + /** + * @brief Getter property for MinRows + * @return Value of MinRows + */ + int getMinRows() const; + + /** + * @brief Setter property for MinCols + */ + void setMinCols(int value); + /** + * @brief Getter property for MinCols + * @return Value of MinCols + */ + int getMinCols() const; + + /** + * @brief Setter property for DefaultRowCount + */ + void setDefaultRowCount(int value); + /** + * @brief Getter property for DefaultRowCount + * @return Value of DefaultRowCount + */ + int getDefaultRowCount() const; + + /** + * @brief Setter property for DefaultColCount + */ + void setDefaultColCount(int value); + /** + * @brief Getter property for DefaultColCount + * @return Value of DefaultColCount + */ + int getDefaultColCount() const; + + /** + * @brief This deserializes a string of data and returns the original 2D array. + */ + static std::vector> DeserializeData(QString dataStr, int nRows, int nCols, char delimiter); + + /** + * @brief This does the reverse of the flattenData function. It expands the data back into a 2D array. + */ + static std::vector> ExpandData(std::vector orig, size_t nRows, size_t nCols); + + /** + * @brief This deserializes a string of headers and returns the original QStringList. + */ + static QStringList DeserializeHeaders(QString headersStr, char delimiter); + + /** + * @brief This returns a serialized string of the data, iterating through columns first. + */ + QString serializeData(char delimiter) const; + + /** + * @brief This returns a serialized string of the row headers list. + */ + QString serializeRowHeaders(char delimiter) const; + + /** + * @brief This returns a serialized string of the column headers list. + */ + QString serializeColumnHeaders(char delimiter) const; + + /** + * @brief This returns a flattened vector of the data. + */ + QVector flattenData() const; + + /** + * @brief Writes the contents of the proxy to the json object 'json' + * @param json + * @return + */ + void writeJson(QJsonObject& json) const; + + /** + * @brief Reads the contents of the json object 'json' into the proxy + * @param json + * @return + */ + bool readJson(QJsonObject& json); + + /** + * @brief Table data getter and setter + */ + std::vector> getTableData() const; + void setTableData(const std::vector>& data); + + /** + * @brief Calculates and returns the number of rows + */ + int getNumRows() const; + + /** + * @brief Calculates and returns the number of columns + */ + int getNumCols() const; + + /** + * @brief Checks if the DynamicTableData object is empty. + */ + bool isEmpty(); + + DynamicTableData(const DynamicTableData& rhs); + DynamicTableData& operator=(const DynamicTableData& rhs); + bool operator==(const DynamicTableData& rhs) const; + bool operator!=(const DynamicTableData& rhs) const; + +private: + QStringList m_ColHeaders = {}; + QStringList m_RowHeaders = {}; + bool m_DynamicRows = {}; + bool m_DynamicCols = {}; + int m_MinRows = {}; + int m_MinCols = {}; + int m_DefaultRowCount = {}; + int m_DefaultColCount = {}; + + std::vector> m_TableData; + + /** + * @brief Writes the contents of the data to a QJsonObject + * @param data + * @return QJsonArray + */ + void writeData(QJsonObject& object) const; + + /** + * @brief Reads the contents of the QJsonObject into a 2D array + * @param object + * @return 2D array + */ + std::vector> readData(QJsonObject object); + + /** + * @brief Checks that the dimensions between all variables are the same. If not, adjusts dimensions + * to match numRows and numCols. + */ + void checkAndAdjustDimensions(); }; Q_DECLARE_METATYPE(DynamicTableData) - diff --git a/Source/SIMPLib/FilterParameters/DynamicTableFilterParameter.cpp b/Source/SIMPLib/FilterParameters/DynamicTableFilterParameter.cpp index 316278559c..b4c8d81bf4 100644 --- a/Source/SIMPLib/FilterParameters/DynamicTableFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/DynamicTableFilterParameter.cpp @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "DynamicTableFilterParameter.h" +#include + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -51,7 +53,8 @@ DynamicTableFilterParameter::~DynamicTableFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -DynamicTableFilterParameter::Pointer DynamicTableFilterParameter::New(const QString& humanLabel, const QString& propertyName, DynamicTableData defaultTableData, FilterParameter::Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) +DynamicTableFilterParameter::Pointer DynamicTableFilterParameter::Create(const QString& humanLabel, const QString& propertyName, DynamicTableData defaultTableData, FilterParameter::Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { DynamicTableFilterParameter::Pointer ptr = DynamicTableFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -80,7 +83,6 @@ DynamicTableFilterParameter::Pointer DynamicTableFilterParameter::New(const QStr } } - ptr->setErrorCondition(0); ptr->setErrorMessage("There is no error."); return ptr; } @@ -99,6 +101,10 @@ QString DynamicTableFilterParameter::getWidgetType() const void DynamicTableFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonObject jsonObj = jsonValue.toObject(); @@ -111,9 +117,9 @@ void DynamicTableFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DynamicTableFilterParameter::writeJson(QJsonObject& json) +void DynamicTableFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { DynamicTableData dynamicData = m_GetterCallback(); QJsonObject jsonObj; @@ -121,3 +127,88 @@ void DynamicTableFilterParameter::writeJson(QJsonObject& json) json[getPropertyName()] = jsonObj; } } + +// ----------------------------------------------------------------------------- +DynamicTableFilterParameter::Pointer DynamicTableFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +DynamicTableFilterParameter::Pointer DynamicTableFilterParameter::New() +{ + Pointer sharedPtr(new(DynamicTableFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString DynamicTableFilterParameter::getNameOfClass() const +{ + return QString("DynamicTableFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString DynamicTableFilterParameter::ClassName() +{ + return QString("DynamicTableFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void DynamicTableFilterParameter::setDefaultTableData(const DynamicTableData& value) +{ + m_DefaultTableData = value; +} + +// ----------------------------------------------------------------------------- +DynamicTableData DynamicTableFilterParameter::getDefaultTableData() const +{ + return m_DefaultTableData; +} + +// ----------------------------------------------------------------------------- +void DynamicTableFilterParameter::setErrorCondition(int value) +{ + m_ErrorCondition = value; +} + +// ----------------------------------------------------------------------------- +int DynamicTableFilterParameter::getErrorCondition() const +{ + return m_ErrorCondition; +} + +// ----------------------------------------------------------------------------- +void DynamicTableFilterParameter::setErrorMessage(const QString& value) +{ + m_ErrorMessage = value; +} + +// ----------------------------------------------------------------------------- +QString DynamicTableFilterParameter::getErrorMessage() const +{ + return m_ErrorMessage; +} + +// ----------------------------------------------------------------------------- +void DynamicTableFilterParameter::setSetterCallback(const DynamicTableFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DynamicTableFilterParameter::SetterCallbackType DynamicTableFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void DynamicTableFilterParameter::setGetterCallback(const DynamicTableFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +DynamicTableFilterParameter::GetterCallbackType DynamicTableFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/DynamicTableFilterParameter.h b/Source/SIMPLib/FilterParameters/DynamicTableFilterParameter.h old mode 100755 new mode 100644 index c1a673c4a8..265c1f93a1 --- a/Source/SIMPLib/FilterParameters/DynamicTableFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/DynamicTableFilterParameter.h @@ -1,44 +1,46 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/FilterParameters/DynamicTableData.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" /** * @brief SIMPL_NEW_DYN_TABLE_FP This macro is a short-form way of instantiating an instance of @@ -51,12 +53,10 @@ * IsColsDynamic (opt.), MinRowCount (opt.), MinColCount (opt.), GroupIndex (opt.)) * * Example 1 (instantiated within a filter called [DynamicTableExample](@ref dynamictableexample), with 5 optional parameters): - * SIMPL_NEW_DYN_TABLE_FP("Dynamic Table 5", DynamicData5, FilterParameter::Parameter, DynamicTableExample, true, true, 0, 0, 0); + * SIMPL_NEW_DYN_TABLE_FP("Dynamic Table 5", DynamicData5, FilterParameter::Category::Parameter, DynamicTableExample, true, true, 0, 0, 0); */ -#define SIMPL_NEW_DYN_TABLE_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (DynamicTableFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_DYN_TABLE_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(DynamicTableFilterParameter, __VA_ARGS__)) /** * @brief The DynamicTableFilterParameter class is used by filters to instantiate an DynamicTableWidget. By instantiating an instance of @@ -64,90 +64,157 @@ */ class SIMPLib_EXPORT DynamicTableFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(DynamicTableFilterParameter) - SIMPL_STATIC_NEW_MACRO(DynamicTableFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(DynamicTableFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the DynamicTableFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DYN_TABLE_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param isRowsDynamic Boolean that determines whether the row count is dynamic or fixed - * @param isColsDynamic Boolean that determines whether the column count is dynamic or fixed - * @param minRowCount Minimum number of rows possible - * @param minColCount Minimum number of columns possible - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - DynamicTableData defaultTableData, FilterParameter::Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - int groupIndex = -1); - - ~DynamicTableFilterParameter() override; - - SIMPL_INSTANCE_PROPERTY(DynamicTableData, DefaultTableData) - SIMPL_INSTANCE_PROPERTY(int, ErrorCondition) - SIMPL_INSTANCE_PROPERTY(QString, ErrorMessage) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief DynamicTableFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - DynamicTableFilterParameter(); - - public: - DynamicTableFilterParameter(const DynamicTableFilterParameter&) = delete; // Copy Constructor Not Implemented - DynamicTableFilterParameter(DynamicTableFilterParameter&&) = delete; // Move Constructor Not Implemented - DynamicTableFilterParameter& operator=(const DynamicTableFilterParameter&) = delete; // Copy Assignment Not Implemented - DynamicTableFilterParameter& operator=(DynamicTableFilterParameter&&) = delete; // Move Assignment Not Implemented + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(DynamicTableFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(DynamicTableFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = DynamicTableFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for DynamicTableFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for DynamicTableFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the DynamicTableFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_DYN_TABLE_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param isRowsDynamic Boolean that determines whether the row count is dynamic or fixed + * @param isColsDynamic Boolean that determines whether the column count is dynamic or fixed + * @param minRowCount Minimum number of rows possible + * @param minColCount Minimum number of columns possible + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, DynamicTableData defaultTableData, FilterParameter::Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~DynamicTableFilterParameter() override; + + /** + * @brief Setter property for DefaultTableData + */ + void setDefaultTableData(const DynamicTableData& value); + /** + * @brief Getter property for DefaultTableData + * @return Value of DefaultTableData + */ + DynamicTableData getDefaultTableData() const; + + /** + * @brief Setter property for ErrorCondition + */ + void setErrorCondition(int value); + /** + * @brief Getter property for ErrorCondition + * @return Value of ErrorCondition + */ + int getErrorCondition() const; + + /** + * @brief Setter property for ErrorMessage + */ + void setErrorMessage(const QString& value); + /** + * @brief Getter property for ErrorMessage + * @return Value of ErrorMessage + */ + QString getErrorMessage() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const DynamicTableFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + DynamicTableFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const DynamicTableFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + DynamicTableFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief DynamicTableFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + DynamicTableFilterParameter(); + +public: + DynamicTableFilterParameter(const DynamicTableFilterParameter&) = delete; // Copy Constructor Not Implemented + DynamicTableFilterParameter(DynamicTableFilterParameter&&) = delete; // Move Constructor Not Implemented + DynamicTableFilterParameter& operator=(const DynamicTableFilterParameter&) = delete; // Copy Assignment Not Implemented + DynamicTableFilterParameter& operator=(DynamicTableFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + DynamicTableData m_DefaultTableData = {}; + int m_ErrorCondition = {}; + QString m_ErrorMessage = {}; + DynamicTableFilterParameter::SetterCallbackType m_SetterCallback = {}; + DynamicTableFilterParameter::GetterCallbackType m_GetterCallback = {}; }; - diff --git a/Source/SIMPLib/FilterParameters/FileListInfo.cpp b/Source/SIMPLib/FilterParameters/FileListInfo.cpp new file mode 100644 index 0000000000..8a3662a1e2 --- /dev/null +++ b/Source/SIMPLib/FilterParameters/FileListInfo.cpp @@ -0,0 +1,69 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "FileListInfo.h" + +// ----------------------------------------------------------------------------- +FileListInfo::FileListInfo() = default; + +// ----------------------------------------------------------------------------- +FileListInfo::~FileListInfo() = default; + +// ----------------------------------------------------------------------------- +void FileListInfo::writeSuperclassJson(QJsonObject& json) const +{ + json["PaddingDigits"] = static_cast(PaddingDigits); + json["Ordering"] = static_cast(Ordering); + json["IncrementIndex"] = static_cast(IncrementIndex); + json["InputPath"] = InputPath; + json["FilePrefix"] = FilePrefix; + json["FileSuffix"] = FileSuffix; + json["FileExtension"] = FileExtension; +} + +// ----------------------------------------------------------------------------- +bool FileListInfo::readSuperclassJson(QJsonObject& json) +{ + if(json["PaddingDigits"].isDouble() && json["Ordering"].isDouble() && json["IncrementIndex"].isDouble() && json["InputPath"].isString() && json["FilePrefix"].isString() && + json["FileSuffix"].isString() && json["FileExtension"].isString()) + { + PaddingDigits = static_cast(json["PaddingDigits"].toInt()); + Ordering = static_cast(json["Ordering"].toInt()); + IncrementIndex = static_cast(json["IncrementIndex"].toInt()); + InputPath = json["InputPath"].toString(); + FilePrefix = json["FilePrefix"].toString(); + FileSuffix = json["FileSuffix"].toString(); + FileExtension = json["FileExtension"].toString(); + return true; + } + return false; +} diff --git a/Source/SIMPLib/FilterParameters/FileListInfo.h b/Source/SIMPLib/FilterParameters/FileListInfo.h index d4f841338e..536f526473 100644 --- a/Source/SIMPLib/FilterParameters/FileListInfo.h +++ b/Source/SIMPLib/FilterParameters/FileListInfo.h @@ -1,5 +1,6 @@ /* ============================================================================ * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -11,9 +12,9 @@ * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * - * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its - * contributors may be used to endorse or promote products derived from this software - * without specific prior written permission. + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -26,55 +27,62 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once #include +#include #include -typedef struct +#include "SIMPLib/SIMPLib.h" + +class SIMPLib_EXPORT FileListInfo { + +public: + virtual ~FileListInfo(); + qint32 PaddingDigits = 3; - quint32 Ordering = 0; /* Ordering=0 = Ascending, Ordering=1 = Descending */ - qint32 StartIndex = 0; - qint32 EndIndex = 1; + quint32 Ordering = 0; /* Ordering=0 = RowColumn, Ordering=1 = ColumnRow */ qint32 IncrementIndex = 1; QString InputPath; QString FilePrefix; QString FileSuffix; QString FileExtension; - void writeJson(QJsonObject& json) - { - json["PaddingDigits"] = static_cast(PaddingDigits); - json["Ordering"] = static_cast(Ordering); - json["StartIndex"] = static_cast(StartIndex); - json["EndIndex"] = static_cast(EndIndex); - json["IncrementIndex"] = static_cast(IncrementIndex); - json["InputPath"] = InputPath; - json["FilePrefix"] = FilePrefix; - json["FileSuffix"] = FileSuffix; - json["FileExtension"] = FileExtension; - } + /** + * @brief writeJson + * @param json + */ + virtual void writeJson(QJsonObject& json) const = 0; + + /** + * @brief readJson + * @param json + * @return + */ + virtual bool readJson(QJsonObject& json) = 0; + +protected: + FileListInfo(); + + /** + * @brief writeSuperclassJson + * @param json + */ + void writeSuperclassJson(QJsonObject& json) const; - bool readJson(QJsonObject& json) - { - if(json["PaddingDigits"].isDouble() && json["Ordering"].isDouble() && json["StartIndex"].isDouble() && json["EndIndex"].isDouble() && json["IncrementIndex"].isDouble() && - json["InputPath"].isString() && json["FilePrefix"].isString() && json["FileSuffix"].isString() && json["FileExtension"].isString()) - { - PaddingDigits = static_cast(json["PaddingDigits"].toDouble()); - Ordering = static_cast(json["Ordering"].toDouble()); - StartIndex = static_cast(json["StartIndex"].toDouble()); - EndIndex = static_cast(json["EndIndex"].toDouble()); - IncrementIndex = static_cast(json["IncrementIndex"].toDouble()); - InputPath = json["InputPath"].toString(); - FilePrefix = json["FilePrefix"].toString(); - FileSuffix = json["FileSuffix"].toString(); - FileExtension = json["FileExtension"].toString(); - return true; - } - return false; - } -} FileListInfo_t; + /** + * @brief readSuperclassJson + * @param json + * @return + */ + bool readSuperclassJson(QJsonObject& json); -Q_DECLARE_METATYPE(FileListInfo_t) +public: + FileListInfo(const FileListInfo&) = default; // Copy Constructor Not Implemented + FileListInfo(FileListInfo&&) = default; // Move Constructor Not Implemented + FileListInfo& operator=(const FileListInfo&) = default; // Copy Assignment Not Implemented + FileListInfo& operator=(FileListInfo&&) = default; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/FilterParameters/FileListInfoFilterParameter.cpp b/Source/SIMPLib/FilterParameters/FileListInfoFilterParameter.cpp index 586f30b162..8ae1a6298e 100644 --- a/Source/SIMPLib/FilterParameters/FileListInfoFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/FileListInfoFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "FileListInfoFilterParameter.h" @@ -51,8 +51,8 @@ FileListInfoFilterParameter::~FileListInfoFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FileListInfoFilterParameter::Pointer FileListInfoFilterParameter::New(const QString& humanLabel, const QString& propertyName, const FileListInfo_t& defaultValue, FilterParameter::Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback) +FileListInfoFilterParameter::Pointer FileListInfoFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const StackFileListInfo& defaultValue, + FilterParameter::Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback) { FileListInfoFilterParameter::Pointer ptr = FileListInfoFilterParameter::New(); @@ -82,10 +82,14 @@ QString FileListInfoFilterParameter::getWidgetType() const void FileListInfoFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonObject jsonObj = jsonValue.toObject(); - FileListInfo_t fileListInfo; + StackFileListInfo fileListInfo; fileListInfo.readJson(jsonObj); m_SetterCallback(fileListInfo); } @@ -94,13 +98,62 @@ void FileListInfoFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FileListInfoFilterParameter::writeJson(QJsonObject& json) +void FileListInfoFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { - FileListInfo_t fileListInfo = m_GetterCallback(); + StackFileListInfo fileListInfo = m_GetterCallback(); QJsonObject jsonObj; fileListInfo.writeJson(jsonObj); json[getPropertyName()] = jsonObj; } } + +// ----------------------------------------------------------------------------- +FileListInfoFilterParameter::Pointer FileListInfoFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +FileListInfoFilterParameter::Pointer FileListInfoFilterParameter::New() +{ + Pointer sharedPtr(new(FileListInfoFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString FileListInfoFilterParameter::getNameOfClass() const +{ + return QString("FileListInfoFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString FileListInfoFilterParameter::ClassName() +{ + return QString("FileListInfoFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void FileListInfoFilterParameter::setSetterCallback(const FileListInfoFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +FileListInfoFilterParameter::SetterCallbackType FileListInfoFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void FileListInfoFilterParameter::setGetterCallback(const FileListInfoFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +FileListInfoFilterParameter::GetterCallbackType FileListInfoFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/FileListInfoFilterParameter.h b/Source/SIMPLib/FilterParameters/FileListInfoFilterParameter.h old mode 100755 new mode 100644 index 130a62e67d..34e10b2c71 --- a/Source/SIMPLib/FilterParameters/FileListInfoFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/FileListInfoFilterParameter.h @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,14 +35,14 @@ #pragma once -#include +#include + #include -#include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/FilterParameters/FileListInfo.h" -#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" +#include "SIMPLib/FilterParameters/StackFileListInfo.h" /** * @brief SIMPL_NEW_FILELISTINFO_FP This macro is a short-form way of instantiating an instance of @@ -53,7 +53,7 @@ * SIMPL_NEW_FILELISTINFO_FP("HumanLabel", PropertyName, Category, FilterName) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample)): - * SIMPL_NEW_FILELISTINFO_FP("Input File List", InputFileListInfo, FilterParameter::Parameter, GenericExample); + * SIMPL_NEW_FILELISTINFO_FP("Input File List", InputFileListInfo, FilterParameter::Category::Parameter, GenericExample); */ #define SIMPL_NEW_FILELISTINFO_FP(...) \ SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(FileListInfoFilterParameter, __VA_ARGS__)) @@ -64,13 +64,33 @@ */ class SIMPLib_EXPORT FileListInfoFilterParameter : public FilterParameter { + + PYB11_BEGIN_BINDINGS(FileListInfoFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(FileListInfoFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + public: - SIMPL_SHARED_POINTERS(FileListInfoFilterParameter) - SIMPL_STATIC_NEW_MACRO(FileListInfoFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(FileListInfoFilterParameter, FilterParameter) + using Self = FileListInfoFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - typedef std::function SetterCallbackType; - typedef std::function GetterCallbackType; + static Pointer New(); + + /** + * @brief Returns the name of the class for FileListInfoFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for FileListInfoFilterParameter + */ + static QString ClassName(); + + typedef std::function SetterCallbackType; + typedef std::function GetterCallbackType; /** * @brief New This function instantiates an instance of the FileListInfoFilterParameter. Although this @@ -88,8 +108,8 @@ class SIMPLib_EXPORT FileListInfoFilterParameter : public FilterParameter * that this FilterParameter subclass represents. * @return */ - static Pointer New(const QString& humanLabel, const QString& propertyName, const FileListInfo_t& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback); + static Pointer Create(const QString& humanLabel, const QString& propertyName, const StackFileListInfo& defaultValue, Category category, SetterCallbackType setterCallback, + GetterCallbackType getterCallback); ~FileListInfoFilterParameter() override; @@ -110,21 +130,37 @@ class SIMPLib_EXPORT FileListInfoFilterParameter : public FilterParameter * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. * @param json The QJsonObject that the filter parameter writes to. */ - void writeJson(QJsonObject& json) override; + void writeJson(QJsonObject& json) const override; /** * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property * that this FilterParameter subclass represents. * from the filter parameter. */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const FileListInfoFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + FileListInfoFilterParameter::SetterCallbackType getSetterCallback() const; /** * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property * that this FilterParameter subclass represents. * @return The GetterCallback */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const FileListInfoFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + FileListInfoFilterParameter::GetterCallbackType getGetterCallback() const; protected: /** @@ -134,9 +170,12 @@ class SIMPLib_EXPORT FileListInfoFilterParameter : public FilterParameter FileListInfoFilterParameter(); public: - FileListInfoFilterParameter(const FileListInfoFilterParameter&) = delete; // Copy Constructor Not Implemented - FileListInfoFilterParameter(FileListInfoFilterParameter&&) = delete; // Move Constructor Not Implemented + FileListInfoFilterParameter(const FileListInfoFilterParameter&) = delete; // Copy Constructor Not Implemented + FileListInfoFilterParameter(FileListInfoFilterParameter&&) = delete; // Move Constructor Not Implemented FileListInfoFilterParameter& operator=(const FileListInfoFilterParameter&) = delete; // Copy Assignment Not Implemented FileListInfoFilterParameter& operator=(FileListInfoFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +private: + FileListInfoFilterParameter::SetterCallbackType m_SetterCallback = {}; + FileListInfoFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/FilterParameter.cpp b/Source/SIMPLib/FilterParameters/FilterParameter.cpp index 868823d7f0..ae612316bd 100644 --- a/Source/SIMPLib/FilterParameters/FilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/FilterParameter.cpp @@ -1,44 +1,44 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "FilterParameter.h" #include -#include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" +#include "SIMPLib/Filtering/AbstractFilter.h" // ----------------------------------------------------------------------------- // @@ -46,7 +46,7 @@ FilterParameter::FilterParameter() : m_HumanLabel("") , m_PropertyName("") -, m_Category(Uncategorized) +, m_Category(FilterParameter::Category::Uncategorized) , m_ReadOnly(false) , m_GroupIndex(-1) { @@ -68,7 +68,7 @@ void FilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FilterParameter::writeJson(QJsonObject& json) +void FilterParameter::writeJson(QJsonObject& json) const { Q_UNUSED(json) } @@ -76,49 +76,160 @@ void FilterParameter::writeJson(QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void FilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { QVariant var = filter->property(qPrintable(getPropertyName())); - if(var.isValid() && var.canConvert()) + if(!var.isValid()) + { + return; + } + + if(var.canConvert()) { DataArrayPath path = var.value(); + if(path == renamePath.first) + { + return; + } if(path.updatePath(renamePath)) { var.setValue(path); filter->setProperty(qPrintable(getPropertyName()), var); - emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); } } - else if(var.isValid() && var.canConvert()) + else if(var.canConvert()) { DataContainerArrayProxy proxy = var.value(); proxy.updatePath(renamePath); var.setValue(proxy); filter->setProperty(qPrintable(getPropertyName()), var); - emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); } - else if(var.isValid() && var.canConvert()) + else if(var.canConvert()) { DataContainerProxy proxy = var.value(); proxy.updatePath(renamePath); var.setValue(proxy); filter->setProperty(qPrintable(getPropertyName()), var); - emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); } - else if(var.isValid() && var.canConvert()) + else if(var.canConvert()) { AttributeMatrixProxy proxy = var.value(); proxy.updatePath(renamePath); var.setValue(proxy); filter->setProperty(qPrintable(getPropertyName()), var); - emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); } - else if(var.isValid() && var.canConvert()) + else if(var.canConvert()) { DataArrayProxy proxy = var.value(); proxy.updatePath(renamePath); var.setValue(proxy); filter->setProperty(qPrintable(getPropertyName()), var); - emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); } } + +// ----------------------------------------------------------------------------- +FilterParameter::Pointer FilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString FilterParameter::getNameOfClass() const +{ + return QString("FilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString FilterParameter::ClassName() +{ + return QString("FilterParameter"); +} + +// ----------------------------------------------------------------------------- +void FilterParameter::setHumanLabel(const QString& value) +{ + m_HumanLabel = value; +} + +// ----------------------------------------------------------------------------- +QString FilterParameter::getHumanLabel() const +{ + return m_HumanLabel; +} + +// ----------------------------------------------------------------------------- +void FilterParameter::setPropertyName(const QString& value) +{ + m_PropertyName = value; +} + +// ----------------------------------------------------------------------------- +QString FilterParameter::getPropertyName() const +{ + return m_PropertyName; +} + +// ----------------------------------------------------------------------------- +void FilterParameter::setLegacyPropertyName(const QString& value) +{ + m_LegacyPropertyName = value; +} + +// ----------------------------------------------------------------------------- +QString FilterParameter::getLegacyPropertyName() const +{ + return m_LegacyPropertyName; +} + +// ----------------------------------------------------------------------------- +void FilterParameter::setCategory(const FilterParameter::Category& value) +{ + m_Category = value; +} + +// ----------------------------------------------------------------------------- +FilterParameter::Category FilterParameter::getCategory() const +{ + return m_Category; +} + +// ----------------------------------------------------------------------------- +void FilterParameter::setReadOnly(bool value) +{ + m_ReadOnly = value; +} + +// ----------------------------------------------------------------------------- +bool FilterParameter::getReadOnly() const +{ + return m_ReadOnly; +} + +// ----------------------------------------------------------------------------- +void FilterParameter::setGroupIndex(int value) +{ + m_GroupIndex = value; +} + +// ----------------------------------------------------------------------------- +int FilterParameter::getGroupIndex() const +{ + return m_GroupIndex; +} + +// ----------------------------------------------------------------------------- +void FilterParameter::setDefaultValue(const QVariant& value) +{ + m_DefaultValue = value; +} + +// ----------------------------------------------------------------------------- +QVariant FilterParameter::getDefaultValue() const +{ + return m_DefaultValue; +} diff --git a/Source/SIMPLib/FilterParameters/FilterParameter.h b/Source/SIMPLib/FilterParameters/FilterParameter.h old mode 100755 new mode 100644 index e965aa7bf7..53a91b57e3 --- a/Source/SIMPLib/FilterParameters/FilterParameter.h +++ b/Source/SIMPLib/FilterParameters/FilterParameter.h @@ -1,50 +1,47 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once #include +#include - -#include -#include #include +#include #include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataContainers/DataArrayPath.h" class AbstractFilter; @@ -59,65 +56,167 @@ class AbstractFilter; */ class SIMPLib_EXPORT FilterParameter { - public: - SIMPL_SHARED_POINTERS(FilterParameter) - SIMPL_TYPE_MACRO(FilterParameter) - - enum Category - { - Parameter = 0, - RequiredArray = 1, - CreatedArray = 2, - Uncategorized = 3 - }; - - virtual ~FilterParameter(); - - SIMPL_INSTANCE_STRING_PROPERTY(HumanLabel) - SIMPL_INSTANCE_STRING_PROPERTY(PropertyName) - - /** - * @brief getWidgetType This is a pure virtual function. All subclasses need - * to implement this function. - * @return - */ - virtual QString getWidgetType() const = 0; - - SIMPL_VIRTUAL_INSTANCE_PROPERTY(QVariant, DefaultValue) - SIMPL_INSTANCE_PROPERTY(Category, Category) - SIMPL_INSTANCE_PROPERTY(bool, ReadOnly) - SIMPL_INSTANCE_PROPERTY(int, GroupIndex) - - /** - * @brief readJson - * @return - */ - virtual void readJson(const QJsonObject &json); - - /** - * @brief writeJson - * @return - */ - virtual void writeJson(QJsonObject &json); - - /** - * @brief Handle DataArrayPath changes if necessary - * @param filter - * @param renamePath - */ - virtual void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath); - - protected: - FilterParameter(); - - public: - FilterParameter(const FilterParameter&) = delete; // Copy Constructor Not Implemented - FilterParameter(FilterParameter&&) = delete; // Move Constructor Not Implemented - FilterParameter& operator=(const FilterParameter&) = delete; // Copy Assignment Not Implemented - FilterParameter& operator=(FilterParameter&&) = delete; // Move Assignment Not Implemented + + // clang-format off + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(FilterParameter) + PYB11_SHARED_POINTERS(FilterParameter) + + PYB11_ENUMERATION(Category) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = FilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for FilterParameter + */ + virtual QString getNameOfClass() const; + /** + * @brief Returns the name of the class for FilterParameter + */ + static QString ClassName(); + + using EnumType = uint32_t; + + enum class Category : EnumType + { + Parameter = 0, + RequiredArray = 1, + CreatedArray = 2, + Uncategorized = 3 + }; + + virtual ~FilterParameter(); + + /** + * @brief Setter property for HumanLabel + */ + void setHumanLabel(const QString& value); + /** + * @brief Getter property for HumanLabel + * @return Value of HumanLabel + */ + QString getHumanLabel() const; + + /** + * @brief Setter property for PropertyName + */ + void setPropertyName(const QString& value); + /** + * @brief Getter property for PropertyName + * @return Value of PropertyName + */ + QString getPropertyName() const; + + /** + * @brief This sets an alternate or legacy property name that was used in past versions of a filter. + * + * This can be useful if the filter changed the name of the property and to keep old pipeline files working + * @param value + */ + void setLegacyPropertyName(const QString& value); + + /** + * @brief Returns the legacy property name + * @return + */ + QString getLegacyPropertyName() const; + + /** + * @brief getWidgetType This is a pure virtual function. All subclasses need + * to implement this function. + * @return + */ + virtual QString getWidgetType() const = 0; + + /** + * @brief Setter property for DefaultValue + */ + virtual void setDefaultValue(const QVariant& value); + + /** + * @brief getDefaultValue + * @return + */ + virtual QVariant getDefaultValue() const; + + /** + * @brief Setter property for Category + */ + void setCategory(const FilterParameter::Category& value); + /** + * @brief Getter property for Category + * @return Value of Category + */ + FilterParameter::Category getCategory() const; + + /** + * @brief Setter property for ReadOnly + */ + void setReadOnly(bool value); + /** + * @brief Getter property for ReadOnly + * @return Value of ReadOnly + */ + bool getReadOnly() const; + + /** + * @brief Setter property for GroupIndex + */ + void setGroupIndex(int value); + /** + * @brief Getter property for GroupIndex + * @return Value of GroupIndex + */ + int getGroupIndex() const; + + /** + * @brief readJson + * @return + */ + virtual void readJson(const QJsonObject& json); + + /** + * @brief writeJson + * @return + */ + virtual void writeJson(QJsonObject& json) const; + + /** + * @brief Handle DataArrayPath changes if necessary + * @param filter + * @param renamePath + */ + virtual void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath); + +protected: + FilterParameter(); + +public: + FilterParameter(const FilterParameter&) = delete; // Copy Constructor Not Implemented + FilterParameter(FilterParameter&&) = delete; // Move Constructor Not Implemented + FilterParameter& operator=(const FilterParameter&) = delete; // Copy Assignment Not Implemented + FilterParameter& operator=(FilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + QVariant m_DefaultValue = {}; + + QString m_HumanLabel = {}; + QString m_PropertyName = {}; + QString m_LegacyPropertyName = {}; + FilterParameter::Category m_Category = {}; + bool m_ReadOnly = {}; + int m_GroupIndex = {}; }; -typedef QVector FilterParameterVector; +using FilterParameterVectorType = std::vector; // ----------------------------------------------------------------------------- // This section of Macros allows each FilterParameter subclass to create a macro @@ -127,71 +226,43 @@ typedef QVector FilterParameterVector; // __VA__ARGS__ // ----------------------------------------------------------------------------- -#define SIMPL_BIND_SETTER(CLASS, PTR, PROP)\ -std::bind(&CLASS::set##PROP, PTR, std::placeholders::_1) +#define SIMPL_BIND_SETTER(CLASS, PTR, PROP) std::bind(&CLASS::set##PROP, PTR, std::placeholders::_1) -#define SIMPL_BIND_GETTER(CLASS, PTR, PROP)\ -std::bind(&CLASS::get##PROP, PTR) +#define SIMPL_BIND_GETTER(CLASS, PTR, PROP) std::bind(&CLASS::get##PROP, PTR) // Define overrides that can be used by the expansion of our main macro. // Each subclass can define a macro that takes up to nine (9) arguments // to the constructor. These macros support a minimum of 4 arguments. -#define SIMPL_NEW_FP_9(Class, Desc, Prop, Category, Filter, Index, A, B, C, D)\ - Class::New(Desc, #Prop, get##Prop(), Category,\ - SIMPL_BIND_SETTER(Filter, this, Prop),\ - SIMPL_BIND_GETTER(Filter, this, Prop),\ - Index, A, B, C, D) - -#define SIMPL_NEW_FP_8(Class, Desc, Prop, Category, Filter, Index, A, B, C)\ - Class::New(Desc, #Prop, get##Prop(), Category,\ - SIMPL_BIND_SETTER(Filter, this, Prop),\ - SIMPL_BIND_GETTER(Filter, this, Prop),\ - Index, A, B, C) - -#define SIMPL_NEW_FP_7(Class, Desc, Prop, Category, Filter, Index, A, B)\ - Class::New(Desc, #Prop, get##Prop(), Category,\ - SIMPL_BIND_SETTER(Filter, this, Prop),\ - SIMPL_BIND_GETTER(Filter, this, Prop),\ - Index, A, B) - -#define SIMPL_NEW_FP_6(Class, Desc, Prop, Category, Filter, Index, A)\ - Class::New(Desc, #Prop, get##Prop(), Category,\ - SIMPL_BIND_SETTER(Filter, this, Prop),\ - SIMPL_BIND_GETTER(Filter, this, Prop),\ - Index, A) - -#define SIMPL_NEW_FP_5(Class, Desc, Prop, Category, Filter, Index)\ - Class::New(Desc, #Prop, get##Prop(), Category,\ - SIMPL_BIND_SETTER(Filter, this, Prop),\ - SIMPL_BIND_GETTER(Filter, this, Prop),\ - Index) - -#define SIMPL_NEW_FP_4(Class, Desc, Prop, Category, Filter)\ - Class::New(Desc, #Prop, get##Prop(), Category,\ - SIMPL_BIND_SETTER(Filter, this, Prop),\ - SIMPL_BIND_GETTER(Filter, this, Prop)) - -#define SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP_5(Class, Desc, Prop, Category, Filter, Index)\ - Class::New(Desc, #Prop, get##Prop(), Category,\ - SIMPL_BIND_GETTER(Filter, this, Prop),\ - Index) - -#define SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP_4(Class, Desc, Prop, Category, Filter)\ - Class::New(Desc, #Prop, get##Prop(), Category,\ - SIMPL_BIND_GETTER(Filter, this, Prop)) +#define SIMPL_NEW_FP_9(Class, Desc, Prop, Category, Filter, Index, A, B, C, D) \ + Class::Create(Desc, #Prop, get##Prop(), Category, SIMPL_BIND_SETTER(Filter, this, Prop), SIMPL_BIND_GETTER(Filter, this, Prop), Index, A, B, C, D) + +#define SIMPL_NEW_FP_8(Class, Desc, Prop, Category, Filter, Index, A, B, C) \ + Class::Create(Desc, #Prop, get##Prop(), Category, SIMPL_BIND_SETTER(Filter, this, Prop), SIMPL_BIND_GETTER(Filter, this, Prop), Index, A, B, C) + +#define SIMPL_NEW_FP_7(Class, Desc, Prop, Category, Filter, Index, A, B) \ + Class::Create(Desc, #Prop, get##Prop(), Category, SIMPL_BIND_SETTER(Filter, this, Prop), SIMPL_BIND_GETTER(Filter, this, Prop), Index, A, B) + +#define SIMPL_NEW_FP_6(Class, Desc, Prop, Category, Filter, Index, A) \ + Class::Create(Desc, #Prop, get##Prop(), Category, SIMPL_BIND_SETTER(Filter, this, Prop), SIMPL_BIND_GETTER(Filter, this, Prop), Index, A) +#define SIMPL_NEW_FP_5(Class, Desc, Prop, Category, Filter, Index) \ + Class::Create(Desc, #Prop, get##Prop(), Category, SIMPL_BIND_SETTER(Filter, this, Prop), SIMPL_BIND_GETTER(Filter, this, Prop), Index) + +#define SIMPL_NEW_FP_4(Class, Desc, Prop, Category, Filter) Class::Create(Desc, #Prop, get##Prop(), Category, SIMPL_BIND_SETTER(Filter, this, Prop), SIMPL_BIND_GETTER(Filter, this, Prop)) + +#define SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP_5(Class, Desc, Prop, Category, Filter, Index) Class::Create(Desc, #Prop, get##Prop(), Category, SIMPL_BIND_GETTER(Filter, this, Prop), Index) + +#define SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP_4(Class, Desc, Prop, Category, Filter) Class::Create(Desc, #Prop, get##Prop(), Category, SIMPL_BIND_GETTER(Filter, this, Prop)) /** * @brief This macro is needed for Visual Studio due to differences of VAR_ARGS when * passed to another macro that results in a new macro that needs expansion. */ -#define SIMPL_EXPAND( x ) x +#define SIMPL_EXPAND(x) x // ----------------------------------------------------------------------------- // Define a macro that uses the "paired, sliding arg list" // technique to select the appropriate override. #define _FP_GET_OVERRIDE(A, B, C, D, E, F, G, H, I, NAME, ...) NAME #define _FP_GET_PREFLIGHTUPDATEDVALUE_OVERRIDE(A, B, C, D, E, NAME, ...) NAME - - diff --git a/Source/SIMPLib/FilterParameters/Float2ndOrderPolynomial.cpp b/Source/SIMPLib/FilterParameters/Float2ndOrderPolynomial.cpp new file mode 100644 index 0000000000..a43cf080a9 --- /dev/null +++ b/Source/SIMPLib/FilterParameters/Float2ndOrderPolynomial.cpp @@ -0,0 +1,76 @@ +/* ============================================================================ + * Copyright (c) 2021-2021 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include "Float2ndOrderPolynomial.h" + +// ----------------------------------------------------------------------------- +Float2ndOrderPolynomial::Float2ndOrderPolynomial() = default; + +// ----------------------------------------------------------------------------- +Float2ndOrderPolynomial::~Float2ndOrderPolynomial() = default; + +// ----------------------------------------------------------------------------- +Float2ndOrderPolynomial::Float2ndOrderPolynomial(float c00, float c01, float c10, float c11, float c02, float c20) +: c20(c20) +, c02(c02) +, c11(c11) +, c10(c10) +, c01(c01) +, c00(c00) +{ +} + +// ----------------------------------------------------------------------------- +void Float2ndOrderPolynomial::writeJson(QJsonObject& json) const +{ + json["c20"] = c20; + json["c02"] = c02; + json["c11"] = c11; + json["c10"] = c10; + json["c01"] = c01; + json["c00"] = c00; +} + +// ----------------------------------------------------------------------------- +bool Float2ndOrderPolynomial::readJson(const QJsonObject& json) +{ + if(json["c20"].isDouble() && json["c02"].isDouble() && json["c11"].isDouble() && json["c10"].isDouble() && json["c01"].isDouble() && json["c00"].isDouble()) + { + c20 = static_cast(json["c20"].toDouble()); + c02 = static_cast(json["c02"].toDouble()); + c11 = static_cast(json["c11"].toDouble()); + c10 = static_cast(json["c10"].toDouble()); + c01 = static_cast(json["c01"].toDouble()); + c00 = static_cast(json["c00"].toDouble()); + return true; + } + return false; +} diff --git a/Source/SIMPLib/FilterParameters/Float2ndOrderPolynomial.h b/Source/SIMPLib/FilterParameters/Float2ndOrderPolynomial.h new file mode 100644 index 0000000000..1f56d2155e --- /dev/null +++ b/Source/SIMPLib/FilterParameters/Float2ndOrderPolynomial.h @@ -0,0 +1,86 @@ +/* ============================================================================ + * Copyright (c) 2021-2021 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#pragma once +#include +#include +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLPythonMacros.h" + +/** + * @brief The Float2ndOrderPolynomial class + */ +class SIMPLib_EXPORT Float2ndOrderPolynomial +{ + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(Float2ndOrderPolynomial) + PYB11_CREATION(float float float float float float) + PYB11_END_BINDINGS() + // End Python bindings declarations +public: + Float2ndOrderPolynomial(); + ~Float2ndOrderPolynomial(); + + /** + * @brief Float2ndOrderPolynomial + * @param c00 + * @param c01 + * @param c10 + * @param c11 + * @param c02 + * @param c20 + */ + Float2ndOrderPolynomial(float c00, float c01, float c10, float c11, float c02, float c20); + + float c20 = 0.0f; + float c02 = 0.0f; + float c11 = 0.0f; + float c10 = 0.0f; + float c01 = 0.0f; + float c00 = 0.0f; + + /** + * @brief writeJson + * @param json + */ + void writeJson(QJsonObject& json) const; + + /** + * @brief readJson + * @param json + * @return + */ + bool readJson(const QJsonObject& json); +}; + +Q_DECLARE_METATYPE(Float2ndOrderPolynomial) diff --git a/Source/SIMPLib/FilterParameters/Float4thOrderPolynomial.cpp b/Source/SIMPLib/FilterParameters/Float4thOrderPolynomial.cpp new file mode 100644 index 0000000000..13df9554ed --- /dev/null +++ b/Source/SIMPLib/FilterParameters/Float4thOrderPolynomial.cpp @@ -0,0 +1,69 @@ +#include "Float4thOrderPolynomial.h" + +Float4thOrderPolynomial::Float4thOrderPolynomial() = default; + +Float4thOrderPolynomial::~Float4thOrderPolynomial() = default; + +Float4thOrderPolynomial::Float4thOrderPolynomial(float c00, float c01, float c10, float c11, float c02, float c20, float c12, float c21, float c03, float c30, float c22, float c13, float c31, + float c04, float c40) +: c40(c40) +, c04(c04) +, c31(c31) +, c13(c13) +, c22(c22) +, c30(c30) +, c03(c03) +, c21(c21) +, c12(c12) +, c20(c20) +, c02(c02) +, c11(c11) +, c10(c10) +, c01(c01) +, c00(c00) +{ +} +void Float4thOrderPolynomial::writeJson(QJsonObject& json) const +{ + json["c40"] = static_cast(c40); + json["c04"] = static_cast(c04); + json["c31"] = static_cast(c31); + json["c13"] = static_cast(c13); + json["c22"] = static_cast(c22); + json["c30"] = static_cast(c30); + json["c03"] = static_cast(c03); + json["c21"] = static_cast(c21); + json["c12"] = static_cast(c12); + json["c20"] = static_cast(c20); + json["c02"] = static_cast(c02); + json["c11"] = static_cast(c11); + json["c10"] = static_cast(c10); + json["c01"] = static_cast(c01); + json["c00"] = static_cast(c00); +} + +bool Float4thOrderPolynomial::readJson(const QJsonObject& json) +{ + if(json["c40"].isDouble() && json["c04"].isDouble() && json["c31"].isDouble() && json["c13"].isDouble() && json["c22"].isDouble() && json["c30"].isDouble() && json["c03"].isDouble() && + json["c21"].isDouble() && json["c12"].isDouble() && json["c20"].isDouble() && json["c02"].isDouble() && json["c11"].isDouble() && json["c10"].isDouble() && json["c01"].isDouble() && + json["c00"].isDouble()) + { + c40 = static_cast(json["c40"].toDouble()); + c04 = static_cast(json["c04"].toDouble()); + c31 = static_cast(json["c31"].toDouble()); + c13 = static_cast(json["c13"].toDouble()); + c22 = static_cast(json["c22"].toDouble()); + c30 = static_cast(json["c30"].toDouble()); + c03 = static_cast(json["c03"].toDouble()); + c21 = static_cast(json["c21"].toDouble()); + c12 = static_cast(json["c12"].toDouble()); + c20 = static_cast(json["c20"].toDouble()); + c02 = static_cast(json["c02"].toDouble()); + c11 = static_cast(json["c11"].toDouble()); + c10 = static_cast(json["c10"].toDouble()); + c01 = static_cast(json["c01"].toDouble()); + c00 = static_cast(json["c00"].toDouble()); + return true; + } + return false; +} diff --git a/Source/SIMPLib/FilterParameters/Float4thOrderPolynomial.h b/Source/SIMPLib/FilterParameters/Float4thOrderPolynomial.h new file mode 100644 index 0000000000..fd0c239ecb --- /dev/null +++ b/Source/SIMPLib/FilterParameters/Float4thOrderPolynomial.h @@ -0,0 +1,53 @@ +#pragma once + +#include +#include +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLPythonMacros.h" + +class SIMPLib_EXPORT Float4thOrderPolynomial +{ + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(Float4thOrderPolynomial) + PYB11_CREATION(float float float float float float float float float float float float float float float) + PYB11_END_BINDINGS() + // End Python bindings declarations +public: + Float4thOrderPolynomial(); + ~Float4thOrderPolynomial(); + + Float4thOrderPolynomial(float c00, float c01, float c10, float c11, float c02, float c20, float c12, float c21, float c03, float c30, float c22, float c13, float c31, float c04, float c40); + + float c40 = 0.0f; + float c04 = 0.0f; + float c31 = 0.0f; + float c13 = 0.0f; + float c22 = 0.0f; + float c30 = 0.0f; + float c03 = 0.0f; + float c21 = 0.0f; + float c12 = 0.0f; + float c20 = 0.0f; + float c02 = 0.0f; + float c11 = 0.0f; + float c10 = 0.0f; + float c01 = 0.0f; + float c00 = 0.0f; + + /** + * @brief writeJson + * @param json + */ + void writeJson(QJsonObject& json) const; + + /** + * @brief readJson + * @param json + * @return + */ + bool readJson(const QJsonObject& json); +}; + +Q_DECLARE_METATYPE(Float4thOrderPolynomial) diff --git a/Source/SIMPLib/FilterParameters/FloatFilterParameter.cpp b/Source/SIMPLib/FilterParameters/FloatFilterParameter.cpp index c7bfa9348d..9a7af51931 100644 --- a/Source/SIMPLib/FilterParameters/FloatFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/FloatFilterParameter.cpp @@ -1,33 +1,33 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "FloatFilterParameter.h" @@ -44,9 +44,8 @@ FloatFilterParameter::~FloatFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatFilterParameter::Pointer FloatFilterParameter::New(const QString& humanLabel, const QString& propertyName, - const float& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex) +FloatFilterParameter::Pointer FloatFilterParameter::Create(const QString& humanLabel, const QString& propertyName, float defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex) { FloatFilterParameter::Pointer ptr = FloatFilterParameter::New(); @@ -75,6 +74,10 @@ QString FloatFilterParameter::getWidgetType() const void FloatFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { float f = static_cast(jsonValue.toDouble()); @@ -85,10 +88,59 @@ void FloatFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FloatFilterParameter::writeJson(QJsonObject& json) +void FloatFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { json[getPropertyName()] = m_GetterCallback(); } } + +// ----------------------------------------------------------------------------- +FloatFilterParameter::Pointer FloatFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +FloatFilterParameter::Pointer FloatFilterParameter::New() +{ + Pointer sharedPtr(new(FloatFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString FloatFilterParameter::getNameOfClass() const +{ + return QString("FloatFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString FloatFilterParameter::ClassName() +{ + return QString("FloatFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void FloatFilterParameter::setSetterCallback(const FloatFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +FloatFilterParameter::SetterCallbackType FloatFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void FloatFilterParameter::setGetterCallback(const FloatFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +FloatFilterParameter::GetterCallbackType FloatFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/FloatFilterParameter.h b/Source/SIMPLib/FilterParameters/FloatFilterParameter.h index 97ad2c875d..b33409eeed 100644 --- a/Source/SIMPLib/FilterParameters/FloatFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/FloatFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" @@ -49,13 +51,10 @@ * SIMPL_NEW_FLOAT_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): - * SIMPL_NEW_FLOAT_FP("Float 2", Float2, FilterParameter::Parameter, GenericExample); + * SIMPL_NEW_FLOAT_FP("Float 2", Float2, FilterParameter::Category::Parameter, GenericExample); */ -#define SIMPL_NEW_FLOAT_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (FloatFilterParameter, __VA_ARGS__)) - +#define SIMPL_NEW_FLOAT_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(FloatFilterParameter, __VA_ARGS__)) /** * @brief The FloatFilterParameter class is used by filters to instantiate an FloatWidget. By instantiating an instance of @@ -63,81 +62,122 @@ */ class SIMPLib_EXPORT FloatFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(FloatFilterParameter) - SIMPL_STATIC_NEW_MACRO(FloatFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(FloatFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the FloatFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_FLOAT_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const float& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); - - ~FloatFilterParameter() override; - - /** + + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(FloatFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(FloatFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations + +public: + using Self = FloatFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for FloatFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for FloatFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the FloatFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_FLOAT_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, float defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~FloatFilterParameter() override; + + /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief FloatFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - FloatFilterParameter(); - - public: - FloatFilterParameter(const FloatFilterParameter&) = delete; // Copy Constructor Not Implemented - FloatFilterParameter(FloatFilterParameter&&) = delete; // Move Constructor Not Implemented - FloatFilterParameter& operator=(const FloatFilterParameter&) = delete; // Copy Assignment Not Implemented - FloatFilterParameter& operator=(FloatFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + QString getWidgetType() const override; + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const FloatFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + FloatFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const FloatFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + FloatFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief FloatFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + FloatFilterParameter(); + +public: + FloatFilterParameter(const FloatFilterParameter&) = delete; // Copy Constructor Not Implemented + FloatFilterParameter(FloatFilterParameter&&) = delete; // Move Constructor Not Implemented + FloatFilterParameter& operator=(const FloatFilterParameter&) = delete; // Copy Assignment Not Implemented + FloatFilterParameter& operator=(FloatFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + FloatFilterParameter::SetterCallbackType m_SetterCallback = {}; + FloatFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.cpp b/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.cpp index 6c258d32d3..9a3c9e703b 100644 --- a/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.cpp @@ -1,35 +1,35 @@ /* ============================================================================ -* Copyright (c) 2016-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-10-D-5210 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2016-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-10-D-5210 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "FloatVec2FilterParameter.h" @@ -46,8 +46,8 @@ FloatVec2FilterParameter::~FloatVec2FilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatVec2FilterParameter::Pointer FloatVec2FilterParameter::New(const QString& humanLabel, const QString& propertyName, const FloatVec2_t& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) +FloatVec2FilterParameter::Pointer FloatVec2FilterParameter::Create(const QString& humanLabel, const QString& propertyName, const FloatVec2Type& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { FloatVec2FilterParameter::Pointer ptr = FloatVec2FilterParameter::New(); @@ -78,11 +78,19 @@ QString FloatVec2FilterParameter::getWidgetType() const void FloatVec2FilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { - QJsonObject obj = jsonValue.toObject(); - FloatVec2_t floatVec2; - floatVec2.readJson(obj); + QJsonObject json = jsonValue.toObject(); + FloatVec2Type floatVec2; + if(json["x"].isDouble() && json["y"].isDouble()) + { + floatVec2[0] = static_cast(json["x"].toDouble()); + floatVec2[1] = static_cast(json["y"].toDouble()); + } m_SetterCallback(floatVec2); } } @@ -90,13 +98,63 @@ void FloatVec2FilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FloatVec2FilterParameter::writeJson(QJsonObject& json) +void FloatVec2FilterParameter::writeJson(QJsonObject& obj) const { - if (m_GetterCallback) + if(m_GetterCallback) { - FloatVec2_t floatVec2 = m_GetterCallback(); - QJsonObject obj; - floatVec2.writeJson(obj); - json[getPropertyName()] = obj; + FloatVec2Type floatVec2 = m_GetterCallback(); + QJsonObject json; + json["x"] = static_cast(floatVec2.getX()); + json["y"] = static_cast(floatVec2.getY()); + obj[getPropertyName()] = json; } } + +// ----------------------------------------------------------------------------- +FloatVec2FilterParameter::Pointer FloatVec2FilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +FloatVec2FilterParameter::Pointer FloatVec2FilterParameter::New() +{ + Pointer sharedPtr(new(FloatVec2FilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString FloatVec2FilterParameter::getNameOfClass() const +{ + return QString("FloatVec2FilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString FloatVec2FilterParameter::ClassName() +{ + return QString("FloatVec2FilterParameter"); +} + +// ----------------------------------------------------------------------------- +void FloatVec2FilterParameter::setSetterCallback(const FloatVec2FilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +FloatVec2FilterParameter::SetterCallbackType FloatVec2FilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void FloatVec2FilterParameter::setGetterCallback(const FloatVec2FilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +FloatVec2FilterParameter::GetterCallbackType FloatVec2FilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.h b/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.h index 3e1898b168..6b406e5d6e 100644 --- a/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.h +++ b/Source/SIMPLib/FilterParameters/FloatVec2FilterParameter.h @@ -1,50 +1,51 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include +#include -#include #include -#include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/FilterParameters/FilterParameter.h" -#include "SIMPLib/FilterParameters/FloatVec2.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLArray.hpp" +#include "SIMPLib/FilterParameters/FilterParameter.h" /** * @brief SIMPL_NEW_FLOAT_VEC3_FP This macro is a short-form way of instantiating an instance of @@ -56,12 +57,10 @@ * SIMPL_NEW_FLOAT_VEC3_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): - * SIMPL_NEW_FLOAT_VEC3_FP("Origin", Origin, FilterParameter::Parameter, GenericExample, 1); + * SIMPL_NEW_FLOAT_VEC3_FP("Origin", Origin, FilterParameter::Category::Parameter, GenericExample, 1); */ -#define SIMPL_NEW_FLOAT_VEC2_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (FloatVec2FilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_FLOAT_VEC2_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(FloatVec2FilterParameter, __VA_ARGS__)) /** * @brief The FloatVec2FilterParameter class is used by filters to instantiate an FloatVec2Widget. By instantiating an instance of @@ -69,80 +68,122 @@ */ class SIMPLib_EXPORT FloatVec2FilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(FloatVec2FilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(FloatVec2FilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(FloatVec2FilterParameter) - SIMPL_STATIC_NEW_MACRO(FloatVec2FilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(FloatVec2FilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the FloatVec2FilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_FLOAT_VEC3_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const FloatVec2_t& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); - - ~FloatVec2FilterParameter() override; + using Self = FloatVec2FilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for FloatVec2FilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for FloatVec2FilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the FloatVec2FilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_FLOAT_VEC3_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const FloatVec2Type& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~FloatVec2FilterParameter() override; /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @return The SetterCallback - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief FloatVec2FilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const FloatVec2FilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + FloatVec2FilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const FloatVec2FilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + FloatVec2FilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief FloatVec2FilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ FloatVec2FilterParameter(); public: - FloatVec2FilterParameter(const FloatVec2FilterParameter&) = delete; // Copy Constructor Not Implemented - FloatVec2FilterParameter(FloatVec2FilterParameter&&) = delete; // Move Constructor Not Implemented + FloatVec2FilterParameter(const FloatVec2FilterParameter&) = delete; // Copy Constructor Not Implemented + FloatVec2FilterParameter(FloatVec2FilterParameter&&) = delete; // Move Constructor Not Implemented FloatVec2FilterParameter& operator=(const FloatVec2FilterParameter&) = delete; // Copy Assignment Not Implemented FloatVec2FilterParameter& operator=(FloatVec2FilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + FloatVec2FilterParameter::SetterCallbackType m_SetterCallback = {}; + FloatVec2FilterParameter::GetterCallbackType m_GetterCallback = {}; }; +Q_DECLARE_METATYPE(FloatVec2Type) diff --git a/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.cpp b/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.cpp index fb1e71e225..7f042b68d0 100644 --- a/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "FloatVec3FilterParameter.h" @@ -48,8 +48,8 @@ FloatVec3FilterParameter::~FloatVec3FilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatVec3FilterParameter::Pointer FloatVec3FilterParameter::New(const QString& humanLabel, const QString& propertyName, const FloatVec3_t& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) +FloatVec3FilterParameter::Pointer FloatVec3FilterParameter::Create(const QString& humanLabel, const QString& propertyName, const FloatVec3Type& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { FloatVec3FilterParameter::Pointer ptr = FloatVec3FilterParameter::New(); @@ -80,11 +80,20 @@ QString FloatVec3FilterParameter::getWidgetType() const void FloatVec3FilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { - QJsonObject obj = jsonValue.toObject(); - FloatVec3_t floatVec3; - floatVec3.readJson(obj); + QJsonObject json = jsonValue.toObject(); + FloatVec3Type floatVec3; + if(json["x"].isDouble() && json["y"].isDouble() && json["z"].isDouble()) + { + floatVec3[0] = static_cast(json["x"].toDouble()); + floatVec3[1] = static_cast(json["y"].toDouble()); + floatVec3[2] = static_cast(json["z"].toDouble()); + } m_SetterCallback(floatVec3); } } @@ -92,13 +101,64 @@ void FloatVec3FilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FloatVec3FilterParameter::writeJson(QJsonObject& json) +void FloatVec3FilterParameter::writeJson(QJsonObject& obj) const { - if (m_GetterCallback) + if(m_GetterCallback) { - FloatVec3_t floatVec3 = m_GetterCallback(); - QJsonObject obj; - floatVec3.writeJson(obj); - json[getPropertyName()] = obj; + FloatVec3Type floatVec3 = m_GetterCallback(); + QJsonObject json; + json["x"] = static_cast(floatVec3.getX()); + json["y"] = static_cast(floatVec3.getY()); + json["z"] = static_cast(floatVec3.getZ()); + obj[getPropertyName()] = json; } } + +// ----------------------------------------------------------------------------- +FloatVec3FilterParameter::Pointer FloatVec3FilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +FloatVec3FilterParameter::Pointer FloatVec3FilterParameter::New() +{ + Pointer sharedPtr(new(FloatVec3FilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString FloatVec3FilterParameter::getNameOfClass() const +{ + return QString("FloatVec3FilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString FloatVec3FilterParameter::ClassName() +{ + return QString("FloatVec3FilterParameter"); +} + +// ----------------------------------------------------------------------------- +void FloatVec3FilterParameter::setSetterCallback(const FloatVec3FilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +FloatVec3FilterParameter::SetterCallbackType FloatVec3FilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void FloatVec3FilterParameter::setGetterCallback(const FloatVec3FilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +FloatVec3FilterParameter::GetterCallbackType FloatVec3FilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.h b/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.h old mode 100755 new mode 100644 index 5615c31635..b17eb1380b --- a/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.h +++ b/Source/SIMPLib/FilterParameters/FloatVec3FilterParameter.h @@ -1,50 +1,51 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include +#include -#include #include -#include +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/FilterParameters/FilterParameter.h" -#include "SIMPLib/FilterParameters/FloatVec3.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLArray.hpp" +#include "SIMPLib/FilterParameters/FilterParameter.h" /** * @brief SIMPL_NEW_FLOAT_VEC3_FP This macro is a short-form way of instantiating an instance of @@ -56,12 +57,10 @@ * SIMPL_NEW_FLOAT_VEC3_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): - * SIMPL_NEW_FLOAT_VEC3_FP("Origin", Origin, FilterParameter::Parameter, GenericExample, 1); + * SIMPL_NEW_FLOAT_VEC3_FP("Origin", Origin, FilterParameter::Category::Parameter, GenericExample, 1); */ -#define SIMPL_NEW_FLOAT_VEC3_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (FloatVec3FilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_FLOAT_VEC3_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(FloatVec3FilterParameter, __VA_ARGS__)) /** * @brief The FloatVec3FilterParameter class is used by filters to instantiate an FloatVec3Widget. By instantiating an instance of @@ -69,80 +68,122 @@ */ class SIMPLib_EXPORT FloatVec3FilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(FloatVec3FilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(FloatVec3FilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(FloatVec3FilterParameter) - SIMPL_STATIC_NEW_MACRO(FloatVec3FilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(FloatVec3FilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the FloatVec3FilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_FLOAT_VEC3_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const FloatVec3_t& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); - - ~FloatVec3FilterParameter() override; + using Self = FloatVec3FilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for FloatVec3FilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for FloatVec3FilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the FloatVec3FilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_FLOAT_VEC3_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const FloatVec3Type& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~FloatVec3FilterParameter() override; /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @return The SetterCallback - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief FloatVec3FilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const FloatVec3FilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + FloatVec3FilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const FloatVec3FilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + FloatVec3FilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief FloatVec3FilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ FloatVec3FilterParameter(); public: - FloatVec3FilterParameter(const FloatVec3FilterParameter&) = delete; // Copy Constructor Not Implemented - FloatVec3FilterParameter(FloatVec3FilterParameter&&) = delete; // Move Constructor Not Implemented + FloatVec3FilterParameter(const FloatVec3FilterParameter&) = delete; // Copy Constructor Not Implemented + FloatVec3FilterParameter(FloatVec3FilterParameter&&) = delete; // Move Constructor Not Implemented FloatVec3FilterParameter& operator=(const FloatVec3FilterParameter&) = delete; // Copy Assignment Not Implemented FloatVec3FilterParameter& operator=(FloatVec3FilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + FloatVec3FilterParameter::SetterCallbackType m_SetterCallback = {}; + FloatVec3FilterParameter::GetterCallbackType m_GetterCallback = {}; }; +Q_DECLARE_METATYPE(FloatVec3Type) diff --git a/Source/SIMPLib/FilterParameters/FourthOrderPolynomialFilterParameter.cpp b/Source/SIMPLib/FilterParameters/FourthOrderPolynomialFilterParameter.cpp index a96fc9b567..1319a4afde 100644 --- a/Source/SIMPLib/FilterParameters/FourthOrderPolynomialFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/FourthOrderPolynomialFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "FourthOrderPolynomialFilterParameter.h" @@ -48,8 +48,9 @@ FourthOrderPolynomialFilterParameter::~FourthOrderPolynomialFilterParameter() = // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FourthOrderPolynomialFilterParameter::Pointer FourthOrderPolynomialFilterParameter::New(const QString& humanLabel, const QString& propertyName, const Float4thOrderPoly_t& defaultValue, - Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) +FourthOrderPolynomialFilterParameter::Pointer FourthOrderPolynomialFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const Float4thOrderPolynomial& defaultValue, + Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + int groupIndex) { FourthOrderPolynomialFilterParameter::Pointer ptr = FourthOrderPolynomialFilterParameter::New(); @@ -80,10 +81,14 @@ QString FourthOrderPolynomialFilterParameter::getWidgetType() const void FourthOrderPolynomialFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonObject obj = jsonValue.toObject(); - Float4thOrderPoly_t poly; + Float4thOrderPolynomial poly; poly.readJson(obj); m_SetterCallback(poly); } @@ -92,13 +97,62 @@ void FourthOrderPolynomialFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FourthOrderPolynomialFilterParameter::writeJson(QJsonObject& json) +void FourthOrderPolynomialFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { - Float4thOrderPoly_t poly = m_GetterCallback(); + Float4thOrderPolynomial poly = m_GetterCallback(); QJsonObject obj; poly.writeJson(obj); json[getPropertyName()] = obj; } } + +// ----------------------------------------------------------------------------- +FourthOrderPolynomialFilterParameter::Pointer FourthOrderPolynomialFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +FourthOrderPolynomialFilterParameter::Pointer FourthOrderPolynomialFilterParameter::New() +{ + Pointer sharedPtr(new(FourthOrderPolynomialFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString FourthOrderPolynomialFilterParameter::getNameOfClass() const +{ + return QString("FourthOrderPolynomialFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString FourthOrderPolynomialFilterParameter::ClassName() +{ + return QString("FourthOrderPolynomialFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void FourthOrderPolynomialFilterParameter::setSetterCallback(const FourthOrderPolynomialFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +FourthOrderPolynomialFilterParameter::SetterCallbackType FourthOrderPolynomialFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void FourthOrderPolynomialFilterParameter::setGetterCallback(const FourthOrderPolynomialFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +FourthOrderPolynomialFilterParameter::GetterCallbackType FourthOrderPolynomialFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/FourthOrderPolynomialFilterParameter.h b/Source/SIMPLib/FilterParameters/FourthOrderPolynomialFilterParameter.h old mode 100755 new mode 100644 index 84cd6f99f5..8a13f66890 --- a/Source/SIMPLib/FilterParameters/FourthOrderPolynomialFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/FourthOrderPolynomialFilterParameter.h @@ -1,127 +1,46 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" - -typedef struct -{ - float c40; float c04; - float c31; float c13; - float c22; - float c30; float c03; - float c21; float c12; float c20; float c02; - float c11; float c10; float c01; float c00; - - void Float4thOrderPoly(const float& C40, const float& C04, - const float& C31, const float& C13, - const float& C22, - const float& C30, const float& C03, - const float& C21, const float& C12, const float& C20, const float& C02, - const float& C11, const float& C10, const float& C01, const float& C00 - ) - { - c40 = C40; - c04 = C04; - c31 = C31; - c13 = C13; - c22 = C22; - c30 = C30; - c03 = C03; - c21 = C21; - c12 = C12; - c20 = C20; - c02 = C02; - c11 = C11; - c10 = C10; - c01 = C01; - c00 = C00; - } - - void writeJson(QJsonObject &json) - { - json["c40"] = static_cast(c40); - json["c04"] = static_cast(c04); - json["c31"] = static_cast(c31); - json["c13"] = static_cast(c13); - json["c22"] = static_cast(c22); - json["c30"] = static_cast(c30); - json["c03"] = static_cast(c03); - json["c21"] = static_cast(c21); - json["c12"] = static_cast(c12); - json["c20"] = static_cast(c20); - json["c02"] = static_cast(c02); - json["c11"] = static_cast(c11); - json["c10"] = static_cast(c10); - json["c01"] = static_cast(c01); - json["c00"] = static_cast(c00); - } - - bool readJson(QJsonObject &json) - { - if (json["c40"].isDouble() && json["c04"].isDouble() && json["c31"].isDouble() && json["c13"].isDouble() - && json["c22"].isDouble() && json["c30"].isDouble() && json["c03"].isDouble() && json["c21"].isDouble() - && json["c12"].isDouble() && json["c20"].isDouble() && json["c02"].isDouble() && json["c11"].isDouble() - && json["c10"].isDouble() && json["c01"].isDouble() && json["c00"].isDouble()) - { - c40 = static_cast(json["c40"].toDouble()); - c04 = static_cast(json["c04"].toDouble()); - c31 = static_cast(json["c31"].toDouble()); - c13 = static_cast(json["c13"].toDouble()); - c22 = static_cast(json["c22"].toDouble()); - c30 = static_cast(json["c30"].toDouble()); - c03 = static_cast(json["c03"].toDouble()); - c21 = static_cast(json["c21"].toDouble()); - c12 = static_cast(json["c12"].toDouble()); - c20 = static_cast(json["c20"].toDouble()); - c02 = static_cast(json["c02"].toDouble()); - c11 = static_cast(json["c11"].toDouble()); - c10 = static_cast(json["c10"].toDouble()); - c01 = static_cast(json["c01"].toDouble()); - c00 = static_cast(json["c00"].toDouble()); - return true; - } - return false; - } -} Float4thOrderPoly_t; - -Q_DECLARE_METATYPE(Float4thOrderPoly_t) - +#include "SIMPLib/FilterParameters/Float4thOrderPolynomial.h" /** * @brief SIMPL_NEW_FourthO_POLY_FP This macro is a short-form way of instantiating an instance of * FourthOrderPolynomialFilterParameter. There are 4 required parameters and 1 optional parameter @@ -132,12 +51,10 @@ Q_DECLARE_METATYPE(Float4thOrderPoly_t) * SIMPL_NEW_FourthO_POLY_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): - * SIMPL_NEW_FourthO_POLY_FP("Fourth Order A Coefficients", FourthOrderACoeff, FilterParameter::Parameter, GenericExample, 2); + * SIMPL_NEW_FourthO_POLY_FP("Fourth Order A Coefficients", FourthOrderACoeff, FilterParameter::Category::Parameter, GenericExample, 2); */ -#define SIMPL_NEW_FourthO_POLY_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (FourthOrderPolynomialFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_FourthO_POLY_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(FourthOrderPolynomialFilterParameter, __VA_ARGS__)) /** * @brief The FourthOrderPolynomialFilterParameter class is used by filters to instantiate an FourthOrderPolynomialWidget. By instantiating an instance of @@ -145,80 +62,120 @@ Q_DECLARE_METATYPE(Float4thOrderPoly_t) */ class SIMPLib_EXPORT FourthOrderPolynomialFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(FourthOrderPolynomialFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(FourthOrderPolynomialFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(FourthOrderPolynomialFilterParameter) - SIMPL_STATIC_NEW_MACRO(FourthOrderPolynomialFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(FourthOrderPolynomialFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the FourthOrderPolynomialFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_FourthO_POLY_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const Float4thOrderPoly_t& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); - - ~FourthOrderPolynomialFilterParameter() override; + using Self = FourthOrderPolynomialFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the FourthOrderPolynomialFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_FourthO_POLY_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const Float4thOrderPolynomial& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + /** + * @brief Returns the name of the class for FourthOrderPolynomialFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for FourthOrderPolynomialFilterParameter + */ + static QString ClassName(); + + ~FourthOrderPolynomialFilterParameter() override; /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @return The SetterCallback - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief FourthOrderPolynomialFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const FourthOrderPolynomialFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + FourthOrderPolynomialFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const FourthOrderPolynomialFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + FourthOrderPolynomialFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief FourthOrderPolynomialFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ FourthOrderPolynomialFilterParameter(); public: - FourthOrderPolynomialFilterParameter(const FourthOrderPolynomialFilterParameter&) = delete; // Copy Constructor Not Implemented - FourthOrderPolynomialFilterParameter(FourthOrderPolynomialFilterParameter&&) = delete; // Move Constructor Not Implemented + FourthOrderPolynomialFilterParameter(const FourthOrderPolynomialFilterParameter&) = delete; // Copy Constructor Not Implemented + FourthOrderPolynomialFilterParameter(FourthOrderPolynomialFilterParameter&&) = delete; // Move Constructor Not Implemented FourthOrderPolynomialFilterParameter& operator=(const FourthOrderPolynomialFilterParameter&) = delete; // Copy Assignment Not Implemented FourthOrderPolynomialFilterParameter& operator=(FourthOrderPolynomialFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +private: + FourthOrderPolynomialFilterParameter::SetterCallbackType m_SetterCallback = {}; + FourthOrderPolynomialFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/GenerateColorTableFilterParameter.cpp b/Source/SIMPLib/FilterParameters/GenerateColorTableFilterParameter.cpp index 9c297b5fcd..f5a25c7182 100644 --- a/Source/SIMPLib/FilterParameters/GenerateColorTableFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/GenerateColorTableFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "GenerateColorTableFilterParameter.h" @@ -48,8 +48,8 @@ GenerateColorTableFilterParameter::~GenerateColorTableFilterParameter() = defaul // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -GenerateColorTableFilterParameter::Pointer GenerateColorTableFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - GenerateColorTable* filter, int groupIndex) +GenerateColorTableFilterParameter::Pointer GenerateColorTableFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, + GenerateColorTable* filter, int groupIndex) { GenerateColorTableFilterParameter::Pointer ptr = GenerateColorTableFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -85,7 +85,7 @@ void GenerateColorTableFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // THIS IS A SPECIAL CASE AND IS NOT STANDARD. DO NOT COPY THIS CODE. // ----------------------------------------------------------------------------- -void GenerateColorTableFilterParameter::writeJson(QJsonObject& json) +void GenerateColorTableFilterParameter::writeJson(QJsonObject& json) const { QString presetName = m_Filter->getSelectedPresetName(); QJsonArray presetControlPoints = m_Filter->getSelectedPresetControlPoints(); @@ -93,3 +93,40 @@ void GenerateColorTableFilterParameter::writeJson(QJsonObject& json) json["SelectedPresetName"] = presetName; json["SelectedPresetControlPoints"] = presetControlPoints; } + +// ----------------------------------------------------------------------------- +GenerateColorTableFilterParameter::Pointer GenerateColorTableFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +GenerateColorTableFilterParameter::Pointer GenerateColorTableFilterParameter::New() +{ + Pointer sharedPtr(new(GenerateColorTableFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString GenerateColorTableFilterParameter::getNameOfClass() const +{ + return QString("GenerateColorTableFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString GenerateColorTableFilterParameter::ClassName() +{ + return QString("GenerateColorTableFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void GenerateColorTableFilterParameter::setFilter(GenerateColorTable* value) +{ + m_Filter = value; +} + +// ----------------------------------------------------------------------------- +GenerateColorTable* GenerateColorTableFilterParameter::getFilter() const +{ + return m_Filter; +} diff --git a/Source/SIMPLib/FilterParameters/GenerateColorTableFilterParameter.h b/Source/SIMPLib/FilterParameters/GenerateColorTableFilterParameter.h old mode 100755 new mode 100644 index be920e487d..ce2062d959 --- a/Source/SIMPLib/FilterParameters/GenerateColorTableFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/GenerateColorTableFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/CoreFilters/GenerateColorTable.h" @@ -47,60 +49,90 @@ */ class SIMPLib_EXPORT GenerateColorTableFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(GenerateColorTableFilterParameter) - SIMPL_STATIC_NEW_MACRO(GenerateColorTableFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(GenerateColorTableFilterParameter, FilterParameter) - - /** - * @brief New This function instantiates an instance of the DataContainerCreationFilterParameter. - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param filter The corresponding filter that sets all its values into the DataContainerReaderWidget. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, GenerateColorTable* filter, - int groupIndex = -1); - - ~GenerateColorTableFilterParameter() override; - - SIMPL_POINTER_PROPERTY(GenerateColorTable, Filter) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - protected: - /** - * @brief GenerateColorTableFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - GenerateColorTableFilterParameter(); - - public: - GenerateColorTableFilterParameter(const GenerateColorTableFilterParameter&) = delete; // Copy Constructor Not Implemented - GenerateColorTableFilterParameter(GenerateColorTableFilterParameter&&) = delete; // Move Constructor Not Implemented - GenerateColorTableFilterParameter& operator=(const GenerateColorTableFilterParameter&) = delete; // Copy Assignment Not Implemented - GenerateColorTableFilterParameter& operator=(GenerateColorTableFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(GenerateColorTableFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(GenerateColorTableFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = GenerateColorTableFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for GenerateColorTableFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for GenerateColorTableFilterParameter + */ + static QString ClassName(); + + /** + * @brief New This function instantiates an instance of the DataContainerCreationFilterParameter. + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param filter The corresponding filter that sets all its values into the DataContainerReaderWidget. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, GenerateColorTable* filter, int groupIndex = -1); + + ~GenerateColorTableFilterParameter() override; + + /** + * @brief Setter property for Filter + */ + void setFilter(GenerateColorTable* value); + /** + * @brief Getter property for Filter + * @return Value of Filter + */ + GenerateColorTable* getFilter() const; + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + +protected: + /** + * @brief GenerateColorTableFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + GenerateColorTableFilterParameter(); + +public: + GenerateColorTableFilterParameter(const GenerateColorTableFilterParameter&) = delete; // Copy Constructor Not Implemented + GenerateColorTableFilterParameter(GenerateColorTableFilterParameter&&) = delete; // Move Constructor Not Implemented + GenerateColorTableFilterParameter& operator=(const GenerateColorTableFilterParameter&) = delete; // Copy Assignment Not Implemented + GenerateColorTableFilterParameter& operator=(GenerateColorTableFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + GenerateColorTable* m_Filter = nullptr; +}; diff --git a/Source/SIMPLib/FilterParameters/H5FilterParametersConstants.h b/Source/SIMPLib/FilterParameters/H5FilterParametersConstants.h old mode 100755 new mode 100644 index ce149ca5db..8a39ffe710 --- a/Source/SIMPLib/FilterParameters/H5FilterParametersConstants.h +++ b/Source/SIMPLib/FilterParameters/H5FilterParametersConstants.h @@ -1,55 +1,51 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once #include - namespace H5FilterParameter { - const QString ArrayNameConstant = "_ArrayName"; - const QString CompOperatorConstant = "_CompOperator"; - const QString CompValueConstant = "_CompValue"; - const QString AngleConstant = "_Angle"; - const QString ComparisonInput = "_ComparisonInput"; - const QString AxisAngleInput = "_AxisAngleInput"; - const QString HConstant = "_H"; - const QString KConstant = "_K"; - const QString LConstant = "_L"; -} - - +const QString ArrayNameConstant = "_ArrayName"; +const QString CompOperatorConstant = "_CompOperator"; +const QString CompValueConstant = "_CompValue"; +const QString AngleConstant = "_Angle"; +const QString ComparisonInput = "_ComparisonInput"; +const QString AxisAngleInput = "_AxisAngleInput"; +const QString HConstant = "_H"; +const QString KConstant = "_K"; +const QString LConstant = "_L"; +} // namespace H5FilterParameter diff --git a/Source/SIMPLib/FilterParameters/H5FilterParametersReader.cpp b/Source/SIMPLib/FilterParameters/H5FilterParametersReader.cpp index 9c69adf303..1248939e99 100644 --- a/Source/SIMPLib/FilterParameters/H5FilterParametersReader.cpp +++ b/Source/SIMPLib/FilterParameters/H5FilterParametersReader.cpp @@ -1,57 +1,56 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "H5FilterParametersReader.h" #include -#include -#include #include #include "H5Support/H5ScopedSentinel.h" #include "H5Support/QH5Lite.h" #include "H5Support/QH5Utilities.h" -#include "SIMPLib/Filtering/FilterFactory.hpp" -#include "SIMPLib/Filtering/FilterManager.h" - #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Common/QtBackwardCompatibilityMacro.h" #include "SIMPLib/FilterParameters/H5FilterParametersConstants.h" #include "SIMPLib/FilterParameters/JsonFilterParametersReader.h" #include "SIMPLib/FilterParameters/JsonFilterParametersWriter.h" +#include "SIMPLib/Filtering/FilterFactory.hpp" +#include "SIMPLib/Filtering/FilterManager.h" +#include "SIMPLib/Messages/PipelineErrorMessage.h" // ----------------------------------------------------------------------------- // @@ -113,7 +112,7 @@ FilterPipeline::Pointer H5FilterParametersReader::readPipelineFromFile(hid_t fid return FilterPipeline::NullPointer(); } - H5ScopedGroupSentinel sentinel(&pipelineGroupId, true); + H5ScopedGroupSentinel sentinel(pipelineGroupId, true); setPipelineGroupId(pipelineGroupId); @@ -145,8 +144,7 @@ FilterPipeline::Pointer H5FilterParametersReader::readPipelineFromFile(hid_t fid else if(nullptr != obs) { QString ss = QObject::tr("The input file contains an unrecognizable pipeline version number, and is therefore incompatible and cannot be read."); - PipelineMessage pm("", ss, -66066, PipelineMessage::MessageType::Error); - pm.setPrefix("H5FilterParametersReader::ReadPipelineFromFile(...)"); + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New("[NOT_READABLE]", QObject::tr("%1: %2").arg("H5FilterParametersReader::ReadPipelineFromFile(...)").arg(ss), -66066); obs->processPipelineMessage(pm); return FilterPipeline::NullPointer(); } @@ -155,7 +153,7 @@ FilterPipeline::Pointer H5FilterParametersReader::readPipelineFromFile(hid_t fid { // Use QH5Lite to ask how many "groups" are in the "Pipeline Group" QList groupList; - herr_t err = QH5Utilities::getGroupObjects(pipelineGroupId, H5Utilities::H5Support_GROUP, groupList); + herr_t err = QH5Utilities::getGroupObjects(pipelineGroupId, H5Utilities::CustomHDFDataTypes::Group, groupList); // Get a FilterManager Instance FilterManager* filterManager = FilterManager::Instance(); @@ -199,7 +197,7 @@ FilterPipeline::Pointer H5FilterParametersReader::readPipelineFromFile(QString f return FilterPipeline::NullPointer(); } - H5ScopedFileSentinel sentinel(&fid, true); + H5ScopedFileSentinel sentinel(fid, true); FilterPipeline::Pointer pipeline = readPipelineFromFile(fid, obs); return pipeline; @@ -217,7 +215,7 @@ QString H5FilterParametersReader::getJsonFromFile(QString filePath, IObserver* o return QString(); } - H5ScopedFileSentinel sentinel(&fid, true); + H5ScopedFileSentinel sentinel(fid, true); // Open the Pipeline Group hid_t pipelineGroupId = H5Gopen(fid, SIMPL::StringConstants::PipelineGroupName.toLatin1().data(), H5P_DEFAULT); @@ -228,7 +226,7 @@ QString H5FilterParametersReader::getJsonFromFile(QString filePath, IObserver* o return QString(); } - sentinel.addGroupId(&pipelineGroupId); + sentinel.addGroupId(pipelineGroupId); setPipelineGroupId(pipelineGroupId); @@ -254,8 +252,7 @@ QString H5FilterParametersReader::getJsonFromFile(QString filePath, IObserver* o else if(nullptr != obs) { QString ss = QObject::tr("The input file contains an unrecognizable pipeline version number, and is therefore incompatible and cannot be read."); - PipelineMessage pm("", ss, -66066, PipelineMessage::MessageType::Error); - pm.setPrefix("H5FilterParametersReader::ReadPipelineFromFile(...)"); + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New("[NOT_READABLE]", QObject::tr("%1: %2").arg("H5FilterParametersReader::ReadPipelineFromFile(...)").arg(ss), -66066); obs->processPipelineMessage(pm); return QString(); } @@ -264,7 +261,7 @@ QString H5FilterParametersReader::getJsonFromFile(QString filePath, IObserver* o { // Use QH5Lite to ask how many "groups" are in the "Pipeline Group" QList groupList; - herr_t err = QH5Utilities::getGroupObjects(pipelineGroupId, H5Utilities::H5Support_GROUP, groupList); + herr_t err = QH5Utilities::getGroupObjects(pipelineGroupId, H5Utilities::CustomHDFDataTypes::Group, groupList); // Get a FilterManager Instance FilterManager* filterManager = FilterManager::Instance(); @@ -295,8 +292,7 @@ QString H5FilterParametersReader::getJsonFromFile(QString filePath, IObserver* o } JsonFilterParametersWriter::Pointer jsonWriter = JsonFilterParametersWriter::New(); - jsonWriter->setExpandReaderFilters(false); - jsonString = jsonWriter->writePipelineToString(pipeline, ""); + jsonString = jsonWriter->writePipelineToString(pipeline, "", false); } return jsonString; @@ -308,7 +304,7 @@ QString H5FilterParametersReader::getJsonFromFile(QString filePath, IObserver* o int H5FilterParametersReader::openFilterGroup(AbstractFilter* filter, int index) { int err = 0; - + std::ignore = filter; if(m_Version < 0) { if(m_PipelineGroupId <= 0) @@ -361,7 +357,7 @@ int H5FilterParametersReader::closeFilterGroup() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString H5FilterParametersReader::readString(const QString name, QString value) +QString H5FilterParametersReader::readString(const QString& name, QString value) { QString defaultStr = value; value.clear(); @@ -372,13 +368,13 @@ QString H5FilterParametersReader::readString(const QString name, QString value) return value; } - return defaultStr; + return defaultStr; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector H5FilterParametersReader::readStrings(const QString name, QVector value) +QVector H5FilterParametersReader::readStrings(const QString& name, QVector value) { int vectorSize = 0; QString str = ""; @@ -399,7 +395,7 @@ QVector H5FilterParametersReader::readStrings(const QString name, QVect // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QStringList H5FilterParametersReader::readStringList(const QString name, QStringList value) +QStringList H5FilterParametersReader::readStringList(const QString& name, QStringList value) { int vectorSize = 0; QString str = ""; @@ -420,7 +416,7 @@ QStringList H5FilterParametersReader::readStringList(const QString name, QString // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int8_t H5FilterParametersReader::readValue(const QString name, int8_t value) +int8_t H5FilterParametersReader::readValue(const QString& name, int8_t value) { QH5Lite::readScalarDataset(m_CurrentGroupId, name, value); return value; @@ -429,7 +425,7 @@ int8_t H5FilterParametersReader::readValue(const QString name, int8_t value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int16_t H5FilterParametersReader::readValue(const QString name, int16_t value) +int16_t H5FilterParametersReader::readValue(const QString& name, int16_t value) { QH5Lite::readScalarDataset(m_CurrentGroupId, name, value); return value; @@ -438,7 +434,7 @@ int16_t H5FilterParametersReader::readValue(const QString name, int16_t value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int32_t H5FilterParametersReader::readValue(const QString name, int32_t value) +int32_t H5FilterParametersReader::readValue(const QString& name, int32_t value) { QH5Lite::readScalarDataset(m_CurrentGroupId, name, value); return value; @@ -447,7 +443,7 @@ int32_t H5FilterParametersReader::readValue(const QString name, int32_t value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int64_t H5FilterParametersReader::readValue(const QString name, int64_t value) +int64_t H5FilterParametersReader::readValue(const QString& name, int64_t value) { QH5Lite::readScalarDataset(m_CurrentGroupId, name, value); return value; @@ -456,7 +452,7 @@ int64_t H5FilterParametersReader::readValue(const QString name, int64_t value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -uint8_t H5FilterParametersReader::readValue(const QString name, uint8_t value) +uint8_t H5FilterParametersReader::readValue(const QString& name, uint8_t value) { QH5Lite::readScalarDataset(m_CurrentGroupId, name, value); return value; @@ -465,7 +461,7 @@ uint8_t H5FilterParametersReader::readValue(const QString name, uint8_t value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -uint16_t H5FilterParametersReader::readValue(const QString name, uint16_t value) +uint16_t H5FilterParametersReader::readValue(const QString& name, uint16_t value) { QH5Lite::readScalarDataset(m_CurrentGroupId, name, value); return value; @@ -474,7 +470,7 @@ uint16_t H5FilterParametersReader::readValue(const QString name, uint16_t value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -uint32_t H5FilterParametersReader::readValue(const QString name, uint32_t value) +uint32_t H5FilterParametersReader::readValue(const QString& name, uint32_t value) { QH5Lite::readScalarDataset(m_CurrentGroupId, name, value); return value; @@ -483,7 +479,7 @@ uint32_t H5FilterParametersReader::readValue(const QString name, uint32_t value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -uint64_t H5FilterParametersReader::readValue(const QString name, uint64_t value) +uint64_t H5FilterParametersReader::readValue(const QString& name, uint64_t value) { QH5Lite::readScalarDataset(m_CurrentGroupId, name, value); return value; @@ -492,7 +488,7 @@ uint64_t H5FilterParametersReader::readValue(const QString name, uint64_t value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -float H5FilterParametersReader::readValue(const QString name, float value) +float H5FilterParametersReader::readValue(const QString& name, float value) { QH5Lite::readScalarDataset(m_CurrentGroupId, name, value); return value; @@ -501,7 +497,7 @@ float H5FilterParametersReader::readValue(const QString name, float value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -double H5FilterParametersReader::readValue(const QString name, double value) +double H5FilterParametersReader::readValue(const QString& name, double value) { QH5Lite::readScalarDataset(m_CurrentGroupId, name, value); return value; @@ -510,17 +506,16 @@ double H5FilterParametersReader::readValue(const QString name, double value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool H5FilterParametersReader::readValue(const QString name, bool value) +bool H5FilterParametersReader::readValue(const QString& name, bool value) { QH5Lite::readScalarDataset(m_CurrentGroupId, name, value); return value; } - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrix::Type H5FilterParametersReader::readValue(const QString name, AttributeMatrix::Type value) +AttributeMatrix::Type H5FilterParametersReader::readValue(const QString& name, AttributeMatrix::Type value) { uint32_t v = static_cast(value); QH5Lite::readScalarDataset(m_CurrentGroupId, name, v); @@ -531,7 +526,7 @@ AttributeMatrix::Type H5FilterParametersReader::readValue(const QString name, At // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector H5FilterParametersReader::readArray(const QString name, QVector value) +QVector H5FilterParametersReader::readArray(const QString& name, QVector value) { int vectorSize = 0; int8_t scalar = 0; @@ -541,7 +536,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVector< return value; } - value.clear(); + value.clear(); for(int i = 0; i < vectorSize; i++) { @@ -556,7 +551,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVector< // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector H5FilterParametersReader::readArray(const QString name, QVector value) +QVector H5FilterParametersReader::readArray(const QString& name, QVector value) { int vectorSize = 0; int16_t scalar = 0; @@ -566,7 +561,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVector return value; } - value.clear(); + value.clear(); for(int i = 0; i < vectorSize; i++) { @@ -581,7 +576,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVector // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector H5FilterParametersReader::readArray(const QString name, QVector value) +QVector H5FilterParametersReader::readArray(const QString& name, QVector value) { int vectorSize = 0; int32_t scalar = 0; @@ -591,7 +586,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVector return value; } - value.clear(); + value.clear(); for(int i = 0; i < vectorSize; i++) { @@ -607,7 +602,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVector // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector H5FilterParametersReader::readArray(const QString name, QVector value) +QVector H5FilterParametersReader::readArray(const QString& name, QVector value) { int vectorSize = 0; int64_t scalar = 0; @@ -617,7 +612,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVector return value; } - value.clear(); + value.clear(); for(int i = 0; i < vectorSize; i++) { @@ -632,7 +627,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVector // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector H5FilterParametersReader::readArray(const QString name, QVector value) +QVector H5FilterParametersReader::readArray(const QString& name, QVector value) { int vectorSize = 0; uint8_t scalar = 0; @@ -642,7 +637,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVector return value; } - value.clear(); + value.clear(); for(int i = 0; i < vectorSize; i++) { @@ -657,7 +652,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVector // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector H5FilterParametersReader::readArray(const QString name, QVector value) +QVector H5FilterParametersReader::readArray(const QString& name, QVector value) { int vectorSize = 0; uint16_t scalar = 0; @@ -667,7 +662,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVecto return value; } - value.clear(); + value.clear(); for(int i = 0; i < vectorSize; i++) { @@ -682,7 +677,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVecto // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector H5FilterParametersReader::readArray(const QString name, QVector value) +QVector H5FilterParametersReader::readArray(const QString& name, QVector value) { int vectorSize = 0; uint32_t scalar = 0; @@ -692,7 +687,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVecto return value; } - value.clear(); + value.clear(); for(int i = 0; i < vectorSize; i++) { @@ -707,7 +702,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVecto // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector H5FilterParametersReader::readArray(const QString name, QVector value) +QVector H5FilterParametersReader::readArray(const QString& name, QVector value) { int vectorSize = 0; uint64_t scalar = 0; @@ -717,7 +712,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVecto return value; } - value.clear(); + value.clear(); for(int i = 0; i < vectorSize; i++) { @@ -732,7 +727,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVecto // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector H5FilterParametersReader::readArray(const QString name, QVector value) +QVector H5FilterParametersReader::readArray(const QString& name, QVector value) { int vectorSize = 0; float scalar = 0.0f; @@ -742,7 +737,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVector H5FilterParametersReader::readArray(const QString name, QVector H5FilterParametersReader::readArray(const QString name, QVector value) +QVector H5FilterParametersReader::readArray(const QString& name, QVector value) { int vectorSize = 0; double scalar = 0.0; @@ -767,7 +762,7 @@ QVector H5FilterParametersReader::readArray(const QString name, QVector< return value; } - value.clear(); + value.clear(); for(int i = 0; i < vectorSize; i++) { @@ -782,10 +777,10 @@ QVector H5FilterParametersReader::readArray(const QString name, QVector< // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IntVec3_t H5FilterParametersReader::readIntVec3(const QString name, IntVec3_t defaultValue) +IntVec3Type H5FilterParametersReader::readIntVec3(const QString& name, IntVec3Type defaultValue) { int err = 0; - IntVec3_t v; + IntVec3Type v; err = QH5Lite::readPointerDataset(m_CurrentGroupId, name, reinterpret_cast(&v)); if(err < 0) { @@ -798,10 +793,10 @@ IntVec3_t H5FilterParametersReader::readIntVec3(const QString name, IntVec3_t de // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatVec3_t H5FilterParametersReader::readFloatVec3(const QString name, FloatVec3_t defaultValue) +FloatVec3Type H5FilterParametersReader::readFloatVec3(const QString& name, FloatVec3Type defaultValue) { int err = 0; - FloatVec3_t v; + FloatVec3Type v; err = QH5Lite::readPointerDataset(m_CurrentGroupId, name, reinterpret_cast(&v)); if(err < 0) { @@ -813,10 +808,10 @@ FloatVec3_t H5FilterParametersReader::readFloatVec3(const QString name, FloatVec // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -Float2ndOrderPoly_t H5FilterParametersReader::readFloat2ndOrderPoly(const QString name, Float2ndOrderPoly_t defaultValue) +Float2ndOrderPolynomial H5FilterParametersReader::readFloat2ndOrderPoly(const QString& name, Float2ndOrderPolynomial defaultValue) { int err = 0; - Float2ndOrderPoly_t v; + Float2ndOrderPolynomial v; err = QH5Lite::readPointerDataset(m_CurrentGroupId, name, reinterpret_cast(&v)); if(err < 0) { @@ -828,7 +823,7 @@ Float2ndOrderPoly_t H5FilterParametersReader::readFloat2ndOrderPoly(const QStrin // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -Float3rdOrderPoly_t H5FilterParametersReader::readFloat3rdOrderPoly(const QString name, Float3rdOrderPoly_t defaultValue) +Float3rdOrderPoly_t H5FilterParametersReader::readFloat3rdOrderPoly(const QString& name, Float3rdOrderPoly_t defaultValue) { int err = 0; Float3rdOrderPoly_t v; @@ -843,10 +838,10 @@ Float3rdOrderPoly_t H5FilterParametersReader::readFloat3rdOrderPoly(const QStrin // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -Float4thOrderPoly_t H5FilterParametersReader::readFloat4thOrderPoly(const QString name, Float4thOrderPoly_t defaultValue) +Float4thOrderPolynomial H5FilterParametersReader::readFloat4thOrderPoly(const QString& name, Float4thOrderPolynomial defaultValue) { int err = 0; - Float4thOrderPoly_t v; + Float4thOrderPolynomial v; err = QH5Lite::readPointerDataset(m_CurrentGroupId, name, reinterpret_cast(&v)); if(err < 0) { @@ -858,10 +853,10 @@ Float4thOrderPoly_t H5FilterParametersReader::readFloat4thOrderPoly(const QStrin // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FileListInfo_t H5FilterParametersReader::readFileListInfo(const QString name, FileListInfo_t defaultValue) +StackFileListInfo H5FilterParametersReader::readFileListInfo(const QString& name, StackFileListInfo defaultValue) { - FileListInfo_t v; + StackFileListInfo v; hid_t gid = QH5Utilities::openHDF5Object(m_CurrentGroupId, name); if(gid < 0) @@ -912,7 +907,7 @@ FileListInfo_t H5FilterParametersReader::readFileListInfo(const QString name, Fi // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ComparisonInput_t H5FilterParametersReader::readComparisonInput(const QString name, ComparisonInput_t defaultValue, int vectorPos) +ComparisonInput_t H5FilterParametersReader::readComparisonInput(const QString& name, ComparisonInput_t defaultValue, int vectorPos) { // QVector comps(1, defaultValue); ComparisonInputs comps; @@ -927,7 +922,7 @@ ComparisonInput_t H5FilterParametersReader::readComparisonInput(const QString na // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ComparisonInputs H5FilterParametersReader::readComparisonInputs(const QString name, ComparisonInputs defValue) +ComparisonInputs H5FilterParametersReader::readComparisonInputs(const QString& name, ComparisonInputs defValue) { int size = 0; QString strData = ""; @@ -947,7 +942,7 @@ ComparisonInputs H5FilterParametersReader::readComparisonInputs(const QString na // Now read the the attribute that says how many arrays are in the data set. err = QH5Lite::readScalarAttribute(m_CurrentGroupId, name, "NumInputs", size); - QStringList strVector = strData.split('\n', QString::SkipEmptyParts); + QStringList strVector = strData.split('\n', QSTRING_SKIP_EMPTY_PARTS); qint32 strVecSize = strVector.size(); if(strVecSize != size) { @@ -960,7 +955,7 @@ ComparisonInputs H5FilterParametersReader::readComparisonInputs(const QString na for(qint32 i = 0; i < size; ++i) { ComparisonInput_t v; - QStringList tokens = strVector[i].split(',', QString::SkipEmptyParts); + QStringList tokens = strVector[i].split(',', QSTRING_SKIP_EMPTY_PARTS); if(!tokens.empty()) { v.dataContainerName = tokens[0]; @@ -989,46 +984,46 @@ ComparisonInputs H5FilterParametersReader::readComparisonInputs(const QString na // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ComparisonInputsAdvanced H5FilterParametersReader::readComparisonInputsAdvanced(const QString name, ComparisonInputsAdvanced defValue) +ComparisonInputsAdvanced H5FilterParametersReader::readComparisonInputsAdvanced(const QString& name, ComparisonInputsAdvanced defValue) { - /* - int size = 0; - QString strData = ""; - bool ok = false; - // See if the data set actually exists, if it does NOT just return what the user passed in as a default value - if(false == QH5Lite::datasetExists(m_CurrentGroupId, name)) - { - return defValue; - } + /* + int size = 0; + QString strData = ""; + bool ok = false; + // See if the data set actually exists, if it does NOT just return what the user passed in as a default value + if(false == QH5Lite::datasetExists(m_CurrentGroupId, name)) + { + return defValue; + } - herr_t err = QH5Lite::readStringDataset(m_CurrentGroupId, name, strData); - if(err < 0) - { - return defValue; // If the data set does not exist no point in going any further - } + herr_t err = QH5Lite::readStringDataset(m_CurrentGroupId, name, strData); + if(err < 0) + { + return defValue; // If the data set does not exist no point in going any further + } - // Now read the the attribute that says how many arrays are in the data set. - err = QH5Lite::readScalarAttribute(m_CurrentGroupId, name, "NumInputs", size); + // Now read the the attribute that says how many arrays are in the data set. + err = QH5Lite::readScalarAttribute(m_CurrentGroupId, name, "NumInputs", size); - QStringList strVector = strData.split('\n', QString::SkipEmptyParts); - qint32 strVecSize = strVector.size(); - if(strVecSize != size) - { - // Something has gone wrong in the tokenization and the number of tokens does not match what - // was written to the HDF5 file. - return defValue; - } - */ + QStringList strVector = strData.split('\n', QSTRING_SKIP_EMPTY_PARTS); + qint32 strVecSize = strVector.size(); + if(strVecSize != size) + { + // Something has gone wrong in the tokenization and the number of tokens does not match what + // was written to the HDF5 file. + return defValue; + } + */ - ComparisonInputsAdvanced inputs; + ComparisonInputsAdvanced inputs; - return inputs; + return inputs; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AxisAngleInput_t H5FilterParametersReader::readAxisAngle(const QString name, AxisAngleInput_t v, int vectorPos) +AxisAngleInput H5FilterParametersReader::readAxisAngle(const QString& name, AxisAngleInput v, int vectorPos) { int err = 0; @@ -1047,10 +1042,11 @@ AxisAngleInput_t H5FilterParametersReader::readAxisAngle(const QString name, Axi // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QVector H5FilterParametersReader::readAxisAngles(const QString name, QVector v) +QVector H5FilterParametersReader::readAxisAngles(const QString& name, QVector v) { - QVector axisAngleInputsVector; - AxisAngleInput_t axisAngleDummyInput; + std::ignore = v; + QVector axisAngleInputsVector; + AxisAngleInput axisAngleDummyInput; axisAngleDummyInput.angle = 0.0f; axisAngleDummyInput.h = 0.0f; axisAngleDummyInput.k = 0.0f; @@ -1066,7 +1062,7 @@ QVector H5FilterParametersReader::readAxisAngles(const QString // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QSet H5FilterParametersReader::readArraySelections(const QString name, QSet v) +QSet H5FilterParametersReader::readArraySelections(const QString& name, QSet v) { int size = 0; QString strData = ""; @@ -1086,7 +1082,7 @@ QSet H5FilterParametersReader::readArraySelections(const QString name, // Now read the the attribute that says how many arrays are in the data set. err = QH5Lite::readScalarAttribute(m_CurrentGroupId, name, "NumArrays", size); - QStringList strVector = strData.split('\n', QString::SkipEmptyParts); + QStringList strVector = strData.split('\n', QSTRING_SKIP_EMPTY_PARTS); qint32 strVecSize = strVector.size(); if(strVecSize != size) { @@ -1109,13 +1105,13 @@ DataContainerArrayProxy H5FilterParametersReader::readDataContainerArrayProxy(co DataContainerArrayProxy dcaProxy; // Open the top level group that holds all the values for this filter parameter hid_t dcaGid = QH5Utilities::openHDF5Object(m_CurrentGroupId, name); - H5ScopedGroupSentinel sentinel(&dcaGid, true); + H5ScopedGroupSentinel sentinel(dcaGid, true); if(dcaGid < 0) { return defValue; } QList dcaNames; - int err = QH5Utilities::getGroupObjects(dcaGid, H5Utilities::H5Support_GROUP, dcaNames); + int err = QH5Utilities::getGroupObjects(dcaGid, H5Utilities::CustomHDFDataTypes::Group, dcaNames); if(err < 0) { return defValue; @@ -1124,13 +1120,13 @@ DataContainerArrayProxy H5FilterParametersReader::readDataContainerArrayProxy(co for(const auto& dcName : dcaNames) { hid_t dcGid = QH5Utilities::openHDF5Object(dcaGid, dcName); - H5ScopedGroupSentinel sentinal_dc(&dcGid, false); + H5ScopedGroupSentinel sentinal_dc(dcGid, false); DataContainerProxy dcProxy; dcProxy.setName(dcName); dcProxy.setFlag(Qt::Checked); // Loop over the attribute Matrices QList amNames; - err = QH5Utilities::getGroupObjects(dcGid, H5Utilities::H5Support_GROUP, amNames); + err = QH5Utilities::getGroupObjects(dcGid, H5Utilities::CustomHDFDataTypes::Group, amNames); if(err < 0) { return defValue; @@ -1139,7 +1135,7 @@ DataContainerArrayProxy H5FilterParametersReader::readDataContainerArrayProxy(co for(const auto& amName : amNames) { hid_t amGid = QH5Utilities::openHDF5Object(dcGid, amName); - H5ScopedGroupSentinel sentinal_am(&amGid, false); + H5ScopedGroupSentinel sentinal_am(amGid, false); AttributeMatrixProxy amProxy(amName, 1u); amProxy.setFlag(Qt::Checked); QString data; // Output will be read into this object @@ -1178,7 +1174,7 @@ DataArrayPath H5FilterParametersReader::readDataArrayPath(const QString& name, D return path; } - return def; + return def; } // ----------------------------------------------------------------------------- @@ -1234,13 +1230,13 @@ DynamicTableData H5FilterParametersReader::readDynamicTableData(const QString& n return tableData; } - return def; + return def; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QPair H5FilterParametersReader::readPairOfDoubles(const QString& name, QPair v) +FPRangePair H5FilterParametersReader::readPairOfDoubles(const QString& name, const FPRangePair& v) { /*int err = QH5Lite::writeScalarAttribute(m_CurrentGroupId, name, "Min", v.first); if (err < 0) { return err; } @@ -1261,8 +1257,45 @@ QPair H5FilterParametersReader::readPairOfDoubles(const QString& return v; } - QPair value; + FPRangePair value; value.first = min; value.second = max; return value; } + +// ----------------------------------------------------------------------------- +H5FilterParametersReader::Pointer H5FilterParametersReader::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +H5FilterParametersReader::Pointer H5FilterParametersReader::New() +{ + Pointer sharedPtr(new(H5FilterParametersReader)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString H5FilterParametersReader::getNameOfClass() const +{ + return QString("H5FilterParametersReader"); +} + +// ----------------------------------------------------------------------------- +QString H5FilterParametersReader::ClassName() +{ + return QString("H5FilterParametersReader"); +} + +// ----------------------------------------------------------------------------- +void H5FilterParametersReader::setPipelineGroupId(hid_t value) +{ + m_PipelineGroupId = value; +} + +// ----------------------------------------------------------------------------- +hid_t H5FilterParametersReader::getPipelineGroupId() const +{ + return m_PipelineGroupId; +} diff --git a/Source/SIMPLib/FilterParameters/H5FilterParametersReader.h b/Source/SIMPLib/FilterParameters/H5FilterParametersReader.h index e312379281..249f63ac71 100644 --- a/Source/SIMPLib/FilterParameters/H5FilterParametersReader.h +++ b/Source/SIMPLib/FilterParameters/H5FilterParametersReader.h @@ -1,168 +1,191 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include "hdf5.h" #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/Filtering/FilterPipeline.h" -#include "SIMPLib/SIMPLib.h" /* * */ class SIMPLib_EXPORT H5FilterParametersReader : public AbstractFilterParametersReader { - public: - SIMPL_SHARED_POINTERS(H5FilterParametersReader) - SIMPL_STATIC_NEW_MACRO(H5FilterParametersReader) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(H5FilterParametersReader, AbstractFilterParametersReader) - - ~H5FilterParametersReader() override; - - /** - * @brief OpenDREAM3DFile This will open the HDF5 based DREAM3D file and open the proper HDF5 internal - * group that is associated with the pipeline storage - * @param filepath - * @param fid The HDF5 file Id that represents the open HDF5 file - * @return Return a pointer to a newly instantiated instance of this class. A Null Pointer will be returned if - * the file can not be opened or the group is missing. - */ - static Pointer OpenDREAM3DFileForReadingPipeline(QString filePath, hid_t& fid); - - SIMPL_INSTANCE_PROPERTY(hid_t, PipelineGroupId) - - hid_t getCurrentGroupId() const; - - int openFilterGroup(AbstractFilter* filter, int index) override; - int closeFilterGroup() override; - - /** - * @brief ReadPipelineFromFile - * @param filePath - * @return - */ - FilterPipeline::Pointer readPipelineFromFile(QString filePath, IObserver* obs = nullptr); - - /** - * @brief readPipelineFromFile - * @param fid - * @param obs - * @return - */ - FilterPipeline::Pointer readPipelineFromFile(hid_t fid, IObserver* obs = nullptr); - - /** - * @brief getJsonFromFile - * @param filePath - * @param obs - * @return - */ - QString getJsonFromFile(QString filePath, IObserver* obs = nullptr); - - QString readString(const QString name, QString value) override; - QVector readStrings(const QString name, QVector value) override; - QStringList readStringList(const QString name, QStringList value) override; - - int8_t readValue(const QString name, int8_t value) override; - int16_t readValue(const QString name, int16_t value) override; - int32_t readValue(const QString name, int32_t value) override; - int64_t readValue(const QString name, int64_t value) override; - uint8_t readValue(const QString name, uint8_t value) override; - uint16_t readValue(const QString name, uint16_t value) override; - uint32_t readValue(const QString name, uint32_t value) override; - uint64_t readValue(const QString name, uint64_t value) override; - float readValue(const QString name, float value) override; - double readValue(const QString name, double value) override; - bool readValue(const QString name, bool value) override; - AttributeMatrix::Type readValue(const QString name, AttributeMatrix::Type value) override; - - QVector readArray(const QString name, QVector value) override; - QVector readArray(const QString name, QVector value) override; - QVector readArray(const QString name, QVector value) override; - QVector readArray(const QString name, QVector value) override; - QVector readArray(const QString name, QVector value) override; - QVector readArray(const QString name, QVector value) override; - QVector readArray(const QString name, QVector value) override; - QVector readArray(const QString name, QVector value) override; - QVector readArray(const QString name, QVector value) override; - QVector readArray(const QString name, QVector value) override; - - IntVec3_t readIntVec3(const QString name, IntVec3_t v) override; - FloatVec3_t readFloatVec3(const QString name, FloatVec3_t v) override; - - Float2ndOrderPoly_t readFloat2ndOrderPoly(const QString name, Float2ndOrderPoly_t v) override; - Float3rdOrderPoly_t readFloat3rdOrderPoly(const QString name, Float3rdOrderPoly_t v) override; - Float4thOrderPoly_t readFloat4thOrderPoly(const QString name, Float4thOrderPoly_t v) override; - FileListInfo_t readFileListInfo(const QString name, FileListInfo_t v) override; - ComparisonInput_t readComparisonInput(const QString name, ComparisonInput_t v, int vectorPos) override; - ComparisonInputs readComparisonInputs(const QString name, ComparisonInputs v) override; - ComparisonInputsAdvanced readComparisonInputsAdvanced(const QString name, ComparisonInputsAdvanced v) override; - AxisAngleInput_t readAxisAngle(const QString name, AxisAngleInput_t v, int vectorPos) override; - QVector readAxisAngles(const QString name, QVector defValue) override; - QSet readArraySelections(const QString name, QSet v) override; - - DataContainerArrayProxy readDataContainerArrayProxy(const QString& name, DataContainerArrayProxy v) override; - DataArrayPath readDataArrayPath(const QString& name, DataArrayPath v) override; - QVector readDataArrayPathVector(const QString& name, QVector def) override; - DynamicTableData readDynamicTableData(const QString& name, DynamicTableData def) override; - - QPair readPairOfDoubles(const QString& name, QPair v) override; - - protected: - H5FilterParametersReader(); - - private: - hid_t m_CurrentGroupId = -1; - QJsonObject m_PipelineRoot; - QJsonObject m_CurrentFilterObject; - int m_Version = -1; - int m_CurrentIndex = -1; - - public: - H5FilterParametersReader(const H5FilterParametersReader&) = delete; // Copy Constructor Not Implemented - H5FilterParametersReader(H5FilterParametersReader&&) = delete; // Move Constructor Not Implemented - H5FilterParametersReader& operator=(const H5FilterParametersReader&) = delete; // Copy Assignment Not Implemented - H5FilterParametersReader& operator=(H5FilterParametersReader&&) = delete; // Move Assignment Not Implemented +public: + using Self = H5FilterParametersReader; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for H5FilterParametersReader + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for H5FilterParametersReader + */ + static QString ClassName(); + + ~H5FilterParametersReader() override; + + /** + * @brief OpenDREAM3DFile This will open the HDF5 based DREAM3D file and open the proper HDF5 internal + * group that is associated with the pipeline storage + * @param filepath + * @param fid The HDF5 file Id that represents the open HDF5 file + * @return Return a pointer to a newly instantiated instance of this class. A Null Pointer will be returned if + * the file can not be opened or the group is missing. + */ + static Pointer OpenDREAM3DFileForReadingPipeline(QString filePath, hid_t& fid); + + /** + * @brief Setter property for PipelineGroupId + */ + void setPipelineGroupId(hid_t value); + /** + * @brief Getter property for PipelineGroupId + * @return Value of PipelineGroupId + */ + hid_t getPipelineGroupId() const; + + hid_t getCurrentGroupId() const; + + int openFilterGroup(AbstractFilter* filter, int index) override; + int closeFilterGroup() override; + + /** + * @brief ReadPipelineFromFile + * @param filePath + * @return + */ + FilterPipeline::Pointer readPipelineFromFile(QString filePath, IObserver* obs = nullptr); + + /** + * @brief readPipelineFromFile + * @param fid + * @param obs + * @return + */ + FilterPipeline::Pointer readPipelineFromFile(hid_t fid, IObserver* obs = nullptr); + + /** + * @brief getJsonFromFile + * @param filePath + * @param obs + * @return + */ + QString getJsonFromFile(QString filePath, IObserver* obs = nullptr); + + QString readString(const QString& name, QString value) override; + QVector readStrings(const QString& name, QVector value) override; + QStringList readStringList(const QString& name, QStringList value) override; + + int8_t readValue(const QString& name, int8_t value) override; + int16_t readValue(const QString& name, int16_t value) override; + int32_t readValue(const QString& name, int32_t value) override; + int64_t readValue(const QString& name, int64_t value) override; + uint8_t readValue(const QString& name, uint8_t value) override; + uint16_t readValue(const QString& name, uint16_t value) override; + uint32_t readValue(const QString& name, uint32_t value) override; + uint64_t readValue(const QString& name, uint64_t value) override; + float readValue(const QString& name, float value) override; + double readValue(const QString& name, double value) override; + bool readValue(const QString& name, bool value) override; + AttributeMatrix::Type readValue(const QString& name, AttributeMatrix::Type value) override; + + QVector readArray(const QString& name, QVector value) override; + QVector readArray(const QString& name, QVector value) override; + QVector readArray(const QString& name, QVector value) override; + QVector readArray(const QString& name, QVector value) override; + QVector readArray(const QString& name, QVector value) override; + QVector readArray(const QString& name, QVector value) override; + QVector readArray(const QString& name, QVector value) override; + QVector readArray(const QString& name, QVector value) override; + QVector readArray(const QString& name, QVector value) override; + QVector readArray(const QString& name, QVector value) override; + + IntVec3Type readIntVec3(const QString& name, IntVec3Type v) override; + FloatVec3Type readFloatVec3(const QString& name, FloatVec3Type v) override; + + Float2ndOrderPolynomial readFloat2ndOrderPoly(const QString& name, Float2ndOrderPolynomial v) override; + Float3rdOrderPoly_t readFloat3rdOrderPoly(const QString& name, Float3rdOrderPoly_t v) override; + Float4thOrderPolynomial readFloat4thOrderPoly(const QString& name, Float4thOrderPolynomial v) override; + StackFileListInfo readFileListInfo(const QString& name, StackFileListInfo v) override; + ComparisonInput_t readComparisonInput(const QString& name, ComparisonInput_t v, int vectorPos) override; + ComparisonInputs readComparisonInputs(const QString& name, ComparisonInputs v) override; + ComparisonInputsAdvanced readComparisonInputsAdvanced(const QString& name, ComparisonInputsAdvanced v) override; + AxisAngleInput readAxisAngle(const QString& name, AxisAngleInput v, int vectorPos) override; + QVector readAxisAngles(const QString& name, QVector defValue) override; + QSet readArraySelections(const QString& name, QSet v) override; + + DataContainerArrayProxy readDataContainerArrayProxy(const QString& name, DataContainerArrayProxy v) override; + DataArrayPath readDataArrayPath(const QString& name, DataArrayPath v) override; + QVector readDataArrayPathVector(const QString& name, QVector def) override; + DynamicTableData readDynamicTableData(const QString& name, DynamicTableData def) override; + + FPRangePair readPairOfDoubles(const QString& name, const FPRangePair& v) override; + +protected: + H5FilterParametersReader(); + +private: + hid_t m_PipelineGroupId = {}; + + hid_t m_CurrentGroupId = -1; + QJsonObject m_PipelineRoot; + QJsonObject m_CurrentFilterObject; + int m_Version = -1; + int m_CurrentIndex = -1; + +public: + H5FilterParametersReader(const H5FilterParametersReader&) = delete; // Copy Constructor Not Implemented + H5FilterParametersReader(H5FilterParametersReader&&) = delete; // Move Constructor Not Implemented + H5FilterParametersReader& operator=(const H5FilterParametersReader&) = delete; // Copy Assignment Not Implemented + H5FilterParametersReader& operator=(H5FilterParametersReader&&) = delete; // Move Assignment Not Implemented }; - - diff --git a/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.cpp b/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.cpp index ff813536f2..ad80a7c811 100644 --- a/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.cpp +++ b/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.cpp @@ -1,53 +1,56 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "H5FilterParametersWriter.h" -#include +#include + #include -#include +#include +#include +#include "H5Support/H5ScopedSentinel.h" #include "H5Support/QH5Lite.h" #include "H5Support/QH5Utilities.h" -#include "H5Support/H5ScopedSentinel.h" - +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/FilterParameters/H5FilterParametersConstants.h" #include "SIMPLib/FilterParameters/JsonFilterParametersWriter.h" -#include "SIMPLib/SIMPLibVersion.h" +#include "SIMPLib/Messages/GenericErrorMessage.h" +#include "SIMPLib/Messages/PipelineErrorMessage.h" // ----------------------------------------------------------------------------- // @@ -70,17 +73,17 @@ hid_t H5FilterParametersWriter::getCurrentGroupId() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int H5FilterParametersWriter::writePipelineToFile(FilterPipeline::Pointer pipeline, QString filePath, QString pipelineName, QList obs) +int H5FilterParametersWriter::writePipelineToFile(FilterPipeline::Pointer pipeline, QString filePath, QString pipelineName, bool expandPipeline, QList obs) { if(nullptr == pipeline.get()) { if(!obs.empty()) { - PipelineMessage pm(JsonFilterParametersWriter::ClassName(), "FilterPipeline Object was nullptr for writing", -1, PipelineMessage::MessageType::Error); + GenericErrorMessage::Pointer pm = GenericErrorMessage::New(QObject::tr("%1: %2").arg(JsonFilterParametersWriter::ClassName()).arg("FilterPipeline Object was nullptr for writing"), -1); - for (int i = 0; i < obs.size(); i++) + for(int i = 0; i < obs.size(); i++) { - if (obs[i] != nullptr) + if(obs[i] != nullptr) { obs[i]->processPipelineMessage(pm); } @@ -106,11 +109,12 @@ int H5FilterParametersWriter::writePipelineToFile(FilterPipeline::Pointer pipeli { if(!obs.empty()) { - PipelineMessage pm(JsonFilterParametersWriter::ClassName(), "Output .dream3d file could not be created.", -1, PipelineMessage::MessageType::Error); + PipelineErrorMessage::Pointer pm = + PipelineErrorMessage::New(pipeline->getName(), QObject::tr("%1: %2").arg(JsonFilterParametersWriter::ClassName()).arg("Output .dream3d file could not be created."), -1); - for (int i = 0; i < obs.size(); i++) + for(int i = 0; i < obs.size(); i++) { - if (obs[i] != nullptr) + if(obs[i] != nullptr) { obs[i]->processPipelineMessage(pm); } @@ -122,21 +126,21 @@ int H5FilterParametersWriter::writePipelineToFile(FilterPipeline::Pointer pipeli // This will make sure if we return early from this method that the HDF5 File is properly closed. // This will also take care of making sure all groups and file ids are closed // before this method returns. - H5ScopedFileSentinel scopedFileSentinel(&fileId, true); + H5ScopedFileSentinel scopedFileSentinel(fileId, true); // Write our File Version string to the Root "/" group QH5Lite::writeStringAttribute(fileId, "/", SIMPL::HDF5::FileVersionName, SIMPL::HDF5::FileVersion); QH5Lite::writeStringAttribute(fileId, "/", SIMPL::HDF5::DREAM3DVersion, SIMPLib::Version::Complete()); hid_t pipelineGroupId = QH5Utilities::createGroup(fileId, SIMPL::StringConstants::PipelineGroupName); - scopedFileSentinel.addGroupId(&pipelineGroupId); + scopedFileSentinel.addGroupId(pipelineGroupId); setGroupId(pipelineGroupId); QH5Lite::writeScalarAttribute(pipelineGroupId, "/" + SIMPL::StringConstants::PipelineGroupName, SIMPL::StringConstants::PipelineVersionName, 2); QH5Lite::writeStringAttribute(pipelineGroupId, "/" + SIMPL::StringConstants::PipelineGroupName, SIMPL::StringConstants::PipelineCurrentName, pipelineName); JsonFilterParametersWriter::Pointer jsonWriter = JsonFilterParametersWriter::New(); - QString jsonString = jsonWriter->writePipelineToString(pipeline, pipelineName, obs); + QString jsonString = jsonWriter->writePipelineToString(pipeline, pipelineName, expandPipeline, obs); QH5Lite::writeStringDataset(pipelineGroupId, pipelineName, jsonString); return 0; @@ -474,7 +478,7 @@ int H5FilterParametersWriter::writeValue(const QString& name, QVector va // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int H5FilterParametersWriter::writeValue(const QString& name, IntVec3_t v) +int H5FilterParametersWriter::writeValue(const QString& name, IntVec3Type v) { int err = 0; int32_t rank = 1; @@ -486,7 +490,7 @@ int H5FilterParametersWriter::writeValue(const QString& name, IntVec3_t v) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int H5FilterParametersWriter::writeValue(const QString& name, FloatVec3_t v) +int H5FilterParametersWriter::writeValue(const QString& name, FloatVec3Type v) { int err = 0; int32_t rank = 1; @@ -498,7 +502,7 @@ int H5FilterParametersWriter::writeValue(const QString& name, FloatVec3_t v) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int H5FilterParametersWriter::writeValue(const QString& name, Float2ndOrderPoly_t v) +int H5FilterParametersWriter::writeValue(const QString& name, Float2ndOrderPolynomial v) { int err = 0; int32_t rank = 1; @@ -522,7 +526,7 @@ int H5FilterParametersWriter::writeValue(const QString& name, Float3rdOrderPoly_ // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int H5FilterParametersWriter::writeValue(const QString& name, Float4thOrderPoly_t v) +int H5FilterParametersWriter::writeValue(const QString& name, Float4thOrderPolynomial v) { int err = 0; int32_t rank = 1; @@ -534,7 +538,7 @@ int H5FilterParametersWriter::writeValue(const QString& name, Float4thOrderPoly_ // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int H5FilterParametersWriter::writeValue(const QString& name, FileListInfo_t v) +int H5FilterParametersWriter::writeValue(const QString& name, StackFileListInfo v) { int err = 0; hid_t dcaGid = QH5Utilities::createGroup(m_CurrentGroupId, name); @@ -599,7 +603,7 @@ int H5FilterParametersWriter::writeValue(const QString& name, ComparisonInputs v // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int H5FilterParametersWriter::writeValue(const QString& name, AxisAngleInput_t v) +int H5FilterParametersWriter::writeValue(const QString& name, AxisAngleInput v) { int numQFilters = static_cast(1); int err = writeValue(name, numQFilters); @@ -624,7 +628,7 @@ int H5FilterParametersWriter::writeValue(const QString& name, AxisAngleInput_t v // ----------------------------------------------------------------------------- // These are actually written as a binary 4x1 float array as an attribute // ----------------------------------------------------------------------------- -int H5FilterParametersWriter::writeValue(const QString& name, AxisAngleInput_t v, int vectorPos) +int H5FilterParametersWriter::writeValue(const QString& name, AxisAngleInput v, int vectorPos) { int err = 0; int32_t rank = 1; @@ -639,7 +643,7 @@ int H5FilterParametersWriter::writeValue(const QString& name, AxisAngleInput_t v // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int H5FilterParametersWriter::writeValue(const QString& name, QVector v) +int H5FilterParametersWriter::writeValue(const QString& name, QVector v) { int numQFilters = static_cast(v.size()); int err = writeValue(name, numQFilters); @@ -821,3 +825,52 @@ int H5FilterParametersWriter::writeValue(const QString& name, const QPair(nullptr)); +} + +// ----------------------------------------------------------------------------- +H5FilterParametersWriter::Pointer H5FilterParametersWriter::New() +{ + Pointer sharedPtr(new(H5FilterParametersWriter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString H5FilterParametersWriter::getNameOfClass() const +{ + return QString("H5FilterParametersWriter"); +} + +// ----------------------------------------------------------------------------- +QString H5FilterParametersWriter::ClassName() +{ + return QString("H5FilterParametersWriter"); +} + +// ----------------------------------------------------------------------------- +void H5FilterParametersWriter::setPipelineGroupId(hid_t value) +{ + m_PipelineGroupId = value; +} + +// ----------------------------------------------------------------------------- +hid_t H5FilterParametersWriter::getPipelineGroupId() const +{ + return m_PipelineGroupId; +} + +// ----------------------------------------------------------------------------- +void H5FilterParametersWriter::setGroupId(hid_t value) +{ + m_GroupId = value; +} + +// ----------------------------------------------------------------------------- +hid_t H5FilterParametersWriter::getGroupId() const +{ + return m_GroupId; +} diff --git a/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.h b/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.h index d0e8926691..aea1f5893a 100644 --- a/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.h +++ b/Source/SIMPLib/FilterParameters/H5FilterParametersWriter.h @@ -1,145 +1,178 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include "hdf5.h" #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersWriter.h" #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/Filtering/FilterPipeline.h" -#include "SIMPLib/SIMPLib.h" /* * */ class SIMPLib_EXPORT H5FilterParametersWriter : public AbstractFilterParametersWriter { - public: - SIMPL_SHARED_POINTERS(H5FilterParametersWriter) - SIMPL_STATIC_NEW_MACRO(H5FilterParametersWriter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(H5FilterParametersWriter, AbstractFilterParametersWriter) - - /** - * @brief WritePipelineToFile This function will write a pipeline to an HDF5 based - * DREAM3D file. The file path passed in WILL BE OVER WRITTEN by this - * function WITHOUT WARNING - * @param pipeline The pipeline to be written - * @param filePath The file path to write - * @param name The name of the pipeline (Typically the nameo of the file) - * @param obs Any observer that we can pass error/warning messages back to in case something goes wrong. - * @return - */ - int writePipelineToFile(FilterPipeline::Pointer pipeline, QString filePath, QString pipelineName, QList obs = QList()) override; - - SIMPL_INSTANCE_PROPERTY(hid_t, PipelineGroupId) - - ~H5FilterParametersWriter() override; - - SIMPL_INSTANCE_PROPERTY(hid_t, GroupId) - hid_t getCurrentGroupId() const; - - int openFilterGroup(AbstractFilter* filter, int index) override; - int closeFilterGroup() override; - - int writeValue(const QString& name, const QString& value) override; - int writeValue(const QString& name, const QVector& value) override; - int writeValue(const QString& name, const QStringList& value) override; - - int writeValue(const QString& name, int8_t value) override; - int writeValue(const QString& name, int16_t value) override; - int writeValue(const QString& name, int32_t value) override; - int writeValue(const QString& name, int64_t value) override; - int writeValue(const QString& name, uint8_t value) override; - int writeValue(const QString& name, uint16_t value) override; - int writeValue(const QString& name, uint32_t value) override; - int writeValue(const QString& name, uint64_t value) override; - int writeValue(const QString& name, float value) override; - int writeValue(const QString& name, double value) override; - - int writeValue(const QString& name, QVector value) override; - int writeValue(const QString& name, QVector value) override; - int writeValue(const QString& name, QVector value) override; - int writeValue(const QString& name, QVector value) override; - int writeValue(const QString& name, QVector value) override; - int writeValue(const QString& name, QVector value) override; - int writeValue(const QString& name, QVector value) override; - int writeValue(const QString& name, QVector value) override; - int writeValue(const QString& name, QVector value) override; - int writeValue(const QString& name, QVector value) override; - - int writeValue(const QString& name, IntVec3_t v) override; - int writeValue(const QString& name, FloatVec3_t v) override; - - int writeValue(const QString& name, Float2ndOrderPoly_t v) override; - int writeValue(const QString& name, Float3rdOrderPoly_t v) override; - int writeValue(const QString& name, Float4thOrderPoly_t v) override; - int writeValue(const QString& name, FileListInfo_t v) override; - - int writeValue(const QString& name, ComparisonInput_t v) override; - int writeValue(const QString& name, ComparisonInputs v) override; - - int writeValue(const QString& name, AxisAngleInput_t v) override; - int writeValue(const QString& name, QVector v) override; - - int writeArraySelections(const QString& name, QSet v) override; - int writeValue(const QString& name, DataContainerArrayProxy& dcaProxy) override; - int writeValue(const QString& name, const DataArrayPath& v) override; - int writeValue(const QString& name, const QVector& paths) override; - - int writeValue(const QString& name, const DynamicTableData& v) override; - - int writeValue(const QString& name, const QPair& v) override; - - protected: - H5FilterParametersWriter(); - - int writeValue(const QString& name, AxisAngleInput_t v, int notUsed) override; - - private: - hid_t m_CurrentGroupId; - - public: - H5FilterParametersWriter(const H5FilterParametersWriter&) = delete; // Copy Constructor Not Implemented - H5FilterParametersWriter(H5FilterParametersWriter&&) = delete; // Move Constructor Not Implemented - H5FilterParametersWriter& operator=(const H5FilterParametersWriter&) = delete; // Copy Assignment Not Implemented - H5FilterParametersWriter& operator=(H5FilterParametersWriter&&) = delete; // Move Assignment Not Implemented +public: + using Self = H5FilterParametersWriter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for H5FilterParametersWriter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for H5FilterParametersWriter + */ + static QString ClassName(); + + /** + * @brief WritePipelineToFile This function will write a pipeline to an HDF5 based + * DREAM3D file. The file path passed in WILL BE OVER WRITTEN by this + * function WITHOUT WARNING + * @param pipeline The pipeline to be written + * @param filePath The file path to write + * @param name The name of the pipeline (Typically the nameo of the file) + * @param obs Any observer that we can pass error/warning messages back to in case something goes wrong. + * @return + */ + int writePipelineToFile(FilterPipeline::Pointer pipeline, QString filePath, QString pipelineName, bool expandPipeline, QList obs = QList()) override; + + /** + * @brief Setter property for PipelineGroupId + */ + void setPipelineGroupId(hid_t value); + /** + * @brief Getter property for PipelineGroupId + * @return Value of PipelineGroupId + */ + hid_t getPipelineGroupId() const; + + ~H5FilterParametersWriter() override; + + /** + * @brief Setter property for GroupId + */ + void setGroupId(hid_t value); + /** + * @brief Getter property for GroupId + * @return Value of GroupId + */ + hid_t getGroupId() const; + + hid_t getCurrentGroupId() const; + + int openFilterGroup(AbstractFilter* filter, int index) override; + int closeFilterGroup() override; + + int writeValue(const QString& name, const QString& value) override; + int writeValue(const QString& name, const QVector& value) override; + int writeValue(const QString& name, const QStringList& value) override; + + int writeValue(const QString& name, int8_t value) override; + int writeValue(const QString& name, int16_t value) override; + int writeValue(const QString& name, int32_t value) override; + int writeValue(const QString& name, int64_t value) override; + int writeValue(const QString& name, uint8_t value) override; + int writeValue(const QString& name, uint16_t value) override; + int writeValue(const QString& name, uint32_t value) override; + int writeValue(const QString& name, uint64_t value) override; + int writeValue(const QString& name, float value) override; + int writeValue(const QString& name, double value) override; + + int writeValue(const QString& name, QVector value) override; + int writeValue(const QString& name, QVector value) override; + int writeValue(const QString& name, QVector value) override; + int writeValue(const QString& name, QVector value) override; + int writeValue(const QString& name, QVector value) override; + int writeValue(const QString& name, QVector value) override; + int writeValue(const QString& name, QVector value) override; + int writeValue(const QString& name, QVector value) override; + int writeValue(const QString& name, QVector value) override; + int writeValue(const QString& name, QVector value) override; + + int writeValue(const QString& name, IntVec3Type v) override; + int writeValue(const QString& name, FloatVec3Type v) override; + + int writeValue(const QString& name, Float2ndOrderPolynomial v) override; + int writeValue(const QString& name, Float3rdOrderPoly_t v) override; + int writeValue(const QString& name, Float4thOrderPolynomial v) override; + int writeValue(const QString& name, StackFileListInfo v) override; + + int writeValue(const QString& name, ComparisonInput_t v) override; + int writeValue(const QString& name, ComparisonInputs v) override; + + int writeValue(const QString& name, AxisAngleInput v) override; + int writeValue(const QString& name, QVector v) override; + + int writeArraySelections(const QString& name, QSet v) override; + int writeValue(const QString& name, DataContainerArrayProxy& dcaProxy) override; + int writeValue(const QString& name, const DataArrayPath& v) override; + int writeValue(const QString& name, const QVector& paths) override; + + int writeValue(const QString& name, const DynamicTableData& v) override; + + int writeValue(const QString& name, const QPair& v) override; + +protected: + H5FilterParametersWriter(); + + int writeValue(const QString& name, AxisAngleInput v, int notUsed) override; + +private: + hid_t m_PipelineGroupId = {}; + hid_t m_GroupId = {}; + + hid_t m_CurrentGroupId = -1; + +public: + H5FilterParametersWriter(const H5FilterParametersWriter&) = delete; // Copy Constructor Not Implemented + H5FilterParametersWriter(H5FilterParametersWriter&&) = delete; // Move Constructor Not Implemented + H5FilterParametersWriter& operator=(const H5FilterParametersWriter&) = delete; // Copy Assignment Not Implemented + H5FilterParametersWriter& operator=(H5FilterParametersWriter&&) = delete; // Move Assignment Not Implemented }; - - diff --git a/Source/SIMPLib/FilterParameters/ImportHDF5DatasetFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ImportHDF5DatasetFilterParameter.cpp index 41fce6826f..85c8286404 100644 --- a/Source/SIMPLib/FilterParameters/ImportHDF5DatasetFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/ImportHDF5DatasetFilterParameter.cpp @@ -50,8 +50,8 @@ ImportHDF5DatasetFilterParameter::~ImportHDF5DatasetFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ImportHDF5DatasetFilterParameter::Pointer ImportHDF5DatasetFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QVariant& filePathDefaultValue, - const QVariant& datasetDefaultValue, Category category, ImportHDF5Dataset* filter, int groupIndex) +ImportHDF5DatasetFilterParameter::Pointer ImportHDF5DatasetFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& filePathDefaultValue, + const QString& datasetDefaultValue, Category category, ImportHDF5Dataset* filter, int groupIndex) { ImportHDF5DatasetFilterParameter::Pointer ptr = ImportHDF5DatasetFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -101,7 +101,7 @@ void ImportHDF5DatasetFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // THIS IS A SPECIAL CASE AND IS NOT STANDARD. DO NOT COPY THIS CODE. // ----------------------------------------------------------------------------- -void ImportHDF5DatasetFilterParameter::writeJson(QJsonObject& json) +void ImportHDF5DatasetFilterParameter::writeJson(QJsonObject& json) const { json["HDF5FilePath"] = m_Filter->getHDF5FilePath(); @@ -117,3 +117,46 @@ void ImportHDF5DatasetFilterParameter::writeJson(QJsonObject& json) } json["Dataset Import Info Array"] = importInfoArray; } + +// ----------------------------------------------------------------------------- +ImportHDF5DatasetFilterParameter::Pointer ImportHDF5DatasetFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +ImportHDF5DatasetFilterParameter::Pointer ImportHDF5DatasetFilterParameter::New() +{ + Pointer sharedPtr(new(ImportHDF5DatasetFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString ImportHDF5DatasetFilterParameter::getNameOfClass() const +{ + return QString("ImportHDF5DatasetFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString ImportHDF5DatasetFilterParameter::ClassName() +{ + return QString("ImportHDF5DatasetFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void ImportHDF5DatasetFilterParameter::setFilter(ImportHDF5Dataset* value) +{ + m_Filter = value; +} + +// ----------------------------------------------------------------------------- +ImportHDF5Dataset* ImportHDF5DatasetFilterParameter::getFilter() const +{ + return m_Filter; +} + +// ----------------------------------------------------------------------------- +void ImportHDF5DatasetFilterParameter::setDataSetDefaultValue(const QVariant& value) +{ + m_DataSetDefaultValue = value; +} diff --git a/Source/SIMPLib/FilterParameters/ImportHDF5DatasetFilterParameter.h b/Source/SIMPLib/FilterParameters/ImportHDF5DatasetFilterParameter.h index 65086bb4e3..ca31e98295 100644 --- a/Source/SIMPLib/FilterParameters/ImportHDF5DatasetFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ImportHDF5DatasetFilterParameter.h @@ -32,24 +32,60 @@ #pragma once +#include + #include "SIMPLib/FilterParameters/FilterParameter.h" class ImportHDF5Dataset; class SIMPLib_EXPORT ImportHDF5DatasetFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(ImportHDF5DatasetFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(ImportHDF5DatasetFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(ImportHDF5DatasetFilterParameter) - SIMPL_STATIC_NEW_MACRO(ImportHDF5DatasetFilterParameter) - SIMPL_TYPE_MACRO(ImportHDF5DatasetFilterParameter) + using Self = ImportHDF5DatasetFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for ImportHDF5DatasetFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ImportHDF5DatasetFilterParameter + */ + static QString ClassName(); - static Pointer New(const QString& humanLabel, const QString& propertyName, const QVariant& filePathDefaultValue, const QVariant& datasetDefaultValue, Category category, ImportHDF5Dataset* filter, - int groupIndex = -1); + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& filePathDefaultValue, const QString& datasetDefaultValue, Category category, ImportHDF5Dataset* filter, + int groupIndex = -1); ~ImportHDF5DatasetFilterParameter() override; - SIMPL_VIRTUAL_INSTANCE_PROPERTY(QVariant, DataSetDefaultValue) - SIMPL_POINTER_PROPERTY(ImportHDF5Dataset, Filter) + /** + * @brief Setter property for DataSetDefaultValue + */ + virtual void setDataSetDefaultValue(const QVariant& value); + + /** + * @brief Setter property for Filter + */ + void setFilter(ImportHDF5Dataset* value); + /** + * @brief Getter property for Filter + * @return Value of Filter + */ + ImportHDF5Dataset* getFilter() const; QString getWidgetType() const override; @@ -63,14 +99,19 @@ class SIMPLib_EXPORT ImportHDF5DatasetFilterParameter : public FilterParameter * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. * @param json The QJsonObject that the filter parameter writes to. */ - void writeJson(QJsonObject& json) override; + void writeJson(QJsonObject& json) const override; protected: ImportHDF5DatasetFilterParameter(); public: - ImportHDF5DatasetFilterParameter(const ImportHDF5DatasetFilterParameter&) = delete; // Copy Constructor Not Implemented - ImportHDF5DatasetFilterParameter(ImportHDF5DatasetFilterParameter&&) = delete; // Move Constructor Not Implemented + ImportHDF5DatasetFilterParameter(const ImportHDF5DatasetFilterParameter&) = delete; // Copy Constructor Not Implemented + ImportHDF5DatasetFilterParameter(ImportHDF5DatasetFilterParameter&&) = delete; // Move Constructor Not Implemented ImportHDF5DatasetFilterParameter& operator=(const ImportHDF5DatasetFilterParameter&) = delete; // Copy Assignment Not Implemented ImportHDF5DatasetFilterParameter& operator=(ImportHDF5DatasetFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + QVariant m_DataSetDefaultValue = {}; + + ImportHDF5Dataset* m_Filter = nullptr; }; diff --git a/Source/SIMPLib/FilterParameters/InputFileFilterParameter.cpp b/Source/SIMPLib/FilterParameters/InputFileFilterParameter.cpp index f8f5455281..0ce0643d78 100644 --- a/Source/SIMPLib/FilterParameters/InputFileFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/InputFileFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "InputFileFilterParameter.h" @@ -52,9 +52,9 @@ InputFileFilterParameter::~InputFileFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -InputFileFilterParameter::Pointer InputFileFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, const QString& fileExtension, const QString& fileType, - int groupIndex) +InputFileFilterParameter::Pointer InputFileFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, const QString& fileExtension, + const QString& fileType, int groupIndex) { InputFileFilterParameter::Pointer ptr = InputFileFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -79,24 +79,50 @@ QString InputFileFilterParameter::getWidgetType() const } // ----------------------------------------------------------------------------- -// +InputFileFilterParameter::Pointer InputFileFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + // ----------------------------------------------------------------------------- -void InputFileFilterParameter::readJson(const QJsonObject& json) +InputFileFilterParameter::Pointer InputFileFilterParameter::New() { - QJsonValue jsonValue = json[getPropertyName()]; - if(!jsonValue.isUndefined() && m_SetterCallback) - { - m_SetterCallback(jsonValue.toString("")); - } + Pointer sharedPtr(new(InputFileFilterParameter)); + return sharedPtr; } // ----------------------------------------------------------------------------- -// +QString InputFileFilterParameter::getNameOfClass() const +{ + return QString("InputFileFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString InputFileFilterParameter::ClassName() +{ + return QString("InputFileFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void InputFileFilterParameter::setFileExtension(const QString& value) +{ + m_FileExtension = value; +} + +// ----------------------------------------------------------------------------- +QString InputFileFilterParameter::getFileExtension() const +{ + return m_FileExtension; +} + +// ----------------------------------------------------------------------------- +void InputFileFilterParameter::setFileType(const QString& value) +{ + m_FileType = value; +} + // ----------------------------------------------------------------------------- -void InputFileFilterParameter::writeJson(QJsonObject& json) +QString InputFileFilterParameter::getFileType() const { - if(m_GetterCallback) - { - json[getPropertyName()] = m_GetterCallback(); - } + return m_FileType; } diff --git a/Source/SIMPLib/FilterParameters/InputFileFilterParameter.h b/Source/SIMPLib/FilterParameters/InputFileFilterParameter.h old mode 100755 new mode 100644 index 2b40687ce2..91e2515b6a --- a/Source/SIMPLib/FilterParameters/InputFileFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/InputFileFilterParameter.h @@ -1,43 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" +#include "SIMPLib/FilterParameters/AbstractIOFilterParameter.h" /** * @brief SIMPL_NEW_INPUT_FILE_FP This macro is a short-form way of instantiating an instance of @@ -49,99 +51,112 @@ * SIMPL_NEW_INPUT_FILE_FP("HumanLabel", PropertyName, Category, FilterName, FileExtension, FileType, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional parameters): - * SIMPL_NEW_INPUT_FILE_FP("Input File", InputFile, FilterParameter::Parameter, GenericExample, "*.txt", "", 1); + * SIMPL_NEW_INPUT_FILE_FP("Input File", InputFile, FilterParameter::Category::Parameter, GenericExample, "*.txt", "", 1); */ -#define SIMPL_NEW_INPUT_FILE_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (InputFileFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_INPUT_FILE_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(InputFileFilterParameter, __VA_ARGS__)) /** * @brief The InputFileFilterParameter class is used by filters to instantiate an InputFileWidget. By instantiating an instance of * this class in a filter's setupFilterParameters() method, an InputFileWidget will appear in the filter's "filter input" section in the DREAM3D GUI. */ -class SIMPLib_EXPORT InputFileFilterParameter : public FilterParameter +class SIMPLib_EXPORT InputFileFilterParameter : public AbstractIOFilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(InputFileFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(InputFileFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(InputFileFilterParameter) - SIMPL_STATIC_NEW_MACRO(InputFileFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(InputFileFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the InputFileFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_INPUT_FILE_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param fileExtension The possible file extensions that this InputFileWidget accepts. - * @param fileType The possible file types that this InputFileWidget accepts. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, const QString& fileExtension = QString(""), - const QString& fileType = QString(""), int groupIndex = -1); - - ~InputFileFilterParameter() override; - - SIMPL_INSTANCE_STRING_PROPERTY(FileExtension) - SIMPL_INSTANCE_STRING_PROPERTY(FileType) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief InputFileFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + using Self = InputFileFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for InputFileFilterParameter + */ + QString getNameOfClass() const override; + + /** + * @brief Returns the name of the class for InputFileFilterParameter + */ + static QString ClassName(); + + /** + * @brief New This function instantiates an instance of the InputFileFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_INPUT_FILE_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param fileExtension The possible file extensions that this InputFileWidget accepts. + * @param fileType The possible file types that this InputFileWidget accepts. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const QString& fileExtension = QString(""), const QString& fileType = QString(""), int groupIndex = -1); + + ~InputFileFilterParameter() override; + + /** + * @brief Setter property for FileExtension + */ + void setFileExtension(const QString& value); + + /** + * @brief Getter property for FileExtension + * @return Value of FileExtension + */ + QString getFileExtension() const; + + /** + * @brief Setter property for FileType + */ + void setFileType(const QString& value); + + /** + * @brief Getter property for FileType + * @return Value of FileType + */ + QString getFileType() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + +protected: + /** + * @brief InputFileFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ InputFileFilterParameter(); public: - InputFileFilterParameter(const InputFileFilterParameter&) = delete; // Copy Constructor Not Implemented - InputFileFilterParameter(InputFileFilterParameter&&) = delete; // Move Constructor Not Implemented + InputFileFilterParameter(const InputFileFilterParameter&) = delete; // Copy Constructor Not Implemented + InputFileFilterParameter(InputFileFilterParameter&&) = delete; // Move Constructor Not Implemented InputFileFilterParameter& operator=(const InputFileFilterParameter&) = delete; // Copy Assignment Not Implemented InputFileFilterParameter& operator=(InputFileFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +private: + QString m_FileExtension = {}; + QString m_FileType = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/InputPathFilterParameter.cpp b/Source/SIMPLib/FilterParameters/InputPathFilterParameter.cpp index d4992904ff..8d603d34af 100644 --- a/Source/SIMPLib/FilterParameters/InputPathFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/InputPathFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "InputPathFilterParameter.h" @@ -48,17 +48,14 @@ InputPathFilterParameter::~InputPathFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -InputPathFilterParameter::Pointer InputPathFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, const QString& fileExtension, const QString& fileType, - int groupIndex) +InputPathFilterParameter::Pointer InputPathFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { InputPathFilterParameter::Pointer ptr = InputPathFilterParameter::New(); ptr->setHumanLabel(humanLabel); ptr->setPropertyName(propertyName); ptr->setDefaultValue(defaultValue); ptr->setCategory(category); - ptr->setFileExtension(fileExtension); - ptr->setFileType(fileType); ptr->setGroupIndex(groupIndex); ptr->setSetterCallback(setterCallback); ptr->setGetterCallback(getterCallback); @@ -75,24 +72,26 @@ QString InputPathFilterParameter::getWidgetType() const } // ----------------------------------------------------------------------------- -// +InputPathFilterParameter::Pointer InputPathFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + // ----------------------------------------------------------------------------- -void InputPathFilterParameter::readJson(const QJsonObject& json) +InputPathFilterParameter::Pointer InputPathFilterParameter::New() { - QJsonValue jsonValue = json[getPropertyName()]; - if(!jsonValue.isUndefined() && m_SetterCallback) - { - m_SetterCallback(jsonValue.toString("")); - } + Pointer sharedPtr(new(InputPathFilterParameter)); + return sharedPtr; } // ----------------------------------------------------------------------------- -// +QString InputPathFilterParameter::getNameOfClass() const +{ + return QString("InputPathFilterParameter"); +} + // ----------------------------------------------------------------------------- -void InputPathFilterParameter::writeJson(QJsonObject& json) +QString InputPathFilterParameter::ClassName() { - if(m_GetterCallback) - { - json[getPropertyName()] = m_GetterCallback(); - } + return QString("InputPathFilterParameter"); } diff --git a/Source/SIMPLib/FilterParameters/InputPathFilterParameter.h b/Source/SIMPLib/FilterParameters/InputPathFilterParameter.h old mode 100755 new mode 100644 index ebdbd5b0c6..2c50423ff7 --- a/Source/SIMPLib/FilterParameters/InputPathFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/InputPathFilterParameter.h @@ -1,43 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" +#include "SIMPLib/FilterParameters/AbstractIOFilterParameter.h" /** * @brief SIMPL_NEW_INPUT_PATH_FP This macro is a short-form way of instantiating an instance of @@ -49,99 +51,86 @@ * SIMPL_NEW_INPUT_PATH_FP("HumanLabel", PropertyName, Category, FilterName, FileExtension, FileType, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional parameters): - * SIMPL_NEW_INPUT_PATH_FP("Input Path", InputPath, FilterParameter::Parameter, GenericExample, "*.txt", "", 2); + * SIMPL_NEW_INPUT_PATH_FP("Input Path", InputPath, FilterParameter::Category::Parameter, GenericExample, "*.txt", "", 2); */ -#define SIMPL_NEW_INPUT_PATH_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (InputPathFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_INPUT_PATH_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(InputPathFilterParameter, __VA_ARGS__)) /** * @brief The InputPathFilterParameter class is used by filters to instantiate an InputPathWidget. By instantiating an instance of * this class in a filter's setupFilterParameters() method, an InputPathWidget will appear in the filter's "filter input" section in the DREAM3D GUI. */ -class SIMPLib_EXPORT InputPathFilterParameter : public FilterParameter +class SIMPLib_EXPORT InputPathFilterParameter : public AbstractIOFilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(InputPathFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(InputPathFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(InputPathFilterParameter) - SIMPL_STATIC_NEW_MACRO(InputPathFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(InputPathFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the InputPathFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_INPUT_PATH_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param fileExtension The possible file extensions that this InputPathWidget accepts. - * @param fileType The possible file types that this InputPathWidget accepts. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, const QString& fileExtension = QString(""), - const QString& fileType = QString(""), int groupIndex = -1); - - ~InputPathFilterParameter() override; - - SIMPL_INSTANCE_STRING_PROPERTY(FileExtension) - SIMPL_INSTANCE_STRING_PROPERTY(FileType) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief InputPathFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + using Self = InputPathFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for InputPathFilterParameter + */ + QString getNameOfClass() const override; + + /** + * @brief Returns the name of the class for InputPathFilterParameter + */ + static QString ClassName(); + + /** + * @brief New This function instantiates an instance of the InputPathFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_INPUT_PATH_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param fileExtension The possible file extensions that this InputPathWidget accepts. + * @param fileType The possible file types that this InputPathWidget accepts. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~InputPathFilterParameter() override; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + +protected: + /** + * @brief InputPathFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ InputPathFilterParameter(); public: - InputPathFilterParameter(const InputPathFilterParameter&) = delete; // Copy Constructor Not Implemented - InputPathFilterParameter(InputPathFilterParameter&&) = delete; // Move Constructor Not Implemented + InputPathFilterParameter(const InputPathFilterParameter&) = delete; // Copy Constructor Not Implemented + InputPathFilterParameter(InputPathFilterParameter&&) = delete; // Move Constructor Not Implemented InputPathFilterParameter& operator=(const InputPathFilterParameter&) = delete; // Copy Assignment Not Implemented InputPathFilterParameter& operator=(InputPathFilterParameter&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/FilterParameters/IntFilterParameter.cpp b/Source/SIMPLib/FilterParameters/IntFilterParameter.cpp index 0e5acda479..99f86851d1 100644 --- a/Source/SIMPLib/FilterParameters/IntFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/IntFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "IntFilterParameter.h" @@ -48,8 +48,8 @@ IntFilterParameter::~IntFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IntFilterParameter::Pointer IntFilterParameter::New(const QString& humanLabel, const QString& propertyName, const int& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex) +IntFilterParameter::Pointer IntFilterParameter::Create(const QString& humanLabel, const QString& propertyName, int defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex) { IntFilterParameter::Pointer ptr = IntFilterParameter::New(); @@ -78,6 +78,10 @@ QString IntFilterParameter::getWidgetType() const void IntFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { m_SetterCallback(jsonValue.toInt(0.0)); @@ -87,10 +91,59 @@ void IntFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void IntFilterParameter::writeJson(QJsonObject& json) +void IntFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { json[getPropertyName()] = m_GetterCallback(); } } + +// ----------------------------------------------------------------------------- +IntFilterParameter::Pointer IntFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +IntFilterParameter::Pointer IntFilterParameter::New() +{ + Pointer sharedPtr(new(IntFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString IntFilterParameter::getNameOfClass() const +{ + return QString("IntFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString IntFilterParameter::ClassName() +{ + return QString("IntFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void IntFilterParameter::setSetterCallback(const IntFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +IntFilterParameter::SetterCallbackType IntFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void IntFilterParameter::setGetterCallback(const IntFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +IntFilterParameter::GetterCallbackType IntFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/IntFilterParameter.h b/Source/SIMPLib/FilterParameters/IntFilterParameter.h old mode 100755 new mode 100644 index 8d4746d3bc..90debd54c9 --- a/Source/SIMPLib/FilterParameters/IntFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/IntFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" @@ -49,12 +51,10 @@ * SIMPL_NEW_INTEGER_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): - * SIMPL_NEW_INTEGER_FP("Max Iterations", MaxIterations, FilterParameter::Parameter, GenericExample, 0); + * SIMPL_NEW_INTEGER_FP("Max Iterations", MaxIterations, FilterParameter::Category::Parameter, GenericExample, 0); */ -#define SIMPL_NEW_INTEGER_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (IntFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_INTEGER_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(IntFilterParameter, __VA_ARGS__)) /** * @brief The IntFilterParameter class is used by filters to instantiate an IntWidget. By instantiating an instance of @@ -62,81 +62,120 @@ */ class SIMPLib_EXPORT IntFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(IntFilterParameter) - SIMPL_STATIC_NEW_MACRO(IntFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(IntFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the IntFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_INTEGER_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const int& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); - - ~IntFilterParameter() override; - - /** + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(IntFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(IntFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = IntFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for IntFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for IntFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the IntFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_INTEGER_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, int defaultValue, Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + int groupIndex = -1); + + ~IntFilterParameter() override; + + /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief IntFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - IntFilterParameter(); - - public: - IntFilterParameter(const IntFilterParameter&) = delete; // Copy Constructor Not Implemented - IntFilterParameter(IntFilterParameter&&) = delete; // Move Constructor Not Implemented - IntFilterParameter& operator=(const IntFilterParameter&) = delete; // Copy Assignment Not Implemented - IntFilterParameter& operator=(IntFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + QString getWidgetType() const override; + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const IntFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + IntFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const IntFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + IntFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief IntFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + IntFilterParameter(); + +public: + IntFilterParameter(const IntFilterParameter&) = delete; // Copy Constructor Not Implemented + IntFilterParameter(IntFilterParameter&&) = delete; // Move Constructor Not Implemented + IntFilterParameter& operator=(const IntFilterParameter&) = delete; // Copy Assignment Not Implemented + IntFilterParameter& operator=(IntFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + IntFilterParameter::SetterCallbackType m_SetterCallback = {}; + IntFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/IntVec2FilterParameter.cpp b/Source/SIMPLib/FilterParameters/IntVec2FilterParameter.cpp new file mode 100644 index 0000000000..2c62bffe95 --- /dev/null +++ b/Source/SIMPLib/FilterParameters/IntVec2FilterParameter.cpp @@ -0,0 +1,160 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "IntVec2FilterParameter.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IntVec2FilterParameter::IntVec2FilterParameter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IntVec2FilterParameter::~IntVec2FilterParameter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +IntVec2FilterParameter::Pointer IntVec2FilterParameter::Create(const QString& humanLabel, const QString& propertyName, const IntVec2Type& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) +{ + + IntVec2FilterParameter::Pointer ptr = IntVec2FilterParameter::New(); + ptr->setHumanLabel(humanLabel); + ptr->setPropertyName(propertyName); + QVariant v; + v.setValue(defaultValue); + ptr->setDefaultValue(v); + ptr->setCategory(category); + ptr->setGroupIndex(groupIndex); + ptr->setSetterCallback(setterCallback); + ptr->setGetterCallback(getterCallback); + + return ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString IntVec2FilterParameter::getWidgetType() const +{ + return QString("IntVec2Widget"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void IntVec2FilterParameter::readJson(const QJsonObject& json) +{ + QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } + if(!jsonValue.isUndefined() && m_SetterCallback) + { + QJsonObject json = jsonValue.toObject(); + IntVec2Type intVec2; + if(json["x"].isDouble() && json["y"].isDouble()) + { + intVec2[0] = json["x"].toInt(); + intVec2[1] = json["y"].toInt(); + } + m_SetterCallback(intVec2); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void IntVec2FilterParameter::writeJson(QJsonObject& obj) const +{ + if(m_GetterCallback) + { + IntVec2Type intVec2 = m_GetterCallback(); + QJsonObject json; + json["x"] = intVec2.getX(); + json["y"] = intVec2.getY(); + obj[getPropertyName()] = json; + } +} + +// ----------------------------------------------------------------------------- +IntVec2FilterParameter::Pointer IntVec2FilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +IntVec2FilterParameter::Pointer IntVec2FilterParameter::New() +{ + Pointer sharedPtr(new(IntVec2FilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString IntVec2FilterParameter::getNameOfClass() const +{ + return QString("IntVec2FilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString IntVec2FilterParameter::ClassName() +{ + return QString("IntVec2FilterParameter"); +} + +// ----------------------------------------------------------------------------- +void IntVec2FilterParameter::setSetterCallback(const IntVec2FilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +IntVec2FilterParameter::SetterCallbackType IntVec2FilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void IntVec2FilterParameter::setGetterCallback(const IntVec2FilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +IntVec2FilterParameter::GetterCallbackType IntVec2FilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/IntVec2FilterParameter.h b/Source/SIMPLib/FilterParameters/IntVec2FilterParameter.h new file mode 100644 index 0000000000..e7bb386b79 --- /dev/null +++ b/Source/SIMPLib/FilterParameters/IntVec2FilterParameter.h @@ -0,0 +1,183 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include + +#include + +#include "SIMPLib/Common/SIMPLArray.hpp" +#include "SIMPLib/FilterParameters/FilterParameter.h" + +/** + * @brief SIMPL_NEW_INT_VEC2_FP This macro is a short-form way of instantiating an instance of + * IntVec2FilterParameter. There are 4 required parameters and 2 optional parameter + * that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, + * FilterName (class name), Units (optional), GroupIndex (optional). + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_INT_VEC2_FP("HumanLabel", PropertyName, Category, FilterName, Units, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional parameters): + * SIMPL_NEW_INT_VEC2_FP("Dimensions (XY)", Dimensions, FilterParameter::Category::Parameter, GenericExample); + */ +#define SIMPL_NEW_INT_VEC2_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(IntVec2FilterParameter, __VA_ARGS__)) + +/** + * @brief The IntVec2FilterParameter class is used by filters to instantiate an IntVec2Widget. By instantiating an instance of + * this class in a filter's setupFilterParameters() method, an IntVec2Widget will appear in the filter's "filter input" section in the DREAM3D GUI. + */ +class SIMPLib_EXPORT IntVec2FilterParameter : public FilterParameter +{ + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(IntVec2FilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(IntVec2FilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = IntVec2FilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for IntVec2FilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for IntVec2FilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the IntVec2FilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_INT_VEC2_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const IntVec2Type& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~IntVec2FilterParameter() override; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const IntVec2FilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + IntVec2FilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const IntVec2FilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + IntVec2FilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief IntVec2FilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + IntVec2FilterParameter(); + +public: + IntVec2FilterParameter(const IntVec2FilterParameter&) = delete; // Copy Constructor Not Implemented + IntVec2FilterParameter(IntVec2FilterParameter&&) = delete; // Move Constructor Not Implemented + IntVec2FilterParameter& operator=(const IntVec2FilterParameter&) = delete; // Copy Assignment Not Implemented + IntVec2FilterParameter& operator=(IntVec2FilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + IntVec2FilterParameter::SetterCallbackType m_SetterCallback = {}; + IntVec2FilterParameter::GetterCallbackType m_GetterCallback = {}; +}; + +Q_DECLARE_METATYPE(IntVec2Type) diff --git a/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.cpp b/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.cpp index 8bbda60e11..acee821e5d 100644 --- a/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "IntVec3FilterParameter.h" @@ -48,8 +48,8 @@ IntVec3FilterParameter::~IntVec3FilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IntVec3FilterParameter::Pointer IntVec3FilterParameter::New(const QString& humanLabel, const QString& propertyName, const IntVec3_t& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex) +IntVec3FilterParameter::Pointer IntVec3FilterParameter::Create(const QString& humanLabel, const QString& propertyName, const IntVec3Type& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { IntVec3FilterParameter::Pointer ptr = IntVec3FilterParameter::New(); @@ -80,11 +80,20 @@ QString IntVec3FilterParameter::getWidgetType() const void IntVec3FilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { - QJsonObject obj = jsonValue.toObject(); - IntVec3_t intVec3; - intVec3.readJson(obj); + QJsonObject json = jsonValue.toObject(); + IntVec3Type intVec3; + if(json["x"].isDouble() && json["y"].isDouble() && json["z"].isDouble()) + { + intVec3[0] = json["x"].toInt(); + intVec3[1] = json["y"].toInt(); + intVec3[2] = json["z"].toInt(); + } m_SetterCallback(intVec3); } } @@ -92,13 +101,64 @@ void IntVec3FilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void IntVec3FilterParameter::writeJson(QJsonObject& json) +void IntVec3FilterParameter::writeJson(QJsonObject& obj) const { - if (m_GetterCallback) + if(m_GetterCallback) { - IntVec3_t intVec3 = m_GetterCallback(); - QJsonObject obj; - intVec3.writeJson(obj); - json[getPropertyName()] = obj; + IntVec3Type intVec3 = m_GetterCallback(); + QJsonObject json; + json["x"] = intVec3.getX(); + json["y"] = intVec3.getY(); + json["z"] = intVec3.getZ(); + obj[getPropertyName()] = json; } } + +// ----------------------------------------------------------------------------- +IntVec3FilterParameter::Pointer IntVec3FilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +IntVec3FilterParameter::Pointer IntVec3FilterParameter::New() +{ + Pointer sharedPtr(new(IntVec3FilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString IntVec3FilterParameter::getNameOfClass() const +{ + return QString("IntVec3FilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString IntVec3FilterParameter::ClassName() +{ + return QString("IntVec3FilterParameter"); +} + +// ----------------------------------------------------------------------------- +void IntVec3FilterParameter::setSetterCallback(const IntVec3FilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +IntVec3FilterParameter::SetterCallbackType IntVec3FilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void IntVec3FilterParameter::setGetterCallback(const IntVec3FilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +IntVec3FilterParameter::GetterCallbackType IntVec3FilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.h b/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.h old mode 100755 new mode 100644 index b73828c2cc..af450dfa48 --- a/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.h +++ b/Source/SIMPLib/FilterParameters/IntVec3FilterParameter.h @@ -1,44 +1,47 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include +#include + #include +#include "SIMPLib/Common/SIMPLArray.hpp" #include "SIMPLib/FilterParameters/FilterParameter.h" -#include "SIMPLib/FilterParameters/IntVec3.h" /** * @brief SIMPL_NEW_INT_VEC3_FP This macro is a short-form way of instantiating an instance of @@ -50,12 +53,10 @@ * SIMPL_NEW_INT_VEC3_FP("HumanLabel", PropertyName, Category, FilterName, Units, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional parameters): - * SIMPL_NEW_INT_VEC3_FP("Dimensions (XYZ)", Dimensions, FilterParameter::Parameter, GenericExample); + * SIMPL_NEW_INT_VEC3_FP("Dimensions (XYZ)", Dimensions, FilterParameter::Category::Parameter, GenericExample); */ -#define SIMPL_NEW_INT_VEC3_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (IntVec3FilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_INT_VEC3_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(IntVec3FilterParameter, __VA_ARGS__)) /** * @brief The IntVec3FilterParameter class is used by filters to instantiate an IntVec3Widget. By instantiating an instance of @@ -63,80 +64,122 @@ */ class SIMPLib_EXPORT IntVec3FilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(IntVec3FilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(IntVec3FilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(IntVec3FilterParameter) - SIMPL_STATIC_NEW_MACRO(IntVec3FilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(IntVec3FilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the IntVec3FilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_INT_VEC3_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const IntVec3_t& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); - - ~IntVec3FilterParameter() override; + using Self = IntVec3FilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for IntVec3FilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for IntVec3FilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the IntVec3FilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_INT_VEC3_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const IntVec3Type& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~IntVec3FilterParameter() override; /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @return The SetterCallback - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief IntVec3FilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const IntVec3FilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + IntVec3FilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const IntVec3FilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + IntVec3FilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief IntVec3FilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ IntVec3FilterParameter(); public: - IntVec3FilterParameter(const IntVec3FilterParameter&) = delete; // Copy Constructor Not Implemented - IntVec3FilterParameter(IntVec3FilterParameter&&) = delete; // Move Constructor Not Implemented + IntVec3FilterParameter(const IntVec3FilterParameter&) = delete; // Copy Constructor Not Implemented + IntVec3FilterParameter(IntVec3FilterParameter&&) = delete; // Move Constructor Not Implemented IntVec3FilterParameter& operator=(const IntVec3FilterParameter&) = delete; // Copy Assignment Not Implemented IntVec3FilterParameter& operator=(IntVec3FilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + IntVec3FilterParameter::SetterCallbackType m_SetterCallback = {}; + IntVec3FilterParameter::GetterCallbackType m_GetterCallback = {}; }; +Q_DECLARE_METATYPE(IntVec3Type) diff --git a/Source/SIMPLib/FilterParameters/JsonFilterParametersReader.cpp b/Source/SIMPLib/FilterParameters/JsonFilterParametersReader.cpp index 21a485610c..dc2bfcf6f7 100644 --- a/Source/SIMPLib/FilterParameters/JsonFilterParametersReader.cpp +++ b/Source/SIMPLib/FilterParameters/JsonFilterParametersReader.cpp @@ -1,50 +1,49 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "JsonFilterParametersReader.h" -#include #include -#include #include -#include #include +#include #include "SIMPLib/Common/Constants.h" #include "SIMPLib/CoreFilters/EmptyFilter.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" +#include "SIMPLib/Messages/PipelineErrorMessage.h" #include "SIMPLib/Utilities/StringOperations.h" // ----------------------------------------------------------------------------- @@ -176,7 +175,7 @@ FilterPipeline::Pointer JsonFilterParametersReader::readPipelineFromFile(QString currentLine++; } - PipelineMessage pm(JsonFilterParametersReader::ClassName(), msg, -1, PipelineMessage::MessageType::Error); + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New("[NOT_READABLE]", QObject::tr("%1: %2").arg(JsonFilterParametersReader::ClassName()).arg(msg), -1); obs->processPipelineMessage(pm); } return FilterPipeline::NullPointer(); @@ -223,7 +222,7 @@ QString JsonFilterParametersReader::getJsonFromFile(QString filePath, IObserver* { QString msg = createErrorMessageFromJsonParseError(parseError); msg = QString("File '%1' had errors while parsing the json data.%2").arg(filePath) + msg; - PipelineMessage pm(JsonFilterParametersReader::ClassName(), msg, -1, PipelineMessage::MessageType::Error); + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New("[NOT_READABLE]", QObject::tr("%1: %2").arg(JsonFilterParametersReader::ClassName()).arg(msg), -1); obs->processPipelineMessage(pm); } return QString(); @@ -389,6 +388,17 @@ FilterPipeline::Pointer JsonFilterParametersReader::readPipelineFromString(QStri return pipeline; } +// ----------------------------------------------------------------------------- +FilterPipeline::Pointer JsonFilterParametersReader::readPipelineFromJson(const QJsonObject& contents, IObserver* obs) +{ + setPipelineContents(contents); + + FilterPipeline::Pointer pipeline = readPipeline(obs); + closeFile(); + + return pipeline; +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -396,19 +406,22 @@ FilterPipeline::Pointer JsonFilterParametersReader::readPipeline(IObserver* obs) { FilterManager* filtManager = FilterManager::Instance(); FilterFactory::Pointer emptyFilterFactory = FilterFactory::New(); - filtManager->addFilterFactory("EmptyFilter", emptyFilterFactory); + if(!filtManager->contains(emptyFilterFactory->getUuid())) + { + filtManager->addFilterFactory("EmptyFilter", emptyFilterFactory); + } if(!containsGroup(SIMPL::Settings::PipelineBuilderGroup)) { return FilterPipeline::NullPointer(); } - + QJsonObject builderObj = m_Root[SIMPL::Settings::PipelineBuilderGroup].toObject(); int filterCount = builderObj[SIMPL::Settings::NumFilters].toInt(); m_MaxFilterIndex = filterCount - 1; // Zero based indexing - + FilterPipeline::Pointer pipeline; - + if(filterCount >= 0) { pipeline = FilterPipeline::New(); @@ -419,11 +432,11 @@ FilterPipeline::Pointer JsonFilterParametersReader::readPipeline(IObserver* obs) { pipeline = FilterPipeline::NullPointer(); } - + for(int i = 0; i < filterCount; ++i) { openFilterGroup(nullptr, i); - + IFilterFactory::Pointer factory = IFilterFactory::NullPointer(); QString filterName = m_CurrentFilterIndex[SIMPL::Settings::FilterName].toString(); bool filterEnabled = m_CurrentFilterIndex[SIMPL::Settings::FilterEnabled].toBool(true); @@ -443,11 +456,11 @@ FilterPipeline::Pointer JsonFilterParametersReader::readPipeline(IObserver* obs) factory = filtManager->getFactoryFromClassName(filterName); } } - + if(nullptr != factory.get()) { AbstractFilter::Pointer filter = factory->create(); - + if(nullptr != filter.get()) { filter->setEnabled(filterEnabled); @@ -456,7 +469,7 @@ FilterPipeline::Pointer JsonFilterParametersReader::readPipeline(IObserver* obs) } } else // Could not find the filter because the specific name has not been registered. This could - // be due to a name change for the filter. + // be due to a name change for the filter. { EmptyFilter::Pointer filter = EmptyFilter::New(); QString humanLabel = QString("UNKNOWN FILTER: ") + filterName; @@ -464,15 +477,17 @@ FilterPipeline::Pointer JsonFilterParametersReader::readPipeline(IObserver* obs) filter->setOriginalFilterName(filterName); filter->setEnabled(filterEnabled); pipeline->pushBack(filter); - + if(nullptr != obs) { - QString ss = QObject::tr("An attempt to instantiate a filter from the pipeline file resulted in an error.\ - Possible reasons include a name change of the filter, plugin not loading or a simple spelling mistake? A \ - blank filter has been inserted in its place. Possible error message is: %1") - .arg(filterName); - PipelineMessage pm(filterName, ss, -66066, PipelineMessage::MessageType::Error); - pm.setPrefix("JsonFilterParametersReader::ReadPipelineFromFile()"); + QString msg; + QTextStream ss(&msg); + ss << "An attempt to instantiate a filter from the pipeline file resulted in an error.\n" + << "Possible reasons include a name change of the filter, plugin not loading or a simple spelling mistake? A \n" + << "blank filter has been inserted in its place. The filter name is: " << filterName << "\n"; + + QString prefix = "JsonFilterParametersReader::ReadPipelineFromFile()"; + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New(pipeline->getName(), QObject::tr("%1: %2").arg(prefix).arg(msg), -66066); obs->processPipelineMessage(pm); } } @@ -510,7 +525,7 @@ void JsonFilterParametersReader::readNameOfPipelineFromFile(QString filePath, QS { QString msg = createErrorMessageFromJsonParseError(parseError); msg = QString("File '%1' had errors while parsing the json data.%2").arg(fInfo.absoluteFilePath()) + msg; - PipelineMessage pm(JsonFilterParametersReader::ClassName(), msg, -1, PipelineMessage::MessageType::Error); + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New("[NOT_READABLE]", QObject::tr("%1: %2").arg(JsonFilterParametersReader::ClassName()).arg(msg), -1); obs->processPipelineMessage(pm); } name = QString("ERROR: Could not open file specified."); @@ -586,6 +601,17 @@ int JsonFilterParametersReader::setPipelineContents(QString contents) return err; } +// ----------------------------------------------------------------------------- +void JsonFilterParametersReader::setPipelineContents(const QJsonObject& contents) +{ + if(!m_Root.isEmpty() || !m_CurrentFilterIndex.isEmpty()) + { + closeFile(); + } + + m_Root = contents; +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -605,7 +631,7 @@ int JsonFilterParametersReader::openFilterGroup(AbstractFilter* unused, int inde Q_ASSERT(m_Root.isEmpty() == false); int err = 0; QString numStr = QString::number(index); - if(m_Root.find(numStr) != m_Root.end() ) + if(m_Root.find(numStr) != m_Root.end()) { m_CurrentFilterIndex = m_Root[numStr].toObject(); } @@ -675,3 +701,52 @@ int JsonFilterParametersReader::closeGroup() m_CurrentFilterIndex = QJsonObject(); return 0; } + +// ----------------------------------------------------------------------------- +JsonFilterParametersReader::Pointer JsonFilterParametersReader::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +JsonFilterParametersReader::Pointer JsonFilterParametersReader::New() +{ + Pointer sharedPtr(new(JsonFilterParametersReader)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString JsonFilterParametersReader::getNameOfClass() const +{ + return QString("JsonFilterParametersReader"); +} + +// ----------------------------------------------------------------------------- +QString JsonFilterParametersReader::ClassName() +{ + return QString("JsonFilterParametersReader"); +} + +// ----------------------------------------------------------------------------- +void JsonFilterParametersReader::setFileName(const QString& value) +{ + m_FileName = value; +} + +// ----------------------------------------------------------------------------- +QString JsonFilterParametersReader::getFileName() const +{ + return m_FileName; +} + +// ----------------------------------------------------------------------------- +void JsonFilterParametersReader::setMaxFilterIndex(int value) +{ + m_MaxFilterIndex = value; +} + +// ----------------------------------------------------------------------------- +int JsonFilterParametersReader::getMaxFilterIndex() const +{ + return m_MaxFilterIndex; +} diff --git a/Source/SIMPLib/FilterParameters/JsonFilterParametersReader.h b/Source/SIMPLib/FilterParameters/JsonFilterParametersReader.h index 6fc0396a20..38ca4a43c8 100644 --- a/Source/SIMPLib/FilterParameters/JsonFilterParametersReader.h +++ b/Source/SIMPLib/FilterParameters/JsonFilterParametersReader.h @@ -1,175 +1,235 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include + +#include #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersReader.h" #include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/Filtering/FilterPipeline.h" -#include "SIMPLib/SIMPLib.h" /** * @brief The JsonFilterParametersReader class */ class SIMPLib_EXPORT JsonFilterParametersReader : public AbstractFilterParametersReader { - public: - SIMPL_SHARED_POINTERS(JsonFilterParametersReader) - SIMPL_STATIC_NEW_MACRO(JsonFilterParametersReader) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(JsonFilterParametersReader, AbstractFilterParametersReader) - - ~JsonFilterParametersReader() override; - - SIMPL_INSTANCE_PROPERTY(QString, FileName) - SIMPL_INSTANCE_PROPERTY(int, MaxFilterIndex) - - /** - * @brief ReadPipelineFromFile Reads the Json formatted file and returns a FilterPipeline object - * that contains all the filters that could be found. If a filter can not be found then that filter is simply skipped. - * If the IObserver is NON-Null then an error message will be passed to it with an error message - * @param filePath The path to the INI formatted file - * @param format The format of the file which is anything that QSettings understands - * @param obs An IObserver object to report errors. - * @return Shared Pointer to a FilterPipeline Instance - */ - FilterPipeline::Pointer readPipelineFromFile(QString filePath, IObserver* obs = nullptr); - - /** - * @brief getJsonFromFile Reads the Json formatted file and returns a json string - * that contains all the filters that could be found. If a filter can not be found then that filter is simply skipped. - * If the IObserver is NON-Null then an error message will be passed to it with an error message - * @param filePath The path to the INI formatted file - * @param format The format of the file which is anything that QSettings understands - * @param obs An IObserver object to report errors. - * @return Shared Pointer to a FilterPipeline Instance - */ - QString getJsonFromFile(QString filePath, IObserver* obs = nullptr); - - /** - * @brief ReadPipelineFromString Reads the Json formatted file and returns a FilterPipeline object - * that contains all the filters that could be found. If a filter can not be found then that filter is simply skipped. - * If the IObserver is NON-Null then an error message will be passed to it with an error message - * @param filePath The path to the INI formatted file - * @param format The format of the file which is anything that QSettings understands - * @param obs An IObserver object to report errors. - * @return Shared Pointer to a FilterPipeline Instance - */ - FilterPipeline::Pointer readPipelineFromString(QString contents, IObserver* obs = nullptr); - - /** - * @brief Gets the name of the pipeline from a pipeline file - * @param filePath The absolute path to the pipeline file. - * @param name Sets the name of the pipeline into this variable - * @param version Sets the DREAM3D Version into this variable. - * @param obs Any observer that needs to know about errors. - * @return - */ - void readNameOfPipelineFromFile(QString filePath, QString& name, QString& version, IObserver* obs = nullptr); - - /** - * @brief Generate an html formatted string that summarizes the pipeline file by listing - * each filter by it's human name and C++ class name. - * @param filePath The path to the pipeline file - * @param obs Any observer that needs to know about errors. - * @return html formatted string - */ - static QString HtmlSummaryFromFile(QString filePath, IObserver* obs); - - /** - * @brief Opens the pipeline file for operations - * @param filePath The path to the pipeline file - * @return - */ - QJsonParseError openFile(QString filePath); - - /** - * @brief setPipelineContents - * @param contents - * @return - */ - int setPipelineContents(QString contents); - - /** - * @brief closeFile - */ - void closeFile(); - - /** - * @brief openFilterGroup - * @param unused - * @param index - * @return - */ - int openFilterGroup(AbstractFilter* unused, int index) override; - - /** - * @brief closeFilterGroup - * @return - */ - int closeFilterGroup() override; - - /* - * @brief getCurrentGroupObject - * @return - */ - QJsonObject& getCurrentGroupObject(); - - bool containsGroup(QString key); - - int openGroup(QString key); - int closeGroup(); - - protected: - JsonFilterParametersReader(); - - private: - QJsonObject m_Root; - QJsonObject m_CurrentFilterIndex; - - FilterPipeline::Pointer readPipeline(IObserver* obs); - - public: - JsonFilterParametersReader(const JsonFilterParametersReader&) = delete; // Copy Constructor Not Implemented - JsonFilterParametersReader(JsonFilterParametersReader&&) = delete; // Move Constructor Not Implemented - JsonFilterParametersReader& operator=(const JsonFilterParametersReader&) = delete; // Copy Assignment Not Implemented - JsonFilterParametersReader& operator=(JsonFilterParametersReader&&) = delete; // Move Assignment Not Implemented -}; - + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(JsonFilterParametersReader) + PYB11_SHARED_POINTERS(JsonFilterParametersReader) + PYB11_STATIC_NEW_MACRO(JsonFilterParametersReader) + PYB11_METHOD(FilterPipeline::Pointer readPipelineFromFile) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = JsonFilterParametersReader; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for JsonFilterParametersReader + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for JsonFilterParametersReader + */ + static QString ClassName(); + + ~JsonFilterParametersReader() override; + + /** + * @brief Setter property for FileName + */ + void setFileName(const QString& value); + /** + * @brief Getter property for FileName + * @return Value of FileName + */ + QString getFileName() const; + + /** + * @brief Setter property for MaxFilterIndex + */ + void setMaxFilterIndex(int value); + /** + * @brief Getter property for MaxFilterIndex + * @return Value of MaxFilterIndex + */ + int getMaxFilterIndex() const; + + /** + * @brief ReadPipelineFromFile Reads the Json formatted file and returns a FilterPipeline object + * that contains all the filters that could be found. If a filter can not be found then that filter is simply skipped. + * If the IObserver is NON-Null then an error message will be passed to it with an error message + * @param filePath The path to the INI formatted file + * @param format The format of the file which is anything that QSettings understands + * @param obs An IObserver object to report errors. + * @return Shared Pointer to a FilterPipeline Instance + */ + FilterPipeline::Pointer readPipelineFromFile(QString filePath, IObserver* obs = nullptr); + + /** + * @brief getJsonFromFile Reads the Json formatted file and returns a json string + * that contains all the filters that could be found. If a filter can not be found then that filter is simply skipped. + * If the IObserver is NON-Null then an error message will be passed to it with an error message + * @param filePath The path to the INI formatted file + * @param format The format of the file which is anything that QSettings understands + * @param obs An IObserver object to report errors. + * @return Shared Pointer to a FilterPipeline Instance + */ + QString getJsonFromFile(QString filePath, IObserver* obs = nullptr); + + /** + * @brief ReadPipelineFromString Reads the Json formatted file and returns a FilterPipeline object + * that contains all the filters that could be found. If a filter can not be found then that filter is simply skipped. + * If the IObserver is NON-Null then an error message will be passed to it with an error message + * @param filePath The path to the INI formatted file + * @param format The format of the file which is anything that QSettings understands + * @param obs An IObserver object to report errors. + * @return Shared Pointer to a FilterPipeline Instance + */ + FilterPipeline::Pointer readPipelineFromString(QString contents, IObserver* obs = nullptr); + + /** + * @brief ReadPipelineFromString Reads the Json and returns a FilterPipeline object + * that contains all the filters that could be found. If a filter can not be found then that filter is simply skipped. + * If the IObserver is NON-Null then an error message will be passed to it with an error message + * @param filePath The path to the INI formatted file + * @param format The format of the file which is anything that QSettings understands + * @param obs An IObserver object to report errors. + * @return Shared Pointer to a FilterPipeline Instance + */ + FilterPipeline::Pointer readPipelineFromJson(const QJsonObject& contents, IObserver* obs = nullptr); + + /** + * @brief Gets the name of the pipeline from a pipeline file + * @param filePath The absolute path to the pipeline file. + * @param name Sets the name of the pipeline into this variable + * @param version Sets the DREAM3D Version into this variable. + * @param obs Any observer that needs to know about errors. + * @return + */ + void readNameOfPipelineFromFile(QString filePath, QString& name, QString& version, IObserver* obs = nullptr); + + /** + * @brief Generate an html formatted string that summarizes the pipeline file by listing + * each filter by it's human name and C++ class name. + * @param filePath The path to the pipeline file + * @param obs Any observer that needs to know about errors. + * @return html formatted string + */ + static QString HtmlSummaryFromFile(QString filePath, IObserver* obs); + + /** + * @brief Opens the pipeline file for operations + * @param filePath The path to the pipeline file + * @return + */ + QJsonParseError openFile(QString filePath); + + /** + * @brief setPipelineContents + * @param contents + * @return + */ + int setPipelineContents(QString contents); + + /** + * @brief setPipelineContents + * @param contents + * @return + */ + void setPipelineContents(const QJsonObject& contents); + + /** + * @brief closeFile + */ + void closeFile(); + + /** + * @brief openFilterGroup + * @param unused + * @param index + * @return + */ + int openFilterGroup(AbstractFilter* unused, int index) override; + + /** + * @brief closeFilterGroup + * @return + */ + int closeFilterGroup() override; + + /* + * @brief getCurrentGroupObject + * @return + */ + QJsonObject& getCurrentGroupObject(); + + bool containsGroup(QString key); + + int openGroup(QString key); + int closeGroup(); + +protected: + JsonFilterParametersReader(); + +private: + QString m_FileName = {}; + int m_MaxFilterIndex = {}; + + QJsonObject m_Root; + QJsonObject m_CurrentFilterIndex; + + FilterPipeline::Pointer readPipeline(IObserver* obs); + +public: + JsonFilterParametersReader(const JsonFilterParametersReader&) = delete; // Copy Constructor Not Implemented + JsonFilterParametersReader(JsonFilterParametersReader&&) = delete; // Move Constructor Not Implemented + JsonFilterParametersReader& operator=(const JsonFilterParametersReader&) = delete; // Copy Assignment Not Implemented + JsonFilterParametersReader& operator=(JsonFilterParametersReader&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/FilterParameters/JsonFilterParametersWriter.cpp b/Source/SIMPLib/FilterParameters/JsonFilterParametersWriter.cpp index fd027f0187..88876b6be0 100644 --- a/Source/SIMPLib/FilterParameters/JsonFilterParametersWriter.cpp +++ b/Source/SIMPLib/FilterParameters/JsonFilterParametersWriter.cpp @@ -1,69 +1,63 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include #include -#include #include #include +#include #include "JsonFilterParametersWriter.h" + #include "SIMPLib/Common/Constants.h" #include "SIMPLib/CoreFilters/DataContainerReader.h" +#include "SIMPLib/Filtering/BadFilter.h" +#include "SIMPLib/Messages/PipelineErrorMessage.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -JsonFilterParametersWriter::JsonFilterParametersWriter() -: - m_ExpandReaderFilters(true) -, m_MaxFilterIndex(-1) -, m_CurrentIndex(0) - -{ -} +JsonFilterParametersWriter::JsonFilterParametersWriter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -JsonFilterParametersWriter::JsonFilterParametersWriter(QString& fileName, QString& pipelineName, int& numFilters) -: m_MaxFilterIndex(-1) -, m_CurrentIndex(0) +JsonFilterParametersWriter::JsonFilterParametersWriter(QString& fileName, QString& pipelineName) +: m_FileName(fileName) +, m_PipelineName(pipelineName) { - m_FileName = fileName; - m_PipelineName = pipelineName; } // ----------------------------------------------------------------------------- @@ -74,10 +68,10 @@ JsonFilterParametersWriter::~JsonFilterParametersWriter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int JsonFilterParametersWriter::writePipelineToFile(FilterPipeline::Pointer pipeline, QString filePath, QString pipelineName, QList obs) +int JsonFilterParametersWriter::writePipelineToFile(FilterPipeline::Pointer pipeline, QString filePath, QString pipelineName, bool expandPipeline, QList obs) { int err = 0; - err = populateWriter(pipeline, pipelineName, obs); + err = populateWriter(pipeline, pipelineName, expandPipeline, obs); if(err < 0) { return err; @@ -89,12 +83,23 @@ int JsonFilterParametersWriter::writePipelineToFile(FilterPipeline::Pointer pipe return err; } +// ----------------------------------------------------------------------------- +int JsonFilterParametersWriter::exportPipelineToFile(FilterPipeline::Pointer pipeline, QString filePath, QString pipelineName, bool expandPipeline, IObserver* obs) +{ + return writePipelineToFile(pipeline, filePath, pipelineName, expandPipeline, {obs}); +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString JsonFilterParametersWriter::writePipelineToString(FilterPipeline::Pointer pipeline, QString pipelineName, QList obs) +QString JsonFilterParametersWriter::writePipelineToString(FilterPipeline::Pointer pipeline, QString pipelineName, bool expandPipeline, QList obs) { - populateWriter(pipeline, pipelineName, obs); + int err = 0; + err = populateWriter(pipeline, pipelineName, expandPipeline, obs); + if(err < 0) + { + return {""}; + } QJsonDocument doc = toDocument(); QString contents = QString::fromStdString(doc.toJson().toStdString()); @@ -107,17 +112,18 @@ QString JsonFilterParametersWriter::writePipelineToString(FilterPipeline::Pointe // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int JsonFilterParametersWriter::populateWriter(FilterPipeline::Pointer pipeline, QString pipelineName, QList obs) +int JsonFilterParametersWriter::populateWriter(FilterPipeline::Pointer pipeline, QString pipelineName, bool expandPipeline, QList obs) { if(nullptr == pipeline.get()) { if(!obs.empty()) { - PipelineMessage pm(JsonFilterParametersWriter::ClassName(), "FilterPipeline Object was nullptr for writing", -1, PipelineMessage::MessageType::Error); + PipelineErrorMessage::Pointer pm = + PipelineErrorMessage::New(pipeline->getName(), QObject::tr("%1: FilterPipeline Object was nullptr for writing").arg(JsonFilterParametersWriter::ClassName()), -1); - for (int i = 0; i < obs.size(); i++) + for(int i = 0; i < obs.size(); i++) { - if (obs[i] != nullptr) + if(obs[i] != nullptr) { obs[i]->processPipelineMessage(pm); } @@ -143,7 +149,7 @@ int JsonFilterParametersWriter::populateWriter(FilterPipeline::Pointer pipeline, if(nullptr != filter.get()) { DataContainerReader::Pointer reader = std::dynamic_pointer_cast(filter); - if((reader.get() != nullptr) && m_ExpandReaderFilters) + if((reader.get() != nullptr) && expandPipeline) { offset = reader->writeExistingPipelineToFile(m_Root, i); } @@ -153,7 +159,7 @@ int JsonFilterParametersWriter::populateWriter(FilterPipeline::Pointer pipeline, } else { - AbstractFilter::Pointer badFilter = AbstractFilter::New(); + AbstractFilter::Pointer badFilter = BadFilter::New(); openFilterGroup(badFilter.get(), i + offset); m_CurrentFilterIndex["Unknown Filter"] = "ERROR: Filter instance was nullptr within the SVPipelineFilterWidget instance. Report this error to the DREAM3D Developers"; closeFilterGroup(); @@ -290,7 +296,7 @@ int JsonFilterParametersWriter::closeFilterGroup() // ----------------------------------------------------------------------------- QString JsonFilterParametersWriter::generateIndexString(int currentIndex) { - Q_UNUSED(currentIndex); + Q_UNUSED(currentIndex) QString numStr = QString::number(m_CurrentIndex); if(m_MaxFilterIndex > 10) @@ -310,3 +316,64 @@ QString JsonFilterParametersWriter::generateIndexString(int currentIndex) } return numStr; } + +// ----------------------------------------------------------------------------- +JsonFilterParametersWriter::Pointer JsonFilterParametersWriter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +JsonFilterParametersWriter::Pointer JsonFilterParametersWriter::New() +{ + Pointer sharedPtr(new(JsonFilterParametersWriter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString JsonFilterParametersWriter::getNameOfClass() const +{ + return QString("JsonFilterParametersWriter"); +} + +// ----------------------------------------------------------------------------- +QString JsonFilterParametersWriter::ClassName() +{ + return QString("JsonFilterParametersWriter"); +} + +// ----------------------------------------------------------------------------- +void JsonFilterParametersWriter::setFileName(const QString& value) +{ + m_FileName = value; +} + +// ----------------------------------------------------------------------------- +QString JsonFilterParametersWriter::getFileName() const +{ + return m_FileName; +} + +// ----------------------------------------------------------------------------- +void JsonFilterParametersWriter::setPipelineName(const QString& value) +{ + m_PipelineName = value; +} + +// ----------------------------------------------------------------------------- +QString JsonFilterParametersWriter::getPipelineName() const +{ + return m_PipelineName; +} + +// ----------------------------------------------------------------------------- +void JsonFilterParametersWriter::setMaxFilterIndex(int value) +{ + m_MaxFilterIndex = value; +} + +// ----------------------------------------------------------------------------- +int JsonFilterParametersWriter::getMaxFilterIndex() const +{ + return m_MaxFilterIndex; +} diff --git a/Source/SIMPLib/FilterParameters/JsonFilterParametersWriter.h b/Source/SIMPLib/FilterParameters/JsonFilterParametersWriter.h index 62f3df79aa..11534bbd7a 100644 --- a/Source/SIMPLib/FilterParameters/JsonFilterParametersWriter.h +++ b/Source/SIMPLib/FilterParameters/JsonFilterParametersWriter.h @@ -1,49 +1,50 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" #include "SIMPLib/FilterParameters/AbstractFilterParametersWriter.h" #include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/Filtering/FilterPipeline.h" -#include "SIMPLib/SIMPLib.h" /** * @class @@ -54,90 +55,175 @@ */ class SIMPLib_EXPORT JsonFilterParametersWriter : public AbstractFilterParametersWriter { - public: - SIMPL_SHARED_POINTERS(JsonFilterParametersWriter) - SIMPL_STATIC_NEW_MACRO(JsonFilterParametersWriter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(JsonFilterParametersWriter, AbstractFilterParametersWriter) - - SIMPL_INSTANCE_PROPERTY(QString, FileName) - SIMPL_INSTANCE_PROPERTY(QString, PipelineName) - SIMPL_INSTANCE_PROPERTY(bool, ExpandReaderFilters) - - JsonFilterParametersWriter(QString& fileName, QString& pipelineName, int& numFilters); - - ~JsonFilterParametersWriter() override; - - /** - * @brief WritePipelineToFile This function will write a pipeline to a - * JSON file. The file path passed in WILL BE OVER WRITTEN by this - * function WITHOUT WARNING - * @param pipeline The pipeline to be written - * @param filePath The file path to write - * @param pipelineName The name of the pipeline (Typically the name of the file) - * @param obs Any observer that we can pass error/warning messages back to in case something goes wrong. - * @return - */ - int writePipelineToFile(FilterPipeline::Pointer pipeline, QString filePath, QString pipelineName, QList obs = QList()) override; - - /** - * @brief WritePipelineToString This function will write a pipeline to a QString. - * @param pipeline The pipeline to be written - * @param pipelineName The name of the pipeline (Typically the name of the file) - * @param obs Any observer that we can pass error/warning messages back to in case something goes wrong. - * @return The pipeline as a QString - */ - QString writePipelineToString(FilterPipeline::Pointer pipeline, QString pipelineName, QList obs = QList()); - - /** - * @brief openFilterGroup - * @param unused - * @param index - * @return - */ - int openFilterGroup(AbstractFilter* unused, int index) override; - - /** - * @brief closeFilterGroup - * @return - */ - int closeFilterGroup() override; - - - /** - * @brief getCurrentGroupObject - * @return - */ - QJsonObject& getCurrentGroupObject(); - - SIMPL_INSTANCE_PROPERTY(int, MaxFilterIndex) - - protected: - JsonFilterParametersWriter(); - - private: - QJsonObject m_Root; - QJsonObject m_CurrentFilterIndex; - int m_CurrentIndex; - - int populateWriter(FilterPipeline::Pointer pipeline, QString pipelineName, QList obs); - void writePipeline(); - void clearWriter(); - - QJsonDocument toDocument(); - - /** - * @brief generateIndexString Generates a possibly padded string that represents - * the current filter index. Used during the JSON document creation. - * @param currentIndex The numerical index that the string should be generated for. - * @return - */ - QString generateIndexString(int currentIndex); - - public: - JsonFilterParametersWriter(const JsonFilterParametersWriter&) = delete; // Copy Constructor Not Implemented - JsonFilterParametersWriter(JsonFilterParametersWriter&&) = delete; // Move Constructor Not Implemented - JsonFilterParametersWriter& operator=(const JsonFilterParametersWriter&) = delete; // Copy Assignment Not Implemented - JsonFilterParametersWriter& operator=(JsonFilterParametersWriter&&) = delete; // Move Assignment Not Implemented + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(JsonFilterParametersWriter) + PYB11_SHARED_POINTERS(JsonFilterParametersWriter) + PYB11_STATIC_NEW_MACRO(JsonFilterParametersWriter) + PYB11_METHOD(FilterPipeline::Pointer exportPipelineToFile) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = JsonFilterParametersWriter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief JsonFilterParametersWriter + * @param fileName + * @param pipelineName + */ + JsonFilterParametersWriter(QString& fileName, QString& pipelineName); + + ~JsonFilterParametersWriter() override; + + /** + * @brief Returns the name of the class for JsonFilterParametersWriter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for JsonFilterParametersWriter + */ + static QString ClassName(); + + /** + * @brief Setter property for FileName + */ + void setFileName(const QString& value); + /** + * @brief Getter property for FileName + * @return Value of FileName + */ + QString getFileName() const; + + /** + * @brief Setter property for PipelineName + */ + void setPipelineName(const QString& value); + /** + * @brief Getter property for PipelineName + * @return Value of PipelineName + */ + QString getPipelineName() const; + + /** + * @brief WritePipelineToFile This function will write a pipeline to a + * JSON file. The file path passed in WILL BE OVER WRITTEN by this + * function WITHOUT WARNING + * @param pipeline The pipeline to be written + * @param filePath The file path to write + * @param pipelineName The name of the pipeline (Typically the name of the file) + * @param expandPipeline Expand any embeded pipelines that are in DataContainerReader filters + * @param obs Any list of observers that we can pass error/warning messages back to in case something goes wrong. + * @return + */ + int writePipelineToFile(FilterPipeline::Pointer pipeline, QString filePath, QString pipelineName, bool expandPipelines, QList obs = QList()) override; + + /** + * @brief exportPipelineToFile This function will write a pipeline to a + * JSON file. The file path passed in WILL BE OVER WRITTEN by this + * function WITHOUT WARNING + * @param pipeline The pipeline to be written + * @param filePath The file path to write + * @param pipelineName The name of the pipeline (Typically the name of the file) + * @param expandPipeline Expand any embeded pipelines that are in DataContainerReader filters + * @param obs Any observer that we can pass error/warning messages back to in case something goes wrong. + * @return + */ + int exportPipelineToFile(FilterPipeline::Pointer pipeline, QString filePath, QString pipelineName, bool expandPipelines, IObserver* obs = nullptr); + + /** + * @brief WritePipelineToString This function will write a pipeline to a QString. + * @param pipeline The pipeline to be written + * @param pipelineName The name of the pipeline (Typically the name of the file) + * @param expandPipeline Expand any embeded pipelines that are in DataContainerReader filters + * @param obs Any observer that we can pass error/warning messages back to in case something goes wrong. + * @return The pipeline as a QString + */ + QString writePipelineToString(FilterPipeline::Pointer pipeline, QString pipelineName, bool expandPipeline, QList obs = QList()); + + /** + * @brief openFilterGroup + * @param unused + * @param index + * @return + */ + int openFilterGroup(AbstractFilter* unused, int index) override; + + /** + * @brief closeFilterGroup + * @return + */ + int closeFilterGroup() override; + +protected: + JsonFilterParametersWriter(); + +private: + int m_CurrentIndex = 0; + int m_MaxFilterIndex = -1; + QString m_FileName = {}; + QString m_PipelineName = {}; + QJsonObject m_Root; + QJsonObject m_CurrentFilterIndex; + + /** + * @brief Setter property for MaxFilterIndex + */ + void setMaxFilterIndex(int value); + /** + * @brief Getter property for MaxFilterIndex + * @return Value of MaxFilterIndex + */ + int getMaxFilterIndex() const; + + /** + * @brief getCurrentGroupObject + * @return + */ + QJsonObject& getCurrentGroupObject(); + + /** + * @brief populateWriter + * @param pipeline + * @param pipelineName + * @param obs + * @return + */ + int populateWriter(FilterPipeline::Pointer pipeline, QString pipelineName, bool expandPipeline, QList obs); + + /** + * @brief writePipeline + */ + void writePipeline(); + + /** + * @brief clearWriter + */ + void clearWriter(); + + /** + * @brief toDocument + * @return + */ + QJsonDocument toDocument(); + + /** + * @brief generateIndexString Generates a possibly padded string that represents + * the current filter index. Used during the JSON document creation. + * @param currentIndex The numerical index that the string should be generated for. + * @return + */ + QString generateIndexString(int currentIndex); + +public: + JsonFilterParametersWriter(const JsonFilterParametersWriter&) = delete; // Copy Constructor Not Implemented + JsonFilterParametersWriter(JsonFilterParametersWriter&&) = delete; // Move Constructor Not Implemented + JsonFilterParametersWriter& operator=(const JsonFilterParametersWriter&) = delete; // Copy Assignment Not Implemented + JsonFilterParametersWriter& operator=(JsonFilterParametersWriter&&) = delete; // Move Assignment Not Implemented }; - - diff --git a/Source/SIMPLib/FilterParameters/LinkedBooleanFilterParameter.cpp b/Source/SIMPLib/FilterParameters/LinkedBooleanFilterParameter.cpp index 999cdd8495..af66ffa7b7 100644 --- a/Source/SIMPLib/FilterParameters/LinkedBooleanFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/LinkedBooleanFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "LinkedBooleanFilterParameter.h" @@ -48,8 +48,9 @@ LinkedBooleanFilterParameter::~LinkedBooleanFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -LinkedBooleanFilterParameter::Pointer LinkedBooleanFilterParameter::New(const QString& humanLabel, const QString& propertyName, const bool& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, QStringList conditionalProperties, int groupIndex) +LinkedBooleanFilterParameter::Pointer LinkedBooleanFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const bool& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + const std::vector& conditionalProperties, int groupIndex) { LinkedBooleanFilterParameter::Pointer ptr = LinkedBooleanFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -78,6 +79,10 @@ QString LinkedBooleanFilterParameter::getWidgetType() const void LinkedBooleanFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { m_SetterCallback(static_cast(jsonValue.toInt())); @@ -87,10 +92,71 @@ void LinkedBooleanFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void LinkedBooleanFilterParameter::writeJson(QJsonObject& json) +void LinkedBooleanFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { json[getPropertyName()] = static_cast(m_GetterCallback()); } } + +// ----------------------------------------------------------------------------- +LinkedBooleanFilterParameter::Pointer LinkedBooleanFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +LinkedBooleanFilterParameter::Pointer LinkedBooleanFilterParameter::New() +{ + Pointer sharedPtr(new(LinkedBooleanFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString LinkedBooleanFilterParameter::getNameOfClass() const +{ + return QString("LinkedBooleanFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString LinkedBooleanFilterParameter::ClassName() +{ + return QString("LinkedBooleanFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void LinkedBooleanFilterParameter::setConditionalProperties(const std::vector& value) +{ + m_ConditionalProperties = value; +} + +// ----------------------------------------------------------------------------- +std::vector LinkedBooleanFilterParameter::getConditionalProperties() const +{ + return m_ConditionalProperties; +} + +// ----------------------------------------------------------------------------- +void LinkedBooleanFilterParameter::setSetterCallback(const LinkedBooleanFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +LinkedBooleanFilterParameter::SetterCallbackType LinkedBooleanFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void LinkedBooleanFilterParameter::setGetterCallback(const LinkedBooleanFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +LinkedBooleanFilterParameter::GetterCallbackType LinkedBooleanFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/LinkedBooleanFilterParameter.h b/Source/SIMPLib/FilterParameters/LinkedBooleanFilterParameter.h old mode 100755 new mode 100644 index d977b8982d..a1e7ae62e8 --- a/Source/SIMPLib/FilterParameters/LinkedBooleanFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/LinkedBooleanFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" @@ -49,12 +51,10 @@ * SIMPL_NEW_LINKED_BOOL_FP("HumanLabel", PropertyName, Category, FilterName, ConditionalProperties, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): - * SIMPL_NEW_LINKED_BOOL_FP("Bool1", Bool1, FilterParameter::Parameter, GenericExample, linkedProps); + * SIMPL_NEW_LINKED_BOOL_FP("Bool1", Bool1, FilterParameter::Category::Parameter, GenericExample, linkedProps); */ -#define SIMPL_NEW_LINKED_BOOL_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (LinkedBooleanFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_LINKED_BOOL_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(LinkedBooleanFilterParameter, __VA_ARGS__)) /** * @brief The LinkedBooleanFilterParameter class is used by filters to instantiate an LinkedBooleanWidget. By instantiating an instance of @@ -62,85 +62,132 @@ */ class SIMPLib_EXPORT LinkedBooleanFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(LinkedBooleanFilterParameter) - SIMPL_STATIC_NEW_MACRO(LinkedBooleanFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(LinkedBooleanFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the LinkedBooleanFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_LINKED_BOOL_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param conditionalProperties The properties that appear/disappear when the LinkedBooleanWidget's checkbox is toggled. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const bool& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - QStringList conditionalProperties, int groupIndex = -1); - - ~LinkedBooleanFilterParameter() override; - - SIMPL_INSTANCE_PROPERTY(QStringList, ConditionalProperties) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief LinkedBooleanFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - LinkedBooleanFilterParameter(); - - public: - LinkedBooleanFilterParameter(const LinkedBooleanFilterParameter&) = delete; // Copy Constructor Not Implemented - LinkedBooleanFilterParameter(LinkedBooleanFilterParameter&&) = delete; // Move Constructor Not Implemented - LinkedBooleanFilterParameter& operator=(const LinkedBooleanFilterParameter&) = delete; // Copy Assignment Not Implemented - LinkedBooleanFilterParameter& operator=(LinkedBooleanFilterParameter&&) = delete; // Move Assignment Not Implemented + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(LinkedBooleanFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(LinkedBooleanFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = LinkedBooleanFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for LinkedBooleanFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for LinkedBooleanFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the LinkedBooleanFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_LINKED_BOOL_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param conditionalProperties The properties that appear/disappear when the LinkedBooleanWidget's checkbox is toggled. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const bool& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const std::vector& conditionalProperties, int groupIndex = -1); + + ~LinkedBooleanFilterParameter() override; + + /** + * @brief Setter property for ConditionalProperties + */ + void setConditionalProperties(const std::vector& value); + /** + * @brief Getter property for ConditionalProperties + * @return Value of ConditionalProperties + */ + std::vector getConditionalProperties() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const LinkedBooleanFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + LinkedBooleanFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const LinkedBooleanFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + LinkedBooleanFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief LinkedBooleanFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + LinkedBooleanFilterParameter(); + +public: + LinkedBooleanFilterParameter(const LinkedBooleanFilterParameter&) = delete; // Copy Constructor Not Implemented + LinkedBooleanFilterParameter(LinkedBooleanFilterParameter&&) = delete; // Move Constructor Not Implemented + LinkedBooleanFilterParameter& operator=(const LinkedBooleanFilterParameter&) = delete; // Copy Assignment Not Implemented + LinkedBooleanFilterParameter& operator=(LinkedBooleanFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + std::vector m_ConditionalProperties = {}; + LinkedBooleanFilterParameter::SetterCallbackType m_SetterCallback = {}; + LinkedBooleanFilterParameter::GetterCallbackType m_GetterCallback = {}; }; - diff --git a/Source/SIMPLib/FilterParameters/LinkedChoicesFilterParameter.cpp b/Source/SIMPLib/FilterParameters/LinkedChoicesFilterParameter.cpp index 890e75221b..d25216c293 100644 --- a/Source/SIMPLib/FilterParameters/LinkedChoicesFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/LinkedChoicesFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "LinkedChoicesFilterParameter.h" @@ -48,9 +48,9 @@ LinkedChoicesFilterParameter::~LinkedChoicesFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -LinkedChoicesFilterParameter::Pointer LinkedChoicesFilterParameter::New(const QString& humanLabel, const QString& propertyName, const int& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, QVector choices, QStringList linkedProperties, - int groupIndex) +LinkedChoicesFilterParameter::Pointer LinkedChoicesFilterParameter::Create(const QString& humanLabel, const QString& propertyName, int defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, const std::vector& choices, + const std::vector& linkedProperties, int groupIndex) { LinkedChoicesFilterParameter::Pointer ptr = LinkedChoicesFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -81,19 +81,56 @@ QString LinkedChoicesFilterParameter::getWidgetType() const void LinkedChoicesFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; - if(!jsonValue.isUndefined() && m_SetterCallback) + if(!jsonValue.isUndefined() && getSetterCallback()) { - m_SetterCallback(jsonValue.toInt(0.0)); + getSetterCallback()(jsonValue.toInt(0.0)); } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void LinkedChoicesFilterParameter::writeJson(QJsonObject& json) +void LinkedChoicesFilterParameter::writeJson(QJsonObject& json) const { - if(m_GetterCallback) + if(getGetterCallback()) { - json[getPropertyName()] = m_GetterCallback(); + json[getPropertyName()] = getGetterCallback()(); } } + +// ----------------------------------------------------------------------------- +LinkedChoicesFilterParameter::Pointer LinkedChoicesFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +LinkedChoicesFilterParameter::Pointer LinkedChoicesFilterParameter::New() +{ + Pointer sharedPtr(new(LinkedChoicesFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString LinkedChoicesFilterParameter::getNameOfClass() const +{ + return QString("LinkedChoicesFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString LinkedChoicesFilterParameter::ClassName() +{ + return QString("LinkedChoicesFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void LinkedChoicesFilterParameter::setLinkedProperties(const std::vector& value) +{ + m_LinkedProperties = value; +} + +// ----------------------------------------------------------------------------- +std::vector LinkedChoicesFilterParameter::getLinkedProperties() const +{ + return m_LinkedProperties; +} diff --git a/Source/SIMPLib/FilterParameters/LinkedChoicesFilterParameter.h b/Source/SIMPLib/FilterParameters/LinkedChoicesFilterParameter.h old mode 100755 new mode 100644 index e49798789b..c7c404175d --- a/Source/SIMPLib/FilterParameters/LinkedChoicesFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/LinkedChoicesFilterParameter.h @@ -1,44 +1,46 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/FilterParameters/ChoiceFilterParameter.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" /** * @brief The LinkedChoicesFilterParameter class is used by filters to instantiate an LinkedChoicesWidget. By instantiating an instance of @@ -46,87 +48,99 @@ */ class SIMPLib_EXPORT LinkedChoicesFilterParameter : public ChoiceFilterParameter { - public: - SIMPL_SHARED_POINTERS(LinkedChoicesFilterParameter) - SIMPL_STATIC_NEW_MACRO(LinkedChoicesFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(LinkedChoicesFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the LinkedChoicesFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_LINKED_CHOICES_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param choices The selections that appear in the LinkedChoicesWidget. - * @param linkedProperties The properties that appear/disappear when a selection is chosen. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const int& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - QVector choices, QStringList linkedProperties, - int groupIndex = -1); - - ~LinkedChoicesFilterParameter() override; - - SIMPL_INSTANCE_PROPERTY(QStringList, LinkedProperties) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief LinkedChoicesFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - LinkedChoicesFilterParameter(); - - public: - LinkedChoicesFilterParameter(const LinkedChoicesFilterParameter&) = delete; // Copy Constructor Not Implemented - LinkedChoicesFilterParameter(LinkedChoicesFilterParameter&&) = delete; // Move Constructor Not Implemented - LinkedChoicesFilterParameter& operator=(const LinkedChoicesFilterParameter&) = delete; // Copy Assignment Not Implemented - LinkedChoicesFilterParameter& operator=(LinkedChoicesFilterParameter&&) = delete; // Move Assignment Not Implemented + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(LinkedChoicesFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(LinkedChoicesFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations + +public: + using Self = LinkedChoicesFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for LinkedChoicesFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for LinkedChoicesFilterParameter + */ + static QString ClassName(); + + /** + * @brief New This function instantiates an instance of the LinkedChoicesFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_LINKED_CHOICES_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param choices The selections that appear in the LinkedChoicesWidget. + * @param linkedProperties The properties that appear/disappear when a selection is chosen. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, int defaultValue, Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + const std::vector& choices, const std::vector& linkedProperties, int groupIndex = -1); + + ~LinkedChoicesFilterParameter() override; + + /** + * @brief Setter property for LinkedProperties + */ + void setLinkedProperties(const std::vector& value); + /** + * @brief Getter property for LinkedProperties + * @return Value of LinkedProperties + */ + std::vector getLinkedProperties() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + +protected: + /** + * @brief LinkedChoicesFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + LinkedChoicesFilterParameter(); + +public: + LinkedChoicesFilterParameter(const LinkedChoicesFilterParameter&) = delete; // Copy Constructor Not Implemented + LinkedChoicesFilterParameter(LinkedChoicesFilterParameter&&) = delete; // Move Constructor Not Implemented + LinkedChoicesFilterParameter& operator=(const LinkedChoicesFilterParameter&) = delete; // Copy Assignment Not Implemented + LinkedChoicesFilterParameter& operator=(LinkedChoicesFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + std::vector m_LinkedProperties = {}; }; - diff --git a/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.cpp index dc749c9594..09ed7863a1 100644 --- a/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.cpp @@ -1,39 +1,40 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "LinkedDataContainerSelectionFilterParameter.h" +#include "SIMPLib/Filtering/AbstractFilter.h" // ----------------------------------------------------------------------------- // @@ -48,9 +49,10 @@ LinkedDataContainerSelectionFilterParameter::~LinkedDataContainerSelectionFilter // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -LinkedDataContainerSelectionFilterParameter::Pointer LinkedDataContainerSelectionFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, const RequirementType req, QStringList linkedProperties, - int groupIndex) +LinkedDataContainerSelectionFilterParameter::Pointer LinkedDataContainerSelectionFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, + Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const RequirementType& req, + const std::vector& linkedProperties, int groupIndex) { LinkedDataContainerSelectionFilterParameter::Pointer ptr = LinkedDataContainerSelectionFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -82,19 +84,126 @@ QString LinkedDataContainerSelectionFilterParameter::getWidgetType() const void LinkedDataContainerSelectionFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { - m_SetterCallback(jsonValue.toString("")); + QJsonObject obj = jsonValue.toObject(); + DataArrayPath dap; + if(dap.readJson(obj)) + { + m_SetterCallback(dap); + } + else // this is in here for historical where we used to save the value as a string + { + QString dcName = jsonValue.toString(""); + DataArrayPath dap(dcName, "", ""); + m_SetterCallback(dap); + } } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void LinkedDataContainerSelectionFilterParameter::writeJson(QJsonObject& json) +void LinkedDataContainerSelectionFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { - json[getPropertyName()] = m_GetterCallback(); + DataArrayPath dap = m_GetterCallback(); + QJsonObject obj; + dap.writeJson(obj); + json[getPropertyName()] = obj; } } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void LinkedDataContainerSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + DataArrayPath oldPath; + DataArrayPath newPath; + std::tie(oldPath, newPath) = renamePath; + + if(oldPath == m_GetterCallback() && oldPath.getDataContainerName() != newPath.getDataContainerName()) + { + m_SetterCallback(newPath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); + } +} + +// ----------------------------------------------------------------------------- +LinkedDataContainerSelectionFilterParameter::Pointer LinkedDataContainerSelectionFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +LinkedDataContainerSelectionFilterParameter::Pointer LinkedDataContainerSelectionFilterParameter::New() +{ + Pointer sharedPtr(new(LinkedDataContainerSelectionFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString LinkedDataContainerSelectionFilterParameter::getNameOfClass() const +{ + return QString("LinkedDataContainerSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString LinkedDataContainerSelectionFilterParameter::ClassName() +{ + return QString("LinkedDataContainerSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void LinkedDataContainerSelectionFilterParameter::setLinkedProperties(const std::vector& value) +{ + m_LinkedProperties = value; +} + +// ----------------------------------------------------------------------------- +std::vector LinkedDataContainerSelectionFilterParameter::getLinkedProperties() const +{ + return m_LinkedProperties; +} + +// ----------------------------------------------------------------------------- +void LinkedDataContainerSelectionFilterParameter::setDefaultGeometryTypes(const IGeometry::Types& value) +{ + m_DefaultGeometryTypes = value; +} + +// ----------------------------------------------------------------------------- +IGeometry::Types LinkedDataContainerSelectionFilterParameter::getDefaultGeometryTypes() const +{ + return m_DefaultGeometryTypes; +} + +// ----------------------------------------------------------------------------- +void LinkedDataContainerSelectionFilterParameter::setSetterCallback(const LinkedDataContainerSelectionFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +LinkedDataContainerSelectionFilterParameter::SetterCallbackType LinkedDataContainerSelectionFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void LinkedDataContainerSelectionFilterParameter::setGetterCallback(const LinkedDataContainerSelectionFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +LinkedDataContainerSelectionFilterParameter::GetterCallbackType LinkedDataContainerSelectionFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.h index 566619b303..bc104705ee 100644 --- a/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/LinkedDataContainerSelectionFilterParameter.h @@ -1,45 +1,49 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Geometry/IGeometry.h" +class AbstractFilter; + // FP: Documentation incomplete because there isn't currently a way to instantiate this filter parameter // in one line. /** @@ -48,10 +52,8 @@ * that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, * FilterName (class name), Choices, LinkedProperties, GroupIndex (optional). */ -#define SIMPL_NEW_LINKED_DC_SELECTION_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (LinkedDataContainerSelectionFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_LINKED_DC_SELECTION_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(LinkedDataContainerSelectionFilterParameter, __VA_ARGS__)) /** * @brief The LinkedDataContainerSelectionFilterParameter class is used by filters to instantiate a LinkedDataContainerSelectionWidget. By instantiating an instance of @@ -59,93 +61,155 @@ */ class SIMPLib_EXPORT LinkedDataContainerSelectionFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(LinkedDataContainerSelectionFilterParameter) - SIMPL_STATIC_NEW_MACRO(LinkedDataContainerSelectionFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(LinkedDataContainerSelectionFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - typedef struct - { - IGeometry::Types dcGeometryTypes; - } RequirementType; - - /** - * @brief New This function instantiates an instance of the LinkedDataContainerSelectionFilterParameter. This function must be used to instantiate the class; the - * SIMPL_NEW_LINKED_DC_SELECTION_FP macro does not properly instantiate the class, so this static New method must be used. - * - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param choices The selections that appear in the LinkedChoicesWidget. - * @param linkedProperties The properties that appear/disappear when a selection is chosen. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, QStringList linkedProperties, - int groupIndex = -1); - - ~LinkedDataContainerSelectionFilterParameter() override; - - SIMPL_INSTANCE_PROPERTY(QStringList, LinkedProperties) - SIMPL_INSTANCE_PROPERTY(IGeometry::Types, DefaultGeometryTypes) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief LinkedDataContainerSelectionFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - LinkedDataContainerSelectionFilterParameter(); - - public: - LinkedDataContainerSelectionFilterParameter(const LinkedDataContainerSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented - LinkedDataContainerSelectionFilterParameter(LinkedDataContainerSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented - LinkedDataContainerSelectionFilterParameter& operator=(const LinkedDataContainerSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented - LinkedDataContainerSelectionFilterParameter& operator=(LinkedDataContainerSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(LinkedDataContainerSelectionFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(LinkedDataContainerSelectionFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_CUSTOM() + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = LinkedDataContainerSelectionFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for LinkedDataContainerSelectionFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for LinkedDataContainerSelectionFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + struct RequirementType + { + IGeometry::Types dcGeometryTypes; + }; + + /** + * @brief New This function instantiates an instance of the LinkedDataContainerSelectionFilterParameter. This function must be used to instantiate the class; the + * SIMPL_NEW_LINKED_DC_SELECTION_FP macro does not properly instantiate the class, so this static New method must be used. + * + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param choices The selections that appear in the LinkedChoicesWidget. + * @param linkedProperties The properties that appear/disappear when a selection is chosen. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const DataArrayPath& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const RequirementType& req, const std::vector& linkedProperties, int groupIndex = -1); + + ~LinkedDataContainerSelectionFilterParameter() override; + + /** + * @brief Setter property for LinkedProperties + */ + void setLinkedProperties(const std::vector& value); + /** + * @brief Getter property for LinkedProperties + * @return Value of LinkedProperties + */ + std::vector getLinkedProperties() const; + + /** + * @brief Setter property for DefaultGeometryTypes + */ + void setDefaultGeometryTypes(const IGeometry::Types& value); + /** + * @brief Getter property for DefaultGeometryTypes + * @return Value of DefaultGeometryTypes + */ + IGeometry::Types getDefaultGeometryTypes() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const LinkedDataContainerSelectionFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + LinkedDataContainerSelectionFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const LinkedDataContainerSelectionFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + LinkedDataContainerSelectionFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handle DataArrayPath changes if necessary + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief LinkedDataContainerSelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + LinkedDataContainerSelectionFilterParameter(); + +public: + LinkedDataContainerSelectionFilterParameter(const LinkedDataContainerSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + LinkedDataContainerSelectionFilterParameter(LinkedDataContainerSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + LinkedDataContainerSelectionFilterParameter& operator=(const LinkedDataContainerSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented + LinkedDataContainerSelectionFilterParameter& operator=(LinkedDataContainerSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + std::vector m_LinkedProperties = {}; + IGeometry::Types m_DefaultGeometryTypes = {}; + LinkedDataContainerSelectionFilterParameter::SetterCallbackType m_SetterCallback = {}; + LinkedDataContainerSelectionFilterParameter::GetterCallbackType m_GetterCallback = {}; }; - diff --git a/Source/SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.cpp b/Source/SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.cpp new file mode 100644 index 0000000000..dda3596239 --- /dev/null +++ b/Source/SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.cpp @@ -0,0 +1,375 @@ +/* ============================================================================ + * Copyright (c) 2019-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5280 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "LinkedPathCreationFilterParameter.h" + +#include + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::unique_ptr LinkedPathCreationFilterParameter::CreateLinkedPath(LinkedDataPath::GetterCallbackType callback, DataArrayPathHelper::DataType dataType) +{ + return std::make_unique(callback, dataType); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::unique_ptr LinkedPathCreationFilterParameter::CreateLinkedPath(LinkedStringPath::GetterCallbackType dcCallback) +{ + return std::make_unique(dcCallback); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::unique_ptr LinkedPathCreationFilterParameter::CreateLinkedPath(LinkedStringPath::GetterCallbackType dcCallback, + LinkedStringPath::GetterCallbackType amCallback) +{ + return std::make_unique(dcCallback, amCallback); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::unique_ptr LinkedPathCreationFilterParameter::CreateLinkedPath(LinkedMixedPath::PathGetterCallbackType dcCallback, + LinkedMixedPath::PathGetterCallbackType amCallback) +{ + return std::make_unique(dcCallback, amCallback); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::unique_ptr LinkedPathCreationFilterParameter::CreateLinkedPath(LinkedMixedPath::PathGetterCallbackType dcCallback, + LinkedMixedPath::StringGetterCallbackType amCallback) +{ + return std::make_unique(dcCallback, amCallback); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::unique_ptr LinkedPathCreationFilterParameter::CreateLinkedPath(LinkedMixedPath::PathGetterCallbackType pathCallback) +{ + return std::make_unique(pathCallback, DataArrayPathHelper::DataType::DataContainer); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::unique_ptr LinkedPathCreationFilterParameter::CreateLinkedPath(LinkedAdvComparisonPath::GetterCallbackType callback) +{ + return std::make_unique(callback); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +LinkedPathCreationFilterParameter::LinkedPathCreationFilterParameter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +LinkedPathCreationFilterParameter::~LinkedPathCreationFilterParameter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +LinkedPathCreationFilterParameter::Pointer LinkedPathCreationFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + std::unique_ptr linkedPath, int groupIndex) +{ + + LinkedPathCreationFilterParameter::Pointer ptr = LinkedPathCreationFilterParameter::New(); + ptr->setHumanLabel(humanLabel); + ptr->setPropertyName(propertyName); + ptr->setDefaultValue(defaultValue); + ptr->setLinkedPath(std::move(linkedPath)); + ptr->setCategory(category); + ptr->setGroupIndex(groupIndex); + ptr->setSetterCallback(setterCallback); + ptr->setGetterCallback(getterCallback); + + return ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString LinkedPathCreationFilterParameter::getWidgetType() const +{ + return QString("LinkedPathCreationWidget"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void LinkedPathCreationFilterParameter::readJson(const QJsonObject& json) +{ + QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } + if(!jsonValue.isUndefined() && m_SetterCallback) + { + m_SetterCallback(jsonValue.toString("")); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void LinkedPathCreationFilterParameter::writeJson(QJsonObject& json) const +{ + if(m_GetterCallback) + { + json[getPropertyName()] = m_GetterCallback(); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +LinkedPathCreationFilterParameter::LinkedStringPath::LinkedStringPath(GetterCallbackType getDc) +: dcGetter(getDc) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +LinkedPathCreationFilterParameter::LinkedStringPath::LinkedStringPath(GetterCallbackType getDc, GetterCallbackType getAm) +: dcGetter(getDc) +, amGetter(getAm) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +LinkedPathCreationFilterParameter::LinkedMixedPath::LinkedMixedPath(PathGetterCallbackType getDc, StringGetterCallbackType getAm) +: dcGetter(getDc) +, amGetter(getAm) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +LinkedPathCreationFilterParameter::LinkedMixedPath::LinkedMixedPath(PathGetterCallbackType dc, PathGetterCallbackType am) +: dcGetter(dc) +, amPathGetter(am) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +LinkedPathCreationFilterParameter::LinkedDataPath::LinkedDataPath(GetterCallbackType getPath) +: pathGetter(getPath) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +LinkedPathCreationFilterParameter::LinkedDataPath::LinkedDataPath(GetterCallbackType getPath, DataArrayPathHelper::DataType targetLevel) +: pathGetter(getPath) +, m_TargetPathType(targetLevel) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +LinkedPathCreationFilterParameter::LinkedAdvComparisonPath::LinkedAdvComparisonPath(GetterCallbackType advComp) +: compGetter(advComp) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataArrayPath LinkedPathCreationFilterParameter::LinkedStringPath::generatePath() +{ + DataArrayPath linkedPath; + // Use std::function operator bool to check if this is a callable function + if(dcGetter) + { + linkedPath.setDataContainerName(dcGetter()); + if(amGetter) + { + linkedPath.setAttributeMatrixName(amGetter()); + } + } + return linkedPath; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataArrayPath LinkedPathCreationFilterParameter::LinkedMixedPath::generatePath() +{ + DataArrayPath linkedPath; + // Use std::function operator bool to check if this is a callable function + if(dcGetter && amGetter) + { + linkedPath.setDataContainerName(dcGetter().getDataContainerName()); + linkedPath.setAttributeMatrixName(amGetter()); + } + else if(dcGetter && amPathGetter) + { + linkedPath.setDataContainerName(dcGetter().getDataContainerName()); + linkedPath.setAttributeMatrixName(amPathGetter().getAttributeMatrixName()); + } + // else + //{ + // throw std::invalid_argument("Invalid linked AttributeMatrix path"); + //} + return linkedPath; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataArrayPath LinkedPathCreationFilterParameter::LinkedDataPath::generatePath() +{ + if(!pathGetter) + { + return DataArrayPath(); + } + DataArrayPath linkedPath = pathGetter(); + switch(m_TargetPathType) + { + case DataArrayPathHelper::DataType::DataContainer: + return DataArrayPath(linkedPath.getDataContainerName(), "", ""); + case DataArrayPathHelper::DataType::AttributeMatrix: + return DataArrayPath(linkedPath.getDataContainerName(), linkedPath.getAttributeMatrixName(), ""); + case DataArrayPathHelper::DataType::DataArray: + throw std::domain_error("LinkedPathCreationFilterParameter cannot target a child path underneath DataArray"); + case DataArrayPathHelper::DataType::None: + return linkedPath; + } + return DataArrayPath(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataArrayPath LinkedPathCreationFilterParameter::LinkedAdvComparisonPath::generatePath() +{ + DataArrayPath linkedPath; + // Use std::function operator bool to check if this is a callable function + if(compGetter) + { + linkedPath.setDataContainerName(compGetter().getDataContainerName()); + linkedPath.setAttributeMatrixName(compGetter().getAttributeMatrixName()); + } + // else + //{ + // throw std::invalid_argument("Invalid linked AttributeMatrix path"); + //} + return linkedPath; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void LinkedPathCreationFilterParameter::setLinkedPath(std::unique_ptr linkedPath) +{ + m_LinkedPath = std::move(linkedPath); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataArrayPath LinkedPathCreationFilterParameter::getLinkedDataArrayPath() const +{ + if(m_LinkedPath) + { + return m_LinkedPath->generatePath(); + } + return DataArrayPath("", "", ""); +} + +// ----------------------------------------------------------------------------- +LinkedPathCreationFilterParameter::Pointer LinkedPathCreationFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +LinkedPathCreationFilterParameter::Pointer LinkedPathCreationFilterParameter::New() +{ + Pointer sharedPtr(new(LinkedPathCreationFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString LinkedPathCreationFilterParameter::getNameOfClass() const +{ + return QString("LinkedPathCreationFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString LinkedPathCreationFilterParameter::ClassName() +{ + return QString("LinkedPathCreationFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void LinkedPathCreationFilterParameter::setSetterCallback(const LinkedPathCreationFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +LinkedPathCreationFilterParameter::SetterCallbackType LinkedPathCreationFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void LinkedPathCreationFilterParameter::setGetterCallback(const LinkedPathCreationFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +LinkedPathCreationFilterParameter::GetterCallbackType LinkedPathCreationFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.h b/Source/SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.h new file mode 100644 index 0000000000..8075ea7384 --- /dev/null +++ b/Source/SIMPLib/FilterParameters/LinkedPathCreationFilterParameter.h @@ -0,0 +1,405 @@ +/* ============================================================================ + * Copyright (c) 2019-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5280 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include + +#include "SIMPLib/FilterParameters/FilterParameter.h" +#include "SIMPLib/Filtering/ComparisonInputs.h" +#include "SIMPLib/Filtering/ComparisonInputsAdvanced.h" + +// Helper macros: LinkedPath +#define SIMPL_NEW_LINKED_DC_PATH(FILTER, PTR, LINKED_PROP) LinkedPathCreationFilterParameter::CreateLinkedPath(SIMPL_BIND_GETTER(FILTER, PTR, LINKED_PROP)) +#define SIMPL_NEW_LINKED_AM_PATH(FILTER, PTR, DC_PROP, AM_PROP) LinkedPathCreationFilterParameter::CreateLinkedPath(SIMPL_BIND_GETTER(FILTER, PTR, DC_PROP), SIMPL_BIND_GETTER(FILTER, PTR, AM_PROP)) +#define SIMPL_NEW_LINKED_ADV_COMPARE(FILTER, PTR, COMP_PROP) LinkedPathCreationFilterParameter::CreateLinkedPath(SIMPL_BIND_GETTER(FILTER, PTR, COMP_PROP)) + +// Helper macros: Index / NoIndex implementations +#define SIMPL_NEW_DA_FROM_ADV_COMPARISON_NoIndex(Desc, Prop, LinkedComp, Category, Filter) \ + LinkedPathCreationFilterParameter::Create(Desc, #Prop, get##Prop(), Category, SIMPL_BIND_SETTER(Filter, this, Prop), SIMPL_BIND_GETTER(Filter, this, Prop), \ + SIMPL_NEW_LINKED_ADV_COMPARE(Filter, this, LinkedComp)) +#define SIMPL_NEW_DA_FROM_ADV_COMPARISON_Index(Desc, Prop, LinkedComp, Category, Filter, Index) \ + LinkedPathCreationFilterParameter::Create(Desc, #Prop, get##Prop(), Category, SIMPL_BIND_SETTER(Filter, this, Prop), SIMPL_BIND_GETTER(Filter, this, Prop), \ + SIMPL_NEW_LINKED_ADV_COMPARE(Filter, this, LinkedComp), Index) + +#define SIMPL_NEW_LINKED_ATTRIBUTE_MATRIX_Index(Desc, Prop, LinkedDcProp, LinkedAmProp, Category, Filter, Index) \ + LinkedPathCreationFilterParameter::Create(Desc, #Prop, get##Prop(), Category, SIMPL_BIND_SETTER(Filter, this, Prop), SIMPL_BIND_GETTER(Filter, this, Prop), \ + SIMPL_NEW_LINKED_AM_PATH(Filter, this, LinkedDcProp, LinkedAmProp), Index) +#define SIMPL_NEW_LINKED_ATTRIBUTE_MATRIX_NoIndex(Desc, Prop, LinkedDcProp, LinkedAmProp, Category, Filter) \ + LinkedPathCreationFilterParameter::Create(Desc, #Prop, get##Prop(), Category, SIMPL_BIND_SETTER(Filter, this, Prop), SIMPL_BIND_GETTER(Filter, this, Prop), \ + SIMPL_NEW_LINKED_AM_PATH(Filter, this, LinkedDcProp, LinkedAmProp)) +#define SIMPL_NEW_LINKED_DATA_CONTAINER_Index(Desc, Prop, LinkedProp, Category, Filter, Index) \ + LinkedPathCreationFilterParameter::Create(Desc, #Prop, get##Prop(), Category, SIMPL_BIND_SETTER(Filter, this, Prop), SIMPL_BIND_GETTER(Filter, this, Prop), \ + SIMPL_NEW_LINKED_DC_PATH(Filter, this, LinkedProp), Index) +#define SIMPL_NEW_LINKED_DATA_CONTAINER_NoIndex(Desc, Prop, LinkedProp, Category, Filter) \ + LinkedPathCreationFilterParameter::Create(Desc, #Prop, get##Prop(), Category, SIMPL_BIND_SETTER(Filter, this, Prop), SIMPL_BIND_GETTER(Filter, this, Prop), \ + SIMPL_NEW_LINKED_DC_PATH(Filter, this, LinkedProp)) + +// Helper macros: Expansion +#define _FP_GET_OVERRIDE6(A, B, C, D, E, F, NAME, ...) NAME +#define _FP_GET_OVERRIDE7(A, B, C, D, E, F, G, NAME, ...) NAME + +// Creation Macros +/** + * @brief SIMPL_NEW_AM_WITH_LINKED_DC_FP This macro is a short-form way of instantiating an instance of + * LinkedPathCreationFilterParameter. There are 5 required parameters and 1 optional parameter + * that are passed to this macro in the following order: HumanLabel, PropertyName, LinkedDcProperty (DataArrayPath or name), + * Category, FilterName (class name), GroupIndex (optional) + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_AM_WITH_LINKED_DC_FP("HumanLabel", PropertyName, DcName, Category, FilterName, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): + * SIMPL_NEW_AM_WITH_LINKED_DC_FP("Cell Matrix", CellMatrixName, DcName, FilterParameter::Category::Parameter, GenericExample); + */ +#define SIMPL_NEW_AM_WITH_LINKED_DC_FP(...) SIMPL_EXPAND(_FP_GET_OVERRIDE6(__VA_ARGS__, SIMPL_NEW_LINKED_DATA_CONTAINER_Index, SIMPL_NEW_LINKED_DATA_CONTAINER_NoIndex)(__VA_ARGS__)) + +/** + * @brief SIMPL_NEW_DA_WITH_LINKED_AM_FP This macro is a short-form way of instantiating an instance of + * LinkedPathCreationFilterParameter. There are 6 required parameters and 1 optional parameter + * that are passed to this macro in the following order: HumanLabel, PropertyName, LinkedDcProperty (DataArrayPath or name), + * LinkedAmProperty, Category, FilterName (class name), GroupIndex (optional) + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_DA_WITH_LINKED_AM_FP("HumanLabel", PropertyName, DcName, AmName, Category, FilterName, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): + * SIMPL_NEW_DA_WITH_LINKED_AM_FP("Feature Id", CellMatrixName, DcName, AmName, FilterParameter::Category::Parameter, GenericExample); + */ +#define SIMPL_NEW_DA_WITH_LINKED_AM_FP(...) SIMPL_EXPAND(_FP_GET_OVERRIDE7(__VA_ARGS__, SIMPL_NEW_LINKED_ATTRIBUTE_MATRIX_Index, SIMPL_NEW_LINKED_ATTRIBUTE_MATRIX_NoIndex)(__VA_ARGS__)) + +// Special cases +/** + * @brief SIMPL_NEW_DA_FROM_ADV_COMPARISON_FP This macro is a short-form way of instantiating an instance of + * LinkedPathCreationFilterParameter. There are 5 required parameters and 1 optional parameter + * that are passed to this macro in the following order: HumanLabel, PropertyName, LinkedProperty, Category, + * FilterName (class name), GroupIndex (optional) + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_DA_FROM_ADV_COMPARISON_FP("HumanLabel", PropertyName, LinkedAdvComparisonProperty, Category, FilterName, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): + * SIMPL_NEW_DA_FROM_ADV_COMPARISON_FP("Mask", MaskName, AdvComparison, FilterParameter::Category::Parameter, GenericExample); + */ +#define SIMPL_NEW_DA_FROM_ADV_COMPARISON_FP(...) SIMPL_EXPAND(_FP_GET_OVERRIDE6(__VA_ARGS__, SIMPL_NEW_DA_FROM_ADV_COMPARISON_Index, SIMPL_NEW_DA_FROM_ADV_COMPARISON_NoIndex)(__VA_ARGS__)) + +/** + * @brief The LinkedPathCreationFilterParameter class is used by filters to instantiate an StringWidget. By instantiating an instance of + * this class in a filter's setupFilterParameters() method, a StringWidget will appear in the filter's "filter input" section in the DREAM3D GUI. + */ +class SIMPLib_EXPORT LinkedPathCreationFilterParameter : public FilterParameter +{ + // Start Python bindings declarations + // clang-format off +// PYB11_BEGIN_BINDINGS(LinkedPathCreationFilterParameter SUPERCLASS FilterParameter) +// PYB11_SHARED_POINTERS(LinkedPathCreationFilterParameter) +// PYB11_STATIC_CREATION(Create) +// PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = LinkedPathCreationFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for LinkedPathCreationFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for LinkedPathCreationFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief The ILinkedPath interface is used for generating the linked path from either multiple string properties or a DataArrayPath property + */ + class SIMPLib_EXPORT ILinkedPath + { + public: + /** + * @brief Generates a DataArrayPath to the target container + * @return + */ + virtual DataArrayPath generatePath() = 0; + + virtual ~ILinkedPath() = default; + }; + + /** + * @brief The LinkedStringPath struct stores getters for the DataContainer and AttributeMatrix string properties. + * These getters are used to generate a DataArrayPath to the target container. + */ + class SIMPLib_EXPORT LinkedStringPath : public ILinkedPath + { + public: + using GetterCallbackType = std::function; + LinkedStringPath(GetterCallbackType getDc); + LinkedStringPath(GetterCallbackType getDc, GetterCallbackType getAm); + + /** + * @brief Generates a DataArrayPath to the target container + * @return + */ + DataArrayPath generatePath() override; + + private: + GetterCallbackType dcGetter; + GetterCallbackType amGetter; + }; + /** + * @brief The LinkedStringPath struct stores getters for the DataContainer and AttributeMatrix string properties. + * These getters are used to generate a DataArrayPath to the target container. + */ + class SIMPLib_EXPORT LinkedMixedPath : public ILinkedPath + { + public: + using StringGetterCallbackType = std::function; + using PathGetterCallbackType = std::function; + LinkedMixedPath(PathGetterCallbackType dc, StringGetterCallbackType am); + LinkedMixedPath(PathGetterCallbackType dc, PathGetterCallbackType am); + + /** + * @brief Generates a DataArrayPath to the target container + * @return + */ + DataArrayPath generatePath() override; + + private: + PathGetterCallbackType dcGetter; + StringGetterCallbackType amGetter; + PathGetterCallbackType amPathGetter; + }; + /** + * @brief The LinkedDataPath struct stores a getter for the target DataArrayPath. + */ + class SIMPLib_EXPORT LinkedDataPath : public ILinkedPath + { + public: + using GetterCallbackType = std::function; + LinkedDataPath(GetterCallbackType getPath); + LinkedDataPath(GetterCallbackType getPath, DataArrayPathHelper::DataType targetLevel); + + /** + * @brief Generates a DataArrayPath to the target container + * @return + */ + DataArrayPath generatePath() override; + + private: + GetterCallbackType pathGetter; + DataArrayPathHelper::DataType m_TargetPathType = DataArrayPathHelper::DataType::None; + }; + /** + * @brief The LinkedAdvComparisonPath stores a getter for the target ComparisonInputsAdvanced DataArrayPath + */ + class SIMPLib_EXPORT LinkedAdvComparisonPath : public ILinkedPath + { + public: + using GetterCallbackType = std::function; + LinkedAdvComparisonPath(GetterCallbackType comparison); + + /** + * @brief Generates a DataArrayPath to the target container + * @return + */ + DataArrayPath generatePath() override; + + private: + GetterCallbackType compGetter; + }; + + /** + * @brief Create and return an ILinkedPath based on the given Parameters + * @param DataArrayPath getter + * @param DataType + * @return + */ + static std::unique_ptr CreateLinkedPath(LinkedDataPath::GetterCallbackType, DataArrayPathHelper::DataType); + + /** + * @brief Create and return an ILinkedPath based on the given Parameters + * @param QString getter + * @return + */ + static std::unique_ptr CreateLinkedPath(LinkedStringPath::GetterCallbackType); + + /** + * @brief Create and return an ILinkedPath based on the given Parameters + * @param QString getter + * @param QString getter + * @return + */ + static std::unique_ptr CreateLinkedPath(LinkedStringPath::GetterCallbackType, LinkedStringPath::GetterCallbackType); + + /** + * @brief Create and return an ILinkedPath based on the given Parameters + * @param DataArrayPath getter + * @param DataArrayPath getter + * @return + */ + static std::unique_ptr CreateLinkedPath(LinkedMixedPath::PathGetterCallbackType, LinkedMixedPath::PathGetterCallbackType); + + /** + * @brief Create and return an ILinkedPath based on the given Parameters + * @param DataArrayPath getter + * @param QString getter + * @return + */ + static std::unique_ptr CreateLinkedPath(LinkedMixedPath::PathGetterCallbackType, LinkedMixedPath::StringGetterCallbackType); + + /** + * @brief Create and return an ILinkedPath based on the given Parameters + * @param DataArrayPath dcGetter + * @return + */ + static std::unique_ptr CreateLinkedPath(LinkedMixedPath::PathGetterCallbackType dcGetter); + + /** + * @brief Create and return an ILinkedPath based on the given Parameters + * @param AdvancedComparison getter + * @return + */ + static std::unique_ptr CreateLinkedPath(LinkedAdvComparisonPath::GetterCallbackType); + + /** + * @brief New This function instantiates an instance of the LinkedPathCreationFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_STRING_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, std::unique_ptr linkedPath, int groupIndex = -1); + + ~LinkedPathCreationFilterParameter() override; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const LinkedPathCreationFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + LinkedPathCreationFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const LinkedPathCreationFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + LinkedPathCreationFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Set the ILinkedPath for determining what the parent container is + * @param linkedPath + */ + void setLinkedPath(std::unique_ptr linkedPath); + + /** + * @brief Returned the linked DataArrayPath + * @return + */ + DataArrayPath getLinkedDataArrayPath() const; + +protected: + /** + * @brief LinkedPathCreationFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + LinkedPathCreationFilterParameter(); + +private: + LinkedPathCreationFilterParameter::SetterCallbackType m_SetterCallback = {}; + LinkedPathCreationFilterParameter::GetterCallbackType m_GetterCallback = {}; + + std::unique_ptr m_LinkedPath = nullptr; + +public: + LinkedPathCreationFilterParameter(const LinkedPathCreationFilterParameter&) = delete; // Copy Constructor Not Implemented + LinkedPathCreationFilterParameter(LinkedPathCreationFilterParameter&&) = delete; // Move Constructor Not Implemented + LinkedPathCreationFilterParameter& operator=(const LinkedPathCreationFilterParameter&) = delete; // Copy Assignment Not Implemented + LinkedPathCreationFilterParameter& operator=(LinkedPathCreationFilterParameter&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/FilterParameters/MontageFileListInfo.cpp b/Source/SIMPLib/FilterParameters/MontageFileListInfo.cpp new file mode 100644 index 0000000000..6dc0222919 --- /dev/null +++ b/Source/SIMPLib/FilterParameters/MontageFileListInfo.cpp @@ -0,0 +1,79 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "MontageFileListInfo.h" + +// ----------------------------------------------------------------------------- +MontageFileListInfo::MontageFileListInfo() = default; + +// ----------------------------------------------------------------------------- +MontageFileListInfo::~MontageFileListInfo() = default; + +// ----------------------------------------------------------------------------- +MontageFileListInfo::MontageFileListInfo(int32_t rowStart, int32_t rowEnd, int32_t colStart, int32_t colEnd) +: RowStart(rowStart) +, RowEnd(rowEnd) +, ColStart(colStart) +, ColEnd(colEnd) +{ +} + +// ----------------------------------------------------------------------------- +void MontageFileListInfo::writeJson(QJsonObject& json) const +{ + writeSuperclassJson(json); + + json["RowStart"] = static_cast(RowStart); + json["RowEnd"] = static_cast(RowEnd); + json["ColStart"] = static_cast(ColStart); + json["ColEnd"] = static_cast(ColEnd); +} + +// ----------------------------------------------------------------------------- +bool MontageFileListInfo::readJson(QJsonObject& json) +{ + bool result = readSuperclassJson(json); + if(!result) + { + return false; + } + + if(json["RowStart"].isDouble() && json["RowEnd"].isDouble() && json["ColStart"].isDouble() && json["ColEnd"].isDouble()) + { + RowStart = static_cast(json["RowStart"].toInt()); + RowEnd = static_cast(json["RowEnd"].toInt()); + ColStart = static_cast(json["ColStart"].toInt()); + ColEnd = static_cast(json["ColEnd"].toInt()); + return true; + } + return false; +} diff --git a/Source/SIMPLib/FilterParameters/MontageFileListInfo.h b/Source/SIMPLib/FilterParameters/MontageFileListInfo.h new file mode 100644 index 0000000000..9addc643cc --- /dev/null +++ b/Source/SIMPLib/FilterParameters/MontageFileListInfo.h @@ -0,0 +1,78 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#pragma once + +#include +#include +#include + +#include "SIMPLib/FilterParameters/FileListInfo.h" + +class SIMPLib_EXPORT MontageFileListInfo : public FileListInfo +{ + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(MontageFileListInfo) + PYB11_CREATION(int32_t int32_t int32_t int32_t) + PYB11_END_BINDINGS() + // End Python bindings declarations +public: + MontageFileListInfo(); + ~MontageFileListInfo() override; + + MontageFileListInfo(int32_t rowStart, int32_t rowEnd, int32_t colStart, int32_t colEnd); + + int32_t RowStart = 0; + int32_t RowEnd = 2; + int32_t ColStart = 0; + int32_t ColEnd = 2; + + /** + * @brief writeJson + * @param json + */ + void writeJson(QJsonObject& json) const override; + + /** + * @brief readJson + * @param json + * @return + */ + bool readJson(QJsonObject& json) override; + +public: + MontageFileListInfo(const MontageFileListInfo&) = default; // Copy Constructor Not Implemented + MontageFileListInfo(MontageFileListInfo&&) = default; // Move Constructor Not Implemented + MontageFileListInfo& operator=(const MontageFileListInfo&) = default; // Copy Assignment Not Implemented + MontageFileListInfo& operator=(MontageFileListInfo&&) = default; // Move Assignment Not Implemented +}; + +Q_DECLARE_METATYPE(MontageFileListInfo) diff --git a/Source/SIMPLib/FilterParameters/MontageSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/MontageSelectionFilterParameter.cpp new file mode 100644 index 0000000000..d0c4944b6b --- /dev/null +++ b/Source/SIMPLib/FilterParameters/MontageSelectionFilterParameter.cpp @@ -0,0 +1,146 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "MontageSelectionFilterParameter.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MontageSelectionFilterParameter::MontageSelectionFilterParameter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MontageSelectionFilterParameter::~MontageSelectionFilterParameter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MontageSelectionFilterParameter::Pointer MontageSelectionFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const MontageSelection& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) +{ + MontageSelectionFilterParameter::Pointer ptr = MontageSelectionFilterParameter::New(); + ptr->setHumanLabel(humanLabel); + ptr->setPropertyName(propertyName); + ptr->setDefaultValue(QVariant::fromValue(defaultValue)); + ptr->setCategory(category); + ptr->setGroupIndex(groupIndex); + ptr->setSetterCallback(setterCallback); + ptr->setGetterCallback(getterCallback); + + return ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString MontageSelectionFilterParameter::getWidgetType() const +{ + return QString("MontageSelectionWidget"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MontageSelectionFilterParameter::readJson(const QJsonObject& json) +{ + QJsonObject jsonValues = json[getPropertyName()].toObject(); + if(!jsonValues.isEmpty() && m_SetterCallback) + { + MontageSelection selection; + selection.fromJson(jsonValues); + m_SetterCallback(selection); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MontageSelectionFilterParameter::writeJson(QJsonObject& json) const +{ + if(m_GetterCallback) + { + MontageSelection values = m_GetterCallback(); + json[getPropertyName()] = values.toJson(); + } +} + +// ----------------------------------------------------------------------------- +MontageSelectionFilterParameter::Pointer MontageSelectionFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +MontageSelectionFilterParameter::Pointer MontageSelectionFilterParameter::New() +{ + Pointer sharedPtr(new(MontageSelectionFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString MontageSelectionFilterParameter::getNameOfClass() const +{ + return QString("MontageSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString MontageSelectionFilterParameter::ClassName() +{ + return QString("MontageSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void MontageSelectionFilterParameter::setSetterCallback(const MontageSelectionFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +MontageSelectionFilterParameter::SetterCallbackType MontageSelectionFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void MontageSelectionFilterParameter::setGetterCallback(const MontageSelectionFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +MontageSelectionFilterParameter::GetterCallbackType MontageSelectionFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/MontageSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/MontageSelectionFilterParameter.h new file mode 100644 index 0000000000..c1b2db6d7c --- /dev/null +++ b/Source/SIMPLib/FilterParameters/MontageSelectionFilterParameter.h @@ -0,0 +1,181 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include + +#include "SIMPLib/FilterParameters/FilterParameter.h" +#include "SIMPLib/Utilities/MontageSelection.h" + +/** + * @brief SIMPL_NEW_MONTAGE_SELECTION_FP This macro is a short-form way of instantiating an instance of + * MontageSelectionFilterParameter. There are 4 required parameters and 1 optional parameter + * that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, + * FilterName (class name), GroupIndex (optional). + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_MONTAGE_SELECTION_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): + * SIMPL_NEW_MONTAGE_SELECTION_FP("Montage 2", Montage2, FilterParameter::Category::Parameter, GenericExample); + */ +#define SIMPL_NEW_MONTAGE_SELECTION_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(MontageSelectionFilterParameter, __VA_ARGS__)) + +/** + * @brief The MontageSelectionFilterParameter class is used by filters to instantiate an MontageSelectionWidget. By instantiating an instance of + * this class in a filter's setupFilterParameters() method, a MontageSelectionWidget will appear in the filter's "filter input" section in the DREAM3D GUI. + */ +class SIMPLib_EXPORT MontageSelectionFilterParameter : public FilterParameter +{ + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(MontageSelectionFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(MontageSelectionFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = MontageSelectionFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for MontageSelectionFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for MontageSelectionFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the MontageSelectionFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_FLOAT_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const MontageSelection& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~MontageSelectionFilterParameter() override; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const MontageSelectionFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + MontageSelectionFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const MontageSelectionFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + MontageSelectionFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief MontageSelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + MontageSelectionFilterParameter(); + +public: + MontageSelectionFilterParameter(const MontageSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + MontageSelectionFilterParameter(MontageSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + MontageSelectionFilterParameter& operator=(const MontageSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented + MontageSelectionFilterParameter& operator=(MontageSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + MontageSelectionFilterParameter::SetterCallbackType m_SetterCallback = {}; + MontageSelectionFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/MontageStructureSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/MontageStructureSelectionFilterParameter.cpp new file mode 100644 index 0000000000..ee80afa65a --- /dev/null +++ b/Source/SIMPLib/FilterParameters/MontageStructureSelectionFilterParameter.cpp @@ -0,0 +1,184 @@ +/* ============================================================================ + * Copyright (c) 2019-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "MontageStructureSelectionFilterParameter.h" + +#include "SIMPLib/Filtering/AbstractFilter.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MontageStructureSelectionFilterParameter::MontageStructureSelectionFilterParameter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MontageStructureSelectionFilterParameter::~MontageStructureSelectionFilterParameter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MontageStructureSelectionFilterParameter::Pointer MontageStructureSelectionFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, + Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, + int groupIndex) +{ + MontageStructureSelectionFilterParameter::Pointer ptr = MontageStructureSelectionFilterParameter::New(); + ptr->setHumanLabel(humanLabel); + ptr->setPropertyName(propertyName); + QVariant v; + v.setValue(defaultValue); + ptr->setDefaultValue(v); + ptr->setCategory(category); + ptr->setGroupIndex(groupIndex); + ptr->setSetterCallback(setterCallback); + ptr->setGetterCallback(getterCallback); + + return ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString MontageStructureSelectionFilterParameter::getWidgetType() const +{ + return QString("MontageStructureSelectionWidget"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MontageStructureSelectionFilterParameter::readJson(const QJsonObject& json) +{ + QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } + if(jsonValue.isString() && m_SetterCallback) + { + m_SetterCallback(jsonValue.toString()); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MontageStructureSelectionFilterParameter::writeJson(QJsonObject& json) const +{ + if(m_GetterCallback) + { + QString montageName = m_GetterCallback(); + json[getPropertyName()] = montageName; + } +} + +#if 0 +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MontageStructureSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + DataArrayPath oldPath; + DataArrayPath newPath; + std::tie(oldPath, newPath) = renamePath; + + if(oldPath == m_GetterCallback() && oldPath.getDataContainerName() != newPath.getDataContainerName()) + { + m_SetterCallback(newPath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); + } +} +#endif + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MontageStructureSelectionFilterParameter::Pointer MontageStructureSelectionFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MontageStructureSelectionFilterParameter::Pointer MontageStructureSelectionFilterParameter::New() +{ + return Pointer(new MontageStructureSelectionFilterParameter()); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MontageStructureSelectionFilterParameter::SetterCallbackType MontageStructureSelectionFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MontageStructureSelectionFilterParameter::setSetterCallback(const SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MontageStructureSelectionFilterParameter::GetterCallbackType MontageStructureSelectionFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MontageStructureSelectionFilterParameter::setGetterCallback(const GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString MontageStructureSelectionFilterParameter::getNameOfClass() const +{ + return "MontageStructureSelectionFilterParameter"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString MontageStructureSelectionFilterParameter::ClassName() +{ + return "MontageStructureSelectionFilterParameter"; +} diff --git a/Source/SIMPLib/FilterParameters/MontageStructureSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/MontageStructureSelectionFilterParameter.h new file mode 100644 index 0000000000..7ecd9eb3ed --- /dev/null +++ b/Source/SIMPLib/FilterParameters/MontageStructureSelectionFilterParameter.h @@ -0,0 +1,172 @@ +/* ============================================================================ + * Copyright (c) 2019-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" + +/** + * @brief SIMPL_NEW_MONTAGE_STRUCTURE_SELECTION_FP This macro is a short-form way of instantiating an instance of + * MontageStructureSelectionFilterParameter. There are 4 required parameters and 1 optional parameter + * that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, + * FilterName (class name), GroupIndex (optional). + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_MONTAGE_STRUCTURE_SELECTION_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): + * SIMPL_NEW_MONTAGE_STRUCTURE_SELECTION_FP("Montage", NameName, FilterParameter::Category::Parameter, GenericExample, 2); + */ +#define SIMPL_NEW_MONTAGE_STRUCTURE_SELECTION_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(MontageStructureSelectionFilterParameter, __VA_ARGS__)) + +/** + * @brief The MontageStructureSelectionFilterParameter class is used by filters to instantiate an DataContainerSelectionWidget. By instantiating an instance of + * this class in a filter's setupFilterParameters() method, a DataContainerSelectionWidget will appear in the filter's "filter input" section in the DREAM3D GUI. + */ +class SIMPLib_EXPORT MontageStructureSelectionFilterParameter : public FilterParameter +{ + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(MontageStructureSelectionFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(MontageStructureSelectionFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = MontageStructureSelectionFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for StatsDataArray + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for StatsDataArray + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the MontageStructureSelectionFilterParameter. Specifying a RequirementType will + * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. + * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the + * SIMPL_NEW_DC_SELECTION_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, + int groupIndex = -1); + + ~MontageStructureSelectionFilterParameter() override; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + SetterCallbackType getSetterCallback() const; + void setSetterCallback(const SetterCallbackType& value); + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + GetterCallbackType getGetterCallback() const; + void setGetterCallback(const GetterCallbackType& value); + + /** + * @brief Handles changes to the DataArrayPath + * @param filter + * @param renamePath + */ + // void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief MontageStructureSelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + MontageStructureSelectionFilterParameter(); + +private: + SetterCallbackType m_SetterCallback; + GetterCallbackType m_GetterCallback; + +public: + MontageStructureSelectionFilterParameter(const MontageStructureSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + MontageStructureSelectionFilterParameter(MontageStructureSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + MontageStructureSelectionFilterParameter& operator=(const MontageStructureSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented + MontageStructureSelectionFilterParameter& operator=(MontageStructureSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.cpp index 4054b0dfb8..dc140ea6f2 100644 --- a/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "MultiAttributeMatrixSelectionFilterParameter.h" @@ -44,7 +44,7 @@ // // ----------------------------------------------------------------------------- MultiAttributeMatrixSelectionFilterParameter::MultiAttributeMatrixSelectionFilterParameter() -: m_DefaultPaths(QVector()) +: m_DefaultPaths(std::vector()) { } @@ -56,9 +56,10 @@ MultiAttributeMatrixSelectionFilterParameter::~MultiAttributeMatrixSelectionFilt // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -MultiAttributeMatrixSelectionFilterParameter::Pointer MultiAttributeMatrixSelectionFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QVector& defaultValue, - Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex) +MultiAttributeMatrixSelectionFilterParameter::Pointer MultiAttributeMatrixSelectionFilterParameter::Create(const QString& humanLabel, const QString& propertyName, + const std::vector& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + RequirementType req, int groupIndex) { MultiAttributeMatrixSelectionFilterParameter::Pointer ptr = MultiAttributeMatrixSelectionFilterParameter::New(); @@ -91,9 +92,9 @@ QString MultiAttributeMatrixSelectionFilterParameter::getWidgetType() const // // ----------------------------------------------------------------------------- MultiAttributeMatrixSelectionFilterParameter::RequirementType MultiAttributeMatrixSelectionFilterParameter::CreateCategoryRequirement(const QString& primitiveType, size_t allowedCompDim, - AttributeMatrix::Category attributeMatrixCategory) + AttributeMatrix::Category attributeMatrixCategory) { - typedef QVector QVectorOfSizeType; + typedef std::vector SizeTVectorType; MultiAttributeMatrixSelectionFilterParameter::RequirementType req; AttributeMatrix::Types amTypes; if(attributeMatrixCategory == AttributeMatrix::Category::Element) @@ -120,11 +121,11 @@ MultiAttributeMatrixSelectionFilterParameter::RequirementType MultiAttributeMatr req.amTypes = amTypes; if(primitiveType.compare(SIMPL::Defaults::AnyPrimitive) != 0) { - req.daTypes = QVector(1, primitiveType); + req.daTypes = std::vector(1, primitiveType); } if(SIMPL::Defaults::AnyComponentSize != allowedCompDim) { - req.componentDimensions = QVector(1, QVectorOfSizeType(1, allowedCompDim)); + req.componentDimensions = std::vector(1, SizeTVectorType(1, allowedCompDim)); } // if(IGeometry::Type::Unknown != geometryType) // { @@ -136,22 +137,22 @@ MultiAttributeMatrixSelectionFilterParameter::RequirementType MultiAttributeMatr // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -MultiAttributeMatrixSelectionFilterParameter::RequirementType MultiAttributeMatrixSelectionFilterParameter::CreateRequirement(const QString& primitiveType, size_t allowedCompDim, AttributeMatrix::Type attributeMatrixType, - IGeometry::Type geometryType) +MultiAttributeMatrixSelectionFilterParameter::RequirementType MultiAttributeMatrixSelectionFilterParameter::CreateRequirement(const QString& primitiveType, size_t allowedCompDim, + AttributeMatrix::Type attributeMatrixType, IGeometry::Type geometryType) { - typedef QVector QVectorOfSizeType; + typedef std::vector SizeTVectorType; MultiAttributeMatrixSelectionFilterParameter::RequirementType req; if(primitiveType.compare(SIMPL::Defaults::AnyPrimitive) != 0) { - req.daTypes = QVector(1, primitiveType); + req.daTypes = std::vector(1, primitiveType); } if(SIMPL::Defaults::AnyComponentSize != allowedCompDim) { - req.componentDimensions = QVector(1, QVectorOfSizeType(1, allowedCompDim)); + req.componentDimensions = std::vector(1, SizeTVectorType(1, allowedCompDim)); } if(AttributeMatrix::Type::Any != attributeMatrixType) { - QVector amTypes(1, attributeMatrixType); + AttributeMatrix::Types amTypes(1, attributeMatrixType); req.amTypes = amTypes; } if(IGeometry::Type::Any != geometryType) @@ -167,10 +168,14 @@ MultiAttributeMatrixSelectionFilterParameter::RequirementType MultiAttributeMatr void MultiAttributeMatrixSelectionFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonArray arrayObj = jsonValue.toArray(); - QVector dapVec; + std::vector dapVec; for(int i = 0; i < arrayObj.size(); i++) { QJsonObject obj = arrayObj.at(i).toObject(); @@ -186,11 +191,11 @@ void MultiAttributeMatrixSelectionFilterParameter::readJson(const QJsonObject& j // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void MultiAttributeMatrixSelectionFilterParameter::writeJson(QJsonObject& json) +void MultiAttributeMatrixSelectionFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { - QVector dapVec = m_GetterCallback(); + std::vector dapVec = m_GetterCallback(); QJsonArray arrayObj; for(int i = 0; i < dapVec.size(); i++) @@ -208,17 +213,17 @@ void MultiAttributeMatrixSelectionFilterParameter::writeJson(QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void MultiAttributeMatrixSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void MultiAttributeMatrixSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; std::tie(oldPath, newPath) = renamePath; - QVector paths = m_GetterCallback(); - int count = paths.size(); + std::vector paths = m_GetterCallback(); + size_t count = paths.size(); bool updated = false; - for(int i = 0; i < count; i++) + for(size_t i = 0; i < count; i++) { if(paths[i] == oldPath) { @@ -228,5 +233,114 @@ void MultiAttributeMatrixSelectionFilterParameter::dataArrayPathRenamed(Abstract } m_SetterCallback(paths); - emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); +} + +// ----------------------------------------------------------------------------- +MultiAttributeMatrixSelectionFilterParameter::Pointer MultiAttributeMatrixSelectionFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +MultiAttributeMatrixSelectionFilterParameter::Pointer MultiAttributeMatrixSelectionFilterParameter::New() +{ + Pointer sharedPtr(new(MultiAttributeMatrixSelectionFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString MultiAttributeMatrixSelectionFilterParameter::getNameOfClass() const +{ + return QString("MultiAttributeMatrixSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString MultiAttributeMatrixSelectionFilterParameter::ClassName() +{ + return QString("MultiAttributeMatrixSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void MultiAttributeMatrixSelectionFilterParameter::setDefaultPaths(const std::vector& value) +{ + m_DefaultPaths = value; +} + +// ----------------------------------------------------------------------------- +std::vector MultiAttributeMatrixSelectionFilterParameter::getDefaultPaths() const +{ + return m_DefaultPaths; +} + +// ----------------------------------------------------------------------------- +void MultiAttributeMatrixSelectionFilterParameter::setDefaultGeometryTypes(const IGeometry::Types& value) +{ + m_DefaultGeometryTypes = value; +} + +// ----------------------------------------------------------------------------- +IGeometry::Types MultiAttributeMatrixSelectionFilterParameter::getDefaultGeometryTypes() const +{ + return m_DefaultGeometryTypes; +} + +// ----------------------------------------------------------------------------- +void MultiAttributeMatrixSelectionFilterParameter::setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value) +{ + m_DefaultAttributeMatrixTypes = value; +} + +// ----------------------------------------------------------------------------- +AttributeMatrix::Types MultiAttributeMatrixSelectionFilterParameter::getDefaultAttributeMatrixTypes() const +{ + return m_DefaultAttributeMatrixTypes; +} + +// ----------------------------------------------------------------------------- +void MultiAttributeMatrixSelectionFilterParameter::setDefaultAttributeArrayTypes(const std::vector& value) +{ + m_DefaultAttributeArrayTypes = value; +} + +// ----------------------------------------------------------------------------- +std::vector MultiAttributeMatrixSelectionFilterParameter::getDefaultAttributeArrayTypes() const +{ + return m_DefaultAttributeArrayTypes; +} + +// ----------------------------------------------------------------------------- +void MultiAttributeMatrixSelectionFilterParameter::setDefaultComponentDimensions(const std::vector>& value) +{ + m_DefaultComponentDimensions = value; +} + +// ----------------------------------------------------------------------------- +std::vector> MultiAttributeMatrixSelectionFilterParameter::getDefaultComponentDimensions() const +{ + return m_DefaultComponentDimensions; +} + +// ----------------------------------------------------------------------------- +void MultiAttributeMatrixSelectionFilterParameter::setSetterCallback(const MultiAttributeMatrixSelectionFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +MultiAttributeMatrixSelectionFilterParameter::SetterCallbackType MultiAttributeMatrixSelectionFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void MultiAttributeMatrixSelectionFilterParameter::setGetterCallback(const MultiAttributeMatrixSelectionFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +MultiAttributeMatrixSelectionFilterParameter::GetterCallbackType MultiAttributeMatrixSelectionFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; } diff --git a/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.h index 37e35c041d..b4952424e2 100644 --- a/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/MultiAttributeMatrixSelectionFilterParameter.h @@ -1,45 +1,47 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" -#include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/DataContainers/AttributeMatrix.h" +#include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Geometry/IGeometry.h" /** @@ -53,12 +55,10 @@ * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): * MultiAttributeMatrixSelectionFilterParameter::RequirementType req; - * SIMPL_NEW_MDA_SELECTION_FP("Multi Data Array Test", SelectedMultiArrayPaths, FilterParameter::Parameter, GenericExample, req, 0); + * SIMPL_NEW_MDA_SELECTION_FP("Multi Data Array Test", SelectedMultiArrayPaths, FilterParameter::Category::Parameter, GenericExample, req, 0); */ -#define SIMPL_NEW_MAM_SELECTION_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (MultiAttributeMatrixSelectionFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_MAM_SELECTION_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(MultiAttributeMatrixSelectionFilterParameter, __VA_ARGS__)) /** * @brief The MultiAttributeMatrixSelectionFilterParameter class is used by filters to instantiate an MultiDataArraySelectionWidget. By instantiating an instance of @@ -66,131 +66,214 @@ */ class SIMPLib_EXPORT MultiAttributeMatrixSelectionFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(MultiAttributeMatrixSelectionFilterParameter) - SIMPL_STATIC_NEW_MACRO(MultiAttributeMatrixSelectionFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(MultiAttributeMatrixSelectionFilterParameter, FilterParameter) - - typedef std::function)> SetterCallbackType; - typedef std::function(void)> GetterCallbackType; - - typedef struct - { - IGeometry::Types dcGeometryTypes; - AttributeMatrix::Types amTypes; - QVector daTypes; - QVector< QVector > componentDimensions; - } RequirementType; - - /** - * @brief New This function instantiates an instance of the MultiAttributeMatrixSelectionFilterParameter. Specifying a RequirementType will - * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. - * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the - * SIMPL_NEW_MDA_SELECTION_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D - * user interface. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QVector& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex = -1); - - ~MultiAttributeMatrixSelectionFilterParameter() override; - - /** - * @brief CreateRequirement - * @param primitiveType - * @param allowedCompDim - * @param attributeMatrixCategory - * @return - */ - static RequirementType CreateCategoryRequirement(const QString& primitiveType, - size_t allowedCompDim, - AttributeMatrix::Category attributeMatrixCategory); - - /** - * @brief CreateRequirement - * @param primitiveType - * @param allowedCompDim - * @param attributeMatrixType - * @param geometryType - * @return - */ - static RequirementType CreateRequirement(const QString& primitiveType, - size_t allowedCompDim, - AttributeMatrix::Type attributeMatrixType, - IGeometry::Type geometryType); - - SIMPL_INSTANCE_PROPERTY(QVector, DefaultPaths) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - SIMPL_INSTANCE_PROPERTY(IGeometry::Types, DefaultGeometryTypes) - SIMPL_INSTANCE_PROPERTY(QVector, DefaultAttributeMatrixTypes) - SIMPL_INSTANCE_PROPERTY(QVector, DefaultAttributeArrayTypes) - SIMPL_INSTANCE_PROPERTY(QVector< QVector >, DefaultComponentDimensions) - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - /** - * @brief Handle DataArrayPath changes if necessary - * @param filter - * @param renamePath - */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; - - protected: - /** - * @brief MultiAttributeMatrixSelectionFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - MultiAttributeMatrixSelectionFilterParameter(); - - public: - MultiAttributeMatrixSelectionFilterParameter(const MultiAttributeMatrixSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented - MultiAttributeMatrixSelectionFilterParameter(MultiAttributeMatrixSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented - MultiAttributeMatrixSelectionFilterParameter& operator=(const MultiAttributeMatrixSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented - MultiAttributeMatrixSelectionFilterParameter& operator=(MultiAttributeMatrixSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(MultiAttributeMatrixSelectionFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(MultiAttributeMatrixSelectionFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_CUSTOM() + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = MultiAttributeMatrixSelectionFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for MultiAttributeMatrixSelectionFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for MultiAttributeMatrixSelectionFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function)>; + using GetterCallbackType = std::function(void)>; + + struct RequirementType + { + IGeometry::Types dcGeometryTypes; + AttributeMatrix::Types amTypes; + std::vector daTypes; + std::vector> componentDimensions; + }; + + /** + * @brief New This function instantiates an instance of the MultiAttributeMatrixSelectionFilterParameter. Specifying a RequirementType will + * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. + * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the + * SIMPL_NEW_MDA_SELECTION_FP(...) macro at the top of this file. + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D + * user interface. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const std::vector& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, RequirementType req, int groupIndex = -1); + + ~MultiAttributeMatrixSelectionFilterParameter() override; + + /** + * @brief CreateRequirement + * @param primitiveType + * @param allowedCompDim + * @param attributeMatrixCategory + * @return + */ + static RequirementType CreateCategoryRequirement(const QString& primitiveType, size_t allowedCompDim, AttributeMatrix::Category attributeMatrixCategory); + + /** + * @brief CreateRequirement + * @param primitiveType + * @param allowedCompDim + * @param attributeMatrixType + * @param geometryType + * @return + */ + static RequirementType CreateRequirement(const QString& primitiveType, size_t allowedCompDim, AttributeMatrix::Type attributeMatrixType, IGeometry::Type geometryType); + + /** + * @brief Setter property for DefaultPaths + */ + void setDefaultPaths(const std::vector& value); + /** + * @brief Getter property for DefaultPaths + * @return Value of DefaultPaths + */ + std::vector getDefaultPaths() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @brief Setter property for DefaultGeometryTypes + */ + void setDefaultGeometryTypes(const IGeometry::Types& value); + /** + * @brief Getter property for DefaultGeometryTypes + * @return Value of DefaultGeometryTypes + */ + IGeometry::Types getDefaultGeometryTypes() const; + + /** + * @brief Setter property for DefaultAttributeMatrixTypes + */ + void setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value); + /** + * @brief Getter property for DefaultAttributeMatrixTypes + * @return Value of DefaultAttributeMatrixTypes + */ + AttributeMatrix::Types getDefaultAttributeMatrixTypes() const; + + /** + * @brief Setter property for DefaultAttributeArrayTypes + */ + void setDefaultAttributeArrayTypes(const std::vector& value); + /** + * @brief Getter property for DefaultAttributeArrayTypes + * @return Value of DefaultAttributeArrayTypes + */ + std::vector getDefaultAttributeArrayTypes() const; + + /** + * @brief Setter property for DefaultComponentDimensions + */ + void setDefaultComponentDimensions(const std::vector>& value); + /** + * @brief Getter property for DefaultComponentDimensions + * @return Value of DefaultComponentDimensions + */ + std::vector> getDefaultComponentDimensions() const; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const MultiAttributeMatrixSelectionFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + MultiAttributeMatrixSelectionFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const MultiAttributeMatrixSelectionFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + MultiAttributeMatrixSelectionFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handle DataArrayPath changes if necessary + * @param filter + * @param renamePath + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief MultiAttributeMatrixSelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + MultiAttributeMatrixSelectionFilterParameter(); + +public: + MultiAttributeMatrixSelectionFilterParameter(const MultiAttributeMatrixSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + MultiAttributeMatrixSelectionFilterParameter(MultiAttributeMatrixSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + MultiAttributeMatrixSelectionFilterParameter& operator=(const MultiAttributeMatrixSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented + MultiAttributeMatrixSelectionFilterParameter& operator=(MultiAttributeMatrixSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + std::vector m_DefaultPaths = {}; + IGeometry::Types m_DefaultGeometryTypes = {}; + AttributeMatrix::Types m_DefaultAttributeMatrixTypes = {}; + std::vector m_DefaultAttributeArrayTypes = {}; + std::vector> m_DefaultComponentDimensions = {}; + MultiAttributeMatrixSelectionFilterParameter::SetterCallbackType m_SetterCallback = {}; + MultiAttributeMatrixSelectionFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.cpp index d49ee0700e..beca4681a3 100644 --- a/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "MultiDataArraySelectionFilterParameter.h" @@ -44,7 +44,7 @@ // // ----------------------------------------------------------------------------- MultiDataArraySelectionFilterParameter::MultiDataArraySelectionFilterParameter() -: m_DefaultPaths(QVector()) +: m_DefaultPaths(std::vector()) { } @@ -56,9 +56,9 @@ MultiDataArraySelectionFilterParameter::~MultiDataArraySelectionFilterParameter( // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -MultiDataArraySelectionFilterParameter::Pointer MultiDataArraySelectionFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QVector& defaultValue, - Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex) +MultiDataArraySelectionFilterParameter::Pointer MultiDataArraySelectionFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const std::vector& defaultValue, + Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + RequirementType req, int groupIndex) { MultiDataArraySelectionFilterParameter::Pointer ptr = MultiDataArraySelectionFilterParameter::New(); @@ -93,7 +93,7 @@ QString MultiDataArraySelectionFilterParameter::getWidgetType() const MultiDataArraySelectionFilterParameter::RequirementType MultiDataArraySelectionFilterParameter::CreateCategoryRequirement(const QString& primitiveType, size_t allowedCompDim, AttributeMatrix::Category attributeMatrixCategory) { - typedef QVector QVectorOfSizeType; + typedef std::vector SizeTVectorType; MultiDataArraySelectionFilterParameter::RequirementType req; AttributeMatrix::Types amTypes; if(attributeMatrixCategory == AttributeMatrix::Category::Element) @@ -120,11 +120,11 @@ MultiDataArraySelectionFilterParameter::RequirementType MultiDataArraySelectionF req.amTypes = amTypes; if(primitiveType.compare(SIMPL::Defaults::AnyPrimitive) != 0) { - req.daTypes = QVector(1, primitiveType); + req.daTypes = std::vector(1, primitiveType); } if(SIMPL::Defaults::AnyComponentSize != allowedCompDim) { - req.componentDimensions = QVector(1, QVectorOfSizeType(1, allowedCompDim)); + req.componentDimensions = std::vector(1, SizeTVectorType(1, allowedCompDim)); } // if(IGeometry::Type::Unknown != geometryType) // { @@ -136,22 +136,22 @@ MultiDataArraySelectionFilterParameter::RequirementType MultiDataArraySelectionF // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -MultiDataArraySelectionFilterParameter::RequirementType MultiDataArraySelectionFilterParameter::CreateRequirement(const QString& primitiveType, size_t allowedCompDim, AttributeMatrix::Type attributeMatrixType, - IGeometry::Type geometryType) +MultiDataArraySelectionFilterParameter::RequirementType MultiDataArraySelectionFilterParameter::CreateRequirement(const QString& primitiveType, size_t allowedCompDim, + AttributeMatrix::Type attributeMatrixType, IGeometry::Type geometryType) { - typedef QVector QVectorOfSizeType; + typedef std::vector SizeTVectorType; MultiDataArraySelectionFilterParameter::RequirementType req; if(primitiveType.compare(SIMPL::Defaults::AnyPrimitive) != 0) { - req.daTypes = QVector(1, primitiveType); + req.daTypes = std::vector(1, primitiveType); } if(SIMPL::Defaults::AnyComponentSize != allowedCompDim) { - req.componentDimensions = QVector(1, QVectorOfSizeType(1, allowedCompDim)); + req.componentDimensions = std::vector(1, SizeTVectorType(1, allowedCompDim)); } if(AttributeMatrix::Type::Any != attributeMatrixType) { - QVector amTypes(1, attributeMatrixType); + AttributeMatrix::Types amTypes(1, attributeMatrixType); req.amTypes = amTypes; } if(IGeometry::Type::Any != geometryType) @@ -167,10 +167,14 @@ MultiDataArraySelectionFilterParameter::RequirementType MultiDataArraySelectionF void MultiDataArraySelectionFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonArray arrayObj = jsonValue.toArray(); - QVector dapVec; + std::vector dapVec; for(int i = 0; i < arrayObj.size(); i++) { QJsonObject obj = arrayObj.at(i).toObject(); @@ -186,11 +190,11 @@ void MultiDataArraySelectionFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void MultiDataArraySelectionFilterParameter::writeJson(QJsonObject& json) +void MultiDataArraySelectionFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { - QVector dapVec = m_GetterCallback(); + std::vector dapVec = m_GetterCallback(); QJsonArray arrayObj; for(int i = 0; i < dapVec.size(); i++) @@ -208,13 +212,13 @@ void MultiDataArraySelectionFilterParameter::writeJson(QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void MultiDataArraySelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void MultiDataArraySelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; std::tie(oldPath, newPath) = renamePath; - QVector paths = m_GetterCallback(); + std::vector paths = m_GetterCallback(); int count = paths.size(); bool updated = false; @@ -228,5 +232,114 @@ void MultiDataArraySelectionFilterParameter::dataArrayPathRenamed(AbstractFilter } m_SetterCallback(paths); - emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); +} + +// ----------------------------------------------------------------------------- +MultiDataArraySelectionFilterParameter::Pointer MultiDataArraySelectionFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +MultiDataArraySelectionFilterParameter::Pointer MultiDataArraySelectionFilterParameter::New() +{ + Pointer sharedPtr(new(MultiDataArraySelectionFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString MultiDataArraySelectionFilterParameter::getNameOfClass() const +{ + return QString("MultiDataArraySelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString MultiDataArraySelectionFilterParameter::ClassName() +{ + return QString("MultiDataArraySelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void MultiDataArraySelectionFilterParameter::setDefaultPaths(const std::vector& value) +{ + m_DefaultPaths = value; +} + +// ----------------------------------------------------------------------------- +std::vector MultiDataArraySelectionFilterParameter::getDefaultPaths() const +{ + return m_DefaultPaths; +} + +// ----------------------------------------------------------------------------- +void MultiDataArraySelectionFilterParameter::setDefaultGeometryTypes(const IGeometry::Types& value) +{ + m_DefaultGeometryTypes = value; +} + +// ----------------------------------------------------------------------------- +IGeometry::Types MultiDataArraySelectionFilterParameter::getDefaultGeometryTypes() const +{ + return m_DefaultGeometryTypes; +} + +// ----------------------------------------------------------------------------- +void MultiDataArraySelectionFilterParameter::setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value) +{ + m_DefaultAttributeMatrixTypes = value; +} + +// ----------------------------------------------------------------------------- +AttributeMatrix::Types MultiDataArraySelectionFilterParameter::getDefaultAttributeMatrixTypes() const +{ + return m_DefaultAttributeMatrixTypes; +} + +// ----------------------------------------------------------------------------- +void MultiDataArraySelectionFilterParameter::setDefaultAttributeArrayTypes(const std::vector& value) +{ + m_DefaultAttributeArrayTypes = value; +} + +// ----------------------------------------------------------------------------- +std::vector MultiDataArraySelectionFilterParameter::getDefaultAttributeArrayTypes() const +{ + return m_DefaultAttributeArrayTypes; +} + +// ----------------------------------------------------------------------------- +void MultiDataArraySelectionFilterParameter::setDefaultComponentDimensions(const std::vector>& value) +{ + m_DefaultComponentDimensions = value; +} + +// ----------------------------------------------------------------------------- +std::vector> MultiDataArraySelectionFilterParameter::getDefaultComponentDimensions() const +{ + return m_DefaultComponentDimensions; +} + +// ----------------------------------------------------------------------------- +void MultiDataArraySelectionFilterParameter::setSetterCallback(const MultiDataArraySelectionFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +MultiDataArraySelectionFilterParameter::SetterCallbackType MultiDataArraySelectionFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void MultiDataArraySelectionFilterParameter::setGetterCallback(const MultiDataArraySelectionFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +MultiDataArraySelectionFilterParameter::GetterCallbackType MultiDataArraySelectionFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; } diff --git a/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.h old mode 100755 new mode 100644 index 25f26dbeba..fadd27bb58 --- a/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/MultiDataArraySelectionFilterParameter.h @@ -1,45 +1,47 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" -#include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/DataContainers/AttributeMatrix.h" +#include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Geometry/IGeometry.h" /** @@ -53,12 +55,10 @@ * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): * MultiDataArraySelectionFilterParameter::RequirementType req; - * SIMPL_NEW_MDA_SELECTION_FP("Multi Data Array Test", SelectedMultiArrayPaths, FilterParameter::Parameter, GenericExample, req, 0); + * SIMPL_NEW_MDA_SELECTION_FP("Multi Data Array Test", SelectedMultiArrayPaths, FilterParameter::Category::Parameter, GenericExample, req, 0); */ -#define SIMPL_NEW_MDA_SELECTION_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (MultiDataArraySelectionFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_MDA_SELECTION_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(MultiDataArraySelectionFilterParameter, __VA_ARGS__)) /** * @brief The MultiDataArraySelectionFilterParameter class is used by filters to instantiate an MultiDataArraySelectionWidget. By instantiating an instance of @@ -66,131 +66,214 @@ */ class SIMPLib_EXPORT MultiDataArraySelectionFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(MultiDataArraySelectionFilterParameter) - SIMPL_STATIC_NEW_MACRO(MultiDataArraySelectionFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(MultiDataArraySelectionFilterParameter, FilterParameter) - - typedef std::function)> SetterCallbackType; - typedef std::function(void)> GetterCallbackType; - - typedef struct - { - IGeometry::Types dcGeometryTypes; - AttributeMatrix::Types amTypes; - QVector daTypes; - QVector< QVector > componentDimensions; - } RequirementType; - - /** - * @brief New This function instantiates an instance of the MultiDataArraySelectionFilterParameter. Specifying a RequirementType will - * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. - * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the - * SIMPL_NEW_MDA_SELECTION_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D - * user interface. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QVector& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const RequirementType req, int groupIndex = -1); - - ~MultiDataArraySelectionFilterParameter() override; - - /** - * @brief CreateRequirement - * @param primitiveType - * @param allowedCompDim - * @param attributeMatrixCategory - * @return - */ - static RequirementType CreateCategoryRequirement(const QString& primitiveType, - size_t allowedCompDim, - AttributeMatrix::Category attributeMatrixCategory); - - /** - * @brief CreateRequirement - * @param primitiveType - * @param allowedCompDim - * @param attributeMatrixType - * @param geometryType - * @return - */ - static RequirementType CreateRequirement(const QString& primitiveType, - size_t allowedCompDim, - AttributeMatrix::Type attributeMatrixType, - IGeometry::Type geometryType); - - SIMPL_INSTANCE_PROPERTY(QVector, DefaultPaths) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - SIMPL_INSTANCE_PROPERTY(IGeometry::Types, DefaultGeometryTypes) - SIMPL_INSTANCE_PROPERTY(QVector, DefaultAttributeMatrixTypes) - SIMPL_INSTANCE_PROPERTY(QVector, DefaultAttributeArrayTypes) - SIMPL_INSTANCE_PROPERTY(QVector< QVector >, DefaultComponentDimensions) - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - /** - * @brief Handle DataArrayPath changes if necessary - * @param filter - * @param renamePath - */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; - - protected: - /** - * @brief MultiDataArraySelectionFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - MultiDataArraySelectionFilterParameter(); - - public: - MultiDataArraySelectionFilterParameter(const MultiDataArraySelectionFilterParameter&) = delete; // Copy Constructor Not Implemented - MultiDataArraySelectionFilterParameter(MultiDataArraySelectionFilterParameter&&) = delete; // Move Constructor Not Implemented - MultiDataArraySelectionFilterParameter& operator=(const MultiDataArraySelectionFilterParameter&) = delete; // Copy Assignment Not Implemented - MultiDataArraySelectionFilterParameter& operator=(MultiDataArraySelectionFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(MultiDataArraySelectionFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(MultiDataArraySelectionFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_CUSTOM() + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = MultiDataArraySelectionFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for MultiDataArraySelectionFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for MultiDataArraySelectionFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function)>; + using GetterCallbackType = std::function(void)>; + + struct RequirementType + { + IGeometry::Types dcGeometryTypes; + AttributeMatrix::Types amTypes; + std::vector daTypes; + std::vector> componentDimensions; + }; + + /** + * @brief New This function instantiates an instance of the MultiDataArraySelectionFilterParameter. Specifying a RequirementType will + * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. + * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the + * SIMPL_NEW_MDA_SELECTION_FP(...) macro at the top of this file. + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D + * user interface. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const std::vector& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, RequirementType req, int groupIndex = -1); + + ~MultiDataArraySelectionFilterParameter() override; + + /** + * @brief CreateRequirement + * @param primitiveType + * @param allowedCompDim + * @param attributeMatrixCategory + * @return + */ + static RequirementType CreateCategoryRequirement(const QString& primitiveType, size_t allowedCompDim, AttributeMatrix::Category attributeMatrixCategory); + + /** + * @brief CreateRequirement + * @param primitiveType + * @param allowedCompDim + * @param attributeMatrixType + * @param geometryType + * @return + */ + static RequirementType CreateRequirement(const QString& primitiveType, size_t allowedCompDim, AttributeMatrix::Type attributeMatrixType, IGeometry::Type geometryType); + + /** + * @brief Setter property for DefaultPaths + */ + void setDefaultPaths(const std::vector& value); + /** + * @brief Getter property for DefaultPaths + * @return Value of DefaultPaths + */ + std::vector getDefaultPaths() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @brief Setter property for DefaultGeometryTypes + */ + void setDefaultGeometryTypes(const IGeometry::Types& value); + /** + * @brief Getter property for DefaultGeometryTypes + * @return Value of DefaultGeometryTypes + */ + IGeometry::Types getDefaultGeometryTypes() const; + + /** + * @brief Setter property for DefaultAttributeMatrixTypes + */ + void setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value); + /** + * @brief Getter property for DefaultAttributeMatrixTypes + * @return Value of DefaultAttributeMatrixTypes + */ + AttributeMatrix::Types getDefaultAttributeMatrixTypes() const; + + /** + * @brief Setter property for DefaultAttributeArrayTypes + */ + void setDefaultAttributeArrayTypes(const std::vector& value); + /** + * @brief Getter property for DefaultAttributeArrayTypes + * @return Value of DefaultAttributeArrayTypes + */ + std::vector getDefaultAttributeArrayTypes() const; + + /** + * @brief Setter property for DefaultComponentDimensions + */ + void setDefaultComponentDimensions(const std::vector>& value); + /** + * @brief Getter property for DefaultComponentDimensions + * @return Value of DefaultComponentDimensions + */ + std::vector> getDefaultComponentDimensions() const; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const MultiDataArraySelectionFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + MultiDataArraySelectionFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const MultiDataArraySelectionFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + MultiDataArraySelectionFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handle DataArrayPath changes if necessary + * @param filter + * @param renamePath + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief MultiDataArraySelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + MultiDataArraySelectionFilterParameter(); + +public: + MultiDataArraySelectionFilterParameter(const MultiDataArraySelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + MultiDataArraySelectionFilterParameter(MultiDataArraySelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + MultiDataArraySelectionFilterParameter& operator=(const MultiDataArraySelectionFilterParameter&) = delete; // Copy Assignment Not Implemented + MultiDataArraySelectionFilterParameter& operator=(MultiDataArraySelectionFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + std::vector m_DefaultPaths = {}; + IGeometry::Types m_DefaultGeometryTypes = {}; + AttributeMatrix::Types m_DefaultAttributeMatrixTypes = {}; + std::vector m_DefaultAttributeArrayTypes = {}; + std::vector> m_DefaultComponentDimensions = {}; + MultiDataArraySelectionFilterParameter::SetterCallbackType m_SetterCallback = {}; + MultiDataArraySelectionFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.cpp new file mode 100644 index 0000000000..6a4cf5ed56 --- /dev/null +++ b/Source/SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.cpp @@ -0,0 +1,341 @@ +/* ============================================================================ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "MultiDataContainerSelectionFilterParameter.h" + +#include + +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionFilterParameter::MultiDataContainerSelectionFilterParameter() +: m_DefaultNames(std::vector()) +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionFilterParameter::~MultiDataContainerSelectionFilterParameter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionFilterParameter::Pointer MultiDataContainerSelectionFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const std::vector& defaultValue, + Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const RequirementType& req, int groupIndex) +{ + + MultiDataContainerSelectionFilterParameter::Pointer ptr = MultiDataContainerSelectionFilterParameter::New(); + ptr->setHumanLabel(humanLabel); + ptr->setPropertyName(propertyName); + QVariant v; + v.setValue(defaultValue); + ptr->setDefaultValue(v); + ptr->setCategory(category); + ptr->setDefaultGeometryTypes(req.dcGeometryTypes); + ptr->setDefaultAttributeMatrixTypes(req.amTypes); + ptr->setDefaultAttributeArrayTypes(req.daTypes); + ptr->setDefaultComponentDimensions(req.componentDimensions); + ptr->setGroupIndex(groupIndex); + ptr->setSetterCallback(setterCallback); + ptr->setGetterCallback(getterCallback); + + return ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString MultiDataContainerSelectionFilterParameter::getWidgetType() const +{ + return QString("MultiDataContainerSelectionWidget"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionFilterParameter::RequirementType MultiDataContainerSelectionFilterParameter::CreateCategoryRequirement(const QString& primitiveType, size_t allowedCompDim, + AttributeMatrix::Category attributeMatrixCategory) +{ + using SizeTVectorType = std::vector; + MultiDataContainerSelectionFilterParameter::RequirementType req; + AttributeMatrix::Types amTypes; + if(attributeMatrixCategory == AttributeMatrix::Category::Element) + { + amTypes.push_back(AttributeMatrix::Type::Cell); + amTypes.push_back(AttributeMatrix::Type::Face); + amTypes.push_back(AttributeMatrix::Type::Edge); + amTypes.push_back(AttributeMatrix::Type::Vertex); + } + else if(attributeMatrixCategory == AttributeMatrix::Category::Feature) + { + amTypes.push_back(AttributeMatrix::Type::CellFeature); + amTypes.push_back(AttributeMatrix::Type::FaceFeature); + amTypes.push_back(AttributeMatrix::Type::EdgeFeature); + amTypes.push_back(AttributeMatrix::Type::VertexFeature); + } + else if(attributeMatrixCategory == AttributeMatrix::Category::Ensemble) + { + amTypes.push_back(AttributeMatrix::Type::CellEnsemble); + amTypes.push_back(AttributeMatrix::Type::FaceEnsemble); + amTypes.push_back(AttributeMatrix::Type::EdgeEnsemble); + amTypes.push_back(AttributeMatrix::Type::VertexEnsemble); + } + req.amTypes = amTypes; + if(primitiveType.compare(SIMPL::Defaults::AnyPrimitive) != 0) + { + req.daTypes = std::vector(1, primitiveType); + } + if(SIMPL::Defaults::AnyComponentSize != allowedCompDim) + { + req.componentDimensions = std::vector(1, SizeTVectorType(1, allowedCompDim)); + } + // if(IGeometry::Type::Unknown != geometryType) + // { + // req.dcGeometryTypes = IGeometry::Types(1, geometryType); + // } + return req; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionFilterParameter::RequirementType MultiDataContainerSelectionFilterParameter::CreateRequirement(const QString& primitiveType, size_t allowedCompDim, + AttributeMatrix::Type attributeMatrixType, IGeometry::Type geometryType) +{ + using SizeTVectorType = std::vector; + MultiDataContainerSelectionFilterParameter::RequirementType req; + if(primitiveType.compare(SIMPL::Defaults::AnyPrimitive) != 0) + { + req.daTypes = std::vector(1, primitiveType); + } + if(SIMPL::Defaults::AnyComponentSize != allowedCompDim) + { + req.componentDimensions = std::vector(1, SizeTVectorType(1, allowedCompDim)); + } + if(AttributeMatrix::Type::Any != attributeMatrixType) + { + AttributeMatrix::Types amTypes(1, attributeMatrixType); + req.amTypes = amTypes; + } + if(IGeometry::Type::Any != geometryType) + { + req.dcGeometryTypes = IGeometry::Types(1, geometryType); + } + return req; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionFilterParameter::readJson(const QJsonObject& json) +{ + QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } + if(!jsonValue.isUndefined() && m_SetterCallback) + { + QJsonArray arrayObj = jsonValue.toArray(); + std::vector dcList; + for(const auto obj : arrayObj) + { + QString dcName = obj.toString(); + dcList.push_back(dcName); + } + + m_SetterCallback(dcList); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionFilterParameter::writeJson(QJsonObject& json) const +{ + if(m_GetterCallback) + { + std::vector dcList = m_GetterCallback(); + QJsonArray arrayObj; + + for(size_t i = 0; i < dcList.size(); i++) + { + QString dcName = dcList[i]; + arrayObj.push_back(dcName); + } + + json[getPropertyName()] = arrayObj; + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + DataArrayPath oldPath; + DataArrayPath newPath; + std::tie(oldPath, newPath) = renamePath; + + std::vector dcList = m_GetterCallback(); + size_t count = dcList.size(); + bool updated = false; + + for(size_t i = 0; i < count; i++) + { + if(dcList[i] == oldPath.getDataContainerName()) + { + dcList[i] = newPath.getDataContainerName(); + updated = true; + } + } + + m_SetterCallback(dcList); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); +} + +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionFilterParameter::Pointer MultiDataContainerSelectionFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionFilterParameter::Pointer MultiDataContainerSelectionFilterParameter::New() +{ + Pointer sharedPtr(new(MultiDataContainerSelectionFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString MultiDataContainerSelectionFilterParameter::getNameOfClass() const +{ + return QString("MultiDataContainerSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString MultiDataContainerSelectionFilterParameter::ClassName() +{ + return QString("MultiDataContainerSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionFilterParameter::setDefaultNames(const std::vector& value) +{ + m_DefaultNames = value; +} + +// ----------------------------------------------------------------------------- +std::vector MultiDataContainerSelectionFilterParameter::getDefaultNames() const +{ + return m_DefaultNames; +} + +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionFilterParameter::setDefaultGeometryTypes(const IGeometry::Types& value) +{ + m_DefaultGeometryTypes = value; +} + +// ----------------------------------------------------------------------------- +IGeometry::Types MultiDataContainerSelectionFilterParameter::getDefaultGeometryTypes() const +{ + return m_DefaultGeometryTypes; +} + +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionFilterParameter::setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value) +{ + m_DefaultAttributeMatrixTypes = value; +} + +// ----------------------------------------------------------------------------- +AttributeMatrix::Types MultiDataContainerSelectionFilterParameter::getDefaultAttributeMatrixTypes() const +{ + return m_DefaultAttributeMatrixTypes; +} + +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionFilterParameter::setDefaultAttributeArrayTypes(const std::vector& value) +{ + m_DefaultAttributeArrayTypes = value; +} + +// ----------------------------------------------------------------------------- +std::vector MultiDataContainerSelectionFilterParameter::getDefaultAttributeArrayTypes() const +{ + return m_DefaultAttributeArrayTypes; +} + +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionFilterParameter::setDefaultComponentDimensions(const std::vector>& value) +{ + m_DefaultComponentDimensions = value; +} + +// ----------------------------------------------------------------------------- +std::vector> MultiDataContainerSelectionFilterParameter::getDefaultComponentDimensions() const +{ + return m_DefaultComponentDimensions; +} + +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionFilterParameter::setSetterCallback(const MultiDataContainerSelectionFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionFilterParameter::SetterCallbackType MultiDataContainerSelectionFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void MultiDataContainerSelectionFilterParameter::setGetterCallback(const MultiDataContainerSelectionFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +MultiDataContainerSelectionFilterParameter::GetterCallbackType MultiDataContainerSelectionFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.h new file mode 100644 index 0000000000..4bbfbd9f60 --- /dev/null +++ b/Source/SIMPLib/FilterParameters/MultiDataContainerSelectionFilterParameter.h @@ -0,0 +1,280 @@ +/* ============================================================================ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include + +#include + +#include "SIMPLib/DataContainers/AttributeMatrix.h" +#include "SIMPLib/DataContainers/DataArrayPath.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" +#include "SIMPLib/Geometry/IGeometry.h" + +/** + * @brief SIMPL_NEW_MCA_SELECTION_FP This macro is a short-form way of instantiating an instance of + * MultiDataContainerSelectionFilterParameter. There are 5 required parameters and 1 optional parameter + * that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, + * FilterName (class name), RequirementType, GroupIndex (optional). + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_MCA_SELECTION_FP("HumanLabel", PropertyName, Category, FilterName, RequirementType, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): + * MultiDataContainerSelectionFilterParameter::RequirementType req; + * SIMPL_NEW_MCA_SELECTION_FP("Multi Data Container Test", SelectedMultiDataContainers, FilterParameter::Category::Parameter, GenericExample, req, 0); + */ +#define SIMPL_NEW_MDC_SELECTION_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(MultiDataContainerSelectionFilterParameter, __VA_ARGS__)) + +/** + * @brief The MultiDataContainerSelectionFilterParameter class is used by filters to instantiate an MultiDataContainerSelectionWidget. By instantiating an instance of + * this class in a filter's setupFilterParameters() method, a MultiDataContainerSelectionWidget will appear in the filter's "filter input" section in the DREAM3D GUI. + */ +class SIMPLib_EXPORT MultiDataContainerSelectionFilterParameter : public FilterParameter +{ + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(MultiDataContainerSelectionFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(MultiDataContainerSelectionFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_CUSTOM() + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = MultiDataContainerSelectionFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for MultiDataContainerSelectionFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for MultiDataContainerSelectionFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function)>; + using GetterCallbackType = std::function(void)>; + + struct RequirementType + { + IGeometry::Types dcGeometryTypes; + AttributeMatrix::Types amTypes; + std::vector daTypes; + std::vector> componentDimensions; + }; + + /** + * @brief New This function instantiates an instance of the MultiDataContainerSelectionFilterParameter. Specifying a RequirementType will + * automatically grey out Data Containers/Attribute Matrices in the user interface that do not conform to the specified RequirementType. + * Although this function is available to be used, the preferable way to instantiate an instance of this class is to use the + * SIMPL_NEW_MCA_SELECTION_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param req The RequirementType that greys out non-conforming selection options in the DREAM.3D + * user interface. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const std::vector& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const RequirementType& req, int groupIndex = -1); + + ~MultiDataContainerSelectionFilterParameter() override; + + /** + * @brief CreateRequirement + * @param primitiveType + * @param allowedCompDim + * @param attributeMatrixCategory + * @return + */ + static RequirementType CreateCategoryRequirement(const QString& primitiveType, size_t allowedCompDim, AttributeMatrix::Category attributeMatrixCategory); + + /** + * @brief CreateRequirement + * @param primitiveType + * @param allowedCompDim + * @param attributeMatrixType + * @param geometryType + * @return + */ + static RequirementType CreateRequirement(const QString& primitiveType, size_t allowedCompDim, AttributeMatrix::Type attributeMatrixType, IGeometry::Type geometryType); + + /** + * @brief Setter property for DefaultNames + */ + void setDefaultNames(const std::vector& value); + /** + * @brief Getter property for DefaultNames + * @return Value of DefaultNames + */ + std::vector getDefaultNames() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @brief Setter property for DefaultGeometryTypes + */ + void setDefaultGeometryTypes(const IGeometry::Types& value); + /** + * @brief Getter property for DefaultGeometryTypes + * @return Value of DefaultGeometryTypes + */ + IGeometry::Types getDefaultGeometryTypes() const; + + /** + * @brief Setter property for DefaultAttributeMatrixTypes + */ + void setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value); + /** + * @brief Getter property for DefaultAttributeMatrixTypes + * @return Value of DefaultAttributeMatrixTypes + */ + AttributeMatrix::Types getDefaultAttributeMatrixTypes() const; + + /** + * @brief Setter property for DefaultAttributeArrayTypes + */ + void setDefaultAttributeArrayTypes(const std::vector& value); + /** + * @brief Getter property for DefaultAttributeArrayTypes + * @return Value of DefaultAttributeArrayTypes + */ + std::vector getDefaultAttributeArrayTypes() const; + + /** + * @brief Setter property for DefaultComponentDimensions + */ + void setDefaultComponentDimensions(const std::vector>& value); + /** + * @brief Getter property for DefaultComponentDimensions + * @return Value of DefaultComponentDimensions + */ + std::vector> getDefaultComponentDimensions() const; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const MultiDataContainerSelectionFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + MultiDataContainerSelectionFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const MultiDataContainerSelectionFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + MultiDataContainerSelectionFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handle DataArrayPath changes if necessary + * @param filter + * @param renamePath + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + /** + * @brief MultiDataContainerSelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + MultiDataContainerSelectionFilterParameter(); + +public: + MultiDataContainerSelectionFilterParameter(const MultiDataContainerSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + MultiDataContainerSelectionFilterParameter(MultiDataContainerSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + MultiDataContainerSelectionFilterParameter& operator=(const MultiDataContainerSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented + MultiDataContainerSelectionFilterParameter& operator=(MultiDataContainerSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + std::vector m_DefaultNames = {}; + IGeometry::Types m_DefaultGeometryTypes = {}; + AttributeMatrix::Types m_DefaultAttributeMatrixTypes = {}; + std::vector m_DefaultAttributeArrayTypes = {}; + std::vector> m_DefaultComponentDimensions = {}; + MultiDataContainerSelectionFilterParameter::SetterCallbackType m_SetterCallback = {}; + MultiDataContainerSelectionFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/MultiInputFileFilterParameter.cpp b/Source/SIMPLib/FilterParameters/MultiInputFileFilterParameter.cpp new file mode 100644 index 0000000000..ccf55315fb --- /dev/null +++ b/Source/SIMPLib/FilterParameters/MultiInputFileFilterParameter.cpp @@ -0,0 +1,188 @@ +/* ============================================================================ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "MultiInputFileFilterParameter.h" + +#include +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiInputFileFilterParameter::MultiInputFileFilterParameter() +: m_FileExtension("") +, m_FileType("") +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiInputFileFilterParameter::~MultiInputFileFilterParameter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +MultiInputFileFilterParameter::Pointer MultiInputFileFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const VecString& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, const QString& fileExtension, + const QString& fileType, int groupIndex) +{ + MultiInputFileFilterParameter::Pointer ptr = MultiInputFileFilterParameter::New(); + ptr->setHumanLabel(humanLabel); + ptr->setPropertyName(propertyName); + // ptr->setDefaultValue(defaultValue); + ptr->setCategory(category); + ptr->setFileExtension(fileExtension); + ptr->setFileType(fileType); + ptr->setGroupIndex(groupIndex); + ptr->setSetterCallback(setterCallback); + ptr->setGetterCallback(getterCallback); + + return ptr; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString MultiInputFileFilterParameter::getWidgetType() const +{ + return QString("MultiInputFileWidget"); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiInputFileFilterParameter::readJson(const QJsonObject& json) +{ + QJsonArray jFiles = json[getPropertyName()].toArray(); + if(m_SetterCallback) + { + std::vector files; + files.reserve(jFiles.size()); + for(const auto filePath : jFiles) + { + files.push_back(filePath.toString().toStdString()); + } + m_SetterCallback(files); + } +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void MultiInputFileFilterParameter::writeJson(QJsonObject& json) const +{ + if(m_GetterCallback) + { + std::vector files = m_GetterCallback(); + QJsonArray jFiles; + for(const auto& filePath : files) + { + jFiles.append(QString::fromStdString(filePath)); + } + json[getPropertyName()] = jFiles; + } +} + +// ----------------------------------------------------------------------------- +MultiInputFileFilterParameter::Pointer MultiInputFileFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +MultiInputFileFilterParameter::Pointer MultiInputFileFilterParameter::New() +{ + Pointer sharedPtr(new(MultiInputFileFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString MultiInputFileFilterParameter::getNameOfClass() const +{ + return QString("MultiInputFileFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString MultiInputFileFilterParameter::ClassName() +{ + return QString("MultiInputFileFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void MultiInputFileFilterParameter::setFileExtension(const QString& value) +{ + m_FileExtension = value; +} + +// ----------------------------------------------------------------------------- +QString MultiInputFileFilterParameter::getFileExtension() const +{ + return m_FileExtension; +} + +// ----------------------------------------------------------------------------- +void MultiInputFileFilterParameter::setFileType(const QString& value) +{ + m_FileType = value; +} + +// ----------------------------------------------------------------------------- +QString MultiInputFileFilterParameter::getFileType() const +{ + return m_FileType; +} + +// ----------------------------------------------------------------------------- +void MultiInputFileFilterParameter::setSetterCallback(const MultiInputFileFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +MultiInputFileFilterParameter::SetterCallbackType MultiInputFileFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void MultiInputFileFilterParameter::setGetterCallback(const MultiInputFileFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +MultiInputFileFilterParameter::GetterCallbackType MultiInputFileFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/MultiInputFileFilterParameter.h b/Source/SIMPLib/FilterParameters/MultiInputFileFilterParameter.h new file mode 100644 index 0000000000..e0e9bc05db --- /dev/null +++ b/Source/SIMPLib/FilterParameters/MultiInputFileFilterParameter.h @@ -0,0 +1,212 @@ +/* ============================================================================ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include +#include +#include + +#include +#include + +#include "SIMPLib/FilterParameters/FilterParameter.h" + +/** + * @brief SIMPL_NEW_MULTI_INPUT_FILE_FP This macro is a short-form way of instantiating an instance of + * MultiInputFileFilterParameter. There are 4 required parameters and 3 optional parameter + * that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, + * FilterName (class name), RequirementType, GroupIndex (optional). + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_MULTI_INPUT_FILE_FP("HumanLabel", PropertyName, Category, FilterName, FileExtension, FileType, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional parameters): + * SIMPL_NEW_MULTI_INPUT_FILE_FP("Input File", InputFile, FilterParameter::Category::Parameter, GenericExample, "*.txt", "", 1); + */ +#define SIMPL_NEW_MULTI_INPUT_FILE_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(MultiInputFileFilterParameter, __VA_ARGS__)) + +/** + * @brief The MultiInputFileFilterParameter class is used by filters to instantiate an InputFileWidget. By instantiating an instance of + * this class in a filter's setupFilterParameters() method, an InputFileWidget will appear in the filter's "filter input" section in the DREAM3D GUI. + */ +class SIMPLib_EXPORT MultiInputFileFilterParameter : public FilterParameter +{ + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(MultiInputFileFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(MultiInputFileFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = MultiInputFileFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + using VecString = std::vector; + + /** + * @brief Returns the name of the class for MultiInputFileFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for MultiInputFileFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the MultiInputFileFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_MULTI_INPUT_FILE_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param fileExtension The possible file extensions that this InputFileWidget accepts. + * @param fileType The possible file types that this InputFileWidget accepts. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const VecString& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const QString& fileExtension = QString(""), const QString& fileType = QString(""), int groupIndex = -1); + + ~MultiInputFileFilterParameter() override; + + /** + * @brief Setter property for FileExtension + */ + void setFileExtension(const QString& value); + /** + * @brief Getter property for FileExtension + * @return Value of FileExtension + */ + QString getFileExtension() const; + + /** + * @brief Setter property for FileType + */ + void setFileType(const QString& value); + /** + * @brief Getter property for FileType + * @return Value of FileType + */ + QString getFileType() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const MultiInputFileFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + MultiInputFileFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const MultiInputFileFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + MultiInputFileFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief MultiInputFileFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + MultiInputFileFilterParameter(); + +public: + MultiInputFileFilterParameter(const MultiInputFileFilterParameter&) = delete; // Copy Constructor Not Implemented + MultiInputFileFilterParameter(MultiInputFileFilterParameter&&) = delete; // Move Constructor Not Implemented + MultiInputFileFilterParameter& operator=(const MultiInputFileFilterParameter&) = delete; // Copy Assignment Not Implemented + MultiInputFileFilterParameter& operator=(MultiInputFileFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + QString m_FileExtension = {}; + QString m_FileType = {}; + MultiInputFileFilterParameter::SetterCallbackType m_SetterCallback = {}; + MultiInputFileFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; + +Q_DECLARE_METATYPE(std::vector); diff --git a/Source/SIMPLib/FilterParameters/NumericTypeFilterParameter.cpp b/Source/SIMPLib/FilterParameters/NumericTypeFilterParameter.cpp index 2becb3ec5b..2682d1dc11 100644 --- a/Source/SIMPLib/FilterParameters/NumericTypeFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/NumericTypeFilterParameter.cpp @@ -1,42 +1,40 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "NumericTypeFilterParameter.h" -#include - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -50,8 +48,8 @@ NumericTypeFilterParameter::~NumericTypeFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -NumericTypeFilterParameter::Pointer NumericTypeFilterParameter::New(const QString& humanLabel, const QString& propertyName, SIMPL::NumericTypes::Type defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) +NumericTypeFilterParameter::Pointer NumericTypeFilterParameter::Create(const QString& humanLabel, const QString& propertyName, SIMPL::NumericTypes::Type defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { NumericTypeFilterParameter::Pointer ptr = NumericTypeFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -81,6 +79,10 @@ QString NumericTypeFilterParameter::getWidgetType() const void NumericTypeFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { m_SetterCallback(static_cast(jsonValue.toInt(0.0))); @@ -90,10 +92,59 @@ void NumericTypeFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void NumericTypeFilterParameter::writeJson(QJsonObject& json) +void NumericTypeFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { json[getPropertyName()] = static_cast(m_GetterCallback()); } } + +// ----------------------------------------------------------------------------- +NumericTypeFilterParameter::Pointer NumericTypeFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +NumericTypeFilterParameter::Pointer NumericTypeFilterParameter::New() +{ + Pointer sharedPtr(new(NumericTypeFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString NumericTypeFilterParameter::getNameOfClass() const +{ + return QString("NumericTypeFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString NumericTypeFilterParameter::ClassName() +{ + return QString("NumericTypeFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void NumericTypeFilterParameter::setSetterCallback(const NumericTypeFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +NumericTypeFilterParameter::SetterCallbackType NumericTypeFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void NumericTypeFilterParameter::setGetterCallback(const NumericTypeFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +NumericTypeFilterParameter::GetterCallbackType NumericTypeFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/NumericTypeFilterParameter.h b/Source/SIMPLib/FilterParameters/NumericTypeFilterParameter.h index aa93a2263d..246cda03c9 100644 --- a/Source/SIMPLib/FilterParameters/NumericTypeFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/NumericTypeFilterParameter.h @@ -1,78 +1,102 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" /** -* @brief SIMPL_NEW_NUMERICTYPE_SELECTION_FP This macro is a short-form way of instantiating an instance of -* NumericTypeFilterParameter. There are 6 required parameters and 1 optional parameter -* that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, -* FilterName (class name), PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex (optional). -* -* Therefore, the macro should be written like this (this is a concrete example): -* SIMPL_NEW_SHAPETYPE_SELECTION_FP("HumanLabel", PropertyName, Category, FilterName, -* PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex) -* -* Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): -* SIMPL_NEW_SHAPETYPE_SELECTION_FP("Shape Types", ShapeTypeData, FilterParameter::CreatedArray, EstablishShapeTypes, "PhaseCount", "InputPhaseTypesArrayPath"); -*/ -#define SIMPL_NEW_NUMERICTYPE_FP(...) \ + * @brief SIMPL_NEW_NUMERICTYPE_SELECTION_FP This macro is a short-form way of instantiating an instance of + * NumericTypeFilterParameter. There are 6 required parameters and 1 optional parameter + * that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, + * FilterName (class name), PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex (optional). + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_NUMERICTYPE_FP("HumanLabel", PropertyName, Category, FilterName, + * PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): + * SIMPL_NEW_NUMERICTYPE_FP("Shape Types", ShapeTypeData, FilterParameter::Category::CreatedArray, EstablishShapeTypes, "PhaseCount", "InputPhaseTypesArrayPath"); + */ +#define SIMPL_NEW_NUMERICTYPE_FP(...) \ SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(NumericTypeFilterParameter, __VA_ARGS__)) /** -* @brief The NumericTypeFilterParameter class is used by filters to instantiate an ShapeTypeSelectionWidget. By instantiating an instance of -* this class in a filter's setupFilterParameters() method, a ShapeTypeSelectionWidget will appear in the filter's "filter input" section in the DREAM3D GUI. -*/ + * @brief The NumericTypeFilterParameter class is used by filters to instantiate an ShapeTypeSelectionWidget. By instantiating an instance of + * this class in a filter's setupFilterParameters() method, a ShapeTypeSelectionWidget will appear in the filter's "filter input" section in the DREAM3D GUI. + */ class SIMPLib_EXPORT NumericTypeFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(NumericTypeFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(NumericTypeFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(NumericTypeFilterParameter) - SIMPL_STATIC_NEW_MACRO(NumericTypeFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(NumericTypeFilterParameter, FilterParameter) + using Self = NumericTypeFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for NumericTypeFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for NumericTypeFilterParameter + */ + static QString ClassName(); typedef std::function SetterCallbackType; typedef std::function GetterCallbackType; /** * @brief New This function instantiates an instance of the NumericTypeFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_SHAPETYPE_SELECTION_FP(...) macro at the top of this file. + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_NUMERICTYPE_FP(...) macro at the top of this file. * @param humanLabel The name that the users of DREAM.3D see for this filter parameter * @param propertyName The internal property name for this filter parameter. @@ -88,55 +112,74 @@ class SIMPLib_EXPORT NumericTypeFilterParameter : public FilterParameter * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& propertyName, SIMPL::NumericTypes::Type defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex = -1); + static Pointer Create(const QString& humanLabel, const QString& propertyName, SIMPL::NumericTypes::Type defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); ~NumericTypeFilterParameter() override; /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ QString getWidgetType() const override; /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ void readJson(const QJsonObject& json) override; /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @return The SetterCallback - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const NumericTypeFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + NumericTypeFilterParameter::SetterCallbackType getSetterCallback() const; /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const NumericTypeFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + NumericTypeFilterParameter::GetterCallbackType getGetterCallback() const; protected: /** - * @brief NumericTypeFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + * @brief NumericTypeFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ NumericTypeFilterParameter(); public: - NumericTypeFilterParameter(const NumericTypeFilterParameter&) = delete; // Copy Constructor Not Implemented - NumericTypeFilterParameter(NumericTypeFilterParameter&&) = delete; // Move Constructor Not Implemented + NumericTypeFilterParameter(const NumericTypeFilterParameter&) = delete; // Copy Constructor Not Implemented + NumericTypeFilterParameter(NumericTypeFilterParameter&&) = delete; // Move Constructor Not Implemented NumericTypeFilterParameter& operator=(const NumericTypeFilterParameter&) = delete; // Copy Assignment Not Implemented NumericTypeFilterParameter& operator=(NumericTypeFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +private: + NumericTypeFilterParameter::SetterCallbackType m_SetterCallback = {}; + NumericTypeFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/OutputFileFilterParameter.cpp b/Source/SIMPLib/FilterParameters/OutputFileFilterParameter.cpp index 05a06e2a98..7af5244869 100644 --- a/Source/SIMPLib/FilterParameters/OutputFileFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/OutputFileFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "OutputFileFilterParameter.h" @@ -48,9 +48,9 @@ OutputFileFilterParameter::~OutputFileFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OutputFileFilterParameter::Pointer OutputFileFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, const QString& fileExtension, const QString& fileType, - int groupIndex) +OutputFileFilterParameter::Pointer OutputFileFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, const QString& fileExtension, + const QString& fileType, int groupIndex) { OutputFileFilterParameter::Pointer ptr = OutputFileFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -75,24 +75,50 @@ QString OutputFileFilterParameter::getWidgetType() const } // ----------------------------------------------------------------------------- -// +OutputFileFilterParameter::Pointer OutputFileFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + // ----------------------------------------------------------------------------- -void OutputFileFilterParameter::readJson(const QJsonObject& json) +OutputFileFilterParameter::Pointer OutputFileFilterParameter::New() { - QJsonValue jsonValue = json[getPropertyName()]; - if(!jsonValue.isUndefined() && m_SetterCallback) - { - m_SetterCallback(jsonValue.toString("")); - } + Pointer sharedPtr(new(OutputFileFilterParameter)); + return sharedPtr; } // ----------------------------------------------------------------------------- -// +QString OutputFileFilterParameter::getNameOfClass() const +{ + return QString("OutputFileFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString OutputFileFilterParameter::ClassName() +{ + return QString("OutputFileFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void OutputFileFilterParameter::setFileExtension(const QString& value) +{ + m_FileExtension = value; +} + +// ----------------------------------------------------------------------------- +QString OutputFileFilterParameter::getFileExtension() const +{ + return m_FileExtension; +} + +// ----------------------------------------------------------------------------- +void OutputFileFilterParameter::setFileType(const QString& value) +{ + m_FileType = value; +} + // ----------------------------------------------------------------------------- -void OutputFileFilterParameter::writeJson(QJsonObject& json) +QString OutputFileFilterParameter::getFileType() const { - if(m_GetterCallback) - { - json[getPropertyName()] = m_GetterCallback(); - } + return m_FileType; } diff --git a/Source/SIMPLib/FilterParameters/OutputFileFilterParameter.h b/Source/SIMPLib/FilterParameters/OutputFileFilterParameter.h old mode 100755 new mode 100644 index a9276316a9..7d878be4ac --- a/Source/SIMPLib/FilterParameters/OutputFileFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/OutputFileFilterParameter.h @@ -1,43 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" +#include "SIMPLib/FilterParameters/AbstractIOFilterParameter.h" /** * @brief SIMPL_NEW_OUTPUT_FILE_FP This macro is a short-form way of instantiating an instance of @@ -49,28 +51,47 @@ * SIMPL_NEW_OUTPUT_FILE_FP("HumanLabel", PropertyName, Category, FilterName, FileExtension, FileType, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional parameters): - * SIMPL_NEW_OUTPUT_FILE_FP("Output File", OutputFile, FilterParameter::Parameter, GenericExample); + * SIMPL_NEW_OUTPUT_FILE_FP("Output File", OutputFile, FilterParameter::Category::Parameter, GenericExample); */ -#define SIMPL_NEW_OUTPUT_FILE_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (OutputFileFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_OUTPUT_FILE_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(OutputFileFilterParameter, __VA_ARGS__)) /** * @brief The OutputFileFilterParameter class is used by filters to instantiate an OutputFileWidget. By instantiating an instance of * this class in a filter's setupFilterParameters() method, a OutputFileWidget will appear in the filter's "filter input" section in the DREAM3D GUI. */ -class SIMPLib_EXPORT OutputFileFilterParameter : public FilterParameter +class SIMPLib_EXPORT OutputFileFilterParameter : public AbstractIOFilterParameter { - public: - SIMPL_SHARED_POINTERS(OutputFileFilterParameter) - SIMPL_STATIC_NEW_MACRO(OutputFileFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(OutputFileFilterParameter, FilterParameter) + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(OutputFileFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(OutputFileFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = OutputFileFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for OutputFileFilterParameter + */ + QString getNameOfClass() const override; - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; + /** + * @brief Returns the name of the class for OutputFileFilterParameter + */ + static QString ClassName(); - /** + /** * @brief New This function instantiates an instance of the OutputFileFilterParameter. Although this function is available to be used, * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_OUTPUT_FILE_FP(...) macro at the top of this file. @@ -80,71 +101,62 @@ class SIMPLib_EXPORT OutputFileFilterParameter : public FilterParameter * @param category The category for the filter parameter in the DREAM.3D user interface. There * are three categories: Parameter, Required Arrays, and Created Arrays. * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. + * that this FilterParameter subclass represents. * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param fileExtension The possible file extensions that this OutputFileWidget accepts. - * @param fileType The possible file types that this OutputFileWidget accepts. + * that this FilterParameter subclass represents. + * @param fileExtension The possible file extensions that this OutputFileWidget accepts. + * @param fileType The possible file types that this OutputFileWidget accepts. * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const QString& fileExtension = QString(""), - const QString& fileType = QString(""), - int groupIndex = -1); - - ~OutputFileFilterParameter() override; - - SIMPL_INSTANCE_STRING_PROPERTY(FileExtension) - SIMPL_INSTANCE_STRING_PROPERTY(FileType) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief OutputFileFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - OutputFileFilterParameter(); - - public: - OutputFileFilterParameter(const OutputFileFilterParameter&) = delete; // Copy Constructor Not Implemented - OutputFileFilterParameter(OutputFileFilterParameter&&) = delete; // Move Constructor Not Implemented - OutputFileFilterParameter& operator=(const OutputFileFilterParameter&) = delete; // Copy Assignment Not Implemented - OutputFileFilterParameter& operator=(OutputFileFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const QString& fileExtension = QString(""), const QString& fileType = QString(""), int groupIndex = -1); + + ~OutputFileFilterParameter() override; + + /** + * @brief Setter property for FileExtension + */ + void setFileExtension(const QString& value); + /** + * @brief Getter property for FileExtension + * @return Value of FileExtension + */ + QString getFileExtension() const; + + /** + * @brief Setter property for FileType + */ + void setFileType(const QString& value); + + /** + * @brief Getter property for FileType + * @return Value of FileType + */ + QString getFileType() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + +protected: + /** + * @brief OutputFileFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + OutputFileFilterParameter(); + +public: + OutputFileFilterParameter(const OutputFileFilterParameter&) = delete; // Copy Constructor Not Implemented + OutputFileFilterParameter(OutputFileFilterParameter&&) = delete; // Move Constructor Not Implemented + OutputFileFilterParameter& operator=(const OutputFileFilterParameter&) = delete; // Copy Assignment Not Implemented + OutputFileFilterParameter& operator=(OutputFileFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + QString m_FileExtension = {}; + QString m_FileType = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/OutputPathFilterParameter.cpp b/Source/SIMPLib/FilterParameters/OutputPathFilterParameter.cpp index f9822cc712..56aa16c6b5 100644 --- a/Source/SIMPLib/FilterParameters/OutputPathFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/OutputPathFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "OutputPathFilterParameter.h" @@ -48,17 +48,14 @@ OutputPathFilterParameter::~OutputPathFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OutputPathFilterParameter::Pointer OutputPathFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, const QString& fileExtension, const QString& fileType, - int groupIndex) +OutputPathFilterParameter::Pointer OutputPathFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { OutputPathFilterParameter::Pointer ptr = OutputPathFilterParameter::New(); ptr->setHumanLabel(humanLabel); ptr->setPropertyName(propertyName); ptr->setDefaultValue(defaultValue); ptr->setCategory(category); - ptr->setFileExtension(fileExtension); - ptr->setFileType(fileType); ptr->setGroupIndex(groupIndex); ptr->setSetterCallback(setterCallback); ptr->setGetterCallback(getterCallback); @@ -75,24 +72,26 @@ QString OutputPathFilterParameter::getWidgetType() const } // ----------------------------------------------------------------------------- -// +OutputPathFilterParameter::Pointer OutputPathFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + // ----------------------------------------------------------------------------- -void OutputPathFilterParameter::readJson(const QJsonObject& json) +OutputPathFilterParameter::Pointer OutputPathFilterParameter::New() { - QJsonValue jsonValue = json[getPropertyName()]; - if(!jsonValue.isUndefined() && m_SetterCallback) - { - m_SetterCallback(jsonValue.toString("")); - } + Pointer sharedPtr(new(OutputPathFilterParameter)); + return sharedPtr; } // ----------------------------------------------------------------------------- -// +QString OutputPathFilterParameter::getNameOfClass() const +{ + return QString("OutputPathFilterParameter"); +} + // ----------------------------------------------------------------------------- -void OutputPathFilterParameter::writeJson(QJsonObject& json) +QString OutputPathFilterParameter::ClassName() { - if(m_GetterCallback) - { - json[getPropertyName()] = m_GetterCallback(); - } + return QString("OutputPathFilterParameter"); } diff --git a/Source/SIMPLib/FilterParameters/OutputPathFilterParameter.h b/Source/SIMPLib/FilterParameters/OutputPathFilterParameter.h old mode 100755 new mode 100644 index a63c3b0806..6c14d6131f --- a/Source/SIMPLib/FilterParameters/OutputPathFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/OutputPathFilterParameter.h @@ -1,43 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" +#include "SIMPLib/FilterParameters/AbstractIOFilterParameter.h" /** * @brief SIMPL_NEW_OUTPUT_PATH_FP This macro is a short-form way of instantiating an instance of @@ -49,101 +51,86 @@ * SIMPL_NEW_OUTPUT_PATH_FP("HumanLabel", PropertyName, Category, FilterName, FileExtension, FileType, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional parameters): - * SIMPL_NEW_OUTPUT_PATH_FP("Output Path", OutputPath, FilterParameter::Parameter, GenericExample); + * SIMPL_NEW_OUTPUT_PATH_FP("Output Path", OutputPath, FilterParameter::Category::Parameter, GenericExample); */ -#define SIMPL_NEW_OUTPUT_PATH_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (OutputPathFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_OUTPUT_PATH_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(OutputPathFilterParameter, __VA_ARGS__)) /** * @brief The OutputPathFilterParameter class is used by filters to instantiate an OutputPathWidget. By instantiating an instance of * this class in a filter's setupFilterParameters() method, a OutputPathWidget will appear in the filter's "filter input" section in the DREAM3D GUI. */ -class SIMPLib_EXPORT OutputPathFilterParameter : public FilterParameter +class SIMPLib_EXPORT OutputPathFilterParameter : public AbstractIOFilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(OutputPathFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(OutputPathFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(OutputPathFilterParameter) - SIMPL_STATIC_NEW_MACRO(OutputPathFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(OutputPathFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the OutputPathFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_OUTPUT_PATH_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param fileExtension The possible file extensions that this OutputPathWidget accepts. - * @param fileType The possible file types that this OutputPathWidget accepts. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const QString& fileExtension = QString(""), - const QString& fileType = QString(""), - int groupIndex = -1); - - ~OutputPathFilterParameter() override; - - SIMPL_INSTANCE_STRING_PROPERTY(FileExtension) - SIMPL_INSTANCE_STRING_PROPERTY(FileType) - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief OutputPathFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + using Self = OutputPathFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for OutputPathFilterParameter + */ + QString getNameOfClass() const override; + + /** + * @brief Returns the name of the class for OutputPathFilterParameter + */ + static QString ClassName(); + + /** + * @brief New This function instantiates an instance of the OutputPathFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_OUTPUT_PATH_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param fileExtension The possible file extensions that this OutputPathWidget accepts. + * @param fileType The possible file types that this OutputPathWidget accepts. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~OutputPathFilterParameter() override; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + +protected: + /** + * @brief OutputPathFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ OutputPathFilterParameter(); public: - OutputPathFilterParameter(const OutputPathFilterParameter&) = delete; // Copy Constructor Not Implemented - OutputPathFilterParameter(OutputPathFilterParameter&&) = delete; // Move Constructor Not Implemented + OutputPathFilterParameter(const OutputPathFilterParameter&) = delete; // Copy Constructor Not Implemented + OutputPathFilterParameter(OutputPathFilterParameter&&) = delete; // Move Constructor Not Implemented OutputPathFilterParameter& operator=(const OutputPathFilterParameter&) = delete; // Copy Assignment Not Implemented OutputPathFilterParameter& operator=(OutputPathFilterParameter&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/FilterParameters/ParagraphFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ParagraphFilterParameter.cpp index f5712ff6da..f1c8acd250 100644 --- a/Source/SIMPLib/FilterParameters/ParagraphFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/ParagraphFilterParameter.cpp @@ -1,35 +1,35 @@ /* ============================================================================ -* Copyright (c) 2017 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the following contracts: -* United States Air Force Prime Contract FA8650-15-D-5231 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2017 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ParagraphFilterParameter.h" @@ -46,8 +46,8 @@ ParagraphFilterParameter::~ParagraphFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ParagraphFilterParameter::Pointer ParagraphFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, bool allowPreflight, int groupIndex) +ParagraphFilterParameter::Pointer ParagraphFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, bool allowPreflight, int groupIndex) { ParagraphFilterParameter::Pointer ptr = ParagraphFilterParameter::New(); @@ -77,6 +77,10 @@ QString ParagraphFilterParameter::getWidgetType() const void ParagraphFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { m_SetterCallback(jsonValue.toString("")); @@ -86,10 +90,71 @@ void ParagraphFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ParagraphFilterParameter::writeJson(QJsonObject& json) +void ParagraphFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { json[getPropertyName()] = m_GetterCallback(); } } + +// ----------------------------------------------------------------------------- +ParagraphFilterParameter::Pointer ParagraphFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +ParagraphFilterParameter::Pointer ParagraphFilterParameter::New() +{ + Pointer sharedPtr(new(ParagraphFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString ParagraphFilterParameter::getNameOfClass() const +{ + return QString("ParagraphFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString ParagraphFilterParameter::ClassName() +{ + return QString("ParagraphFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void ParagraphFilterParameter::setSetterCallback(const ParagraphFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ParagraphFilterParameter::SetterCallbackType ParagraphFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void ParagraphFilterParameter::setGetterCallback(const ParagraphFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ParagraphFilterParameter::GetterCallbackType ParagraphFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} + +// ----------------------------------------------------------------------------- +void ParagraphFilterParameter::setAllowPreflight(bool value) +{ + m_AllowPreflight = value; +} + +// ----------------------------------------------------------------------------- +bool ParagraphFilterParameter::getAllowPreflight() const +{ + return m_AllowPreflight; +} diff --git a/Source/SIMPLib/FilterParameters/ParagraphFilterParameter.h b/Source/SIMPLib/FilterParameters/ParagraphFilterParameter.h old mode 100755 new mode 100644 index e5f572cf2e..4f57f5a725 --- a/Source/SIMPLib/FilterParameters/ParagraphFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ParagraphFilterParameter.h @@ -1,38 +1,40 @@ /* ============================================================================ -* Copyright (c) 2017 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the following contracts: -* United States Air Force Prime Contract FA8650-15-D-5231 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2017 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" @@ -47,7 +49,7 @@ * SIMPL_NEW_PARAGRAPH_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): - * SIMPL_NEW_PARAGRAPH_FP("STL Output Prefix", StlFilePrefix, FilterParameter::Parameter, GenericExample); + * SIMPL_NEW_PARAGRAPH_FP("STL Output Prefix", StlFilePrefix, FilterParameter::Category::Parameter, GenericExample); */ #define SIMPL_NEW_PARAGRAPH_FP(...) \ SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(ParagraphFilterParameter, __VA_ARGS__)) @@ -58,10 +60,32 @@ */ class SIMPLib_EXPORT ParagraphFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(ParagraphFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(ParagraphFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(ParagraphFilterParameter) - SIMPL_STATIC_NEW_MACRO(ParagraphFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ParagraphFilterParameter, FilterParameter) + using Self = ParagraphFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for ParagraphFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ParagraphFilterParameter + */ + static QString ClassName(); typedef std::function SetterCallbackType; typedef std::function GetterCallbackType; @@ -82,16 +106,16 @@ class SIMPLib_EXPORT ParagraphFilterParameter : public FilterParameter * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, bool allowPreflight = true, - int groupIndex = -1); + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, bool allowPreflight = true, int groupIndex = -1); ~ParagraphFilterParameter() override; /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ QString getWidgetType() const override; /** @@ -104,23 +128,47 @@ class SIMPLib_EXPORT ParagraphFilterParameter : public FilterParameter * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. * @param json The QJsonObject that the filter parameter writes to. */ - void writeJson(QJsonObject& json) override; + void writeJson(QJsonObject& json) const override; /** - * @brief SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) + * @brief SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const ParagraphFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + ParagraphFilterParameter::SetterCallbackType getSetterCallback() const; /** - * @brief GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + * @brief GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const ParagraphFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + ParagraphFilterParameter::GetterCallbackType getGetterCallback() const; - SIMPL_INSTANCE_PROPERTY(bool, AllowPreflight) + /** + * @brief Setter property for AllowPreflight + */ + void setAllowPreflight(bool value); + /** + * @brief Getter property for AllowPreflight + * @return Value of AllowPreflight + */ + bool getAllowPreflight() const; protected: /** @@ -130,9 +178,13 @@ class SIMPLib_EXPORT ParagraphFilterParameter : public FilterParameter ParagraphFilterParameter(); public: - ParagraphFilterParameter(const ParagraphFilterParameter&) = delete; // Copy Constructor Not Implemented - ParagraphFilterParameter(ParagraphFilterParameter&&) = delete; // Move Constructor Not Implemented + ParagraphFilterParameter(const ParagraphFilterParameter&) = delete; // Copy Constructor Not Implemented + ParagraphFilterParameter(ParagraphFilterParameter&&) = delete; // Move Constructor Not Implemented ParagraphFilterParameter& operator=(const ParagraphFilterParameter&) = delete; // Copy Assignment Not Implemented ParagraphFilterParameter& operator=(ParagraphFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +private: + ParagraphFilterParameter::SetterCallbackType m_SetterCallback = {}; + ParagraphFilterParameter::GetterCallbackType m_GetterCallback = {}; + bool m_AllowPreflight = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.cpp index d55da38992..f6bb644861 100644 --- a/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.cpp @@ -1,42 +1,44 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "PhaseTypeSelectionFilterParameter.h" #include +#include "SIMPLib/Filtering/AbstractFilter.h" + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -50,10 +52,10 @@ PhaseTypeSelectionFilterParameter::~PhaseTypeSelectionFilterParameter() = defaul // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PhaseTypeSelectionFilterParameter::Pointer PhaseTypeSelectionFilterParameter::New(const QString& humanLabel, const QString& phaseTypeDataProperty, const DataArrayPath attributeMatrixDefault, - Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const QString& PhaseTypesArrayName, const QString& phaseTypeCountProperty, const QString& attributeMatrixProperty, - const QStringList phaseListChoices, int groupIndex) +PhaseTypeSelectionFilterParameter::Pointer PhaseTypeSelectionFilterParameter::Create(const QString& humanLabel, const QString& phaseTypeDataProperty, const DataArrayPath& attributeMatrixDefault, + Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + const QString& PhaseTypesArrayName, const QString& phaseTypeCountProperty, const QString& attributeMatrixProperty, + const std::vector& phaseListChoices, int groupIndex) { PhaseTypeSelectionFilterParameter::Pointer ptr = PhaseTypeSelectionFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -85,6 +87,10 @@ QString PhaseTypeSelectionFilterParameter::getWidgetType() const void PhaseTypeSelectionFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonArray jsonArray = jsonValue.toArray(); @@ -100,7 +106,7 @@ void PhaseTypeSelectionFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void PhaseTypeSelectionFilterParameter::writeJson(QJsonObject& json) +void PhaseTypeSelectionFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { @@ -115,3 +121,154 @@ void PhaseTypeSelectionFilterParameter::writeJson(QJsonObject& json) json[getPropertyName()] = jsonArray; } } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void PhaseTypeSelectionFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) +{ + QVariant var = filter->property(qPrintable(getAttributeMatrixPathProperty())); + if(var.isValid() && var.canConvert()) + { + DataArrayPath path = var.value(); + if(path.updatePath(renamePath)) + { + var.setValue(path); + filter->setProperty(qPrintable(getAttributeMatrixPathProperty()), var); + Q_EMIT filter->dataArrayPathUpdated(getAttributeMatrixPathProperty(), renamePath); + } + } +} + +// ----------------------------------------------------------------------------- +PhaseTypeSelectionFilterParameter::Pointer PhaseTypeSelectionFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +PhaseTypeSelectionFilterParameter::Pointer PhaseTypeSelectionFilterParameter::New() +{ + Pointer sharedPtr(new(PhaseTypeSelectionFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString PhaseTypeSelectionFilterParameter::getNameOfClass() const +{ + return QString("PhaseTypeSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString PhaseTypeSelectionFilterParameter::ClassName() +{ + return QString("PhaseTypeSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void PhaseTypeSelectionFilterParameter::setPhaseTypeCountProperty(const QString& value) +{ + m_PhaseTypeCountProperty = value; +} + +// ----------------------------------------------------------------------------- +QString PhaseTypeSelectionFilterParameter::getPhaseTypeCountProperty() const +{ + return m_PhaseTypeCountProperty; +} + +// ----------------------------------------------------------------------------- +void PhaseTypeSelectionFilterParameter::setPhaseTypeDataProperty(const QString& value) +{ + m_PhaseTypeDataProperty = value; +} + +// ----------------------------------------------------------------------------- +QString PhaseTypeSelectionFilterParameter::getPhaseTypeDataProperty() const +{ + return m_PhaseTypeDataProperty; +} + +// ----------------------------------------------------------------------------- +void PhaseTypeSelectionFilterParameter::setAttributeMatrixPathProperty(const QString& value) +{ + m_AttributeMatrixPathProperty = value; +} + +// ----------------------------------------------------------------------------- +QString PhaseTypeSelectionFilterParameter::getAttributeMatrixPathProperty() const +{ + return m_AttributeMatrixPathProperty; +} + +// ----------------------------------------------------------------------------- +void PhaseTypeSelectionFilterParameter::setAttributeMatrixPathDefault(const DataArrayPath& value) +{ + m_AttributeMatrixPathDefault = value; +} + +// ----------------------------------------------------------------------------- +DataArrayPath PhaseTypeSelectionFilterParameter::getAttributeMatrixPathDefault() const +{ + return m_AttributeMatrixPathDefault; +} + +// ----------------------------------------------------------------------------- +void PhaseTypeSelectionFilterParameter::setPhaseListChoices(const std::vector& value) +{ + m_PhaseListChoices = value; +} + +// ----------------------------------------------------------------------------- +std::vector PhaseTypeSelectionFilterParameter::getPhaseListChoices() const +{ + return m_PhaseListChoices; +} + +// ----------------------------------------------------------------------------- +void PhaseTypeSelectionFilterParameter::setDefaultGeometryTypes(const IGeometry::Types& value) +{ + m_DefaultGeometryTypes = value; +} + +// ----------------------------------------------------------------------------- +IGeometry::Types PhaseTypeSelectionFilterParameter::getDefaultGeometryTypes() const +{ + return m_DefaultGeometryTypes; +} + +// ----------------------------------------------------------------------------- +void PhaseTypeSelectionFilterParameter::setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value) +{ + m_DefaultAttributeMatrixTypes = value; +} + +// ----------------------------------------------------------------------------- +AttributeMatrix::Types PhaseTypeSelectionFilterParameter::getDefaultAttributeMatrixTypes() const +{ + return m_DefaultAttributeMatrixTypes; +} + +// ----------------------------------------------------------------------------- +void PhaseTypeSelectionFilterParameter::setSetterCallback(const PhaseTypeSelectionFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +PhaseTypeSelectionFilterParameter::SetterCallbackType PhaseTypeSelectionFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void PhaseTypeSelectionFilterParameter::setGetterCallback(const PhaseTypeSelectionFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +PhaseTypeSelectionFilterParameter::GetterCallbackType PhaseTypeSelectionFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.h old mode 100755 new mode 100644 index 50f037641f..62e1e4d9c3 --- a/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/PhaseTypeSelectionFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/Common/PhaseType.h" @@ -46,24 +48,46 @@ // FP: Documentation incomplete because there isn't currently a way to instantiate this filter parameter // in one line. /** -* @brief SIMPL_NEW_PHASETYPE_SELECTION_FP This macro is a short-form way of instantiating an instance of -* PhaseTypeSelectionFilterParameter. There are 8 required parameters and 1 optional parameter -* that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, -* FilterName (class name), PhaseTypesArrayName, PhaseTypeCountProperty, AttributeMatrixProperty, GroupIndex (optional). -*/ + * @brief SIMPL_NEW_PHASETYPE_SELECTION_FP This macro is a short-form way of instantiating an instance of + * PhaseTypeSelectionFilterParameter. There are 8 required parameters and 1 optional parameter + * that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, + * FilterName (class name), PhaseTypesArrayName, PhaseTypeCountProperty, AttributeMatrixProperty, GroupIndex (optional). + */ #define SIMPL_NEW_PHASETYPE_SELECTION_FP(...) \ SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(PhaseTypeSelectionFilterParameter, __VA_ARGS__)) /** -* @brief The PhaseTypeSelectionFilterParameter class is used by filters to instantiate an PhaseTypeSelectionWidget. By instantiating an instance of -* this class in a filter's setupFilterParameters() method, a PhaseTypeSelectionWidget will appear in the filter's "filter input" section in the DREAM3D GUI. -*/ + * @brief The PhaseTypeSelectionFilterParameter class is used by filters to instantiate an PhaseTypeSelectionWidget. By instantiating an instance of + * this class in a filter's setupFilterParameters() method, a PhaseTypeSelectionWidget will appear in the filter's "filter input" section in the DREAM3D GUI. + */ class SIMPLib_EXPORT PhaseTypeSelectionFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off +// PYB11_BEGIN_BINDINGS(PhaseTypeSelectionFilterParameter SUPERCLASS FilterParameter) +// PYB11_SHARED_POINTERS(PhaseTypeSelectionFilterParameter) +// PYB11_STATIC_CREATION(Create) +// PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(PhaseTypeSelectionFilterParameter) - SIMPL_STATIC_NEW_MACRO(PhaseTypeSelectionFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(PhaseTypeSelectionFilterParameter, FilterParameter) + using Self = PhaseTypeSelectionFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for PhaseTypeSelectionFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for PhaseTypeSelectionFilterParameter + */ + static QString ClassName(); typedef std::function SetterCallbackType; typedef std::function GetterCallbackType; @@ -88,65 +112,157 @@ class SIMPLib_EXPORT PhaseTypeSelectionFilterParameter : public FilterParameter * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& phaseTypeDataProperty, const DataArrayPath attributeMatrixDefault, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, const QString& PhaseTypesArrayName, const QString& phaseTypeCountProperty, const QString& attributeMatrixProperty, - const QStringList phaseListChoices, int groupIndex = -1); + static Pointer Create(const QString& humanLabel, const QString& phaseTypeDataProperty, const DataArrayPath& attributeMatrixDefault, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const QString& PhaseTypesArrayName, const QString& phaseTypeCountProperty, const QString& attributeMatrixProperty, + const std::vector& phaseListChoices, int groupIndex = -1); ~PhaseTypeSelectionFilterParameter() override; - SIMPL_INSTANCE_PROPERTY(QString, PhaseTypeCountProperty) - SIMPL_INSTANCE_PROPERTY(QString, PhaseTypeDataProperty) - SIMPL_INSTANCE_PROPERTY(QString, AttributeMatrixPathProperty) - SIMPL_INSTANCE_PROPERTY(DataArrayPath, AttributeMatrixPathDefault) - SIMPL_INSTANCE_PROPERTY(QStringList, PhaseListChoices) + /** + * @brief Setter property for PhaseTypeCountProperty + */ + void setPhaseTypeCountProperty(const QString& value); + /** + * @brief Getter property for PhaseTypeCountProperty + * @return Value of PhaseTypeCountProperty + */ + QString getPhaseTypeCountProperty() const; /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ + * @brief Setter property for PhaseTypeDataProperty + */ + void setPhaseTypeDataProperty(const QString& value); + /** + * @brief Getter property for PhaseTypeDataProperty + * @return Value of PhaseTypeDataProperty + */ + QString getPhaseTypeDataProperty() const; + + /** + * @brief Setter property for AttributeMatrixPathProperty + */ + void setAttributeMatrixPathProperty(const QString& value); + /** + * @brief Getter property for AttributeMatrixPathProperty + * @return Value of AttributeMatrixPathProperty + */ + QString getAttributeMatrixPathProperty() const; + + /** + * @brief Setter property for AttributeMatrixPathDefault + */ + void setAttributeMatrixPathDefault(const DataArrayPath& value); + /** + * @brief Getter property for AttributeMatrixPathDefault + * @return Value of AttributeMatrixPathDefault + */ + DataArrayPath getAttributeMatrixPathDefault() const; + + /** + * @brief Setter property for PhaseListChoices + */ + void setPhaseListChoices(const std::vector& value); + /** + * @brief Getter property for PhaseListChoices + * @return Value of PhaseListChoices + */ + std::vector getPhaseListChoices() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ QString getWidgetType() const override; /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ void readJson(const QJsonObject& json) override; /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; - SIMPL_INSTANCE_PROPERTY(IGeometry::Types, DefaultGeometryTypes) - SIMPL_INSTANCE_PROPERTY(AttributeMatrix::Types, DefaultAttributeMatrixTypes) + /** + * @brief Setter property for DefaultGeometryTypes + */ + void setDefaultGeometryTypes(const IGeometry::Types& value); + /** + * @brief Getter property for DefaultGeometryTypes + * @return Value of DefaultGeometryTypes + */ + IGeometry::Types getDefaultGeometryTypes() const; /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @return The SetterCallback - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) + * @brief Setter property for DefaultAttributeMatrixTypes + */ + void setDefaultAttributeMatrixTypes(const AttributeMatrix::Types& value); + /** + * @brief Getter property for DefaultAttributeMatrixTypes + * @return Value of DefaultAttributeMatrixTypes + */ + AttributeMatrix::Types getDefaultAttributeMatrixTypes() const; /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const PhaseTypeSelectionFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + PhaseTypeSelectionFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const PhaseTypeSelectionFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + PhaseTypeSelectionFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief Handle DataArrayPath changes if necessary + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; protected: /** - * @brief PhaseTypeSelectionFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + * @brief PhaseTypeSelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ PhaseTypeSelectionFilterParameter(); public: - PhaseTypeSelectionFilterParameter(const PhaseTypeSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented - PhaseTypeSelectionFilterParameter(PhaseTypeSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + PhaseTypeSelectionFilterParameter(const PhaseTypeSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + PhaseTypeSelectionFilterParameter(PhaseTypeSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented PhaseTypeSelectionFilterParameter& operator=(const PhaseTypeSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented PhaseTypeSelectionFilterParameter& operator=(PhaseTypeSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +private: + QString m_PhaseTypeCountProperty = {}; + QString m_PhaseTypeDataProperty = {}; + QString m_AttributeMatrixPathProperty = {}; + DataArrayPath m_AttributeMatrixPathDefault = {}; + std::vector m_PhaseListChoices = {}; + IGeometry::Types m_DefaultGeometryTypes = {}; + AttributeMatrix::Types m_DefaultAttributeMatrixTypes = {}; + PhaseTypeSelectionFilterParameter::SetterCallbackType m_SetterCallback = {}; + PhaseTypeSelectionFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/PreflightUpdatedValueFilterParameter.cpp b/Source/SIMPLib/FilterParameters/PreflightUpdatedValueFilterParameter.cpp index f900b4f770..d8b641065e 100644 --- a/Source/SIMPLib/FilterParameters/PreflightUpdatedValueFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/PreflightUpdatedValueFilterParameter.cpp @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "PreflightUpdatedValueFilterParameter.h" +#include + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -48,8 +50,8 @@ PreflightUpdatedValueFilterParameter::~PreflightUpdatedValueFilterParameter() = // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -PreflightUpdatedValueFilterParameter::Pointer PreflightUpdatedValueFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, - GetterCallbackType getterCallback, int groupIndex) +PreflightUpdatedValueFilterParameter::Pointer PreflightUpdatedValueFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, + GetterCallbackType getterCallback, int groupIndex) { PreflightUpdatedValueFilterParameter::Pointer ptr = PreflightUpdatedValueFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -71,12 +73,52 @@ QString PreflightUpdatedValueFilterParameter::getWidgetType() const } // ----------------------------------------------------------------------------- -// +void PreflightUpdatedValueFilterParameter::readJson(const QJsonObject& json) +{ + // We don't want to read this value. Reading does no good since it is a calculated value + std::ignore = json; +} + +// ----------------------------------------------------------------------------- +void PreflightUpdatedValueFilterParameter::writeJson(QJsonObject& json) const +{ + // We don't want to write this value. It serves no purpose saving the value + std::ignore = json; +} + +// ----------------------------------------------------------------------------- +PreflightUpdatedValueFilterParameter::Pointer PreflightUpdatedValueFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +PreflightUpdatedValueFilterParameter::Pointer PreflightUpdatedValueFilterParameter::New() +{ + Pointer sharedPtr(new(PreflightUpdatedValueFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString PreflightUpdatedValueFilterParameter::getNameOfClass() const +{ + return QString("PreflightUpdatedValueFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString PreflightUpdatedValueFilterParameter::ClassName() +{ + return QString("PreflightUpdatedValueFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void PreflightUpdatedValueFilterParameter::setGetterCallback(const PreflightUpdatedValueFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + // ----------------------------------------------------------------------------- -void PreflightUpdatedValueFilterParameter::writeJson(QJsonObject& json) +PreflightUpdatedValueFilterParameter::GetterCallbackType PreflightUpdatedValueFilterParameter::getGetterCallback() const { - if(m_GetterCallback) - { - json[getPropertyName()] = m_GetterCallback(); - } + return m_GetterCallback; } diff --git a/Source/SIMPLib/FilterParameters/PreflightUpdatedValueFilterParameter.h b/Source/SIMPLib/FilterParameters/PreflightUpdatedValueFilterParameter.h old mode 100755 new mode 100644 index 51426ccf89..ba0a20359e --- a/Source/SIMPLib/FilterParameters/PreflightUpdatedValueFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/PreflightUpdatedValueFilterParameter.h @@ -1,41 +1,41 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include #include "SIMPLib/FilterParameters/FilterParameter.h" @@ -49,12 +49,10 @@ * SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): - * SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP("Estimated Primary Features", EstimatedPrimaryFeatures, FilterParameter::Parameter, GenericExample); + * SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP("Estimated Primary Features", EstimatedPrimaryFeatures, FilterParameter::Category::Parameter, GenericExample); */ -#define SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP(...) \ - SIMPL_EXPAND(_FP_GET_PREFLIGHTUPDATEDVALUE_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP_5, SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP_4)\ - (PreflightUpdatedValueFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP(...) \ + SIMPL_EXPAND(_FP_GET_PREFLIGHTUPDATEDVALUE_OVERRIDE(__VA_ARGS__, SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP_5, SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP_4)(PreflightUpdatedValueFilterParameter, __VA_ARGS__)) /** * @brief The PreflightUpdatedValueFilterParameter class is used by filters to instantiate an PreflightUpdatedValueWidget. By instantiating an instance of @@ -62,67 +60,101 @@ */ class SIMPLib_EXPORT PreflightUpdatedValueFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(PreflightUpdatedValueFilterParameter) - SIMPL_STATIC_NEW_MACRO(PreflightUpdatedValueFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(PreflightUpdatedValueFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the PreflightUpdatedValueFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, - Category category, GetterCallbackType getterCallback, - int groupIndex = -1); - - ~PreflightUpdatedValueFilterParameter() override; - - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief PreflightUpdatedValueFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - PreflightUpdatedValueFilterParameter(); - - public: - PreflightUpdatedValueFilterParameter(const PreflightUpdatedValueFilterParameter&) = delete; // Copy Constructor Not Implemented - PreflightUpdatedValueFilterParameter(PreflightUpdatedValueFilterParameter&&) = delete; // Move Constructor Not Implemented - PreflightUpdatedValueFilterParameter& operator=(const PreflightUpdatedValueFilterParameter&) = delete; // Copy Assignment Not Implemented - PreflightUpdatedValueFilterParameter& operator=(PreflightUpdatedValueFilterParameter&&) = delete; // Move Assignment Not Implemented + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(PreflightUpdatedValueFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(PreflightUpdatedValueFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = PreflightUpdatedValueFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for PreflightUpdatedValueFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for PreflightUpdatedValueFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the PreflightUpdatedValueFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_PREFLIGHTUPDATEDVALUE_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, GetterCallbackType getterCallback, int groupIndex = -1); + + ~PreflightUpdatedValueFilterParameter() override; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const PreflightUpdatedValueFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + PreflightUpdatedValueFilterParameter::GetterCallbackType getGetterCallback() const; + + /** + * @brief readJson + * @return + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson + * @return + */ + void writeJson(QJsonObject& json) const override; + +protected: + /** + * @brief PreflightUpdatedValueFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + PreflightUpdatedValueFilterParameter(); + +public: + PreflightUpdatedValueFilterParameter(const PreflightUpdatedValueFilterParameter&) = delete; // Copy Constructor Not Implemented + PreflightUpdatedValueFilterParameter(PreflightUpdatedValueFilterParameter&&) = delete; // Move Constructor Not Implemented + PreflightUpdatedValueFilterParameter& operator=(const PreflightUpdatedValueFilterParameter&) = delete; // Copy Assignment Not Implemented + PreflightUpdatedValueFilterParameter& operator=(PreflightUpdatedValueFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + PreflightUpdatedValueFilterParameter::GetterCallbackType m_GetterCallback = {}; }; - diff --git a/Source/SIMPLib/FilterParameters/RangeFilterParameter.cpp b/Source/SIMPLib/FilterParameters/RangeFilterParameter.cpp index 78a17585ee..24b34a2c41 100644 --- a/Source/SIMPLib/FilterParameters/RangeFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/RangeFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "RangeFilterParameter.h" @@ -48,8 +48,8 @@ RangeFilterParameter::~RangeFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -RangeFilterParameter::Pointer RangeFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QPair& defaultPair, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) +RangeFilterParameter::Pointer RangeFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const FPRangePair& defaultPair, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { RangeFilterParameter::Pointer ptr = RangeFilterParameter::New(); @@ -78,31 +78,96 @@ QString RangeFilterParameter::getWidgetType() const void RangeFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonObject obj = jsonValue.toObject(); - QPair pair; + FPRangePair dataPair; - pair.first = obj["Min"].toDouble(); - pair.second = obj["Max"].toDouble(); + dataPair.first = obj["Min"].toDouble(); + dataPair.second = obj["Max"].toDouble(); - m_SetterCallback(pair); + m_SetterCallback(dataPair); } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void RangeFilterParameter::writeJson(QJsonObject& json) +void RangeFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { - QPair pair = m_GetterCallback(); + FPRangePair dataPair = m_GetterCallback(); QJsonObject obj; - obj["Min"] = pair.first; - obj["Max"] = pair.second; + obj["Min"] = dataPair.first; + obj["Max"] = dataPair.second; json[getPropertyName()] = obj; } } + +// ----------------------------------------------------------------------------- +RangeFilterParameter::Pointer RangeFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +RangeFilterParameter::Pointer RangeFilterParameter::New() +{ + Pointer sharedPtr(new(RangeFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString RangeFilterParameter::getNameOfClass() const +{ + return QString("RangeFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString RangeFilterParameter::ClassName() +{ + return QString("RangeFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void RangeFilterParameter::setDefaultPair(const FPRangePair& value) +{ + m_DefaultPair = value; +} + +// ----------------------------------------------------------------------------- +FPRangePair RangeFilterParameter::getDefaultPair() const +{ + return m_DefaultPair; +} + +// ----------------------------------------------------------------------------- +void RangeFilterParameter::setSetterCallback(const RangeFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +RangeFilterParameter::SetterCallbackType RangeFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void RangeFilterParameter::setGetterCallback(const RangeFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +RangeFilterParameter::GetterCallbackType RangeFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/RangeFilterParameter.h b/Source/SIMPLib/FilterParameters/RangeFilterParameter.h index 35d96ec9f3..b87ab03de8 100644 --- a/Source/SIMPLib/FilterParameters/RangeFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/RangeFilterParameter.h @@ -1,46 +1,48 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include +#include + #include -#include #include "SIMPLib/FilterParameters/FilterParameter.h" -typedef QPair FPRangePair; +typedef std::pair FPRangePair; /** * @brief SIMPL_NEW_RANGE_FP This macro is a short-form way of instantiating an instance of @@ -52,12 +54,10 @@ typedef QPair FPRangePair; * SIMPL_NEW_RANGE_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): - * SIMPL_NEW_RANGE_FP("Initialization Range", InitRange, FilterParameter::Parameter, GenericExample); + * SIMPL_NEW_RANGE_FP("Initialization Range", InitRange, FilterParameter::Category::Parameter, GenericExample); */ -#define SIMPL_NEW_RANGE_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (RangeFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_RANGE_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(RangeFilterParameter, __VA_ARGS__)) /** * @brief The RangeFilterParameter class is used by filters to instantiate an RangeWidget. By instantiating an instance of @@ -65,83 +65,131 @@ typedef QPair FPRangePair; */ class SIMPLib_EXPORT RangeFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(RangeFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(RangeFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(RangeFilterParameter) - SIMPL_STATIC_NEW_MACRO(RangeFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(RangeFilterParameter, FilterParameter) - - typedef std::function)> SetterCallbackType; - typedef std::function(void)> GetterCallbackType; - - /** - * @brief New This function instantiates an instance of the RangeFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_RANGE_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QPair& defaultPair, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - int groupIndex = -1); - - ~RangeFilterParameter() override; + using Self = RangeFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + typedef std::function SetterCallbackType; + typedef std::function GetterCallbackType; + + /** + * @brief New This function instantiates an instance of the RangeFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_RANGE_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const FPRangePair& defaultPair, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + /** + * @brief Returns the name of the class for RangeFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for RangeFilterParameter + */ + static QString ClassName(); + + ~RangeFilterParameter() override; /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - SIMPL_INSTANCE_PROPERTY(FPRangePair, DefaultPair) - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @return The SetterCallback - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief RangeFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @brief Setter property for DefaultPair + */ + void setDefaultPair(const FPRangePair& value); + /** + * @brief Getter property for DefaultPair + * @return Value of DefaultPair + */ + FPRangePair getDefaultPair() const; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const RangeFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + RangeFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const RangeFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + RangeFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief RangeFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ RangeFilterParameter(); public: - RangeFilterParameter(const RangeFilterParameter&) = delete; // Copy Constructor Not Implemented - RangeFilterParameter(RangeFilterParameter&&) = delete; // Move Constructor Not Implemented + RangeFilterParameter(const RangeFilterParameter&) = delete; // Copy Constructor Not Implemented + RangeFilterParameter(RangeFilterParameter&&) = delete; // Move Constructor Not Implemented RangeFilterParameter& operator=(const RangeFilterParameter&) = delete; // Copy Assignment Not Implemented RangeFilterParameter& operator=(RangeFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +private: + FPRangePair m_DefaultPair = {}; + RangeFilterParameter::SetterCallbackType m_SetterCallback = {}; + RangeFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.cpp index e0fdc82174..818a70f352 100644 --- a/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ReadASCIIDataFilterParameter.h" @@ -51,7 +51,7 @@ ReadASCIIDataFilterParameter::~ReadASCIIDataFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ReadASCIIDataFilterParameter::Pointer ReadASCIIDataFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QVariant& defaultValue, Category category, int groupIndex) +ReadASCIIDataFilterParameter::Pointer ReadASCIIDataFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, int groupIndex) { ReadASCIIDataFilterParameter::Pointer ptr = ReadASCIIDataFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -74,11 +74,36 @@ QString ReadASCIIDataFilterParameter::getWidgetType() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ReadASCIIDataFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) +void ReadASCIIDataFilterParameter::dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) { DataArrayPath oldPath; DataArrayPath newPath; std::tie(oldPath, newPath) = renamePath; - emit filter->dataArrayPathUpdated(getPropertyName(), renamePath); + Q_EMIT filter->dataArrayPathUpdated(getPropertyName(), renamePath); +} + +// ----------------------------------------------------------------------------- +ReadASCIIDataFilterParameter::Pointer ReadASCIIDataFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +ReadASCIIDataFilterParameter::Pointer ReadASCIIDataFilterParameter::New() +{ + Pointer sharedPtr(new(ReadASCIIDataFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString ReadASCIIDataFilterParameter::getNameOfClass() const +{ + return QString("ReadASCIIDataFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString ReadASCIIDataFilterParameter::ClassName() +{ + return QString("ReadASCIIDataFilterParameter"); } diff --git a/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.h b/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.h index 05d63b825d..f3818a6521 100644 --- a/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ReadASCIIDataFilterParameter.h @@ -1,71 +1,105 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include "SIMPLib/FilterParameters/FilterParameter.h" class ASCIIWizardData; class SIMPLib_EXPORT ReadASCIIDataFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(ReadASCIIDataFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(ReadASCIIDataFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(ReadASCIIDataFilterParameter) - SIMPL_STATIC_NEW_MACRO(ReadASCIIDataFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ReadASCIIDataFilterParameter, FilterParameter) + using Self = ReadASCIIDataFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - static Pointer New(const QString& humanLabel, const QString& propertyName, const QVariant& defaultValue, Category category, int groupIndex = -1); + static Pointer New(); - ~ReadASCIIDataFilterParameter() override; + /** + * @brief Returns the name of the class for ReadASCIIDataFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ReadASCIIDataFilterParameter + */ + static QString ClassName(); - QString getWidgetType() const override; + /** + * @brief Create + * @param humanLabel + * @param propertyName + * @param defaultValue + * @param category + * @param groupIndex + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, int groupIndex = -1); - /** - * @brief Handle DataArrayPath changes if necessary - * @param filter - * @param renamePath - */ - void dataArrayPathRenamed(AbstractFilter* filter, DataArrayPath::RenameType renamePath) override; + ~ReadASCIIDataFilterParameter() override; - protected: - ReadASCIIDataFilterParameter(); + QString getWidgetType() const override; - public: - ReadASCIIDataFilterParameter(const ReadASCIIDataFilterParameter&) = delete; // Copy Constructor Not Implemented - ReadASCIIDataFilterParameter(ReadASCIIDataFilterParameter&&) = delete; // Move Constructor Not Implemented - ReadASCIIDataFilterParameter& operator=(const ReadASCIIDataFilterParameter&) = delete; // Copy Assignment Not Implemented - ReadASCIIDataFilterParameter& operator=(ReadASCIIDataFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + /** + * @brief Handle DataArrayPath changes if necessary + * @param filter + * @param renamePath + */ + void dataArrayPathRenamed(AbstractFilter* filter, const DataArrayPath::RenameType& renamePath) override; + +protected: + ReadASCIIDataFilterParameter(); +public: + ReadASCIIDataFilterParameter(const ReadASCIIDataFilterParameter&) = delete; // Copy Constructor Not Implemented + ReadASCIIDataFilterParameter(ReadASCIIDataFilterParameter&&) = delete; // Move Constructor Not Implemented + ReadASCIIDataFilterParameter& operator=(const ReadASCIIDataFilterParameter&) = delete; // Copy Assignment Not Implemented + ReadASCIIDataFilterParameter& operator=(ReadASCIIDataFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: +}; diff --git a/Source/SIMPLib/FilterParameters/ScalarTypeFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ScalarTypeFilterParameter.cpp index 205b4772ae..f4780e4c6e 100644 --- a/Source/SIMPLib/FilterParameters/ScalarTypeFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/ScalarTypeFilterParameter.cpp @@ -1,42 +1,40 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ScalarTypeFilterParameter.h" -#include - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -50,8 +48,8 @@ ScalarTypeFilterParameter::~ScalarTypeFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ScalarTypeFilterParameter::Pointer ScalarTypeFilterParameter::New(const QString& humanLabel, const QString& propertyName, SIMPL::ScalarTypes::Type defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) +ScalarTypeFilterParameter::Pointer ScalarTypeFilterParameter::Create(const QString& humanLabel, const QString& propertyName, SIMPL::ScalarTypes::Type defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { ScalarTypeFilterParameter::Pointer ptr = ScalarTypeFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -81,6 +79,10 @@ QString ScalarTypeFilterParameter::getWidgetType() const void ScalarTypeFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { m_SetterCallback(static_cast(jsonValue.toInt(0.0))); @@ -90,10 +92,59 @@ void ScalarTypeFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ScalarTypeFilterParameter::writeJson(QJsonObject& json) +void ScalarTypeFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { json[getPropertyName()] = static_cast(m_GetterCallback()); } } + +// ----------------------------------------------------------------------------- +ScalarTypeFilterParameter::Pointer ScalarTypeFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +ScalarTypeFilterParameter::Pointer ScalarTypeFilterParameter::New() +{ + Pointer sharedPtr(new(ScalarTypeFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString ScalarTypeFilterParameter::getNameOfClass() const +{ + return QString("ScalarTypeFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString ScalarTypeFilterParameter::ClassName() +{ + return QString("ScalarTypeFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void ScalarTypeFilterParameter::setSetterCallback(const ScalarTypeFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ScalarTypeFilterParameter::SetterCallbackType ScalarTypeFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void ScalarTypeFilterParameter::setGetterCallback(const ScalarTypeFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ScalarTypeFilterParameter::GetterCallbackType ScalarTypeFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/ScalarTypeFilterParameter.h b/Source/SIMPLib/FilterParameters/ScalarTypeFilterParameter.h index b921732f63..3d9ab7b457 100644 --- a/Source/SIMPLib/FilterParameters/ScalarTypeFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ScalarTypeFilterParameter.h @@ -1,78 +1,102 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Common/Constants.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" /** -* @brief SIMPL_NEW_NUMERICTYPE_SELECTION_FP This macro is a short-form way of instantiating an instance of -* ScalarTypeFilterParameter. There are 6 required parameters and 1 optional parameter -* that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, -* FilterName (class name), PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex (optional). -* -* Therefore, the macro should be written like this (this is a concrete example): -* SIMPL_NEW_SHAPETYPE_SELECTION_FP("HumanLabel", PropertyName, Category, FilterName, -* PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex) -* -* Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): -* SIMPL_NEW_SHAPETYPE_SELECTION_FP("Shape Types", ShapeTypeData, FilterParameter::CreatedArray, EstablishShapeTypes, "PhaseCount", "InputPhaseTypesArrayPath"); -*/ -#define SIMPL_NEW_SCALARTYPE_FP(...) \ + * @brief SIMPL_NEW_NUMERICTYPE_SELECTION_FP This macro is a short-form way of instantiating an instance of + * ScalarTypeFilterParameter. There are 6 required parameters and 1 optional parameter + * that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, + * FilterName (class name), PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex (optional). + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_SCALARTYPE_FP("HumanLabel", PropertyName, Category, FilterName, + * PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): + * SIMPL_NEW_SCALARTYPE_FP("Shape Types", ShapeTypeData, FilterParameter::Category::CreatedArray, EstablishShapeTypes, "PhaseCount", "InputPhaseTypesArrayPath"); + */ +#define SIMPL_NEW_SCALARTYPE_FP(...) \ SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(ScalarTypeFilterParameter, __VA_ARGS__)) /** -* @brief The ScalarTypeFilterParameter class is used by filters to instantiate an ShapeTypeSelectionWidget. By instantiating an instance of -* this class in a filter's setupFilterParameters() method, a ShapeTypeSelectionWidget will appear in the filter's "filter input" section in the DREAM3D GUI. -*/ + * @brief The ScalarTypeFilterParameter class is used by filters to instantiate an ShapeTypeSelectionWidget. By instantiating an instance of + * this class in a filter's setupFilterParameters() method, a ShapeTypeSelectionWidget will appear in the filter's "filter input" section in the DREAM3D GUI. + */ class SIMPLib_EXPORT ScalarTypeFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(ScalarTypeFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(ScalarTypeFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(ScalarTypeFilterParameter) - SIMPL_STATIC_NEW_MACRO(ScalarTypeFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ScalarTypeFilterParameter, FilterParameter) + using Self = ScalarTypeFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for ScalarTypeFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ScalarTypeFilterParameter + */ + static QString ClassName(); typedef std::function SetterCallbackType; typedef std::function GetterCallbackType; /** * @brief New This function instantiates an instance of the ScalarTypeFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_SHAPETYPE_SELECTION_FP(...) macro at the top of this file. + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_SCALARTYPE_FP(...) macro at the top of this file. * @param humanLabel The name that the users of DREAM.3D see for this filter parameter * @param propertyName The internal property name for this filter parameter. @@ -88,55 +112,74 @@ class SIMPLib_EXPORT ScalarTypeFilterParameter : public FilterParameter * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& propertyName, SIMPL::ScalarTypes::Type defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex = -1); + static Pointer Create(const QString& humanLabel, const QString& propertyName, SIMPL::ScalarTypes::Type defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); ~ScalarTypeFilterParameter() override; /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ QString getWidgetType() const override; /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ void readJson(const QJsonObject& json) override; /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @return The SetterCallback - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const ScalarTypeFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + ScalarTypeFilterParameter::SetterCallbackType getSetterCallback() const; /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const ScalarTypeFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + ScalarTypeFilterParameter::GetterCallbackType getGetterCallback() const; protected: /** - * @brief ScalarTypeFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + * @brief ScalarTypeFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ ScalarTypeFilterParameter(); public: - ScalarTypeFilterParameter(const ScalarTypeFilterParameter&) = delete; // Copy Constructor Not Implemented - ScalarTypeFilterParameter(ScalarTypeFilterParameter&&) = delete; // Move Constructor Not Implemented + ScalarTypeFilterParameter(const ScalarTypeFilterParameter&) = delete; // Copy Constructor Not Implemented + ScalarTypeFilterParameter(ScalarTypeFilterParameter&&) = delete; // Move Constructor Not Implemented ScalarTypeFilterParameter& operator=(const ScalarTypeFilterParameter&) = delete; // Copy Assignment Not Implemented ScalarTypeFilterParameter& operator=(ScalarTypeFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +private: + ScalarTypeFilterParameter::SetterCallbackType m_SetterCallback = {}; + ScalarTypeFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/SecondOrderPolynomialFilterParameter.cpp b/Source/SIMPLib/FilterParameters/SecondOrderPolynomialFilterParameter.cpp index 654925d531..22a94fbc57 100644 --- a/Source/SIMPLib/FilterParameters/SecondOrderPolynomialFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/SecondOrderPolynomialFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "SecondOrderPolynomialFilterParameter.h" @@ -48,8 +48,9 @@ SecondOrderPolynomialFilterParameter::~SecondOrderPolynomialFilterParameter() = // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -SecondOrderPolynomialFilterParameter::Pointer SecondOrderPolynomialFilterParameter::New(const QString& humanLabel, const QString& propertyName, const Float2ndOrderPoly_t& defaultValue, - Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) +SecondOrderPolynomialFilterParameter::Pointer SecondOrderPolynomialFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const Float2ndOrderPolynomial& defaultValue, + Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + int groupIndex) { SecondOrderPolynomialFilterParameter::Pointer ptr = SecondOrderPolynomialFilterParameter::New(); @@ -80,10 +81,14 @@ QString SecondOrderPolynomialFilterParameter::getWidgetType() const void SecondOrderPolynomialFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonObject obj = jsonValue.toObject(); - Float2ndOrderPoly_t poly; + Float2ndOrderPolynomial poly; poly.readJson(obj); m_SetterCallback(poly); } @@ -92,13 +97,62 @@ void SecondOrderPolynomialFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void SecondOrderPolynomialFilterParameter::writeJson(QJsonObject& json) +void SecondOrderPolynomialFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { - Float2ndOrderPoly_t poly = m_GetterCallback(); + Float2ndOrderPolynomial poly = m_GetterCallback(); QJsonObject obj; poly.writeJson(obj); json[getPropertyName()] = obj; } } + +// ----------------------------------------------------------------------------- +SecondOrderPolynomialFilterParameter::Pointer SecondOrderPolynomialFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +SecondOrderPolynomialFilterParameter::Pointer SecondOrderPolynomialFilterParameter::New() +{ + Pointer sharedPtr(new(SecondOrderPolynomialFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString SecondOrderPolynomialFilterParameter::getNameOfClass() const +{ + return QString("SecondOrderPolynomialFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString SecondOrderPolynomialFilterParameter::ClassName() +{ + return QString("SecondOrderPolynomialFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void SecondOrderPolynomialFilterParameter::setSetterCallback(const SecondOrderPolynomialFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +SecondOrderPolynomialFilterParameter::SetterCallbackType SecondOrderPolynomialFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void SecondOrderPolynomialFilterParameter::setGetterCallback(const SecondOrderPolynomialFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +SecondOrderPolynomialFilterParameter::GetterCallbackType SecondOrderPolynomialFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/SecondOrderPolynomialFilterParameter.h b/Source/SIMPLib/FilterParameters/SecondOrderPolynomialFilterParameter.h old mode 100755 new mode 100644 index 9801395431..01a9bf5d55 --- a/Source/SIMPLib/FilterParameters/SecondOrderPolynomialFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/SecondOrderPolynomialFilterParameter.h @@ -1,76 +1,46 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" - -typedef struct -{ - float c20; float c02; float c11; float c10; float c01; float c00; - - void writeJson(QJsonObject &json) - { - json["c20"] = c20; - json["c02"] = c02; - json["c11"] = c11; - json["c10"] = c10; - json["c01"] = c01; - json["c00"] = c00; - } - - bool readJson(QJsonObject &json) - { - if (json["c20"].isDouble() && json["c02"].isDouble() && json["c11"].isDouble() && json["c10"].isDouble() - && json["c01"].isDouble() && json["c00"].isDouble()) - { - c20 = static_cast(json["c20"].toDouble()); - c02 = static_cast(json["c02"].toDouble()); - c11 = static_cast(json["c11"].toDouble()); - c10 = static_cast(json["c10"].toDouble()); - c01 = static_cast(json["c01"].toDouble()); - c00 = static_cast(json["c00"].toDouble()); - return true; - } - return false; - } -} Float2ndOrderPoly_t; - -Q_DECLARE_METATYPE(Float2ndOrderPoly_t) +#include "SIMPLib/FilterParameters/Float2ndOrderPolynomial.h" /** * @brief SIMPL_NEW_SecondO_POLY_FP This macro is a short-form way of instantiating an instance of @@ -82,12 +52,10 @@ Q_DECLARE_METATYPE(Float2ndOrderPoly_t) * SIMPL_NEW_SecondO_POLY_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): - * SIMPL_NEW_SecondO_POLY_FP("Second Order A Coefficients", SecondOrderACoeff, FilterParameter::Parameter, GenericExample, 0); + * SIMPL_NEW_SecondO_POLY_FP("Second Order A Coefficients", SecondOrderACoeff, FilterParameter::Category::Parameter, GenericExample, 0); */ -#define SIMPL_NEW_SecondO_POLY_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (SecondOrderPolynomialFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_SecondO_POLY_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(SecondOrderPolynomialFilterParameter, __VA_ARGS__)) /** * @brief The SecondOrderPolynomialFilterParameter class is used by filters to instantiate an SecondOrderPolynomialWidget. By instantiating an instance of @@ -95,81 +63,120 @@ Q_DECLARE_METATYPE(Float2ndOrderPoly_t) */ class SIMPLib_EXPORT SecondOrderPolynomialFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(SecondOrderPolynomialFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(SecondOrderPolynomialFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(SecondOrderPolynomialFilterParameter) - SIMPL_STATIC_NEW_MACRO(SecondOrderPolynomialFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(SecondOrderPolynomialFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the SecondOrderPolynomialFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_SecondO_POLY_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const Float2ndOrderPoly_t& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - int groupIndex = -1); - - ~SecondOrderPolynomialFilterParameter() override; + using Self = SecondOrderPolynomialFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for SecondOrderPolynomialFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for SecondOrderPolynomialFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the SecondOrderPolynomialFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_SecondO_POLY_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const Float2ndOrderPolynomial& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~SecondOrderPolynomialFilterParameter() override; /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @return The SetterCallback - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief SecondOrderPolynomialFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const SecondOrderPolynomialFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + SecondOrderPolynomialFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const SecondOrderPolynomialFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + SecondOrderPolynomialFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief SecondOrderPolynomialFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ SecondOrderPolynomialFilterParameter(); public: - SecondOrderPolynomialFilterParameter(const SecondOrderPolynomialFilterParameter&) = delete; // Copy Constructor Not Implemented - SecondOrderPolynomialFilterParameter(SecondOrderPolynomialFilterParameter&&) = delete; // Move Constructor Not Implemented + SecondOrderPolynomialFilterParameter(const SecondOrderPolynomialFilterParameter&) = delete; // Copy Constructor Not Implemented + SecondOrderPolynomialFilterParameter(SecondOrderPolynomialFilterParameter&&) = delete; // Move Constructor Not Implemented SecondOrderPolynomialFilterParameter& operator=(const SecondOrderPolynomialFilterParameter&) = delete; // Copy Assignment Not Implemented SecondOrderPolynomialFilterParameter& operator=(SecondOrderPolynomialFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +private: + SecondOrderPolynomialFilterParameter::SetterCallbackType m_SetterCallback = {}; + SecondOrderPolynomialFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/SeparatorFilterParameter.cpp b/Source/SIMPLib/FilterParameters/SeparatorFilterParameter.cpp index d4fbb580be..77fa6ce2ae 100644 --- a/Source/SIMPLib/FilterParameters/SeparatorFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/SeparatorFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "SeparatorFilterParameter.h" @@ -48,7 +48,7 @@ SeparatorFilterParameter::~SeparatorFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -SeparatorFilterParameter::Pointer SeparatorFilterParameter::New(const QString& humanLabel, FilterParameter::Category category) +SeparatorFilterParameter::Pointer SeparatorFilterParameter::Create(const QString& humanLabel, FilterParameter::Category category) { SeparatorFilterParameter::Pointer ptr = SeparatorFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -66,3 +66,28 @@ QString SeparatorFilterParameter::getWidgetType() const { return QString("SeparatorWidget"); } + +// ----------------------------------------------------------------------------- +SeparatorFilterParameter::Pointer SeparatorFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +SeparatorFilterParameter::Pointer SeparatorFilterParameter::New() +{ + Pointer sharedPtr(new(SeparatorFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString SeparatorFilterParameter::getNameOfClass() const +{ + return QString("SeparatorFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString SeparatorFilterParameter::ClassName() +{ + return QString("SeparatorFilterParameter"); +} diff --git a/Source/SIMPLib/FilterParameters/SeparatorFilterParameter.h b/Source/SIMPLib/FilterParameters/SeparatorFilterParameter.h old mode 100755 new mode 100644 index 9ed0662e49..deb24a6d64 --- a/Source/SIMPLib/FilterParameters/SeparatorFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/SeparatorFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include "SIMPLib/FilterParameters/FilterParameter.h" /** @@ -43,41 +45,63 @@ */ class SIMPLib_EXPORT SeparatorFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(SeparatorFilterParameter) - SIMPL_STATIC_NEW_MACRO(SeparatorFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(SeparatorFilterParameter, FilterParameter) + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(SeparatorFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(SeparatorFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = SeparatorFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - /** - * @brief New This function instantiates an instance of the SeparatorFilterParameter. + static Pointer New(); - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @return - */ - static Pointer New(const QString& humanLabel, FilterParameter::Category category); + /** + * @brief Returns the name of the class for SeparatorFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for SeparatorFilterParameter + */ + static QString ClassName(); - ~SeparatorFilterParameter() override; + /** + * @brief New This function instantiates an instance of the SeparatorFilterParameter. + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @return + */ + static Pointer Create(const QString& humanLabel, FilterParameter::Category category); - /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ - QString getWidgetType() const override; + ~SeparatorFilterParameter() override; - protected: - /** - * @brief SeparatorFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - SeparatorFilterParameter(); + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ + QString getWidgetType() const override; - public: - SeparatorFilterParameter(const SeparatorFilterParameter&) = delete; // Copy Constructor Not Implemented - SeparatorFilterParameter(SeparatorFilterParameter&&) = delete; // Move Constructor Not Implemented - SeparatorFilterParameter& operator=(const SeparatorFilterParameter&) = delete; // Copy Assignment Not Implemented - SeparatorFilterParameter& operator=(SeparatorFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +protected: + /** + * @brief SeparatorFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + SeparatorFilterParameter(); +public: + SeparatorFilterParameter(const SeparatorFilterParameter&) = delete; // Copy Constructor Not Implemented + SeparatorFilterParameter(SeparatorFilterParameter&&) = delete; // Move Constructor Not Implemented + SeparatorFilterParameter& operator=(const SeparatorFilterParameter&) = delete; // Copy Assignment Not Implemented + SeparatorFilterParameter& operator=(SeparatorFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: +}; diff --git a/Source/SIMPLib/FilterParameters/ShapeTypeSelectionFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ShapeTypeSelectionFilterParameter.cpp index 563ec09cd6..04f6c16c2f 100644 --- a/Source/SIMPLib/FilterParameters/ShapeTypeSelectionFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/ShapeTypeSelectionFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ShapeTypeSelectionFilterParameter.h" @@ -50,9 +50,9 @@ ShapeTypeSelectionFilterParameter::~ShapeTypeSelectionFilterParameter() = defaul // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ShapeTypeSelectionFilterParameter::Pointer ShapeTypeSelectionFilterParameter::New(const QString& humanLabel, const QString& propertyName, ShapeType::Types defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, const QString& phaseTypeCountProperty, - const QString& phaseTypeArrayPathProperty, int groupIndex) +ShapeTypeSelectionFilterParameter::Pointer ShapeTypeSelectionFilterParameter::Create(const QString& humanLabel, const QString& propertyName, ShapeType::Types defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + const QString& phaseTypeCountProperty, const QString& phaseTypeArrayPathProperty, int groupIndex) { ShapeTypeSelectionFilterParameter::Pointer ptr = ShapeTypeSelectionFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -84,6 +84,10 @@ QString ShapeTypeSelectionFilterParameter::getWidgetType() const void ShapeTypeSelectionFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonArray jsonArray = jsonValue.toArray(); @@ -99,7 +103,7 @@ void ShapeTypeSelectionFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ShapeTypeSelectionFilterParameter::writeJson(QJsonObject& json) +void ShapeTypeSelectionFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { @@ -114,3 +118,76 @@ void ShapeTypeSelectionFilterParameter::writeJson(QJsonObject& json) json[getPropertyName()] = jsonArray; } } + +// ----------------------------------------------------------------------------- +ShapeTypeSelectionFilterParameter::Pointer ShapeTypeSelectionFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +ShapeTypeSelectionFilterParameter::Pointer ShapeTypeSelectionFilterParameter::New() +{ + Pointer sharedPtr(new(ShapeTypeSelectionFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString ShapeTypeSelectionFilterParameter::getNameOfClass() const +{ + return QString("ShapeTypeSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString ShapeTypeSelectionFilterParameter::ClassName() +{ + return QString("ShapeTypeSelectionFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void ShapeTypeSelectionFilterParameter::setPhaseTypeCountProperty(const QString& value) +{ + m_PhaseTypeCountProperty = value; +} + +// ----------------------------------------------------------------------------- +QString ShapeTypeSelectionFilterParameter::getPhaseTypeCountProperty() const +{ + return m_PhaseTypeCountProperty; +} + +// ----------------------------------------------------------------------------- +void ShapeTypeSelectionFilterParameter::setPhaseTypeArrayPathProperty(const QString& value) +{ + m_PhaseTypeArrayPathProperty = value; +} + +// ----------------------------------------------------------------------------- +QString ShapeTypeSelectionFilterParameter::getPhaseTypeArrayPathProperty() const +{ + return m_PhaseTypeArrayPathProperty; +} + +// ----------------------------------------------------------------------------- +void ShapeTypeSelectionFilterParameter::setSetterCallback(const ShapeTypeSelectionFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ShapeTypeSelectionFilterParameter::SetterCallbackType ShapeTypeSelectionFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void ShapeTypeSelectionFilterParameter::setGetterCallback(const ShapeTypeSelectionFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ShapeTypeSelectionFilterParameter::GetterCallbackType ShapeTypeSelectionFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/ShapeTypeSelectionFilterParameter.h b/Source/SIMPLib/FilterParameters/ShapeTypeSelectionFilterParameter.h old mode 100755 new mode 100644 index 0a3f7e6607..8cb8dd605b --- a/Source/SIMPLib/FilterParameters/ShapeTypeSelectionFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ShapeTypeSelectionFilterParameter.h @@ -1,71 +1,95 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include -#include "SIMPLib/FilterParameters/FilterParameter.h" #include "SIMPLib/Common/ShapeType.h" +#include "SIMPLib/FilterParameters/FilterParameter.h" /** -* @brief SIMPL_NEW_SHAPETYPE_SELECTION_FP This macro is a short-form way of instantiating an instance of -* ShapeTypeSelectionFilterParameter. There are 6 required parameters and 1 optional parameter -* that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, -* FilterName (class name), PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex (optional). -* -* Therefore, the macro should be written like this (this is a concrete example): -* SIMPL_NEW_SHAPETYPE_SELECTION_FP("HumanLabel", PropertyName, Category, FilterName, -* PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex) -* -* Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): -* SIMPL_NEW_SHAPETYPE_SELECTION_FP("Shape Types", ShapeTypeData, FilterParameter::CreatedArray, EstablishShapeTypes, "PhaseCount", "InputPhaseTypesArrayPath"); -*/ + * @brief SIMPL_NEW_SHAPETYPE_SELECTION_FP This macro is a short-form way of instantiating an instance of + * ShapeTypeSelectionFilterParameter. There are 6 required parameters and 1 optional parameter + * that are always passed to this macro in the following order: HumanLabel, PropertyName, Category, + * FilterName (class name), PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex (optional). + * + * Therefore, the macro should be written like this (this is a concrete example): + * SIMPL_NEW_SHAPETYPE_SELECTION_FP("HumanLabel", PropertyName, Category, FilterName, + * PhaseTypeCountProperty, PhaseTypeArrayPathProperty, GroupIndex) + * + * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): + * SIMPL_NEW_SHAPETYPE_SELECTION_FP("Shape Types", ShapeTypeData, FilterParameter::Category::CreatedArray, EstablishShapeTypes, "PhaseCount", "InputPhaseTypesArrayPath"); + */ #define SIMPL_NEW_SHAPETYPE_SELECTION_FP(...) \ SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(ShapeTypeSelectionFilterParameter, __VA_ARGS__)) /** -* @brief The ShapeTypeSelectionFilterParameter class is used by filters to instantiate an ShapeTypeSelectionWidget. By instantiating an instance of -* this class in a filter's setupFilterParameters() method, a ShapeTypeSelectionWidget will appear in the filter's "filter input" section in the DREAM3D GUI. -*/ + * @brief The ShapeTypeSelectionFilterParameter class is used by filters to instantiate an ShapeTypeSelectionWidget. By instantiating an instance of + * this class in a filter's setupFilterParameters() method, a ShapeTypeSelectionWidget will appear in the filter's "filter input" section in the DREAM3D GUI. + */ class SIMPLib_EXPORT ShapeTypeSelectionFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(ShapeTypeSelectionFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(ShapeTypeSelectionFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(ShapeTypeSelectionFilterParameter) - SIMPL_STATIC_NEW_MACRO(ShapeTypeSelectionFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ShapeTypeSelectionFilterParameter, FilterParameter) + using Self = ShapeTypeSelectionFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for ShapeTypeSelectionFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ShapeTypeSelectionFilterParameter + */ + static QString ClassName(); typedef std::function SetterCallbackType; typedef std::function GetterCallbackType; @@ -88,58 +112,96 @@ class SIMPLib_EXPORT ShapeTypeSelectionFilterParameter : public FilterParameter * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& propertyName, ShapeType::Types defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, - const QString& phaseTypeCountProperty, const QString& phaseTypeArrayPathProperty, int groupIndex = -1); + static Pointer Create(const QString& humanLabel, const QString& propertyName, ShapeType::Types defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, const QString& phaseTypeCountProperty, const QString& phaseTypeArrayPathProperty, int groupIndex = -1); ~ShapeTypeSelectionFilterParameter() override; - SIMPL_INSTANCE_PROPERTY(QString, PhaseTypeCountProperty) - SIMPL_INSTANCE_PROPERTY(QString, PhaseTypeArrayPathProperty) + /** + * @brief Setter property for PhaseTypeCountProperty + */ + void setPhaseTypeCountProperty(const QString& value); + /** + * @brief Getter property for PhaseTypeCountProperty + * @return Value of PhaseTypeCountProperty + */ + QString getPhaseTypeCountProperty() const; /** - * @brief getWidgetType Returns the type of widget that displays and controls - * this FilterParameter subclass - * @return - */ + * @brief Setter property for PhaseTypeArrayPathProperty + */ + void setPhaseTypeArrayPathProperty(const QString& value); + /** + * @brief Getter property for PhaseTypeArrayPathProperty + * @return Value of PhaseTypeArrayPathProperty + */ + QString getPhaseTypeArrayPathProperty() const; + + /** + * @brief getWidgetType Returns the type of widget that displays and controls + * this FilterParameter subclass + * @return + */ QString getWidgetType() const override; /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ void readJson(const QJsonObject& json) override; /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @return The SetterCallback - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const ShapeTypeSelectionFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + ShapeTypeSelectionFilterParameter::SetterCallbackType getSetterCallback() const; /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const ShapeTypeSelectionFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + ShapeTypeSelectionFilterParameter::GetterCallbackType getGetterCallback() const; protected: /** - * @brief ShapeTypeSelectionFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + * @brief ShapeTypeSelectionFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ ShapeTypeSelectionFilterParameter(); public: - ShapeTypeSelectionFilterParameter(const ShapeTypeSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented - ShapeTypeSelectionFilterParameter(ShapeTypeSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented + ShapeTypeSelectionFilterParameter(const ShapeTypeSelectionFilterParameter&) = delete; // Copy Constructor Not Implemented + ShapeTypeSelectionFilterParameter(ShapeTypeSelectionFilterParameter&&) = delete; // Move Constructor Not Implemented ShapeTypeSelectionFilterParameter& operator=(const ShapeTypeSelectionFilterParameter&) = delete; // Copy Assignment Not Implemented ShapeTypeSelectionFilterParameter& operator=(ShapeTypeSelectionFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +private: + QString m_PhaseTypeCountProperty = {}; + QString m_PhaseTypeArrayPathProperty = {}; + ShapeTypeSelectionFilterParameter::SetterCallbackType m_SetterCallback = {}; + ShapeTypeSelectionFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/SourceList.cmake b/Source/SIMPLib/FilterParameters/SourceList.cmake index bb43bb5e4d..2c3b84ab4a 100755 --- a/Source/SIMPLib/FilterParameters/SourceList.cmake +++ b/Source/SIMPLib/FilterParameters/SourceList.cmake @@ -24,12 +24,14 @@ set(SIMPLib_${SUBDIR_NAME}_HDRS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ChoiceFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ComparisonSelectionAdvancedFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ComparisonSelectionFilterParameter.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ConstrainedFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ConstrainedDoubleFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ConstrainedIntFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataArrayCreationFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataArraySelectionFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerArrayProxyFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerCreationFilterParameter.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerGridSelectionFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerReaderFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerSelectionFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DoubleFilterParameter.h @@ -39,9 +41,7 @@ set(SIMPLib_${SUBDIR_NAME}_HDRS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FileListInfoFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FloatFilterParameter.h - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FloatVec2.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FloatVec2FilterParameter.h - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FloatVec3.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FloatVec3FilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FourthOrderPolynomialFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/GenerateColorTableFilterParameter.h @@ -52,14 +52,19 @@ set(SIMPLib_${SUBDIR_NAME}_HDRS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/InputFileFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/InputPathFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IntFilterParameter.h - ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IntVec3.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IntVec2FilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IntVec3FilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/JsonFilterParametersReader.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/JsonFilterParametersWriter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/LinkedBooleanFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/LinkedChoicesFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/LinkedDataContainerSelectionFilterParameter.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/LinkedPathCreationFilterParameter.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MontageFileListInfo.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MontageSelectionFilterParameter.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MontageStructureSelectionFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MultiAttributeMatrixSelectionFilterParameter.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MultiDataContainerSelectionFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MultiDataArraySelectionFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/NumericTypeFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/OutputFileFilterParameter.h @@ -73,11 +78,16 @@ set(SIMPLib_${SUBDIR_NAME}_HDRS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SecondOrderPolynomialFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SeparatorFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ShapeTypeSelectionFilterParameter.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/StackFileListInfo.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/StringFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ThirdOrderPolynomial.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ThirdOrderPolynomialFilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/UInt64FilterParameter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/UnknownFilterParameter.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MultiInputFileFilterParameter.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Float4thOrderPolynomial.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Float2ndOrderPolynomial.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractIOFilterParameter.h ) set(SIMPLib_${SUBDIR_NAME}_SRCS @@ -86,6 +96,7 @@ set(SIMPLib_${SUBDIR_NAME}_SRCS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AttributeMatrixCreationFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AttributeMatrixSelectionFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AxisAngleFilterParameter.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AxisAngleInput.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/BooleanFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/CalculatorFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ChoiceFilterParameter.cpp @@ -97,12 +108,14 @@ set(SIMPLib_${SUBDIR_NAME}_SRCS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataArraySelectionFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerArrayProxyFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerCreationFilterParameter.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerGridSelectionFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerReaderFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DataContainerSelectionFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DoubleFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DynamicChoiceFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DynamicTableData.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/DynamicTableFilterParameter.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FileListInfo.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FileListInfoFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FloatFilterParameter.cpp @@ -115,13 +128,19 @@ set(SIMPLib_${SUBDIR_NAME}_SRCS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/InputFileFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/InputPathFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IntFilterParameter.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IntVec2FilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/IntVec3FilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/JsonFilterParametersReader.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/JsonFilterParametersWriter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/LinkedBooleanFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/LinkedChoicesFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/LinkedDataContainerSelectionFilterParameter.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/LinkedPathCreationFilterParameter.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MontageFileListInfo.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MontageSelectionFilterParameter.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MontageStructureSelectionFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MultiAttributeMatrixSelectionFilterParameter.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MultiDataContainerSelectionFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MultiDataArraySelectionFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/NumericTypeFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/OutputFileFilterParameter.cpp @@ -136,10 +155,15 @@ set(SIMPLib_${SUBDIR_NAME}_SRCS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SecondOrderPolynomialFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/SeparatorFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ShapeTypeSelectionFilterParameter.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/StackFileListInfo.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/StringFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ThirdOrderPolynomialFilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/UInt64FilterParameter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/UnknownFilterParameter.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/MultiInputFileFilterParameter.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Float4thOrderPolynomial.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/Float2ndOrderPolynomial.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractIOFilterParameter.cpp ) cmp_IDE_SOURCE_PROPERTIES( "${SUBDIR_NAME}" "${SIMPLib_${SUBDIR_NAME}_HDRS};${SIMPLib_${SUBDIR_NAME}_Moc_HDRS}" "${SIMPLib_${SUBDIR_NAME}_SRCS}" "${PROJECT_INSTALL_HEADERS}") diff --git a/Source/SIMPLib/FilterParameters/StackFileListInfo.cpp b/Source/SIMPLib/FilterParameters/StackFileListInfo.cpp new file mode 100644 index 0000000000..79dc5ed180 --- /dev/null +++ b/Source/SIMPLib/FilterParameters/StackFileListInfo.cpp @@ -0,0 +1,90 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "StackFileListInfo.h" + +// ----------------------------------------------------------------------------- +StackFileListInfo::StackFileListInfo() = default; + +// ----------------------------------------------------------------------------- +StackFileListInfo::StackFileListInfo(const QString& extension, int32_t startIndex, int32_t endIndex, int32_t padding) +{ + FileExtension = extension; + StartIndex = startIndex; + EndIndex = endIndex; + PaddingDigits = padding; +} + +// ----------------------------------------------------------------------------- +StackFileListInfo::StackFileListInfo(int32_t paddingDigits, uint32_t ordering, int32_t startIndex, int32_t endIndex, int32_t incrementIndex, const QString& inputPath, const QString& filePrefix, + const QString& fileSuffix, const QString& fileExtension) +{ + PaddingDigits = paddingDigits; + Ordering = ordering; + IncrementIndex = incrementIndex; + InputPath = inputPath; + FilePrefix = filePrefix; + FileSuffix = fileSuffix; + FileExtension = fileExtension; + StartIndex = startIndex; + EndIndex = endIndex; +} + +// ----------------------------------------------------------------------------- +StackFileListInfo::~StackFileListInfo() = default; + +// ----------------------------------------------------------------------------- +void StackFileListInfo::writeJson(QJsonObject& json) const +{ + writeSuperclassJson(json); + + json["StartIndex"] = static_cast(StartIndex); + json["EndIndex"] = static_cast(EndIndex); +} + +// ----------------------------------------------------------------------------- +bool StackFileListInfo::readJson(QJsonObject& json) +{ + bool result = readSuperclassJson(json); + if(!result) + { + return false; + } + + if(json["StartIndex"].isDouble() && json["EndIndex"].isDouble()) + { + StartIndex = static_cast(json["StartIndex"].toInt()); + EndIndex = static_cast(json["EndIndex"].toInt()); + return true; + } + return false; +} diff --git a/Source/SIMPLib/FilterParameters/StackFileListInfo.h b/Source/SIMPLib/FilterParameters/StackFileListInfo.h new file mode 100644 index 0000000000..44b4a9b4cd --- /dev/null +++ b/Source/SIMPLib/FilterParameters/StackFileListInfo.h @@ -0,0 +1,136 @@ +/* ============================================================================ + * Copyright (c) 2019 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#pragma once + +#include +#include +#include + +#include "SIMPLib/Common/SIMPLPythonMacros.h" +#include "SIMPLib/FilterParameters/FileListInfo.h" + +#define FP_SET_PROPERTY(type, prpty) \ + void set##prpty(const type& value) \ + { \ + this->prpty = value; \ + } + +#define FP_GET_PROPERTY(type, prpty) \ + type get##prpty() const \ + { \ + return prpty; \ + } + +#define FP_PROP_DEC_DEF(type, prpty) \ + FP_SET_PROPERTY(type, prpty) \ + FP_GET_PROPERTY(type, prpty) + +class SIMPLib_EXPORT StackFileListInfo : public FileListInfo +{ + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(StackFileListInfo) + PYB11_CREATION(QString int32_t int32_t int32_t) + PYB11_CREATION(int32_t uint32_t int32_t int32_t int32_t QString QString QString QString) + PYB11_PROPERTY(int32_t PaddingDigits READ getPaddingDigits WRITE setPaddingDigits) + PYB11_PROPERTY(uint32_t Ordering READ getOrdering WRITE setOrdering) + PYB11_PROPERTY(int32_t IncrementIndex READ getIncrementIndex WRITE setIncrementIndex) + PYB11_PROPERTY(QString InputPath READ getInputPath WRITE setInputPath) + PYB11_PROPERTY(QString FilePrefix READ getFilePrefix WRITE setFilePrefix) + PYB11_PROPERTY(QString FileSuffix READ getFileSuffix WRITE setFileSuffix) + PYB11_PROPERTY(QString FileExtension READ getFileExtension WRITE setFileExtension) + PYB11_PROPERTY(int32_t StartIndex READ getStartIndex WRITE setStartIndex) + PYB11_PROPERTY(int32_t EndIndex READ getEndIndex WRITE setEndIndex) + PYB11_END_BINDINGS() + // End Python bindings declarations +public: + StackFileListInfo(); + ~StackFileListInfo() override; + /** + * @brief StackFileListInfo + * @param extension + * @param startIndex + * @param endIndex + * @param padding + */ + StackFileListInfo(const QString& extension, int32_t startIndex, int32_t endIndex, int32_t padding); + + /** + * @brief StackFileListInfo + * @param paddingDigits + * @param ordering + * @param startIndex + * @param endIndex + * @param incrementIndex + * @param inputPath + * @param filePrefix + * @param fileSuffix + * @param fileExtension + */ + StackFileListInfo(int32_t paddingDigits, uint32_t ordering, int32_t startIndex, int32_t endIndex, int32_t incrementIndex, const QString& inputPath, const QString& filePrefix, + const QString& fileSuffix, const QString& fileExtension); + + // These are from the super class + FP_PROP_DEC_DEF(int32_t, PaddingDigits) + FP_PROP_DEC_DEF(uint32_t, Ordering) + FP_PROP_DEC_DEF(int32_t, IncrementIndex) + FP_PROP_DEC_DEF(QString, InputPath) + FP_PROP_DEC_DEF(QString, FilePrefix) + FP_PROP_DEC_DEF(QString, FileSuffix) + FP_PROP_DEC_DEF(QString, FileExtension) + // These are from this subclass + FP_PROP_DEC_DEF(int32_t, StartIndex) + FP_PROP_DEC_DEF(int32_t, EndIndex) + + qint32 StartIndex = 0; + qint32 EndIndex = 1; + + /** + * @brief writeJson + * @param json + */ + void writeJson(QJsonObject& json) const override; + + /** + * @brief readJson + * @param json + * @return + */ + bool readJson(QJsonObject& json) override; + +public: + StackFileListInfo(const StackFileListInfo&) = default; // Copy Constructor Not Implemented + StackFileListInfo(StackFileListInfo&&) = default; // Move Constructor Not Implemented + StackFileListInfo& operator=(const StackFileListInfo&) = default; // Copy Assignment Not Implemented + StackFileListInfo& operator=(StackFileListInfo&&) = default; // Move Assignment Not Implemented +}; + +Q_DECLARE_METATYPE(StackFileListInfo) diff --git a/Source/SIMPLib/FilterParameters/StringFilterParameter.cpp b/Source/SIMPLib/FilterParameters/StringFilterParameter.cpp index b6cb9be877..bc38040084 100644 --- a/Source/SIMPLib/FilterParameters/StringFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/StringFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "StringFilterParameter.h" @@ -48,8 +48,8 @@ StringFilterParameter::~StringFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -StringFilterParameter::Pointer StringFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex) +StringFilterParameter::Pointer StringFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, + const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, int groupIndex) { StringFilterParameter::Pointer ptr = StringFilterParameter::New(); @@ -78,6 +78,10 @@ QString StringFilterParameter::getWidgetType() const void StringFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { m_SetterCallback(jsonValue.toString("")); @@ -87,10 +91,59 @@ void StringFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void StringFilterParameter::writeJson(QJsonObject& json) +void StringFilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { json[getPropertyName()] = m_GetterCallback(); } } + +// ----------------------------------------------------------------------------- +StringFilterParameter::Pointer StringFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +StringFilterParameter::Pointer StringFilterParameter::New() +{ + Pointer sharedPtr(new(StringFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString StringFilterParameter::getNameOfClass() const +{ + return QString("StringFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString StringFilterParameter::ClassName() +{ + return QString("StringFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void StringFilterParameter::setSetterCallback(const StringFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +StringFilterParameter::SetterCallbackType StringFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void StringFilterParameter::setGetterCallback(const StringFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +StringFilterParameter::GetterCallbackType StringFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/StringFilterParameter.h b/Source/SIMPLib/FilterParameters/StringFilterParameter.h old mode 100755 new mode 100644 index 0acc809719..f1d55461f0 --- a/Source/SIMPLib/FilterParameters/StringFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/StringFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" @@ -49,12 +51,10 @@ * SIMPL_NEW_STRING_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), without optional GroupIndex parameter): - * SIMPL_NEW_STRING_FP("STL Output Prefix", StlFilePrefix, FilterParameter::Parameter, GenericExample); + * SIMPL_NEW_STRING_FP("STL Output Prefix", StlFilePrefix, FilterParameter::Category::Parameter, GenericExample); */ -#define SIMPL_NEW_STRING_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (StringFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_STRING_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(StringFilterParameter, __VA_ARGS__)) /** * @brief The StringFilterParameter class is used by filters to instantiate an StringWidget. By instantiating an instance of @@ -62,82 +62,120 @@ */ class SIMPLib_EXPORT StringFilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(StringFilterParameter) - SIMPL_STATIC_NEW_MACRO(StringFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(StringFilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the StringFilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_STRING_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex = -1); - - ~StringFilterParameter() override; - - /** + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(StringFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(StringFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = StringFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for StringFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for StringFilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the StringFilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_STRING_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~StringFilterParameter() override; + + /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief StringFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - StringFilterParameter(); - - public: - StringFilterParameter(const StringFilterParameter&) = delete; // Copy Constructor Not Implemented - StringFilterParameter(StringFilterParameter&&) = delete; // Move Constructor Not Implemented - StringFilterParameter& operator=(const StringFilterParameter&) = delete; // Copy Assignment Not Implemented - StringFilterParameter& operator=(StringFilterParameter&&) = delete; // Move Assignment Not Implemented -}; + QString getWidgetType() const override; + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const StringFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + StringFilterParameter::SetterCallbackType getSetterCallback() const; + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const StringFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + StringFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief StringFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + StringFilterParameter(); + +public: + StringFilterParameter(const StringFilterParameter&) = delete; // Copy Constructor Not Implemented + StringFilterParameter(StringFilterParameter&&) = delete; // Move Constructor Not Implemented + StringFilterParameter& operator=(const StringFilterParameter&) = delete; // Copy Assignment Not Implemented + StringFilterParameter& operator=(StringFilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + StringFilterParameter::SetterCallbackType m_SetterCallback = {}; + StringFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/Testing/Cxx/FilterParametersRWTest.cpp b/Source/SIMPLib/FilterParameters/Testing/Cxx/FilterParametersRWTest.cpp index e10472f37f..d0f229c7dd 100644 --- a/Source/SIMPLib/FilterParameters/Testing/Cxx/FilterParametersRWTest.cpp +++ b/Source/SIMPLib/FilterParameters/Testing/Cxx/FilterParametersRWTest.cpp @@ -1,45 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + #include -#include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/PhaseType.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" @@ -88,8 +85,6 @@ #include "SIMPLib/Filtering/QMetaObjectUtilities.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" #include "SIMPLib/Plugin/SIMPLibPluginLoader.h" -#include "SIMPLib/SIMPLib.h" - #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" @@ -104,12 +99,14 @@ class FilterParametersRWTest m_String1 = "This is the FilterParametersRWTest"; m_ArrayPath1 = DataArrayPath("DataContainer", "AttributeMatrix", "DataArray"); + m_Path1 = DataArrayPath("DataContainer Name", "", ""); + m_AxisAngle1.angle = 2.2f; m_AxisAngle1.h = 3.4f; m_AxisAngle1.k = 6.4f; m_AxisAngle1.l = 8.2f; - m_ComparisonInputs1.addInput("DataContainer", "AttributeMatrix", "DataArrayName", 2, 4.6); + m_ComparisonInputs1.addInput(QString("DataContainer"), QString("AttributeMatrix"), QString("DataArrayName"), 2, 4.6); { DataArrayProxy daProxy = DataArrayProxy("TestPath", "TestName"); @@ -152,15 +149,15 @@ class FilterParametersRWTest } { - m_FloatVec3_1.x = 3.0f; - m_FloatVec3_1.y = 6.7f; - m_FloatVec3_1.z = 32.42f; + m_FloatVec3_1[0] = 3.0f; + m_FloatVec3_1[1] = 6.7f; + m_FloatVec3_1[2] = 32.42f; } { - m_IntVec3_1.x = 3; - m_IntVec3_1.y = 6; - m_IntVec3_1.z = 32; + m_IntVec3_1[0] = 3; + m_IntVec3_1[1] = 6; + m_IntVec3_1[2] = 32; } { @@ -230,94 +227,517 @@ class FilterParametersRWTest } virtual ~FilterParametersRWTest() = default; - SIMPL_INSTANCE_PROPERTY(bool, Bool1) + // ----------------------------------------------------------------------------- + void setBool1(bool value) + { + m_Bool1 = value; + } + + // ----------------------------------------------------------------------------- + bool getBool1() const + { + return m_Bool1; + } + Q_PROPERTY(bool Bool1 READ getBool1 WRITE setBool1) - SIMPL_INSTANCE_PROPERTY(bool, Bool2) + // ----------------------------------------------------------------------------- + void setBool2(bool value) + { + m_Bool2 = value; + } + + // ----------------------------------------------------------------------------- + bool getBool2() const + { + return m_Bool2; + } + Q_PROPERTY(bool Bool2 READ getBool2 WRITE setBool2) - SIMPL_INSTANCE_PROPERTY(int, Int1) + // ----------------------------------------------------------------------------- + void setInt1(int value) + { + m_Int1 = value; + } + + // ----------------------------------------------------------------------------- + int getInt1() const + { + return m_Int1; + } + Q_PROPERTY(int Int1 READ getInt1 WRITE setInt1) - SIMPL_INSTANCE_PROPERTY(int, Int2) + // ----------------------------------------------------------------------------- + void setInt2(int value) + { + m_Int2 = value; + } + + // ----------------------------------------------------------------------------- + int getInt2() const + { + return m_Int2; + } + Q_PROPERTY(int Int2 READ getInt2 WRITE setInt2) - SIMPL_INSTANCE_PROPERTY(double, Double1) + // ----------------------------------------------------------------------------- + void setDouble1(double value) + { + m_Double1 = value; + } + + // ----------------------------------------------------------------------------- + double getDouble1() const + { + return m_Double1; + } + Q_PROPERTY(double Double1 READ getDouble1 WRITE setDouble1) - SIMPL_INSTANCE_PROPERTY(double, Double2) + // ----------------------------------------------------------------------------- + void setDouble2(double value) + { + m_Double2 = value; + } + + // ----------------------------------------------------------------------------- + double getDouble2() const + { + return m_Double2; + } + Q_PROPERTY(double Double2 READ getDouble2 WRITE setDouble2) - SIMPL_INSTANCE_PROPERTY(QString, String1) + // ----------------------------------------------------------------------------- + void setString1(const QString& value) + { + m_String1 = value; + } + + // ----------------------------------------------------------------------------- + QString getString1() const + { + return m_String1; + } + Q_PROPERTY(QString String1 READ getString1 WRITE setString1) - SIMPL_INSTANCE_PROPERTY(QString, String2) + // ----------------------------------------------------------------------------- + void setString2(const QString& value) + { + m_String2 = value; + } + + // ----------------------------------------------------------------------------- + QString getString2() const + { + return m_String2; + } + Q_PROPERTY(QString String2 READ getString2 WRITE setString2) - SIMPL_INSTANCE_PROPERTY(DataArrayPath, ArrayPath1) + // ----------------------------------------------------------------------------- + void setPath1(const DataArrayPath& value) + { + m_Path1 = value; + } + + // ----------------------------------------------------------------------------- + DataArrayPath getPath1() const + { + return m_Path1; + } + + Q_PROPERTY(DataArrayPath Path1 READ getPath1 WRITE setPath1) + // ----------------------------------------------------------------------------- + void setPath2(const DataArrayPath& value) + { + m_Path2 = value; + } + + // ----------------------------------------------------------------------------- + DataArrayPath getPath2() const + { + return m_Path2; + } + + Q_PROPERTY(DataArrayPath Path2 READ getPath2 WRITE setPath2) + + // ----------------------------------------------------------------------------- + void setArrayPath1(const DataArrayPath& value) + { + m_ArrayPath1 = value; + } + + // ----------------------------------------------------------------------------- + DataArrayPath getArrayPath1() const + { + return m_ArrayPath1; + } + Q_PROPERTY(DataArrayPath ArrayPath1 READ getArrayPath1 WRITE setArrayPath1) - SIMPL_INSTANCE_PROPERTY(DataArrayPath, ArrayPath2) + // ----------------------------------------------------------------------------- + void setArrayPath2(const DataArrayPath& value) + { + m_ArrayPath2 = value; + } + + // ----------------------------------------------------------------------------- + DataArrayPath getArrayPath2() const + { + return m_ArrayPath2; + } + Q_PROPERTY(DataArrayPath ArrayPath2 READ getArrayPath2 WRITE setArrayPath2) - SIMPL_INSTANCE_PROPERTY(AxisAngleInput_t, AxisAngle1) - Q_PROPERTY(AxisAngleInput_t AxisAngle1 READ getAxisAngle1 WRITE setAxisAngle1) - SIMPL_INSTANCE_PROPERTY(AxisAngleInput_t, AxisAngle2) - Q_PROPERTY(AxisAngleInput_t AxisAngle2 READ getAxisAngle2 WRITE setAxisAngle2) + // ----------------------------------------------------------------------------- + void setAxisAngle1(const AxisAngleInput& value) + { + m_AxisAngle1 = value; + } + + // ----------------------------------------------------------------------------- + AxisAngleInput getAxisAngle1() const + { + return m_AxisAngle1; + } + + Q_PROPERTY(AxisAngleInput AxisAngle1 READ getAxisAngle1 WRITE setAxisAngle1) + // ----------------------------------------------------------------------------- + void setAxisAngle2(const AxisAngleInput& value) + { + m_AxisAngle2 = value; + } + + // ----------------------------------------------------------------------------- + AxisAngleInput getAxisAngle2() const + { + return m_AxisAngle2; + } + + Q_PROPERTY(AxisAngleInput AxisAngle2 READ getAxisAngle2 WRITE setAxisAngle2) + + // ----------------------------------------------------------------------------- + void setComparisonInputs1(const ComparisonInputs& value) + { + m_ComparisonInputs1 = value; + } + + // ----------------------------------------------------------------------------- + ComparisonInputs getComparisonInputs1() const + { + return m_ComparisonInputs1; + } - SIMPL_INSTANCE_PROPERTY(ComparisonInputs, ComparisonInputs1) Q_PROPERTY(ComparisonInputs ComparisonInputs1 READ getComparisonInputs1 WRITE setComparisonInputs1) - SIMPL_INSTANCE_PROPERTY(ComparisonInputs, ComparisonInputs2) + // ----------------------------------------------------------------------------- + void setComparisonInputs2(const ComparisonInputs& value) + { + m_ComparisonInputs2 = value; + } + + // ----------------------------------------------------------------------------- + ComparisonInputs getComparisonInputs2() const + { + return m_ComparisonInputs2; + } + Q_PROPERTY(ComparisonInputs ComparisonInputs2 READ getComparisonInputs2 WRITE setComparisonInputs2) - SIMPL_INSTANCE_PROPERTY(DataContainerArrayProxy, DcaProxy1) + // ----------------------------------------------------------------------------- + void setDcaProxy1(const DataContainerArrayProxy& value) + { + m_DcaProxy1 = value; + } + + // ----------------------------------------------------------------------------- + DataContainerArrayProxy getDcaProxy1() const + { + return m_DcaProxy1; + } + Q_PROPERTY(DataContainerArrayProxy DcaProxy1 READ getDcaProxy1 WRITE setDcaProxy1) - SIMPL_INSTANCE_PROPERTY(DataContainerArrayProxy, DcaProxy2) + // ----------------------------------------------------------------------------- + void setDcaProxy2(const DataContainerArrayProxy& value) + { + m_DcaProxy2 = value; + } + + // ----------------------------------------------------------------------------- + DataContainerArrayProxy getDcaProxy2() const + { + return m_DcaProxy2; + } + Q_PROPERTY(DataContainerArrayProxy DcaProxy2 READ getDcaProxy2 WRITE setDcaProxy2) - SIMPL_INSTANCE_PROPERTY(DynamicTableData, DynamicData1) + // ----------------------------------------------------------------------------- + void setDynamicData1(const DynamicTableData& value) + { + m_DynamicData1 = value; + } + + // ----------------------------------------------------------------------------- + DynamicTableData getDynamicData1() const + { + return m_DynamicData1; + } + Q_PROPERTY(DynamicTableData DynamicData1 READ getDynamicData1 WRITE setDynamicData1) - SIMPL_INSTANCE_PROPERTY(DynamicTableData, DynamicData2) + // ----------------------------------------------------------------------------- + void setDynamicData2(const DynamicTableData& value) + { + m_DynamicData2 = value; + } + + // ----------------------------------------------------------------------------- + DynamicTableData getDynamicData2() const + { + return m_DynamicData2; + } + Q_PROPERTY(DynamicTableData DynamicData2 READ getDynamicData2 WRITE setDynamicData2) - SIMPL_INSTANCE_PROPERTY(FileListInfo_t, FileListInfo1) - Q_PROPERTY(FileListInfo_t FileListInfo1 READ getFileListInfo1 WRITE setFileListInfo1) - SIMPL_INSTANCE_PROPERTY(FileListInfo_t, FileListInfo2) - Q_PROPERTY(FileListInfo_t FileListInfo2 READ getFileListInfo2 WRITE setFileListInfo2) + // ----------------------------------------------------------------------------- + void setFileListInfo1(const StackFileListInfo& value) + { + m_FileListInfo1 = value; + } + + // ----------------------------------------------------------------------------- + StackFileListInfo getFileListInfo1() const + { + return m_FileListInfo1; + } + + Q_PROPERTY(StackFileListInfo FileListInfo1 READ getFileListInfo1 WRITE setFileListInfo1) + // ----------------------------------------------------------------------------- + void setFileListInfo2(const StackFileListInfo& value) + { + m_FileListInfo2 = value; + } + + // ----------------------------------------------------------------------------- + StackFileListInfo getFileListInfo2() const + { + return m_FileListInfo2; + } + + Q_PROPERTY(StackFileListInfo FileListInfo2 READ getFileListInfo2 WRITE setFileListInfo2) + + // ----------------------------------------------------------------------------- + void setIntVec3_1(const IntVec3Type& value) + { + m_IntVec3_1 = value; + } + + // ----------------------------------------------------------------------------- + IntVec3Type getIntVec3_1() const + { + return m_IntVec3_1; + } - SIMPL_INSTANCE_PROPERTY(IntVec3_t, IntVec3_1) - Q_PROPERTY(IntVec3_t IntVec3_1 READ getIntVec3_1 WRITE setIntVec3_1) - SIMPL_INSTANCE_PROPERTY(IntVec3_t, IntVec3_2) - Q_PROPERTY(IntVec3_t IntVec3_2 READ getIntVec3_2 WRITE setIntVec3_2) + Q_PROPERTY(IntVec3Type IntVec3_1 READ getIntVec3_1 WRITE setIntVec3_1) + // ----------------------------------------------------------------------------- + void setIntVec3_2(const IntVec3Type& value) + { + m_IntVec3_2 = value; + } - SIMPL_INSTANCE_PROPERTY(FloatVec3_t, FloatVec3_1) - Q_PROPERTY(FloatVec3_t FloatVec3_1 READ getFloatVec3_1 WRITE setFloatVec3_1) - SIMPL_INSTANCE_PROPERTY(FloatVec3_t, FloatVec3_2) - Q_PROPERTY(FloatVec3_t FloatVec3_2 READ getFloatVec3_2 WRITE setFloatVec3_2) + // ----------------------------------------------------------------------------- + IntVec3Type getIntVec3_2() const + { + return m_IntVec3_2; + } - SIMPL_INSTANCE_PROPERTY(Float2ndOrderPoly_t, Float2ndOrderPoly_1) - Q_PROPERTY(Float2ndOrderPoly_t Float2ndOrderPoly_1 READ getFloat2ndOrderPoly_1 WRITE setFloat2ndOrderPoly_1) - SIMPL_INSTANCE_PROPERTY(Float2ndOrderPoly_t, Float2ndOrderPoly_2) - Q_PROPERTY(Float2ndOrderPoly_t Float2ndOrderPoly_2 READ getFloat2ndOrderPoly_2 WRITE setFloat2ndOrderPoly_2) + Q_PROPERTY(IntVec3Type IntVec3_2 READ getIntVec3_2 WRITE setIntVec3_2) + + // ----------------------------------------------------------------------------- + void setFloatVec3_1(const FloatVec3Type& value) + { + m_FloatVec3_1 = value; + } + + // ----------------------------------------------------------------------------- + FloatVec3Type getFloatVec3_1() const + { + return m_FloatVec3_1; + } + + Q_PROPERTY(FloatVec3Type FloatVec3_1 READ getFloatVec3_1 WRITE setFloatVec3_1) + // ----------------------------------------------------------------------------- + void setFloatVec3_2(const FloatVec3Type& value) + { + m_FloatVec3_2 = value; + } + + // ----------------------------------------------------------------------------- + FloatVec3Type getFloatVec3_2() const + { + return m_FloatVec3_2; + } + + Q_PROPERTY(FloatVec3Type FloatVec3_2 READ getFloatVec3_2 WRITE setFloatVec3_2) + + // ----------------------------------------------------------------------------- + void setFloat2ndOrderPoly_1(const Float2ndOrderPolynomial& value) + { + m_Float2ndOrderPoly_1 = value; + } + + // ----------------------------------------------------------------------------- + Float2ndOrderPolynomial getFloat2ndOrderPoly_1() const + { + return m_Float2ndOrderPoly_1; + } + + Q_PROPERTY(Float2ndOrderPolynomial Float2ndOrderPoly_1 READ getFloat2ndOrderPoly_1 WRITE setFloat2ndOrderPoly_1) + // ----------------------------------------------------------------------------- + void setFloat2ndOrderPoly_2(const Float2ndOrderPolynomial& value) + { + m_Float2ndOrderPoly_2 = value; + } + + // ----------------------------------------------------------------------------- + Float2ndOrderPolynomial getFloat2ndOrderPoly_2() const + { + return m_Float2ndOrderPoly_2; + } + + Q_PROPERTY(Float2ndOrderPolynomial Float2ndOrderPoly_2 READ getFloat2ndOrderPoly_2 WRITE setFloat2ndOrderPoly_2) + + // ----------------------------------------------------------------------------- + void setFloat3rdOrderPoly_1(const Float3rdOrderPoly_t& value) + { + m_Float3rdOrderPoly_1 = value; + } + + // ----------------------------------------------------------------------------- + Float3rdOrderPoly_t getFloat3rdOrderPoly_1() const + { + return m_Float3rdOrderPoly_1; + } - SIMPL_INSTANCE_PROPERTY(Float3rdOrderPoly_t, Float3rdOrderPoly_1) Q_PROPERTY(Float3rdOrderPoly_t Float3rdOrderPoly_1 READ getFloat3rdOrderPoly_1 WRITE setFloat3rdOrderPoly_1) - SIMPL_INSTANCE_PROPERTY(Float3rdOrderPoly_t, Float3rdOrderPoly_2) + // ----------------------------------------------------------------------------- + void setFloat3rdOrderPoly_2(const Float3rdOrderPoly_t& value) + { + m_Float3rdOrderPoly_2 = value; + } + + // ----------------------------------------------------------------------------- + Float3rdOrderPoly_t getFloat3rdOrderPoly_2() const + { + return m_Float3rdOrderPoly_2; + } + Q_PROPERTY(Float3rdOrderPoly_t Float3rdOrderPoly_2 READ getFloat3rdOrderPoly_2 WRITE setFloat3rdOrderPoly_2) - SIMPL_INSTANCE_PROPERTY(Float4thOrderPoly_t, Float4thOrderPoly_1) - Q_PROPERTY(Float4thOrderPoly_t Float4thOrderPoly_1 READ getFloat4thOrderPoly_1 WRITE setFloat4thOrderPoly_1) - SIMPL_INSTANCE_PROPERTY(Float4thOrderPoly_t, Float4thOrderPoly_2) - Q_PROPERTY(Float4thOrderPoly_t Float4thOrderPoly_2 READ getFloat4thOrderPoly_2 WRITE setFloat4thOrderPoly_2) + // ----------------------------------------------------------------------------- + void setFloat4thOrderPoly_1(const Float4thOrderPolynomial& value) + { + m_Float4thOrderPoly_1 = value; + } + + // ----------------------------------------------------------------------------- + Float4thOrderPolynomial getFloat4thOrderPoly_1() const + { + return m_Float4thOrderPoly_1; + } + + Q_PROPERTY(Float4thOrderPolynomial Float4thOrderPoly_1 READ getFloat4thOrderPoly_1 WRITE setFloat4thOrderPoly_1) + // ----------------------------------------------------------------------------- + void setFloat4thOrderPoly_2(const Float4thOrderPolynomial& value) + { + m_Float4thOrderPoly_2 = value; + } + + // ----------------------------------------------------------------------------- + Float4thOrderPolynomial getFloat4thOrderPoly_2() const + { + return m_Float4thOrderPoly_2; + } + + Q_PROPERTY(Float4thOrderPolynomial Float4thOrderPoly_2 READ getFloat4thOrderPoly_2 WRITE setFloat4thOrderPoly_2) + + // ----------------------------------------------------------------------------- + void setDataArrayPaths1(const std::vector& value) + { + m_DataArrayPaths1 = value; + } + + // ----------------------------------------------------------------------------- + std::vector getDataArrayPaths1() const + { + return m_DataArrayPaths1; + } + + Q_PROPERTY(DataArrayPathVec DataArrayPaths1 READ getDataArrayPaths1 WRITE setDataArrayPaths1) + // ----------------------------------------------------------------------------- + void setDataArrayPaths2(const std::vector& value) + { + m_DataArrayPaths2 = value; + } - SIMPL_INSTANCE_PROPERTY(QVector, DataArrayPaths1) - Q_PROPERTY(QVector DataArrayPaths1 READ getDataArrayPaths1 WRITE setDataArrayPaths1) - SIMPL_INSTANCE_PROPERTY(QVector, DataArrayPaths2) - Q_PROPERTY(QVector DataArrayPaths2 READ getDataArrayPaths2 WRITE setDataArrayPaths2) + // ----------------------------------------------------------------------------- + std::vector getDataArrayPaths2() const + { + return m_DataArrayPaths2; + } + + Q_PROPERTY(DataArrayPathVec DataArrayPaths2 READ getDataArrayPaths2 WRITE setDataArrayPaths2) + + // ----------------------------------------------------------------------------- + void setShapeTypeVector_1(const ShapeType::Types& value) + { + m_ShapeTypeVector_1 = value; + } + + // ----------------------------------------------------------------------------- + ShapeType::Types getShapeTypeVector_1() const + { + return m_ShapeTypeVector_1; + } - SIMPL_INSTANCE_PROPERTY(ShapeType::Types, ShapeTypeVector_1) Q_PROPERTY(ShapeType::Types ShapeTypeVector_1 READ getShapeTypeVector_1 WRITE setShapeTypeVector_1) - SIMPL_INSTANCE_PROPERTY(ShapeType::Types, ShapeTypeVector_2) + // ----------------------------------------------------------------------------- + void setShapeTypeVector_2(const ShapeType::Types& value) + { + m_ShapeTypeVector_2 = value; + } + + // ----------------------------------------------------------------------------- + ShapeType::Types getShapeTypeVector_2() const + { + return m_ShapeTypeVector_2; + } + Q_PROPERTY(ShapeType::Types ShapeTypeVector_2 READ getShapeTypeVector_2 WRITE setShapeTypeVector_2) - SIMPL_INSTANCE_PROPERTY(PhaseType::Types, PhaseTypeVector_1) + // ----------------------------------------------------------------------------- + void setPhaseTypeVector_1(const PhaseType::Types& value) + { + m_PhaseTypeVector_1 = value; + } + + // ----------------------------------------------------------------------------- + PhaseType::Types getPhaseTypeVector_1() const + { + return m_PhaseTypeVector_1; + } + Q_PROPERTY(PhaseType::Types::Types PhaseTypeVector_1 READ getPhaseTypeVector_1 WRITE setPhaseTypeVector_1) - SIMPL_INSTANCE_PROPERTY(PhaseType::Types, PhaseTypeVector_2) + // ----------------------------------------------------------------------------- + void setPhaseTypeVector_2(const PhaseType::Types& value) + { + m_PhaseTypeVector_2 = value; + } + + // ----------------------------------------------------------------------------- + PhaseType::Types getPhaseTypeVector_2() const + { + return m_PhaseTypeVector_2; + } + Q_PROPERTY(PhaseType::Types PhaseTypeVector_2 READ getPhaseTypeVector_2 WRITE setPhaseTypeVector_2) // SIMPL_INSTANCE_PROPERTY(UInt32Vector_t, UInt32Vector_1) @@ -325,12 +745,32 @@ class FilterParametersRWTest // SIMPL_INSTANCE_PROPERTY(UInt32Vector_t, UInt32Vector_2) // Q_PROPERTY(UInt32Vector_t UInt32Vector_2 READ getUInt32Vector_2 WRITE setUInt32Vector_2) - typedef QPair DoublesPair; + // ----------------------------------------------------------------------------- + void setPair1(const FPRangePair& value) + { + m_Pair1 = value; + } + + // ----------------------------------------------------------------------------- + FPRangePair getPair1() const + { + return m_Pair1; + } + + Q_PROPERTY(FPRangePair Pair1 READ getPair1 WRITE setPair1) + // ----------------------------------------------------------------------------- + void setPair2(const FPRangePair& value) + { + m_Pair2 = value; + } + + // ----------------------------------------------------------------------------- + FPRangePair getPair2() const + { + return m_Pair2; + } - SIMPL_INSTANCE_PROPERTY(DoublesPair, Pair1) - Q_PROPERTY(DoublesPair Pair1 READ getPair1 WRITE setPair1) - SIMPL_INSTANCE_PROPERTY(DoublesPair, Pair2) - Q_PROPERTY(DoublesPair Pair2 READ getPair2 WRITE setPair2) + Q_PROPERTY(FPRangePair Pair2 READ getPair2 WRITE setPair2) // ----------------------------------------------------------------------------- // @@ -350,8 +790,8 @@ class FilterParametersRWTest { AttributeMatrixCreationFilterParameter::RequirementType req; AttributeMatrixCreationFilterParameter::Pointer fp = - AttributeMatrixCreationFilterParameter::New("Test", "ArrayPath1", getArrayPath1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, ArrayPath2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, ArrayPath1), req); + AttributeMatrixCreationFilterParameter::Create("Test", "ArrayPath1", getArrayPath1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, ArrayPath2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, ArrayPath1), req); QJsonObject obj; fp->writeJson(obj); @@ -367,8 +807,8 @@ class FilterParametersRWTest { AttributeMatrixSelectionFilterParameter::RequirementType req; AttributeMatrixSelectionFilterParameter::Pointer fp = - AttributeMatrixSelectionFilterParameter::New("Test", "ArrayPath1", getArrayPath1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, ArrayPath2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, ArrayPath1), req); + AttributeMatrixSelectionFilterParameter::Create("Test", "ArrayPath1", getArrayPath1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, ArrayPath2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, ArrayPath1), req); QJsonObject obj; fp->writeJson(obj); @@ -382,8 +822,8 @@ class FilterParametersRWTest } { - AxisAngleFilterParameter::Pointer fp = AxisAngleFilterParameter::New("Test", "AxisAngle1", getAxisAngle1(), FilterParameter::Parameter, - SIMPL_BIND_SETTER(FilterParametersRWTest, this, AxisAngle2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, AxisAngle1)); + AxisAngleFilterParameter::Pointer fp = AxisAngleFilterParameter::Create("Test", "AxisAngle1", getAxisAngle1(), FilterParameter::Category::Parameter, + SIMPL_BIND_SETTER(FilterParametersRWTest, this, AxisAngle2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, AxisAngle1)); QJsonObject obj; fp->writeJson(obj); @@ -394,12 +834,12 @@ class FilterParametersRWTest DREAM3D_REQUIRE_EQUAL(m_AxisAngle1.k, m_AxisAngle2.k) DREAM3D_REQUIRE_EQUAL(m_AxisAngle1.l, m_AxisAngle2.l) - m_AxisAngle2 = AxisAngleInput_t(); + m_AxisAngle2 = AxisAngleInput(); } { - BooleanFilterParameter::Pointer fp = BooleanFilterParameter::New("Test", "Bool1", getBool1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Bool2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, Bool1)); + BooleanFilterParameter::Pointer fp = BooleanFilterParameter::Create("Test", "Bool1", getBool1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Bool2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, Bool1)); QJsonObject obj; fp->writeJson(obj); @@ -411,8 +851,8 @@ class FilterParametersRWTest } { - CalculatorFilterParameter::Pointer fp = CalculatorFilterParameter::New("Test", "String1", getString1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); + CalculatorFilterParameter::Pointer fp = CalculatorFilterParameter::Create("Test", "String1", getString1(), FilterParameter::Category::Parameter, + SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); QJsonObject obj; fp->writeJson(obj); @@ -424,8 +864,8 @@ class FilterParametersRWTest } { - ChoiceFilterParameter::Pointer fp = ChoiceFilterParameter::New("Test", "Int1", getInt1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Int2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, Int1), QVector(), true); + ChoiceFilterParameter::Pointer fp = ChoiceFilterParameter::Create("Test", "Int1", getInt1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Int2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, Int1), std::vector(), true); QJsonObject obj; fp->writeJson(obj); @@ -437,9 +877,9 @@ class FilterParametersRWTest } { - ComparisonSelectionFilterParameter::Pointer fp = - ComparisonSelectionFilterParameter::New("Test", "ComparisonInputs1", ComparisonInputs(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, ComparisonInputs2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, ComparisonInputs1), QVector(), true); + ComparisonSelectionFilterParameter::Pointer fp = ComparisonSelectionFilterParameter::Create("Test", "ComparisonInputs1", ComparisonInputs(), FilterParameter::Category::Parameter, + SIMPL_BIND_SETTER(FilterParametersRWTest, this, ComparisonInputs2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, ComparisonInputs1), std::vector(), true); QJsonObject obj; fp->writeJson(obj); @@ -463,8 +903,8 @@ class FilterParametersRWTest { DataArrayCreationFilterParameter::RequirementType req; DataArrayCreationFilterParameter::Pointer fp = - DataArrayCreationFilterParameter::New("Test", "ArrayPath1", getArrayPath1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, ArrayPath2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, ArrayPath1), req); + DataArrayCreationFilterParameter::Create("Test", "ArrayPath1", getArrayPath1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, ArrayPath2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, ArrayPath1), req); QJsonObject obj; fp->writeJson(obj); @@ -480,8 +920,8 @@ class FilterParametersRWTest { DataArraySelectionFilterParameter::RequirementType req; DataArraySelectionFilterParameter::Pointer fp = - DataArraySelectionFilterParameter::New("Test", "ArrayPath1", getArrayPath1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, ArrayPath2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, ArrayPath1), req); + DataArraySelectionFilterParameter::Create("Test", "ArrayPath1", getArrayPath1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, ArrayPath2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, ArrayPath1), req); QJsonObject obj; fp->writeJson(obj); @@ -496,8 +936,8 @@ class FilterParametersRWTest { DataContainerArrayProxyFilterParameter::Pointer fp = - DataContainerArrayProxyFilterParameter::New("Test", "String1", DataContainerArrayProxy(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, DcaProxy2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, DcaProxy1), DataContainerArrayProxy(), Qt::Checked); + DataContainerArrayProxyFilterParameter::Create("Test", "String1", DataContainerArrayProxy(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, DcaProxy2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, DcaProxy1), DataContainerArrayProxy(), Qt::Checked); QJsonObject obj; fp->writeJson(obj); @@ -512,35 +952,35 @@ class FilterParametersRWTest } { - DataContainerCreationFilterParameter::Pointer fp = DataContainerCreationFilterParameter::New( - "Test", "String1", getString1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); + DataContainerCreationFilterParameter::Pointer fp = DataContainerCreationFilterParameter::Create( + "Test", "Path1", getPath1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Path2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, Path1)); QJsonObject obj; fp->writeJson(obj); fp->readJson(obj); - DREAM3D_REQUIRE_EQUAL(m_String1, m_String2) + DREAM3D_REQUIRE_EQUAL(m_Path1, m_Path2) m_String2.clear(); } { DataContainerSelectionFilterParameter::RequirementType req; - DataContainerSelectionFilterParameter::Pointer fp = DataContainerSelectionFilterParameter::New( - "Test", "String1", getString1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1), req); + DataContainerSelectionFilterParameter::Pointer fp = DataContainerSelectionFilterParameter::Create( + "Test", "Path1", getPath1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Path2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, Path1), req); QJsonObject obj; fp->writeJson(obj); fp->readJson(obj); - DREAM3D_REQUIRE_EQUAL(m_String1, m_String2) + DREAM3D_REQUIRE_EQUAL(m_Path1, m_Path2) m_String2.clear(); } { - DoubleFilterParameter::Pointer fp = DoubleFilterParameter::New("Test", "Double1", getDouble1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Double2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, Double1)); + DoubleFilterParameter::Pointer fp = DoubleFilterParameter::Create("Test", "Double1", getDouble1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Double2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, Double1)); QJsonObject obj; fp->writeJson(obj); @@ -552,8 +992,9 @@ class FilterParametersRWTest } { - DynamicChoiceFilterParameter::Pointer fp = DynamicChoiceFilterParameter::New( - "Test", "String1", getString1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1), ""); + DynamicChoiceFilterParameter::Pointer fp = + DynamicChoiceFilterParameter::Create("Test", "String1", getString1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1), ""); QJsonObject obj; fp->writeJson(obj); @@ -566,8 +1007,8 @@ class FilterParametersRWTest { DynamicTableFilterParameter::Pointer fp = - DynamicTableFilterParameter::New("Test", "DynamicData1", DynamicTableData(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, DynamicData2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, DynamicData1)); + DynamicTableFilterParameter::Create("Test", "DynamicData1", DynamicTableData(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, DynamicData2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, DynamicData1)); QJsonObject obj; fp->writeJson(obj); @@ -583,8 +1024,8 @@ class FilterParametersRWTest { FileListInfoFilterParameter::Pointer fp = - FileListInfoFilterParameter::New("Test", "FileListInfo1", FileListInfo_t(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, FileListInfo2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, FileListInfo1)); + FileListInfoFilterParameter::Create("Test", "FileListInfo1", StackFileListInfo(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, FileListInfo2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, FileListInfo1)); QJsonObject obj; fp->writeJson(obj); @@ -599,28 +1040,29 @@ class FilterParametersRWTest DREAM3D_REQUIRE_EQUAL(m_FileListInfo1.PaddingDigits, m_FileListInfo2.PaddingDigits) DREAM3D_REQUIRE_EQUAL(m_FileListInfo1.StartIndex, m_FileListInfo2.StartIndex) - m_FileListInfo2 = FileListInfo_t(); + m_FileListInfo2 = StackFileListInfo(); } { - FloatVec3FilterParameter::Pointer fp = FloatVec3FilterParameter::New("Test", "FloatVec3_1", FloatVec3_t(), FilterParameter::Parameter, - SIMPL_BIND_SETTER(FilterParametersRWTest, this, FloatVec3_2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, FloatVec3_1)); + FloatVec3FilterParameter::Pointer fp = + FloatVec3FilterParameter::Create("Test", "FloatVec3_1", FloatVec3Type(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, FloatVec3_2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, FloatVec3_1)); QJsonObject obj; fp->writeJson(obj); fp->readJson(obj); - DREAM3D_REQUIRE_EQUAL(m_FloatVec3_1.x, m_FloatVec3_2.x) - DREAM3D_REQUIRE_EQUAL(m_FloatVec3_1.y, m_FloatVec3_2.y) - DREAM3D_REQUIRE_EQUAL(m_FloatVec3_1.z, m_FloatVec3_2.z) + DREAM3D_REQUIRE_EQUAL(m_FloatVec3_1[0], m_FloatVec3_2[0]) + DREAM3D_REQUIRE_EQUAL(m_FloatVec3_1[1], m_FloatVec3_2[1]) + DREAM3D_REQUIRE_EQUAL(m_FloatVec3_1[2], m_FloatVec3_2[2]) - m_FloatVec3_2 = FloatVec3_t(); + m_FloatVec3_2 = FloatVec3Type(); } { FourthOrderPolynomialFilterParameter::Pointer fp = - FourthOrderPolynomialFilterParameter::New("Test", "Float4thOrderPoly_1", Float4thOrderPoly_t(), FilterParameter::Parameter, - SIMPL_BIND_SETTER(FilterParametersRWTest, this, Float4thOrderPoly_2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, Float4thOrderPoly_1)); + FourthOrderPolynomialFilterParameter::Create("Test", "Float4thOrderPoly_1", Float4thOrderPolynomial(), FilterParameter::Category::Parameter, + SIMPL_BIND_SETTER(FilterParametersRWTest, this, Float4thOrderPoly_2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, Float4thOrderPoly_1)); QJsonObject obj; fp->writeJson(obj); @@ -642,12 +1084,12 @@ class FilterParametersRWTest DREAM3D_REQUIRE_EQUAL(m_Float4thOrderPoly_1.c31, m_Float4thOrderPoly_2.c31) DREAM3D_REQUIRE_EQUAL(m_Float4thOrderPoly_1.c40, m_Float4thOrderPoly_2.c40) - m_Float4thOrderPoly_2 = Float4thOrderPoly_t(); + m_Float4thOrderPoly_2 = Float4thOrderPolynomial(); } { - InputFileFilterParameter::Pointer fp = InputFileFilterParameter::New("Test", "String1", getString1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); + InputFileFilterParameter::Pointer fp = InputFileFilterParameter::Create("Test", "String1", getString1(), FilterParameter::Category::Parameter, + SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); QJsonObject obj; fp->writeJson(obj); @@ -659,8 +1101,8 @@ class FilterParametersRWTest } { - InputPathFilterParameter::Pointer fp = InputPathFilterParameter::New("Test", "String1", getString1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); + InputPathFilterParameter::Pointer fp = InputPathFilterParameter::Create("Test", "String1", getString1(), FilterParameter::Category::Parameter, + SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); QJsonObject obj; fp->writeJson(obj); @@ -672,8 +1114,8 @@ class FilterParametersRWTest } { - IntFilterParameter::Pointer fp = - IntFilterParameter::New("Test", "Int1", getInt1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Int2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, Int1)); + IntFilterParameter::Pointer fp = IntFilterParameter::Create("Test", "Int1", getInt1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Int2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, Int1)); QJsonObject obj; fp->writeJson(obj); @@ -685,23 +1127,24 @@ class FilterParametersRWTest } { - IntVec3FilterParameter::Pointer fp = IntVec3FilterParameter::New("Test", "IntVec3_1", IntVec3_t(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, IntVec3_2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, IntVec3_1)); + IntVec3FilterParameter::Pointer fp = IntVec3FilterParameter::Create("Test", "IntVec3_1", IntVec3Type(), FilterParameter::Category::Parameter, + SIMPL_BIND_SETTER(FilterParametersRWTest, this, IntVec3_2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, IntVec3_1)); QJsonObject obj; fp->writeJson(obj); fp->readJson(obj); - DREAM3D_REQUIRE_EQUAL(m_IntVec3_1.x, m_IntVec3_2.x) - DREAM3D_REQUIRE_EQUAL(m_IntVec3_1.y, m_IntVec3_2.y) - DREAM3D_REQUIRE_EQUAL(m_IntVec3_1.z, m_IntVec3_2.z) + DREAM3D_REQUIRE_EQUAL(m_IntVec3_1[0], m_IntVec3_2[0]) + DREAM3D_REQUIRE_EQUAL(m_IntVec3_1[1], m_IntVec3_2[1]) + DREAM3D_REQUIRE_EQUAL(m_IntVec3_1[2], m_IntVec3_2[2]) - m_IntVec3_2 = IntVec3_t(); + m_IntVec3_2 = IntVec3Type(); } { - LinkedBooleanFilterParameter::Pointer fp = LinkedBooleanFilterParameter::New("Test", "Bool1", getBool1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Bool2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, Bool1), QStringList()); + LinkedBooleanFilterParameter::Pointer fp = + LinkedBooleanFilterParameter::Create("Test", "Bool1", getBool1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Bool2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, Bool1), std::vector()); QJsonObject obj; fp->writeJson(obj); @@ -713,8 +1156,9 @@ class FilterParametersRWTest } { - LinkedChoicesFilterParameter::Pointer fp = LinkedChoicesFilterParameter::New("Test", "Int1", getInt1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Int2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, Int1), QVector(), QStringList()); + LinkedChoicesFilterParameter::Pointer fp = + LinkedChoicesFilterParameter::Create("Test", "Int1", getInt1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Int2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, Int1), std::vector(), std::vector()); QJsonObject obj; fp->writeJson(obj); @@ -728,8 +1172,8 @@ class FilterParametersRWTest { MultiDataArraySelectionFilterParameter::RequirementType req; MultiDataArraySelectionFilterParameter::Pointer fp = - MultiDataArraySelectionFilterParameter::New("Test", "DataArrayPaths1", getDataArrayPaths1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, DataArrayPaths2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, DataArrayPaths1), req); + MultiDataArraySelectionFilterParameter::Create("Test", "DataArrayPaths1", getDataArrayPaths1(), FilterParameter::Category::Parameter, + SIMPL_BIND_SETTER(FilterParametersRWTest, this, DataArrayPaths2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, DataArrayPaths1), req); QJsonObject obj; fp->writeJson(obj); @@ -737,19 +1181,19 @@ class FilterParametersRWTest DREAM3D_REQUIRE_EQUAL(m_DataArrayPaths1.size(), m_DataArrayPaths2.size()) - for(int i = 0; i < m_DataArrayPaths1.size(); i++) + for(size_t i = 0; i < m_DataArrayPaths1.size(); i++) { DREAM3D_REQUIRE_EQUAL(m_DataArrayPaths1[i].getDataContainerName(), m_DataArrayPaths2[i].getDataContainerName()) DREAM3D_REQUIRE_EQUAL(m_DataArrayPaths1[i].getAttributeMatrixName(), m_DataArrayPaths2[i].getAttributeMatrixName()) DREAM3D_REQUIRE_EQUAL(m_DataArrayPaths1[i].getDataArrayName(), m_DataArrayPaths2[i].getDataArrayName()) } - m_DataArrayPaths2 = QVector(); + m_DataArrayPaths2 = std::vector(); } { - OutputFileFilterParameter::Pointer fp = OutputFileFilterParameter::New("Test", "String1", getString1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); + OutputFileFilterParameter::Pointer fp = OutputFileFilterParameter::Create("Test", "String1", getString1(), FilterParameter::Category::Parameter, + SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); QJsonObject obj; fp->writeJson(obj); @@ -761,8 +1205,8 @@ class FilterParametersRWTest } { - OutputPathFilterParameter::Pointer fp = OutputPathFilterParameter::New("Test", "String1", getString1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); + OutputPathFilterParameter::Pointer fp = OutputPathFilterParameter::Create("Test", "String1", getString1(), FilterParameter::Category::Parameter, + SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); QJsonObject obj; fp->writeJson(obj); @@ -774,9 +1218,9 @@ class FilterParametersRWTest } { - PhaseTypeSelectionFilterParameter::Pointer fp = - PhaseTypeSelectionFilterParameter::New("Test", "PhaseTypeVector_2", DataArrayPath(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, PhaseTypeVector_2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, PhaseTypeVector_1), "", "", "", QStringList()); + PhaseTypeSelectionFilterParameter::Pointer fp = PhaseTypeSelectionFilterParameter::Create("Test", "PhaseTypeVector_2", DataArrayPath(), FilterParameter::Category::Parameter, + SIMPL_BIND_SETTER(FilterParametersRWTest, this, PhaseTypeVector_2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, PhaseTypeVector_1), "", "", "", std::vector()); QJsonObject obj; fp->writeJson(obj); @@ -792,9 +1236,11 @@ class FilterParametersRWTest // m_PhaseTypeVector_2 = PhaseTypeVector_t(); // Does this line do anything? } +#if 0 +This Filter Parameter is NOT tesed since nothing is read or written for the filter parameter. { PreflightUpdatedValueFilterParameter::Pointer fp = - PreflightUpdatedValueFilterParameter::New("Test", "String2", getString1(), FilterParameter::Parameter, SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); + PreflightUpdatedValueFilterParameter::Create("Test", "String2", getString1(), FilterParameter::Category::Parameter, SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); QJsonObject obj; fp->writeJson(obj); @@ -808,10 +1254,10 @@ class FilterParametersRWTest DREAM3D_REQUIRE_EQUAL(m_String1, result) } - +#endif { - RangeFilterParameter::Pointer fp = RangeFilterParameter::New("Test", "Pair1", getPair1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Pair2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, Pair1)); + RangeFilterParameter::Pointer fp = RangeFilterParameter::Create("Test", "Pair1", getPair1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, Pair2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, Pair1)); QJsonObject obj; fp->writeJson(obj); @@ -820,13 +1266,13 @@ class FilterParametersRWTest DREAM3D_REQUIRE_EQUAL(m_Pair1.first, m_Pair2.first) DREAM3D_REQUIRE_EQUAL(m_Pair1.second, m_Pair2.second) - m_Pair2 = DoublesPair(); + m_Pair2 = FPRangePair(); } { SecondOrderPolynomialFilterParameter::Pointer fp = - SecondOrderPolynomialFilterParameter::New("Test", "Float2ndOrderPoly_1", Float2ndOrderPoly_t(), FilterParameter::Parameter, - SIMPL_BIND_SETTER(FilterParametersRWTest, this, Float2ndOrderPoly_2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, Float2ndOrderPoly_1)); + SecondOrderPolynomialFilterParameter::Create("Test", "Float2ndOrderPoly_1", Float2ndOrderPolynomial(), FilterParameter::Category::Parameter, + SIMPL_BIND_SETTER(FilterParametersRWTest, this, Float2ndOrderPoly_2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, Float2ndOrderPoly_1)); QJsonObject obj; fp->writeJson(obj); @@ -839,17 +1285,15 @@ class FilterParametersRWTest DREAM3D_REQUIRE_EQUAL(m_Float2ndOrderPoly_1.c11, m_Float2ndOrderPoly_2.c11) DREAM3D_REQUIRE_EQUAL(m_Float2ndOrderPoly_1.c20, m_Float2ndOrderPoly_2.c20) - m_Float2ndOrderPoly_2 = Float2ndOrderPoly_t(); + m_Float2ndOrderPoly_2 = Float2ndOrderPolynomial(); } #if 0 { ShapeType::Types shapeData; ShapeTypeSelectionFilterParameter::Pointer fp = - ShapeTypeSelectionFilterParameter::New("Test", "String1", shapeData, FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, ShapeType::Types), + ShapeTypeSelectionFilterParameter::Create("Test", "String1", shapeData, FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, ShapeType::Types), SIMPL_BIND_GETTER(FilterParametersRWTest, this, ShapeType::Types), "String1", ""); - //SIMPL_NEW_SHAPETYPE_SELECTION_FP("Shape Types", ShapeTypeData, FilterParameter::CreatedArray, EstablishShapeTypes, "PhaseCount", "InputPhaseTypesArrayPath"); - QJsonObject obj; fp->writeJson(obj); fp->readJson(obj); @@ -865,8 +1309,8 @@ class FilterParametersRWTest } #endif { - StringFilterParameter::Pointer fp = StringFilterParameter::New("Test", "String1", getString1(), FilterParameter::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), - SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); + StringFilterParameter::Pointer fp = StringFilterParameter::Create("Test", "String1", getString1(), FilterParameter::Category::Parameter, SIMPL_BIND_SETTER(FilterParametersRWTest, this, String2), + SIMPL_BIND_GETTER(FilterParametersRWTest, this, String1)); QJsonObject obj; fp->writeJson(obj); @@ -879,8 +1323,8 @@ class FilterParametersRWTest { ThirdOrderPolynomialFilterParameter::Pointer fp = - ThirdOrderPolynomialFilterParameter::New("Test", "Float3rdOrderPoly_1", Float3rdOrderPoly_t(), FilterParameter::Parameter, - SIMPL_BIND_SETTER(FilterParametersRWTest, this, Float3rdOrderPoly_2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, Float3rdOrderPoly_1)); + ThirdOrderPolynomialFilterParameter::Create("Test", "Float3rdOrderPoly_1", Float3rdOrderPoly_t(), FilterParameter::Category::Parameter, + SIMPL_BIND_SETTER(FilterParametersRWTest, this, Float3rdOrderPoly_2), SIMPL_BIND_GETTER(FilterParametersRWTest, this, Float3rdOrderPoly_1)); QJsonObject obj; fp->writeJson(obj); @@ -968,6 +1412,47 @@ class FilterParametersRWTest } private: + bool m_Bool1 = {}; + bool m_Bool2 = {}; + int m_Int1 = {}; + int m_Int2 = {}; + double m_Double1 = {}; + double m_Double2 = {}; + QString m_String1 = {}; + QString m_String2 = {}; + DataArrayPath m_Path1 = {}; + DataArrayPath m_Path2 = {}; + DataArrayPath m_ArrayPath1 = {}; + DataArrayPath m_ArrayPath2 = {}; + AxisAngleInput m_AxisAngle1 = {}; + AxisAngleInput m_AxisAngle2 = {}; + ComparisonInputs m_ComparisonInputs1 = {}; + ComparisonInputs m_ComparisonInputs2 = {}; + DataContainerArrayProxy m_DcaProxy1 = {}; + DataContainerArrayProxy m_DcaProxy2 = {}; + DynamicTableData m_DynamicData1 = {}; + DynamicTableData m_DynamicData2 = {}; + StackFileListInfo m_FileListInfo1 = {}; + StackFileListInfo m_FileListInfo2 = {}; + IntVec3Type m_IntVec3_1 = {}; + IntVec3Type m_IntVec3_2 = {}; + FloatVec3Type m_FloatVec3_1 = {}; + FloatVec3Type m_FloatVec3_2 = {}; + Float2ndOrderPolynomial m_Float2ndOrderPoly_1 = {}; + Float2ndOrderPolynomial m_Float2ndOrderPoly_2 = {}; + Float3rdOrderPoly_t m_Float3rdOrderPoly_1 = {}; + Float3rdOrderPoly_t m_Float3rdOrderPoly_2 = {}; + Float4thOrderPolynomial m_Float4thOrderPoly_1 = {}; + Float4thOrderPolynomial m_Float4thOrderPoly_2 = {}; + std::vector m_DataArrayPaths1 = {}; + std::vector m_DataArrayPaths2 = {}; + ShapeType::Types m_ShapeTypeVector_1 = {}; + ShapeType::Types m_ShapeTypeVector_2 = {}; + PhaseType::Types m_PhaseTypeVector_1 = {}; + PhaseType::Types m_PhaseTypeVector_2 = {}; + FPRangePair m_Pair1 = {}; + FPRangePair m_Pair2 = {}; + FilterParametersRWTest(const FilterParametersRWTest&); // Copy Constructor Not Implemented void operator=(const FilterParametersRWTest&); // Move assignment Not Implemented }; diff --git a/Source/SIMPLib/FilterParameters/ThirdOrderPolynomial.h b/Source/SIMPLib/FilterParameters/ThirdOrderPolynomial.h index 0985e413a6..762856ed53 100644 --- a/Source/SIMPLib/FilterParameters/ThirdOrderPolynomial.h +++ b/Source/SIMPLib/FilterParameters/ThirdOrderPolynomial.h @@ -31,20 +31,20 @@ #include -typedef struct +struct Float3rdOrderPoly_t { - float c30; - float c03; - float c21; - float c12; - float c20; - float c02; - float c11; - float c10; - float c01; - float c00; + float c30 = 0.0f; + float c03 = 0.0f; + float c21 = 0.0f; + float c12 = 0.0f; + float c20 = 0.0f; + float c02 = 0.0f; + float c11 = 0.0f; + float c10 = 0.0f; + float c01 = 0.0f; + float c00 = 0.0f; - void writeJson(QJsonObject& json) + void writeJson(QJsonObject& json) const { json["c30"] = c30; json["c03"] = c03; @@ -58,7 +58,7 @@ typedef struct json["c00"] = c00; } - bool readJson(QJsonObject& json) + bool readJson(const QJsonObject& json) { if(json["c30"].isDouble() && json["c03"].isDouble() && json["c21"].isDouble() && json["c12"].isDouble() && json["c20"].isDouble() && json["c02"].isDouble() && json["c11"].isDouble() && json["c10"].isDouble() && json["c01"].isDouble() && json["c00"].isDouble()) @@ -77,6 +77,6 @@ typedef struct } return false; } -} Float3rdOrderPoly_t; +}; Q_DECLARE_METATYPE(Float3rdOrderPoly_t) diff --git a/Source/SIMPLib/FilterParameters/ThirdOrderPolynomialFilterParameter.cpp b/Source/SIMPLib/FilterParameters/ThirdOrderPolynomialFilterParameter.cpp index a2d51dc26c..2016f1829c 100644 --- a/Source/SIMPLib/FilterParameters/ThirdOrderPolynomialFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/ThirdOrderPolynomialFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ThirdOrderPolynomialFilterParameter.h" @@ -48,8 +48,9 @@ ThirdOrderPolynomialFilterParameter::~ThirdOrderPolynomialFilterParameter() = de // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ThirdOrderPolynomialFilterParameter::Pointer ThirdOrderPolynomialFilterParameter::New(const QString& humanLabel, const QString& propertyName, const Float3rdOrderPoly_t& defaultValue, - Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, int groupIndex) +ThirdOrderPolynomialFilterParameter::Pointer ThirdOrderPolynomialFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const Float3rdOrderPoly_t& defaultValue, + Category category, const SetterCallbackType& setterCallback, const GetterCallbackType& getterCallback, + int groupIndex) { ThirdOrderPolynomialFilterParameter::Pointer ptr = ThirdOrderPolynomialFilterParameter::New(); @@ -80,6 +81,10 @@ QString ThirdOrderPolynomialFilterParameter::getWidgetType() const void ThirdOrderPolynomialFilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { QJsonObject obj = jsonValue.toObject(); @@ -92,9 +97,9 @@ void ThirdOrderPolynomialFilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ThirdOrderPolynomialFilterParameter::writeJson(QJsonObject& json) +void ThirdOrderPolynomialFilterParameter::writeJson(QJsonObject& json) const { - if (m_GetterCallback) + if(m_GetterCallback) { Float3rdOrderPoly_t poly = m_GetterCallback(); QJsonObject obj; @@ -102,3 +107,52 @@ void ThirdOrderPolynomialFilterParameter::writeJson(QJsonObject& json) json[getPropertyName()] = obj; } } + +// ----------------------------------------------------------------------------- +ThirdOrderPolynomialFilterParameter::Pointer ThirdOrderPolynomialFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +ThirdOrderPolynomialFilterParameter::Pointer ThirdOrderPolynomialFilterParameter::New() +{ + Pointer sharedPtr(new(ThirdOrderPolynomialFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString ThirdOrderPolynomialFilterParameter::getNameOfClass() const +{ + return QString("ThirdOrderPolynomialFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString ThirdOrderPolynomialFilterParameter::ClassName() +{ + return QString("ThirdOrderPolynomialFilterParameter"); +} + +// ----------------------------------------------------------------------------- +void ThirdOrderPolynomialFilterParameter::setSetterCallback(const ThirdOrderPolynomialFilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ThirdOrderPolynomialFilterParameter::SetterCallbackType ThirdOrderPolynomialFilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void ThirdOrderPolynomialFilterParameter::setGetterCallback(const ThirdOrderPolynomialFilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +ThirdOrderPolynomialFilterParameter::GetterCallbackType ThirdOrderPolynomialFilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/ThirdOrderPolynomialFilterParameter.h b/Source/SIMPLib/FilterParameters/ThirdOrderPolynomialFilterParameter.h old mode 100755 new mode 100644 index ac537bc7c6..8377834042 --- a/Source/SIMPLib/FilterParameters/ThirdOrderPolynomialFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/ThirdOrderPolynomialFilterParameter.h @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" @@ -50,12 +52,10 @@ * SIMPL_NEW_ThirdO_POLY_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): - * SIMPL_NEW_ThirdO_POLY_FP("Third Order A Coefficients", ThirdOrderACoeff, FilterParameter::Parameter, WarpRegularGrid, 1); + * SIMPL_NEW_ThirdO_POLY_FP("Third Order A Coefficients", ThirdOrderACoeff, FilterParameter::Category::Parameter, WarpRegularGrid, 1); */ -#define SIMPL_NEW_ThirdO_POLY_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (ThirdOrderPolynomialFilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_ThirdO_POLY_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(ThirdOrderPolynomialFilterParameter, __VA_ARGS__)) /** * @brief The ThirdOrderPolynomialFilterParameter class is used by filters to instantiate an ThirdOrderPolynomialWidget. By instantiating an instance of @@ -63,10 +63,32 @@ */ class SIMPLib_EXPORT ThirdOrderPolynomialFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(ThirdOrderPolynomialFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(ThirdOrderPolynomialFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(ThirdOrderPolynomialFilterParameter) - SIMPL_STATIC_NEW_MACRO(ThirdOrderPolynomialFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ThirdOrderPolynomialFilterParameter, FilterParameter) + using Self = ThirdOrderPolynomialFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for ThirdOrderPolynomialFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ThirdOrderPolynomialFilterParameter + */ + static QString ClassName(); typedef std::function SetterCallbackType; typedef std::function GetterCallbackType; @@ -87,57 +109,74 @@ class SIMPLib_EXPORT ThirdOrderPolynomialFilterParameter : public FilterParamete * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. * @return */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const Float3rdOrderPoly_t& defaultValue, Category category, - SetterCallbackType setterCallback, GetterCallbackType getterCallback, - int groupIndex = -1); + static Pointer Create(const QString& humanLabel, const QString& propertyName, const Float3rdOrderPoly_t& defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); - ~ThirdOrderPolynomialFilterParameter() override; + ~ThirdOrderPolynomialFilterParameter() override; /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @return The SetterCallback - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - protected: - /** - * @brief ThirdOrderPolynomialFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @return The SetterCallback + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const ThirdOrderPolynomialFilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + ThirdOrderPolynomialFilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const ThirdOrderPolynomialFilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + ThirdOrderPolynomialFilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief ThirdOrderPolynomialFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ ThirdOrderPolynomialFilterParameter(); public: - ThirdOrderPolynomialFilterParameter(const ThirdOrderPolynomialFilterParameter&) = delete; // Copy Constructor Not Implemented - ThirdOrderPolynomialFilterParameter(ThirdOrderPolynomialFilterParameter&&) = delete; // Move Constructor Not Implemented + ThirdOrderPolynomialFilterParameter(const ThirdOrderPolynomialFilterParameter&) = delete; // Copy Constructor Not Implemented + ThirdOrderPolynomialFilterParameter(ThirdOrderPolynomialFilterParameter&&) = delete; // Move Constructor Not Implemented ThirdOrderPolynomialFilterParameter& operator=(const ThirdOrderPolynomialFilterParameter&) = delete; // Copy Assignment Not Implemented ThirdOrderPolynomialFilterParameter& operator=(ThirdOrderPolynomialFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +private: + ThirdOrderPolynomialFilterParameter::SetterCallbackType m_SetterCallback = {}; + ThirdOrderPolynomialFilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/UInt64FilterParameter.cpp b/Source/SIMPLib/FilterParameters/UInt64FilterParameter.cpp index 7dbdd12d14..4a7eece35e 100644 --- a/Source/SIMPLib/FilterParameters/UInt64FilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/UInt64FilterParameter.cpp @@ -1,35 +1,35 @@ /* ============================================================================ -* Copyright (c) 2019-2019 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-15-D-5231 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2019-2019 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "UInt64FilterParameter.h" @@ -46,8 +46,8 @@ UInt64FilterParameter::~UInt64FilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -UInt64FilterParameter::Pointer UInt64FilterParameter::New(const QString& humanLabel, const QString& propertyName, uint64_t defaultValue, Category category, SetterCallbackType setterCallback, - GetterCallbackType getterCallback, int groupIndex) +UInt64FilterParameter::Pointer UInt64FilterParameter::Create(const QString& humanLabel, const QString& propertyName, uint64_t defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex) { UInt64FilterParameter::Pointer ptr = UInt64FilterParameter::New(); @@ -76,6 +76,10 @@ QString UInt64FilterParameter::getWidgetType() const void UInt64FilterParameter::readJson(const QJsonObject& json) { QJsonValue jsonValue = json[getPropertyName()]; + if(jsonValue.isUndefined()) + { + jsonValue = json[getLegacyPropertyName()]; + } if(!jsonValue.isUndefined() && m_SetterCallback) { bool ok = false; @@ -87,7 +91,7 @@ void UInt64FilterParameter::readJson(const QJsonObject& json) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void UInt64FilterParameter::writeJson(QJsonObject& json) +void UInt64FilterParameter::writeJson(QJsonObject& json) const { if(m_GetterCallback) { @@ -96,3 +100,52 @@ void UInt64FilterParameter::writeJson(QJsonObject& json) json[getPropertyName()] = strvalue; // Store the value as a string so we maintain all the fidelity of the value } } + +// ----------------------------------------------------------------------------- +UInt64FilterParameter::Pointer UInt64FilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +UInt64FilterParameter::Pointer UInt64FilterParameter::New() +{ + Pointer sharedPtr(new(UInt64FilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString UInt64FilterParameter::getNameOfClass() const +{ + return QString("UInt64FilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString UInt64FilterParameter::ClassName() +{ + return QString("UInt64FilterParameter"); +} + +// ----------------------------------------------------------------------------- +void UInt64FilterParameter::setSetterCallback(const UInt64FilterParameter::SetterCallbackType& value) +{ + m_SetterCallback = value; +} + +// ----------------------------------------------------------------------------- +UInt64FilterParameter::SetterCallbackType UInt64FilterParameter::getSetterCallback() const +{ + return m_SetterCallback; +} + +// ----------------------------------------------------------------------------- +void UInt64FilterParameter::setGetterCallback(const UInt64FilterParameter::GetterCallbackType& value) +{ + m_GetterCallback = value; +} + +// ----------------------------------------------------------------------------- +UInt64FilterParameter::GetterCallbackType UInt64FilterParameter::getGetterCallback() const +{ + return m_GetterCallback; +} diff --git a/Source/SIMPLib/FilterParameters/UInt64FilterParameter.h b/Source/SIMPLib/FilterParameters/UInt64FilterParameter.h index 7c4fdeeaad..e45d9d4718 100644 --- a/Source/SIMPLib/FilterParameters/UInt64FilterParameter.h +++ b/Source/SIMPLib/FilterParameters/UInt64FilterParameter.h @@ -26,13 +26,15 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-15-D-5231 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/FilterParameters/FilterParameter.h" @@ -47,12 +49,10 @@ * SIMPL_NEW_INTEGER_FP("HumanLabel", PropertyName, Category, FilterName, GroupIndex) * * Example 1 (instantiated within a filter called [GenericExample](@ref genericexample), with optional GroupIndex parameter): - * SIMPL_NEW_INTEGER_FP("Max Iterations", MaxIterations, FilterParameter::Parameter, GenericExample, 0); + * SIMPL_NEW_INTEGER_FP("Max Iterations", MaxIterations, FilterParameter::Category::Parameter, GenericExample, 0); */ -#define SIMPL_NEW_UINT64_FP(...) \ - SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, \ - SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)\ - (UInt64FilterParameter, __VA_ARGS__)) +#define SIMPL_NEW_UINT64_FP(...) \ + SIMPL_EXPAND(_FP_GET_OVERRIDE(__VA_ARGS__, SIMPL_NEW_FP_9, SIMPL_NEW_FP_8, SIMPL_NEW_FP_7, SIMPL_NEW_FP_6, SIMPL_NEW_FP_5, SIMPL_NEW_FP_4)(UInt64FilterParameter, __VA_ARGS__)) /** * @brief The UInt64FilterParameter class is used by filters to instantiate an IntWidget. By instantiating an instance of @@ -60,80 +60,120 @@ */ class SIMPLib_EXPORT UInt64FilterParameter : public FilterParameter { - public: - SIMPL_SHARED_POINTERS(UInt64FilterParameter) - SIMPL_STATIC_NEW_MACRO(UInt64FilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(UInt64FilterParameter, FilterParameter) - - using SetterCallbackType = std::function; - using GetterCallbackType = std::function; - - /** - * @brief New This function instantiates an instance of the UInt64FilterParameter. Although this function is available to be used, - * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_INTEGER_FP(...) macro at the top of this file. - - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, uint64_t defaultValue, Category category, SetterCallbackType setterCallback, GetterCallbackType getterCallback, - int groupIndex = -1); - - ~UInt64FilterParameter() override; - - /** + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(UInt64FilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(UInt64FilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations +public: + using Self = UInt64FilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for UInt64FilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for UInt64FilterParameter + */ + static QString ClassName(); + + using SetterCallbackType = std::function; + using GetterCallbackType = std::function; + + /** + * @brief New This function instantiates an instance of the UInt64FilterParameter. Although this function is available to be used, + * the preferable way to instantiate an instance of this class is to use the SIMPL_NEW_INTEGER_FP(...) macro at the top of this file. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param setterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * @param getterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, uint64_t defaultValue, Category category, const SetterCallbackType& setterCallback, + const GetterCallbackType& getterCallback, int groupIndex = -1); + + ~UInt64FilterParameter() override; + + /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; - - /** - * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. - * @param json The QJsonObject that the filter parameter reads from. - */ - void readJson(const QJsonObject& json) override; - - /** - * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. - * @param json The QJsonObject that the filter parameter writes to. - */ - void writeJson(QJsonObject& json) override; - - /** - * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property - * that this FilterParameter subclass represents. - * from the filter parameter. - */ - SIMPL_INSTANCE_PROPERTY(SetterCallbackType, SetterCallback) - - /** - * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property - * that this FilterParameter subclass represents. - * @return The GetterCallback - */ - SIMPL_INSTANCE_PROPERTY(GetterCallbackType, GetterCallback) - - - protected: - /** - * @brief UInt64FilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - UInt64FilterParameter(); - - public: - UInt64FilterParameter(const UInt64FilterParameter&) = delete; // Copy Constructor Not Implemented - UInt64FilterParameter(UInt64FilterParameter&&) = delete; // Move Constructor Not Implemented - UInt64FilterParameter& operator=(const UInt64FilterParameter&) = delete; // Copy Assignment Not Implemented - UInt64FilterParameter& operator=(UInt64FilterParameter&&) = delete; // Move Assignment Not Implemented -}; + QString getWidgetType() const override; + + /** + * @brief readJson Reads this filter parameter's corresponding property out of a QJsonObject. + * @param json The QJsonObject that the filter parameter reads from. + */ + void readJson(const QJsonObject& json) override; + + /** + * @brief writeJson Writes this filter parameter's corresponding property to a QJsonObject. + * @param json The QJsonObject that the filter parameter writes to. + */ + void writeJson(QJsonObject& json) const override; + /** + * @param SetterCallback The method in the AbstractFilter subclass that sets the value of the property + * that this FilterParameter subclass represents. + * from the filter parameter. + */ + /** + * @brief Setter property for SetterCallback + */ + void setSetterCallback(const UInt64FilterParameter::SetterCallbackType& value); + /** + * @brief Getter property for SetterCallback + * @return Value of SetterCallback + */ + UInt64FilterParameter::SetterCallbackType getSetterCallback() const; + + /** + * @param GetterCallback The method in the AbstractFilter subclass that gets the value of the property + * that this FilterParameter subclass represents. + * @return The GetterCallback + */ + /** + * @brief Setter property for GetterCallback + */ + void setGetterCallback(const UInt64FilterParameter::GetterCallbackType& value); + /** + * @brief Getter property for GetterCallback + * @return Value of GetterCallback + */ + UInt64FilterParameter::GetterCallbackType getGetterCallback() const; + +protected: + /** + * @brief UInt64FilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + UInt64FilterParameter(); + +public: + UInt64FilterParameter(const UInt64FilterParameter&) = delete; // Copy Constructor Not Implemented + UInt64FilterParameter(UInt64FilterParameter&&) = delete; // Move Constructor Not Implemented + UInt64FilterParameter& operator=(const UInt64FilterParameter&) = delete; // Copy Assignment Not Implemented + UInt64FilterParameter& operator=(UInt64FilterParameter&&) = delete; // Move Assignment Not Implemented + +private: + UInt64FilterParameter::SetterCallbackType m_SetterCallback = {}; + UInt64FilterParameter::GetterCallbackType m_GetterCallback = {}; +}; diff --git a/Source/SIMPLib/FilterParameters/UnknownFilterParameter.cpp b/Source/SIMPLib/FilterParameters/UnknownFilterParameter.cpp index 1510d55779..48f137a7cf 100644 --- a/Source/SIMPLib/FilterParameters/UnknownFilterParameter.cpp +++ b/Source/SIMPLib/FilterParameters/UnknownFilterParameter.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "UnknownFilterParameter.h" @@ -48,7 +48,7 @@ UnknownFilterParameter::~UnknownFilterParameter() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -UnknownFilterParameter::Pointer UnknownFilterParameter::New(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, int groupIndex) +UnknownFilterParameter::Pointer UnknownFilterParameter::Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, int groupIndex) { UnknownFilterParameter::Pointer ptr = UnknownFilterParameter::New(); ptr->setHumanLabel(humanLabel); @@ -66,3 +66,28 @@ QString UnknownFilterParameter::getWidgetType() const { return QString("UnknownWidget"); } + +// ----------------------------------------------------------------------------- +UnknownFilterParameter::Pointer UnknownFilterParameter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +UnknownFilterParameter::Pointer UnknownFilterParameter::New() +{ + Pointer sharedPtr(new(UnknownFilterParameter)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString UnknownFilterParameter::getNameOfClass() const +{ + return QString("UnknownFilterParameter"); +} + +// ----------------------------------------------------------------------------- +QString UnknownFilterParameter::ClassName() +{ + return QString("UnknownFilterParameter"); +} diff --git a/Source/SIMPLib/FilterParameters/UnknownFilterParameter.h b/Source/SIMPLib/FilterParameters/UnknownFilterParameter.h old mode 100755 new mode 100644 index b3971e5f28..c0f1a64988 --- a/Source/SIMPLib/FilterParameters/UnknownFilterParameter.h +++ b/Source/SIMPLib/FilterParameters/UnknownFilterParameter.h @@ -1,41 +1,41 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include #include "SIMPLib/FilterParameters/FilterParameter.h" @@ -45,45 +45,67 @@ */ class SIMPLib_EXPORT UnknownFilterParameter : public FilterParameter { + // Start Python bindings declarations + // clang-format off + PYB11_BEGIN_BINDINGS(UnknownFilterParameter SUPERCLASS FilterParameter) + PYB11_SHARED_POINTERS(UnknownFilterParameter) + PYB11_STATIC_CREATION(Create) + PYB11_END_BINDINGS() + // clang-format on + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(UnknownFilterParameter) - SIMPL_STATIC_NEW_MACRO(UnknownFilterParameter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(UnknownFilterParameter, FilterParameter) + using Self = UnknownFilterParameter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - /** - * @brief New This function instantiates an instance of the UnknownFilterParameter. + static Pointer New(); - * @param humanLabel The name that the users of DREAM.3D see for this filter parameter - * @param propertyName The internal property name for this filter parameter. - * @param defaultValue The value that this filter parameter will be initialized to by default. - * @param category The category for the filter parameter in the DREAM.3D user interface. There - * are three categories: Parameter, Required Arrays, and Created Arrays. - * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. - * @return - */ - static Pointer New(const QString& humanLabel, const QString& propertyName, - const QString& defaultValue, Category category, int groupIndex = -1); + /** + * @brief Returns the name of the class for UnknownFilterParameter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for UnknownFilterParameter + */ + static QString ClassName(); + + /** + * @brief New This function instantiates an instance of the UnknownFilterParameter. + + * @param humanLabel The name that the users of DREAM.3D see for this filter parameter + * @param propertyName The internal property name for this filter parameter. + * @param defaultValue The value that this filter parameter will be initialized to by default. + * @param category The category for the filter parameter in the DREAM.3D user interface. There + * are three categories: Parameter, Required Arrays, and Created Arrays. + * @param groupIndex Integer that specifies the group that this filter parameter will be placed in. + * @return + */ + static Pointer Create(const QString& humanLabel, const QString& propertyName, const QString& defaultValue, Category category, int groupIndex = -1); - ~UnknownFilterParameter() override; + ~UnknownFilterParameter() override; /** * @brief getWidgetType Returns the type of widget that displays and controls * this FilterParameter subclass * @return */ - QString getWidgetType() const override; + QString getWidgetType() const override; - protected: - /** - * @brief UnknownFilterParameter The default constructor. It is protected because this - * filter parameter should only be instantiated using its New(...) function or short-form macro. - */ - UnknownFilterParameter(); +protected: + /** + * @brief UnknownFilterParameter The default constructor. It is protected because this + * filter parameter should only be instantiated using its New(...) function or short-form macro. + */ + UnknownFilterParameter(); - public: - UnknownFilterParameter(const UnknownFilterParameter&) = delete; // Copy Constructor Not Implemented - UnknownFilterParameter(UnknownFilterParameter&&) = delete; // Move Constructor Not Implemented - UnknownFilterParameter& operator=(const UnknownFilterParameter&) = delete; // Copy Assignment Not Implemented - UnknownFilterParameter& operator=(UnknownFilterParameter&&) = delete; // Move Assignment Not Implemented -}; +public: + UnknownFilterParameter(const UnknownFilterParameter&) = delete; // Copy Constructor Not Implemented + UnknownFilterParameter(UnknownFilterParameter&&) = delete; // Move Constructor Not Implemented + UnknownFilterParameter& operator=(const UnknownFilterParameter&) = delete; // Copy Assignment Not Implemented + UnknownFilterParameter& operator=(UnknownFilterParameter&&) = delete; // Move Assignment Not Implemented +private: +}; diff --git a/Source/SIMPLib/Filtering/AbstractComparison.cpp b/Source/SIMPLib/Filtering/AbstractComparison.cpp index fe47c30cab..d9a0a13a7e 100644 --- a/Source/SIMPLib/Filtering/AbstractComparison.cpp +++ b/Source/SIMPLib/Filtering/AbstractComparison.cpp @@ -1,42 +1,41 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "AbstractComparison.h" #include "SIMPLib/Common/Constants.h" - #include "SIMPLib/Filtering/ComparisonSet.h" #include "SIMPLib/Filtering/ComparisonValue.h" @@ -87,4 +86,21 @@ int AbstractComparison::getUnionOperator() void AbstractComparison::setUnionOperator(int unionOperator) { m_unionOperator = unionOperator; -} \ No newline at end of file +} +// ----------------------------------------------------------------------------- +AbstractComparison::Pointer AbstractComparison::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString AbstractComparison::getNameOfClass() const +{ + return QString("AbstractComparison"); +} + +// ----------------------------------------------------------------------------- +QString AbstractComparison::ClassName() +{ + return QString("AbstractComparison"); +} diff --git a/Source/SIMPLib/Filtering/AbstractComparison.h b/Source/SIMPLib/Filtering/AbstractComparison.h index 63295e2846..1018483065 100644 --- a/Source/SIMPLib/Filtering/AbstractComparison.h +++ b/Source/SIMPLib/Filtering/AbstractComparison.h @@ -1,57 +1,77 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/DataContainers/DataArrayPath.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataContainers/DataArrayPath.h" #include /** -* @brief The AbstractComparison class is used by ComparisonInputsAdvanced as a -* base for both ComparisonSet and ComparisonValue. -*/ + * @brief The AbstractComparison class is used by ComparisonInputsAdvanced as a + * base for both ComparisonSet and ComparisonValue. + */ class SIMPLib_EXPORT AbstractComparison { - PYB11_CREATE_BINDINGS(AbstractComparison) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(AbstractComparison) + PYB11_SHARED_POINTERS(AbstractComparison) PYB11_PROPERTY(int UnionOperator READ getUnionOperator WRITE setUnionOperator) + PYB11_END_BINDINGS() + // End Python bindings declarations + public: - SIMPL_SHARED_POINTERS(AbstractComparison) - SIMPL_TYPE_MACRO(AbstractComparison) + using Self = AbstractComparison; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for AbstractComparison + */ + virtual QString getNameOfClass() const; + /** + * @brief Returns the name of the class for AbstractComparison + */ + static QString ClassName(); virtual ~AbstractComparison(); @@ -77,7 +97,7 @@ class SIMPLib_EXPORT AbstractComparison * @brief Write comparison to JSon * @param json */ - virtual void writeJson(QJsonObject& json) = 0; + virtual void writeJson(QJsonObject& json) const = 0; /** * @brief Read comparison from JSon * @param json @@ -94,5 +114,6 @@ class SIMPLib_EXPORT AbstractComparison int m_unionOperator; AbstractComparison(); -}; +private: +}; diff --git a/Source/SIMPLib/Filtering/AbstractDecisionFilter.cpp b/Source/SIMPLib/Filtering/AbstractDecisionFilter.cpp index 69669a46e0..50b564b80e 100644 --- a/Source/SIMPLib/Filtering/AbstractDecisionFilter.cpp +++ b/Source/SIMPLib/Filtering/AbstractDecisionFilter.cpp @@ -1,37 +1,39 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include #include "AbstractDecisionFilter.h" @@ -52,7 +54,7 @@ AbstractDecisionFilter::~AbstractDecisionFilter() = default; // ----------------------------------------------------------------------------- void AbstractDecisionFilter::setupFilterParameters() { - // FilterParameterVector parameters; + // FilterParameterVectorType parameters; // setFilterParameters(parameters); } @@ -79,21 +81,8 @@ void AbstractDecisionFilter::initialize() // ----------------------------------------------------------------------------- void AbstractDecisionFilter::dataCheck() { - setErrorCondition(0); - setWarningCondition(0); -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void AbstractDecisionFilter::preflight() -{ - setInPreflight(true); - emit preflightAboutToExecute(); - emit updateFilterParameters(this); - dataCheck(); - emit preflightExecuted(); - setInPreflight(false); + clearErrorCode(); + clearWarningCode(); } // ----------------------------------------------------------------------------- @@ -101,10 +90,8 @@ void AbstractDecisionFilter::preflight() // ----------------------------------------------------------------------------- void AbstractDecisionFilter::execute() { - setErrorCondition(0); - setWarningCondition(0); dataCheck(); - if(getErrorCondition() < 0) + if(getErrorCode() < 0) { return; } @@ -133,7 +120,7 @@ AbstractFilter::Pointer AbstractDecisionFilter::newFilterInstance(bool copyFilte // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString AbstractDecisionFilter::getCompiledLibraryName() const +QString AbstractDecisionFilter::getCompiledLibraryName() const { return ""; } @@ -141,7 +128,7 @@ const QString AbstractDecisionFilter::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString AbstractDecisionFilter::getGroupName() const +QString AbstractDecisionFilter::getGroupName() const { return ""; } @@ -149,7 +136,7 @@ const QString AbstractDecisionFilter::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid AbstractDecisionFilter::getUuid() +QUuid AbstractDecisionFilter::getUuid() const { return QUuid("{e4fcd394-6ac6-5559-98a1-1945a0da3427}"); } @@ -157,7 +144,7 @@ const QUuid AbstractDecisionFilter::getUuid() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString AbstractDecisionFilter::getSubGroupName() const +QString AbstractDecisionFilter::getSubGroupName() const { return ""; } @@ -165,7 +152,36 @@ const QString AbstractDecisionFilter::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString AbstractDecisionFilter::getHumanLabel() const +QString AbstractDecisionFilter::getHumanLabel() const { return ""; } + +// ----------------------------------------------------------------------------- +AbstractDecisionFilter::Pointer AbstractDecisionFilter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr AbstractDecisionFilter::New() +{ + struct make_shared_enabler : public AbstractDecisionFilter + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString AbstractDecisionFilter::getNameOfClass() const +{ + return QString("AbstractDecisionFilter"); +} + +// ----------------------------------------------------------------------------- +QString AbstractDecisionFilter::ClassName() +{ + return QString("AbstractDecisionFilter"); +} diff --git a/Source/SIMPLib/Filtering/AbstractDecisionFilter.h b/Source/SIMPLib/Filtering/AbstractDecisionFilter.h old mode 100755 new mode 100644 index 704a7bedf4..ac49226528 --- a/Source/SIMPLib/Filtering/AbstractDecisionFilter.h +++ b/Source/SIMPLib/Filtering/AbstractDecisionFilter.h @@ -1,43 +1,44 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" +#include + #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief The AbstractDecisionFilter class. This class serves as a superclass for other classes @@ -47,22 +48,45 @@ class AbstractDecisionFilter : public AbstractFilter { Q_OBJECT public: - SIMPL_SHARED_POINTERS(AbstractDecisionFilter) - SIMPL_FILTER_NEW_MACRO(AbstractDecisionFilter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(AbstractDecisionFilter, AbstractFilter) + using Self = AbstractDecisionFilter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for AbstractDecisionFilter + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for AbstractDecisionFilter + */ + static QString ClassName(); ~AbstractDecisionFilter() override; /** - * @brief - * @param jsonDoc - */ + * @brief + * @param jsonDoc + */ virtual void extractProperties(const QJsonDocument& jsonDoc); /** * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class */ - const QString getCompiledLibraryName() const override; + QString getCompiledLibraryName() const override; /** * @brief newFilterInstance Reimplemented from @see AbstractFilter class @@ -72,23 +96,23 @@ class AbstractDecisionFilter : public AbstractFilter /** * @brief getGroupName Reimplemented from @see AbstractFilter class */ - const QString getGroupName() const override; + QString getGroupName() const override; /** * @brief getSubGroupName Reimplemented from @see AbstractFilter class */ - const QString getSubGroupName() const override; + QString getSubGroupName() const override; /** * @brief getUuid Return the unique identifier for this filter. * @return A QUuid object. */ - const QUuid getUuid() override; + QUuid getUuid() const override; /** * @brief getHumanLabel Reimplemented from @see AbstractFilter class */ - const QString getHumanLabel() const override; + QString getHumanLabel() const override; /** * @brief setupFilterParameters Reimplemented from @see AbstractFilter class @@ -105,34 +129,7 @@ class AbstractDecisionFilter : public AbstractFilter */ void execute() override; - /** - * @brief preflight Reimplemented from @see AbstractFilter class - */ - void preflight() override; - -signals: - /** - * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters - * be pushed from a user-facing control (such as a widget) - * @param filter Filter instance pointer - */ - void updateFilterParameters(AbstractFilter* filter); - - /** - * @brief parametersChanged Emitted when any Filter parameter is changed internally - */ - void parametersChanged(); - - /** - * @brief preflightAboutToExecute Emitted just before calling dataCheck() - */ - void preflightAboutToExecute(); - - /** - * @brief preflightExecuted Emitted just after calling dataCheck() - */ - void preflightExecuted(); - +Q_SIGNALS: void decisionMade(bool& dm); void targetValue(int& value); @@ -141,7 +138,7 @@ class AbstractDecisionFilter : public AbstractFilter /** * @brief dataCheck Checks for the appropriate parameter values and availability of arrays */ - void dataCheck(); + void dataCheck() override; /** * @brief Initializes all the private instance variables. @@ -149,9 +146,10 @@ class AbstractDecisionFilter : public AbstractFilter void initialize(); public: - AbstractDecisionFilter(const AbstractDecisionFilter&) = delete; // Copy Constructor Not Implemented - AbstractDecisionFilter(AbstractDecisionFilter&&) = delete; // Move Constructor Not Implemented + AbstractDecisionFilter(const AbstractDecisionFilter&) = delete; // Copy Constructor Not Implemented + AbstractDecisionFilter(AbstractDecisionFilter&&) = delete; // Move Constructor Not Implemented AbstractDecisionFilter& operator=(const AbstractDecisionFilter&) = delete; // Copy Assignment Not Implemented AbstractDecisionFilter& operator=(AbstractDecisionFilter&&) = delete; // Move Assignment Not Implemented -}; +private: +}; diff --git a/Source/SIMPLib/Filtering/AbstractFilter.cpp b/Source/SIMPLib/Filtering/AbstractFilter.cpp index 862d4de774..9b7029c4f9 100644 --- a/Source/SIMPLib/Filtering/AbstractFilter.cpp +++ b/Source/SIMPLib/Filtering/AbstractFilter.cpp @@ -1,60 +1,57 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "AbstractFilter.h" -#include +#include +#include -#include "SIMPLib/Common/PipelineMessage.h" +#include "SIMPLib/Common/Constants.h" +#include "SIMPLib/DataContainers/DataContainer.h" +#include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Filtering/FilterManager.h" -#include "SIMPLib/Filtering/IFilterFactory.hpp" -#include "SIMPLib/Filtering/FilterPipeline.h" +#include "SIMPLib/Messages/FilterErrorMessage.h" +#include "SIMPLib/Messages/FilterProgressMessage.h" +#include "SIMPLib/Messages/FilterStatusMessage.h" +#include "SIMPLib/Messages/FilterWarningMessage.h" #include "SIMPLib/Plugin/PluginManager.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- AbstractFilter::AbstractFilter() -: m_ErrorCondition(0) -, m_WarningCondition(0) -, m_InPreflight(false) -, m_Enabled(true) -, m_Removing(false) -, m_PipelineIndex(0) -, m_Cancel(false) - { m_DataContainerArray = DataContainerArray::New(); m_PreviousFilter = NullPointer(); @@ -100,91 +97,36 @@ void AbstractFilter::setCancel(bool value) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AbstractFilter::renameDataArrayPath(DataArrayPath::RenameType renamePath) +void AbstractFilter::renameDataArrayPath(const DataArrayPath::RenameType& renamePath) { - // Updates any DataArrayPath or proxy property assigned to this filter. - // A signal is emitted if a change was required stating the property name, old path, and new path. - // No additional methods are required aside from a connecting slot in filter parameter widgets to update their UI. - // If all filters stored their data paths as DataArrayPaths instead of QString without delimiters, - // this would handle all required updates. This was moved to FilterParameter::dataArrayRenamed. - // However, moving this to FilterParameter does not update any private properties that do not - // have a FilterParameter assigned. -#if 0 - const QMetaObject* metaobject = metaObject(); - int count = metaobject->propertyCount(); - for(int i = 0; i < count; i++) + // If the path is created here, do not rename + for(const auto& createdPath : m_CreatedPaths) { - QMetaProperty metaproperty = metaobject->property(i); - const char* name = metaproperty.name(); - QVariant var = property(name); - if(var.isValid() && var.canConvert()) - { - DataArrayPath path = var.value(); - if(path.updatePath(oldPath, newPath)) - { - //QString ss = QString("Updated property '%1' in %2").arg(name).arg(getHumanLabel()); - //notifyStandardOutputMessage(getHumanLabel(), getPipelineIndex(), ss); - //notifyStatusMessage(getHumanLabel(), ss); - var.setValue(path); - this->setProperty(name, var); - emit dataArrayPathUpdated(name, oldPath, newPath); - } - } - else if(var.isValid() && var.canConvert()) - { - DataContainerArrayProxy proxy = var.value(); - proxy.updatePath(oldPath, newPath); - var.setValue(proxy); - this->setProperty(name, var); - emit dataArrayPathUpdated(name, oldPath, newPath); - } - else if(var.isValid() && var.canConvert()) - { - DataContainerProxy proxy = var.value(); - proxy.updatePath(oldPath, newPath); - var.setValue(proxy); - this->setProperty(name, var); - emit dataArrayPathUpdated(name, oldPath, newPath); - } - else if(var.isValid() && var.canConvert()) - { - AttributeMatrixProxy proxy = var.value(); - proxy.updatePath(oldPath, newPath); - var.setValue(proxy); - this->setProperty(name, var); - emit dataArrayPathUpdated(name, oldPath, newPath); - } - else if(var.isValid() && var.canConvert()) + if(createdPath.second == renamePath.first) { - DataArrayProxy proxy = var.value(); - proxy.updatePath(oldPath, newPath); - var.setValue(proxy); - this->setProperty(name, var); - emit dataArrayPathUpdated(name, oldPath, newPath); + return; } } -#endif // Some filter parameters handle paths as nothing but a QString (i.e. DataContainerSelectionFilterParameter) // This does not store data in a way that represents what is stored or in a consistent manner with anything else. // Because this format cannot be quieried nicely like the above code, filter parameters have to be able to update // their own paths in these cases. In cases where private properties need to be updated but do not have // assigned filter parameters, although this should not be the case, this code, unlike the above snippet, will not update them. - FilterParameterVector filterParams = getFilterParameters(); - for(FilterParameter::Pointer filterParam : filterParams) + FilterParameterVectorType filterParams = getFilterParameters(); + for(FilterParameter::Pointer& filterParam : filterParams) { filterParam->dataArrayPathRenamed(this, renamePath); } -} -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void AbstractFilter::renameDataArrayPaths(DataArrayPath::RenameContainer renamedPaths) -{ - for(DataArrayPath::RenameType rename : renamedPaths) + // Update created paths + for(const auto& createdPathItem : m_CreatedPaths) { - renameDataArrayPath(rename); + DataArrayPath createdPath = createdPathItem.second; + if(createdPath.updatePath(renamePath)) + { + m_CreatedPaths[createdPathItem.first] = createdPath; + } } } @@ -195,23 +137,17 @@ void AbstractFilter::setupFilterParameters() { } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void AbstractFilter::execute() -{ - setErrorCondition(-3015); - notifyErrorMessage(getNameOfClass(), "QAbstractFilter does not implement an execute method. Please use a subclass instead.", getErrorCondition()); -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AbstractFilter::preflight() { setInPreflight(true); - setErrorCondition(-3016); - notifyErrorMessage(getNameOfClass(), "AbstractFilter does not implement a preflight method. Please use a subclass instead.", getErrorCondition()); + Q_EMIT preflightAboutToExecute(); + Q_EMIT updateFilterParameters(this); + dataCheck(); + Q_EMIT preflightExecuted(); + setInPreflight(false); } // ----------------------------------------------------------------------------- @@ -261,7 +197,7 @@ void insertAttributeMatrixPaths(DataContainer::Pointer dc, AttributeMatrix::Poin { paths.push_back(DataArrayPath(dc->getName(), am->getName(), "")); // Insert all DataArrayPaths - for(QString daName : am->getAttributeArrayNames()) + for(const QString& daName : am->getAttributeArrayNames()) { DataArrayPath daPath(dc->getName(), am->getName(), daName); paths.push_back(daPath); @@ -271,11 +207,11 @@ void insertAttributeMatrixPaths(DataContainer::Pointer dc, AttributeMatrix::Poin // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void insertDataContainerPaths(DataContainer::Pointer dc, std::list& paths) +void insertDataContainerPaths(const DataContainer::Pointer& dc, std::list& paths) { - paths.push_back(DataArrayPath(dc->getName(), "", "")); + paths.emplace_back(DataArrayPath(dc->getName(), "", "")); // Insert all AttributeMatrix paths - for(AttributeMatrix::Pointer am : dc->getAttributeMatrices()) + for(const AttributeMatrix::Pointer& am : dc->getAttributeMatrices()) { insertAttributeMatrixPaths(dc, am, paths); } @@ -300,7 +236,7 @@ std::list AbstractFilter::getCreatedPaths() DataContainerArray::Pointer dca = getDataContainerArray(); // Check DataContainers - for(DataContainer::Pointer dc : dca->getDataContainers()) + for(const DataContainer::Pointer& dc : dca->getDataContainers()) { if(!prevDca->doesDataContainerExist(dc->getName())) { @@ -309,7 +245,7 @@ std::list AbstractFilter::getCreatedPaths() else { // Check AttributeMatrices - for(AttributeMatrix::Pointer am : dc->getAttributeMatrices()) + for(const AttributeMatrix::Pointer& am : dc->getAttributeMatrices()) { DataArrayPath amPath(dc->getName(), am->getName(), ""); if(!prevDca->doesAttributeMatrixExist(amPath)) @@ -319,7 +255,7 @@ std::list AbstractFilter::getCreatedPaths() else { // Check DataArrays - for(QString daName : am->getAttributeArrayNames()) + for(const QString& daName : am->getAttributeArrayNames()) { DataArrayPath daPath(dc->getName(), am->getName(), daName); if(!prevDca->doesAttributeArrayExist(daPath)) @@ -334,13 +270,12 @@ std::list AbstractFilter::getCreatedPaths() } else { + // Add all paths if this is the first filter in the pipeline DataContainerArray::Pointer dca = getDataContainerArray(); - - // Check if the DataContainerArray is valid - if(dca) + if(nullptr != dca) { // Add all paths if there is no previous filter to compare to - for(DataContainer::Pointer dc : dca->getDataContainers()) + for(const DataContainer::Pointer& dc : dca->getDataContainers()) { insertDataContainerPaths(dc, createdPaths); } @@ -350,14 +285,41 @@ std::list AbstractFilter::getCreatedPaths() return createdPaths; } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::list AbstractFilter::getCreatedPathsNotRenamed() +{ + std::list createdPaths = getCreatedPaths(); + const DataArrayPath::RenameContainer renamedPaths = getRenamedPaths(); + + for(const auto& renamedPath : renamedPaths) + { + auto iter = std::find(createdPaths.begin(), createdPaths.end(), std::get<0>(renamedPath)); + if(iter != createdPaths.end()) + { + createdPaths.erase(iter); + } + } + + return createdPaths; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::list AbstractFilter::getDeletedPaths() +{ + return std::list(); +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- DataArrayPath::RenameContainer AbstractFilter::getRenamedPaths() { // Implemented in filters that rename existing paths - DataArrayPath::RenameContainer container; - return container; + return m_RenamedPaths; } // ----------------------------------------------------------------------------- @@ -375,10 +337,9 @@ void AbstractFilter::readFilterParameters(AbstractFilterParametersReader* reader // ----------------------------------------------------------------------------- void AbstractFilter::readFilterParameters(QJsonObject& obj) { - QVector filterParameters = getFilterParameters(); - for(int i = 0; i < filterParameters.size(); i++) + FilterParameterVectorType filterParameters = getFilterParameters(); + for(auto const& fp : filterParameters) { - FilterParameter::Pointer fp = filterParameters[i]; fp->readJson(obj); } } @@ -397,8 +358,8 @@ void AbstractFilter::preWriteFilterParameters(QJsonObject& obj, QJsonObject& roo // ----------------------------------------------------------------------------- void AbstractFilter::writeFilterParameters(QJsonObject& obj) const { - QVector filterParameters = getFilterParameters(); - for(auto const fp : filterParameters) + FilterParameterVectorType filterParameters = getFilterParameters(); + for(auto const& fp : filterParameters) { fp->writeJson(obj); } @@ -438,7 +399,7 @@ QJsonObject AbstractFilter::toJson() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -bool AbstractFilter::getCancel() +bool AbstractFilter::getCancel() const { return m_Cancel; } @@ -475,7 +436,7 @@ void AbstractFilter::copyFilterParameterInstanceVariables(AbstractFilter* filter // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString AbstractFilter::getGroupName() const +QString AbstractFilter::getGroupName() const { return "YOUR CLASS SHOULD IMPLEMENT THIS"; } @@ -483,7 +444,7 @@ const QString AbstractFilter::getGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString AbstractFilter::getSubGroupName() const +QString AbstractFilter::getSubGroupName() const { return "YOUR CLASS SHOULD IMPLEMENT THIS"; } @@ -491,7 +452,7 @@ const QString AbstractFilter::getSubGroupName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString AbstractFilter::getHumanLabel() const +QString AbstractFilter::getHumanLabel() const { return "YOUR CLASS SHOULD IMPLEMENT THIS"; } @@ -499,7 +460,7 @@ const QString AbstractFilter::getHumanLabel() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString AbstractFilter::getBrandingString() const +QString AbstractFilter::getBrandingString() const { return ""; } @@ -507,7 +468,7 @@ const QString AbstractFilter::getBrandingString() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString AbstractFilter::getCompiledLibraryName() const +QString AbstractFilter::getCompiledLibraryName() const { return ""; } @@ -515,7 +476,7 @@ const QString AbstractFilter::getCompiledLibraryName() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QString AbstractFilter::getFilterVersion() const +QString AbstractFilter::getFilterVersion() const { return QString("0.0.0"); } @@ -523,35 +484,7 @@ const QString AbstractFilter::getFilterVersion() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -const QUuid AbstractFilter::getUuid() -{ - if(m_Uuid.isNull()) - { - uint l = 100; - ushort w1 = 200; - ushort w2 = 300; - - QString libName = getCompiledLibraryName(); - uchar b[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - int32_t i = 0; - while(i < 8 && i < libName.size()) - { - b[i] = static_cast(libName.at(i).toLatin1()); - i++; - } - QUuid uuid = QUuid(l, w1, w2, b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7]); - QString nameSpace = QString("%1 %2").arg(getNameOfClass()).arg(getHumanLabel()); - QUuid p1 = QUuid::createUuidV5(uuid, nameSpace); - m_Uuid = p1; - } - return m_Uuid; -} - - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -const QString AbstractFilter::generateHtmlSummary() const +QString AbstractFilter::generateHtmlSummary() const { QString html; QTextStream ss(&html); @@ -590,65 +523,55 @@ void AbstractFilter::cleanupFilter() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AbstractFilter::notifyErrorMessage(const QString& humanLabel, const QString& str, int code) +void AbstractFilter::setErrorCondition(int code, const QString& messageText) { - PipelineMessage pm = PipelineMessage::CreateErrorMessage(getNameOfClass(), humanLabel, str, code); - pm.setPipelineIndex(getPipelineIndex()); - emit filterGeneratedMessage(pm); + m_ErrorCode = code; + FilterErrorMessage::Pointer pm = FilterErrorMessage::New(getNameOfClass(), getHumanLabel(), getPipelineIndex(), messageText, code); + Q_EMIT messageGenerated(pm); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AbstractFilter::notifyStatusMessage(const QString& humanLabel, const QString& str) +void AbstractFilter::notifyStatusMessage(const QString& messageText) const { - PipelineMessage pm = PipelineMessage::CreateStatusMessage(getNameOfClass(), humanLabel, str); - pm.setPipelineIndex(getPipelineIndex()); - emit filterGeneratedMessage(pm); + FilterStatusMessage::Pointer pm = FilterStatusMessage::New(getNameOfClass(), getHumanLabel(), getPipelineIndex(), messageText); + Q_EMIT messageGenerated(pm); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AbstractFilter::notifyStatusMessage(const QString& prefix, const QString& humanLabel, const QString& str) +void AbstractFilter::setWarningCondition(int code, const QString& messageText) { - PipelineMessage pm = PipelineMessage::CreateStatusMessage(getNameOfClass(), humanLabel, str); - pm.setPrefix(prefix); - pm.setPipelineIndex(getPipelineIndex()); - emit filterGeneratedMessage(pm); + m_WarningCode = code; + FilterWarningMessage::Pointer pm = FilterWarningMessage::New(getNameOfClass(), getHumanLabel(), getPipelineIndex(), messageText, code); + Q_EMIT messageGenerated(pm); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AbstractFilter::notifyStandardOutputMessage(const QString& humanLabel, int pipelineIndex, const QString& str) +void AbstractFilter::notifyProgressMessage(int progress, const QString& messageText) const { - PipelineMessage pm = PipelineMessage::CreateStandardOutputMessage(humanLabel, pipelineIndex, str); - pm.setPipelineIndex(getPipelineIndex()); - emit filterGeneratedMessage(pm); + FilterProgressMessage::Pointer pm = FilterProgressMessage::New(getNameOfClass(), getHumanLabel(), getPipelineIndex(), messageText, progress); + Q_EMIT messageGenerated(pm); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AbstractFilter::notifyWarningMessage(const QString& humanLabel, const QString& str, int code) +void AbstractFilter::clearErrorCode() { - PipelineMessage pm = PipelineMessage::CreateWarningMessage(getNameOfClass(), humanLabel, str, code); - pm.setPipelineIndex(getPipelineIndex()); - emit filterGeneratedMessage(pm); + m_ErrorCode = 0; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void AbstractFilter::notifyProgressMessage(const QString& prefix, const QString& humanLabel, const QString& str, int progress) +void AbstractFilter::clearWarningCode() { - PipelineMessage pm = PipelineMessage::CreateStatusMessage(getNameOfClass(), humanLabel, str); - pm.setPrefix(prefix); - pm.setProgressValue(progress); - pm.setType(PipelineMessage::MessageType::StatusMessageAndProgressValue); - pm.setPipelineIndex(getPipelineIndex()); - emit filterGeneratedMessage(pm); + m_WarningCode = 0; } // ----------------------------------------------------------------------------- @@ -659,9 +582,169 @@ void AbstractFilter::notifyMissingProperty(FilterParameter* filterParameter) QString ss = QString("Error occurred transferring the Filter Parameter '%1' in Filter '%2' to the filter instance. The pipeline may run but the underlying filter will NOT be using the values from the GUI." " Please report this issue to the developers of this filter.") - .arg(filterParameter->getPropertyName()) - .arg(getHumanLabel()); + .arg(filterParameter->getPropertyName(), getHumanLabel()); + + setWarningCondition(-1, ss); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +bool AbstractFilter::checkIfPathRenamed(const RenameDataPath::DataID_t id, const DataArrayPath& path) +{ + if(id == RenameDataPath::k_Invalid_ID) + { + return false; + } + + if(m_CreatedPaths.find(id) == m_CreatedPaths.end()) + { + m_CreatedPaths[id] = path; + return false; + } + + if(m_CreatedPaths[id] == path) + { + return false; + } + + m_RenamedPaths.push_back(std::make_pair(m_CreatedPaths[id], path)); + m_CreatedPaths[id] = path; + return true; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractFilter::clearRenamedPaths() +{ + m_RenamedPaths.clear(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void AbstractFilter::addPathRename(const DataArrayPath& oldPath, const DataArrayPath& newPath) +{ + m_RenamedPaths.push_back(std::make_pair(oldPath, newPath)); +} + +// ----------------------------------------------------------------------------- +AbstractFilter::Pointer AbstractFilter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString AbstractFilter::ClassName() +{ + return QString("AbstractFilter"); +} - setWarningCondition(-1); - notifyWarningMessage(getHumanLabel(), ss, getWarningCondition()); +// ----------------------------------------------------------------------------- +void AbstractFilter::setDataContainerArray(const DataContainerArray::Pointer& value) +{ + m_DataContainerArray = value; +} + +// ----------------------------------------------------------------------------- +DataContainerArray::Pointer AbstractFilter::getDataContainerArray() const +{ + return m_DataContainerArray; +} + +// ----------------------------------------------------------------------------- +void AbstractFilter::setFilterParameters(const FilterParameterVectorType& value) +{ + m_FilterParameters = value; +} + +// ----------------------------------------------------------------------------- +FilterParameterVectorType AbstractFilter::getFilterParameters() const +{ + return m_FilterParameters; +} + +// ----------------------------------------------------------------------------- +void AbstractFilter::setInPreflight(bool value) +{ + m_InPreflight = value; +} + +// ----------------------------------------------------------------------------- +bool AbstractFilter::getInPreflight() const +{ + return m_InPreflight; +} + +// ----------------------------------------------------------------------------- +void AbstractFilter::setEnabled(bool value) +{ + m_Enabled = value; +} + +// ----------------------------------------------------------------------------- +bool AbstractFilter::getEnabled() const +{ + return m_Enabled; +} + +// ----------------------------------------------------------------------------- +void AbstractFilter::setRemoving(bool value) +{ + m_Removing = value; +} + +// ----------------------------------------------------------------------------- +bool AbstractFilter::getRemoving() const +{ + return m_Removing; +} + +// ----------------------------------------------------------------------------- +void AbstractFilter::setPipelineIndex(int value) +{ + m_PipelineIndex = value; +} + +// ----------------------------------------------------------------------------- +int AbstractFilter::getPipelineIndex() const +{ + return m_PipelineIndex; +} + +// ----------------------------------------------------------------------------- +void AbstractFilter::setPreviousFilter(const AbstractFilter::WeakPointer& value) +{ + m_PreviousFilter = value; +} + +// ----------------------------------------------------------------------------- +AbstractFilter::WeakPointer AbstractFilter::getPreviousFilter() const +{ + return m_PreviousFilter; +} + +// ----------------------------------------------------------------------------- +void AbstractFilter::setNextFilter(const AbstractFilter::WeakPointer& value) +{ + m_NextFilter = value; +} + +// ----------------------------------------------------------------------------- +AbstractFilter::WeakPointer AbstractFilter::getNextFilter() const +{ + return m_NextFilter; +} + +// ----------------------------------------------------------------------------- +int AbstractFilter::getErrorCode() const +{ + return m_ErrorCode; +} + +// ----------------------------------------------------------------------------- +int AbstractFilter::getWarningCode() const +{ + return m_WarningCode; } diff --git a/Source/SIMPLib/Filtering/AbstractFilter.h b/Source/SIMPLib/Filtering/AbstractFilter.h old mode 100755 new mode 100644 index 72470ca614..287be06c80 --- a/Source/SIMPLib/Filtering/AbstractFilter.h +++ b/Source/SIMPLib/Filtering/AbstractFilter.h @@ -1,53 +1,56 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include +#include +#include + +#include #include -#include #include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Observable.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/DataContainers/DataContainerArray.h" +#include "SIMPLib/DataContainers/RenameDataPath.h" #include "SIMPLib/FilterParameters/FilterParameter.h" -#include "SIMPLib/SIMPLib.h" class AbstractFilterParametersReader; class ISIMPLibPlugin; +class DataContainerArray; +using DataContainerArrayShPtrType = std::shared_ptr; /** * @class AbstractFilter AbstractFilter.h DREAM3DLib/Common/AbstractFilter.h @@ -73,32 +76,59 @@ class SIMPLib_EXPORT AbstractFilter : public Observable Q_PROPERTY(int Cancel READ getCancel WRITE setCancel) Q_PROPERTY(bool Enabled READ getEnabled WRITE setEnabled) Q_PROPERTY(bool Removing READ getRemoving WRITE setRemoving) - + // This line MUST be first when exposing a class and properties to Python - PYB11_CREATE_BINDINGS(AbstractFilter) - PYB11_PROPERTY(QString NameOfClass READ getNameOfClass) + + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(AbstractFilter) + PYB11_SHARED_POINTERS(AbstractFilter) + PYB11_PROPERTY(QString NameOfClass READ getNameOfClass) PYB11_PROPERTY(QString GroupName READ getGroupName) PYB11_PROPERTY(QString SubGroupName READ getSubGroupName) PYB11_PROPERTY(QString HumanLabel READ getHumanLabel) PYB11_PROPERTY(QString FilterVersion READ getFilterVersion) PYB11_PROPERTY(QString CompiledLibraryName READ getCompiledLibraryName) + PYB11_PROPERTY(QString DataContainerArray READ getDataContainerArray WRITE setDataContainerArray) PYB11_PROPERTY(bool Cancel READ getCancel WRITE setCancel) PYB11_PROPERTY(bool Enabled READ getEnabled WRITE setEnabled) - PYB11_PROPERTY(QString MessagePrefix READ getMessagePrefix WRITE setMessagePrefix) - PYB11_PROPERTY(int ErrorCondition READ getErrorCondition WRITE setErrorCondition) - PYB11_PROPERTY(int WarningCondition READ getWarningCondition WRITE setWarningCondition) + PYB11_PROPERTY(int ErrorCode READ getErrorCode) + PYB11_PROPERTY(int WarningCode READ getWarningCode) PYB11_PROPERTY(bool InPreflight READ getInPreflight WRITE setInPreflight) PYB11_PROPERTY(int PipelineIndex READ getPipelineIndex WRITE setPipelineIndex) - PYB11_METHOD(void generateHtmlSummary) PYB11_METHOD(void execute) PYB11_METHOD(void preflight) PYB11_METHOD(void setDataContainerArray) - + PYB11_METHOD(void setErrorCondition ARGS code messageText) + PYB11_METHOD(void setWarningCondition ARGS code messageText) + PYB11_METHOD(void notifyStatusMessage ARGS messageText) + PYB11_METHOD(void notifyProgressMessage ARGS progress messageText) + PYB11_METHOD(void clearErrorCode) + PYB11_METHOD(void clearWarningCode) + PYB11_CUSTOM() + PYB11_END_BINDINGS() + // End Python bindings declarations + + // Friend declarations for RenameDataPath so that it can set and check the instance's created data by ID. + friend void RenameDataPath::AlertFilterCreatedPath(AbstractFilter*, RenameDataPath::DataID_t, const DataArrayPath&); + public: - SIMPL_SHARED_POINTERS(AbstractFilter) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(AbstractFilter, Observable) - SIMPL_STATIC_NEW_MACRO(AbstractFilter) + using Self = AbstractFilter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for AbstractFilter + */ + QString getNameOfClass() const override = 0; + + /** + * @brief Returns the name of the class for AbstractFilter + */ + static QString ClassName(); ~AbstractFilter() override; @@ -114,34 +144,34 @@ class SIMPLib_EXPORT AbstractFilter : public Observable * top level sorting in the GUI * @return Group name */ - virtual const QString getGroupName() const; + virtual QString getGroupName() const; /** * @brief getSubGroupName Returns the subgroup name for the filter, which determines its * second level sorting in the GUI * @return Subgroup name */ - virtual const QString getSubGroupName() const; + virtual QString getSubGroupName() const; /** * @brief getUuid Return the unique identifier for this filter. * @return A QUuid object. */ - virtual const QUuid getUuid(); - + virtual QUuid getUuid() const = 0; + /** * @brief getHumanLabel Returns the human label for the filter, which determines its * primary labeling inthe GUI * @return Human lable */ - virtual const QString getHumanLabel() const; + virtual QString getHumanLabel() const; /** * @brief getBrandingString Returns the branding string for the filter, which is a tag * used to denote the filter's association with a specific plugin * @return Branding string */ - virtual const QString getBrandingString() const; + virtual QString getBrandingString() const; /** * @brief getCompiledLibraryName Returns the library name for the filter, which is the @@ -149,13 +179,13 @@ class SIMPLib_EXPORT AbstractFilter : public Observable * plugin * @return Compiled library name */ - virtual const QString getCompiledLibraryName() const; + virtual QString getCompiledLibraryName() const; /** * @brief generateHtmlSummary Generates a brief HTML summary of the filter * @return HTML summary */ - virtual const QString generateHtmlSummary() const; + virtual QString generateHtmlSummary() const; /** * @brief setupFilterParameters Instantiates the filter parameters that are allowed @@ -164,47 +194,47 @@ class SIMPLib_EXPORT AbstractFilter : public Observable virtual void setupFilterParameters(); /** - * @brief readFilterParameters Reads the filter parameters from a file - * @param reader Reader that is used to read the parameters from a file - */ + * @brief readFilterParameters Reads the filter parameters from a file + * @param reader Reader that is used to read the parameters from a file + */ virtual void readFilterParameters(AbstractFilterParametersReader* reader, int index); /** - * @brief readFilterParametersFromJson Reads the filter parameters from a file - * @param reader Reader that is used to read the parameters from a file - */ + * @brief readFilterParametersFromJson Reads the filter parameters from a file + * @param reader Reader that is used to read the parameters from a file + */ virtual void readFilterParameters(QJsonObject& obj); /** * @brief This method is called just before the writeFilterParameters() completes - * @param obj The json object to add the filter parameters into + * @param obj The json object to add the filter parameters into * @param rootObject The parent object of **obj** */ virtual void preWriteFilterParameters(QJsonObject& obj, QJsonObject& rootObject); /** - * @brief writeFilterParametersToJson Writes the filter parameters to a file - * @param obj The json object to add the filter parameters into - */ + * @brief writeFilterParametersToJson Writes the filter parameters to a file + * @param obj The json object to add the filter parameters into + */ virtual void writeFilterParameters(QJsonObject& obj) const; /** * @brief This method is called just after the writeFilterParameters() completes - * @param obj The json object to add the filter parameters into + * @param obj The json object to add the filter parameters into * @param rootObject The parent object of **obj** */ virtual void postWriteFilterParameters(QJsonObject& obj, QJsonObject& rootObject); /** - * @brief toJson Returns the filter and its parameters as a QJsonObject - * @return - */ + * @brief toJson Returns the filter and its parameters as a QJsonObject + * @return + */ virtual QJsonObject toJson(); /** * @brief execute Implements the main functionality of the filter */ - virtual void execute(); + virtual void execute() = 0; /** * @brief preflight Communicates with the GUI to request user settings for the filter and @@ -233,41 +263,122 @@ class SIMPLib_EXPORT AbstractFilter : public Observable * value is an empty string. * @return */ - virtual const QString getFilterVersion() const; - - SIMPL_INSTANCE_PROPERTY(DataContainerArray::Pointer, DataContainerArray) + virtual QString getFilterVersion() const; - SIMPL_INSTANCE_PROPERTY(QVector, FilterParameters) + /** + * @brief Setter property for DataContainerArray + */ + void setDataContainerArray(const DataContainerArrayShPtrType& value); + /** + * @brief Getter property for DataContainerArray + * @return Value of DataContainerArray + */ + DataContainerArrayShPtrType getDataContainerArray() const; - SIMPL_INSTANCE_PROPERTY(QString, MessagePrefix) + /** + * @brief Setter property for FilterParameters + */ + void setFilterParameters(const FilterParameterVectorType& value); + /** + * @brief Getter property for FilterParameters + * @return Value of FilterParameters + */ + FilterParameterVectorType getFilterParameters() const; - SIMPL_INSTANCE_PROPERTY(int, ErrorCondition) + /** + * @brief Getter property for ErrorCode + * @return Value of ErrorCode + */ + int getErrorCode() const; - SIMPL_INSTANCE_PROPERTY(int, WarningCondition) + /** + * @brief Getter property for WarningCode + * @return Value of WarningCode + */ + int getWarningCode() const; - SIMPL_INSTANCE_PROPERTY(bool, InPreflight) + /** + * @brief Setter property for InPreflight + */ + void setInPreflight(bool value); + /** + * @brief Getter property for InPreflight + * @return Value of InPreflight + */ + bool getInPreflight() const; - SIMPL_INSTANCE_PROPERTY(bool, Enabled) + /** + * @brief Setter property for Enabled + */ + void setEnabled(bool value); + /** + * @brief Getter property for Enabled + * @return Value of Enabled + */ + bool getEnabled() const; - SIMPL_INSTANCE_PROPERTY(bool, Removing) + /** + * @brief Setter property for Removing + */ + void setRemoving(bool value); + /** + * @brief Getter property for Removing + * @return Value of Removing + */ + bool getRemoving() const; // ------------------------------ // These functions allow interogating the position the filter is in the pipeline and the previous and next filters // ------------------------------ /** - * @brief This property tells which index the filter is in a pipeline - */ - SIMPL_INSTANCE_PROPERTY(int, PipelineIndex) + * @brief This property tells which index the filter is in a pipeline + */ + /** + * @brief Setter property for PipelineIndex + */ + void setPipelineIndex(int value); + /** + * @brief Getter property for PipelineIndex + * @return Value of PipelineIndex + */ + int getPipelineIndex() const; + + /** + * @brief Returns the previous filter + */ + /** + * @brief Setter property for PreviousFilter + */ + void setPreviousFilter(const AbstractFilter::WeakPointer& value); + /** + * @brief Getter property for PreviousFilter + * @return Value of PreviousFilter + */ + AbstractFilter::WeakPointer getPreviousFilter() const; + + /** + * @brief Returns the next filter in the pipeline + */ + /** + * @brief Setter property for NextFilter + */ + void setNextFilter(const AbstractFilter::WeakPointer& value); + /** + * @brief Getter property for NextFilter + * @return Value of NextFilter + */ + AbstractFilter::WeakPointer getNextFilter() const; /** - * @brief Returns the previous filter - */ - SIMPL_INSTANCE_PROPERTY(AbstractFilter::WeakPointer, PreviousFilter) + * @brief clearErrorCondition + */ + void clearErrorCode(); + /** - * @brief Returns the next filter in the pipeline - */ - SIMPL_INSTANCE_PROPERTY(AbstractFilter::WeakPointer, NextFilter) + * @brief clearWarningCondition + */ + void clearWarningCode(); /** * @brief doesPipelineContainFilterBeforeThis @@ -295,68 +406,54 @@ class SIMPLib_EXPORT AbstractFilter : public Observable std::list getCreatedPaths(); /** - * @brief Returns a list of DataArrayPaths that have been renamed along with their corresponding renamed value + * @brief Returns a list of DataArrayPaths created but not renamed by the filter. * @return */ - virtual DataArrayPath::RenameContainer getRenamedPaths(); - - // ------------------------------ - // These methods are over ridden from the superclass in order to add the - // pipeline index to the PipelineMessage Object. - // ------------------------------ + std::list getCreatedPathsNotRenamed(); /** - * @brief notifyErrorMessage - * @param humanLabel - * @param ss - * @param code + * @brief Returns the list of deleted data paths. + * @return */ - void notifyErrorMessage(const QString& humanLabel, const QString& ss, int code) override; + virtual std::list getDeletedPaths(); /** - * @brief notifyWarningMessage - * @param humanLabel - * @param ss - * @param code + * @brief Returns a list of DataArrayPaths that have been renamed along with their corresponding renamed value + * @return */ - void notifyWarningMessage(const QString& humanLabel, const QString& ss, int code) override; + virtual DataArrayPath::RenameContainer getRenamedPaths(); /** - * @brief notifyStatusMessage - * @param humanLabel - * @param ss + * @brief setErrorCondition + * @param code + * @param messageText */ - void notifyStatusMessage(const QString& humanLabel, const QString& ss) override; + void setErrorCondition(int code, const QString& messageText) override; /** - * @brief notifyStandardOutputMessage - * @param humanLabel - * @param pipelineIndex - * @param ss + * @brief setWarningCondition + * @param code + * @param messageText */ - void notifyStandardOutputMessage(const QString& humanLabel, int pipelineIndex, const QString& ss) override; + void setWarningCondition(int code, const QString& messageText) override; /** * @brief notifyStatusMessage - * @param prefix - * @param humanLabel - * @param ss + * @param messageText */ - void notifyStatusMessage(const QString& prefix, const QString& humanLabel, const QString& ss) override; + void notifyStatusMessage(const QString& messageText) const override; /** * @brief notifyProgressMessage - * @param prefix - * @param humanLabel - * @param str * @param progress + * @param messageText */ - void notifyProgressMessage(const QString& prefix, const QString& humanLabel, const QString& str, int progress) override; + void notifyProgressMessage(int progress, const QString& messageText) const override; /** * @brief notifyMissingProperty * @param filterParameter - */ + */ void notifyMissingProperty(FilterParameter* filterParameter); //--------------- @@ -372,7 +469,7 @@ class SIMPLib_EXPORT AbstractFilter : public Observable * @brief getCancel Returns if the filter has been cancelled. * @return */ - virtual bool getCancel(); + virtual bool getCancel() const; /** * @brief copyFilterParameterInstanceVariables @@ -380,7 +477,12 @@ class SIMPLib_EXPORT AbstractFilter : public Observable */ virtual void copyFilterParameterInstanceVariables(AbstractFilter* filter) const; -signals: + /** + * @brief Clears the renamed paths for the filter instance. + */ + void clearRenamedPaths(); + +Q_SIGNALS: /** * @brief Signal is emitted when filter has completed the execute() method */ @@ -392,17 +494,39 @@ class SIMPLib_EXPORT AbstractFilter : public Observable void filterInProgress(AbstractFilter* filter); /** - * @brief Signal is emitted when a DataArrayPath property is updated - * @param propertyName - * @param renamePath - */ - void dataArrayPathUpdated(QString propertyName, DataArrayPath::RenameType renamePath); + * @brief Signal is emitted when a DataArrayPath property is updated + * @param propertyName + * @param renamePath + */ + void dataArrayPathUpdated(const QString& propertyName, const DataArrayPath::RenameType& renamePath); + + /** + * @brief updateFilterParameters Emitted when the Filter requests all the latest Filter parameters + * be pushed from a user-facing control (such as a widget) + * @param filter Filter instance pointer + */ + void updateFilterParameters(AbstractFilter* filter); + + /** + * @brief parametersChanged Emitted when any Filter parameter is changed internally + */ + void parametersChanged(); -public slots: + /** + * @brief preflightAboutToExecute Emitted just before calling dataCheck() + */ + void preflightAboutToExecute(); /** - * @brief Cancel the operation - */ + * @brief preflightExecuted Emitted just after calling dataCheck() + */ + void preflightExecuted(); + +public Q_SLOTS: + + /** + * @brief Cancel the operation + */ virtual void setCancel(bool value); /** @@ -410,19 +534,46 @@ public slots: * For DataArrayPaths longer than the given path, only the specified values are modified * @param renamePath */ - virtual void renameDataArrayPath(DataArrayPath::RenameType renamePath); + virtual void renameDataArrayPath(const DataArrayPath::RenameType& renamePath); /** - * @brief Updates any DataArrayPath properties from the old paths to their corresponding new paths. - * For DataArrayPaths longer than the new path, only the values provided by the new path are modified - * @param renamedPaths - */ - virtual void renameDataArrayPaths(DataArrayPath::RenameContainer renamedPaths); + * @brief Updates any DataArrayPath properties from the old paths to their corresponding new paths. + * For DataArrayPaths longer than the new path, only the values provided by the new path are modified + * @param renamedPaths + */ + inline void renameDataArrayPaths(const DataArrayPath::RenameContainer& renamedPaths) + { + for(const DataArrayPath::RenameType& rename : renamedPaths) + { + renameDataArrayPath(rename); + } + } protected: AbstractFilter(); -protected slots: + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + virtual void dataCheck() = 0; + + /** + * @brief Checks if the path matches the one saved with the specified ID. Index 0 is used for + * non-renamable DataArrayPaths, and any DataID 0 value will bypass the check and return false. + * If the path does not match and the ID is already used, return true and update the path. If + * the ID is used and the paths match, return false. If the ID has not been used, add the path + * to the createdPaths map. + */ + bool checkIfPathRenamed(RenameDataPath::DataID_t id, const DataArrayPath& path); + + /** + * @brief Adds the specified change to the list of renamed DataArrayPaths. + * @param oldPath + * @param newPath + */ + void addPathRename(const DataArrayPath& oldPath, const DataArrayPath& newPath); + +protected Q_SLOTS: /** * @brief This function will be called after the pipeline is completely done executing. This can be reimplemented * in subclasses to provide cleanup code between pipeline executions. (resetting/clearing variables, updating settings, etc.) @@ -430,13 +581,25 @@ protected slots: virtual void cleanupFilter(); private: - bool m_Cancel; - QUuid m_Uuid; + DataContainerArrayShPtrType m_DataContainerArray = {}; + FilterParameterVectorType m_FilterParameters = {}; + bool m_InPreflight = {false}; + bool m_Enabled = {true}; + bool m_Removing = {false}; + int m_PipelineIndex = {0}; + AbstractFilter::WeakPointer m_PreviousFilter = {}; + AbstractFilter::WeakPointer m_NextFilter = {}; + + bool m_Cancel = false; + int m_ErrorCode = 0; + int m_WarningCode = 0; + + std::map m_CreatedPaths; + DataArrayPath::RenameContainer m_RenamedPaths; public: - AbstractFilter(const AbstractFilter&) = delete; // Copy Constructor Not Implemented - AbstractFilter(AbstractFilter&&) = delete; // Move Constructor Not Implemented + AbstractFilter(const AbstractFilter&) = delete; // Copy Constructor Not Implemented + AbstractFilter(AbstractFilter&&) = delete; // Move Constructor Not Implemented AbstractFilter& operator=(const AbstractFilter&) = delete; // Copy Assignment Not Implemented AbstractFilter& operator=(AbstractFilter&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/Filtering/BadFilter.cpp b/Source/SIMPLib/Filtering/BadFilter.cpp new file mode 100644 index 0000000000..9465148e70 --- /dev/null +++ b/Source/SIMPLib/Filtering/BadFilter.cpp @@ -0,0 +1,165 @@ +/* ============================================================================ + * Copyright (c) 2020 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#include "BadFilter.h" + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +BadFilter::BadFilter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +BadFilter::~BadFilter() = default; + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void BadFilter::setupFilterParameters() +{ +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void BadFilter::dataCheck() +{ + setErrorCondition(-3016, "BadFilter is not meant to be run."); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void BadFilter::execute() +{ + setErrorCondition(-3016, "BadFilter is not meant to be run."); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +AbstractFilter::Pointer BadFilter::newFilterInstance(bool copyFilterParameters) const +{ + BadFilter::Pointer filter = BadFilter::New(); + if(copyFilterParameters) + { + copyFilterParameterInstanceVariables(filter.get()); + } + return filter; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString BadFilter::getCompiledLibraryName() const +{ + return ""; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString BadFilter::getBrandingString() const +{ + return ""; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString BadFilter::getFilterVersion() const +{ + return "0.0.0"; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString BadFilter::getGroupName() const +{ + return ""; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QUuid BadFilter::getUuid() const +{ + return QUuid(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString BadFilter::getSubGroupName() const +{ + return ""; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +QString BadFilter::getHumanLabel() const +{ + return ""; +} + +// ----------------------------------------------------------------------------- +BadFilter::Pointer BadFilter::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +std::shared_ptr BadFilter::New() +{ + struct make_shared_enabler : public BadFilter + { + }; + std::shared_ptr val = std::make_shared(); + val->setupFilterParameters(); + return val; +} + +// ----------------------------------------------------------------------------- +QString BadFilter::getNameOfClass() const +{ + return QString("BadFilter"); +} + +// ----------------------------------------------------------------------------- +QString BadFilter::ClassName() +{ + return QString("BadFilter"); +} diff --git a/Source/SIMPLib/Filtering/BadFilter.h b/Source/SIMPLib/Filtering/BadFilter.h new file mode 100644 index 0000000000..27e7c86a7b --- /dev/null +++ b/Source/SIMPLib/Filtering/BadFilter.h @@ -0,0 +1,146 @@ +/* ============================================================================ + * Copyright (c) 2020 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +#pragma once + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" + +/** + * @brief The BadFilter class. See [Filter documentation](@ref BadFilter) for details. + */ +class SIMPLib_EXPORT BadFilter : public AbstractFilter +{ + Q_OBJECT + +public: + using Self = BadFilter; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + + ~BadFilter() override; + + /** + * @brief Returns a NullPointer wrapped by a shared_ptr<> + * @return + */ + static Pointer NullPointer(); + + /** + * @brief Creates a new object wrapped in a shared_ptr<> + * @return + */ + static Pointer New(); + + /** + * @brief Returns the name of the class for PipelineAnnotation + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for PipelineAnnotation + */ + static QString ClassName(); + + /** + * @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class + */ + QString getCompiledLibraryName() const override; + + /** + * @brief getBrandingString Returns the branding string for the filter, which is a tag + * used to denote the filter's association with specific plugins + * @return Branding string + */ + QString getBrandingString() const override; + + /** + * @brief getFilterVersion Returns a version string for this filter. Default + * value is an empty string. + * @return + */ + QString getFilterVersion() const override; + + /** + * @brief newFilterInstance Reimplemented from @see AbstractFilter class + */ + AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override; + + /** + * @brief getGroupName Reimplemented from @see AbstractFilter class + */ + QString getGroupName() const override; + + /** + * @brief getSubGroupName Reimplemented from @see AbstractFilter class + */ + QString getSubGroupName() const override; + + /** + * @brief getUuid Return the unique identifier for this filter. + * @return A QUuid object. + */ + QUuid getUuid() const override; + + /** + * @brief getHumanLabel Reimplemented from @see AbstractFilter class + */ + QString getHumanLabel() const override; + + /** + * @brief setupFilterParameters Reimplemented from @see AbstractFilter class + */ + void setupFilterParameters() override; + + /** + * @brief execute Reimplemented from @see AbstractFilter class + */ + void execute() override; + +protected: + BadFilter(); + + /** + * @brief dataCheck Checks for the appropriate parameter values and availability of arrays + */ + void dataCheck() override; + +public: + BadFilter(const BadFilter&) = delete; // Copy Constructor Not Implemented + BadFilter(BadFilter&&) = delete; // Move Constructor Not Implemented + BadFilter& operator=(const BadFilter&) = delete; // Copy Assignment Not Implemented + BadFilter& operator=(BadFilter&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/Filtering/ComparisonInputs.cpp b/Source/SIMPLib/Filtering/ComparisonInputs.cpp index ae93fe4d28..ceb7ac8b84 100644 --- a/Source/SIMPLib/Filtering/ComparisonInputs.cpp +++ b/Source/SIMPLib/Filtering/ComparisonInputs.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ComparisonInputs.h" @@ -72,7 +72,7 @@ int ComparisonInputs::size() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ComparisonInputs::addInput(const QString dataContainerName, const QString attributeMatrixName, const QString arrayName, int compOperator, double compValue) +void ComparisonInputs::addInput(const QString& dataContainerName, const QString& attributeMatrixName, const QString& arrayName, int compOperator, double compValue) { ComparisonInput_t v; v.dataContainerName = dataContainerName; diff --git a/Source/SIMPLib/Filtering/ComparisonInputs.h b/Source/SIMPLib/Filtering/ComparisonInputs.h old mode 100755 new mode 100644 index f408518e31..e60262d180 --- a/Source/SIMPLib/Filtering/ComparisonInputs.h +++ b/Source/SIMPLib/Filtering/ComparisonInputs.h @@ -1,65 +1,65 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once #include -#include #include #include #include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" // for SIMPL_PIMPL_PROPERTY_DECL -typedef struct +struct ComparisonInput_t { - PYB11_CREATE_BINDINGS(ComparisonInput_t) - - PYB11_PROPERTY(QString dataContainerName) - PYB11_PROPERTY(QString attributeMatrixName) - PYB11_PROPERTY(QString attributeArrayName) - PYB11_PROPERTY(int compOperator) - PYB11_PROPERTY(double compValue) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ComparisonInput_t) + PYB11_FIELD(dataContainerName) + PYB11_FIELD(attributeMatrixName) + PYB11_FIELD(attributeArrayName) + PYB11_FIELD(compOperator) + PYB11_FIELD(compValue) + PYB11_END_BINDINGS() + // End Python bindings declarations QString dataContainerName; QString attributeMatrixName; QString attributeArrayName; - int compOperator; - double compValue; + int compOperator = 0; + double compValue = 0.0; - void writeJson(QJsonObject& json) + void writeJson(QJsonObject& json) const { json["Data Container Name"] = dataContainerName; json["Attribute Matrix Name"] = attributeMatrixName; @@ -68,7 +68,7 @@ typedef struct json["Comparison Value"] = compValue; } - bool readJson(QJsonObject& json) + bool readJson(const QJsonObject& json) { if(json["Data Container Name"].isString() && json["Attribute Matrix Name"].isString() && json["Attribute Array Name"].isString() && json["Comparison Operator"].isDouble() && json["Comparison Value"].isDouble()) @@ -82,10 +82,7 @@ typedef struct } return false; } - -} ComparisonInput_t; - - +}; /** * @class ComparisonInputs ComparisonInputs.h DREAM3DLib/Common/ComparisonInputs.h @@ -98,14 +95,17 @@ class SIMPLib_EXPORT ComparisonInputs : public QObject { Q_OBJECT // clang-format off - PYB11_CREATE_BINDINGS(ComparisonInputs) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ComparisonInputs) PYB11_CREATION() PYB11_PROPERTY(QVector Inputs READ getInputs) - PYB11_METHOD(void addInput OVERLOAD const.QString,dataContainerName const.QString,attributeMatrixName const.QString,arrayName int,compOperator double,compValue) + PYB11_METHOD(void addInput OVERLOAD const.QString.&,dataContainerName const.QString.&,attributeMatrixName const.QString.&,arrayName int,compOperator double,compValue) PYB11_METHOD(void addInput OVERLOAD const.ComparisonInput_t.&,input) //PYB11_METHOD(ComparisonInput_t& getInput ARGS index) //PYB11_METHOD(ComparisonInput_t& operator[] ARGS index) PYB11_METHOD(int size) + PYB11_END_BINDINGS() + // End Python bindings declarations // clang-format on public: @@ -117,7 +117,7 @@ class SIMPLib_EXPORT ComparisonInputs : public QObject int size(); - void addInput(const QString dataContainerName, const QString attributeMatrixName, const QString arrayName, int compOperator, double compValue); + void addInput(const QString& dataContainerName, const QString& attributeMatrixName, const QString& arrayName, int compOperator, double compValue); void addInput(const ComparisonInput_t& input); ComparisonInput_t& getInput(int index); @@ -133,4 +133,3 @@ class SIMPLib_EXPORT ComparisonInputs : public QObject Q_DECLARE_METATYPE(ComparisonInput_t) Q_DECLARE_METATYPE(ComparisonInputs) - diff --git a/Source/SIMPLib/Filtering/ComparisonInputsAdvanced.cpp b/Source/SIMPLib/Filtering/ComparisonInputsAdvanced.cpp index c15b165a94..ff8029ce48 100644 --- a/Source/SIMPLib/Filtering/ComparisonInputsAdvanced.cpp +++ b/Source/SIMPLib/Filtering/ComparisonInputsAdvanced.cpp @@ -1,40 +1,42 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ComparisonInputsAdvanced.h" +#include + #include "SIMPLib/Filtering/ComparisonSet.h" #include "SIMPLib/Filtering/ComparisonValue.h" @@ -124,7 +126,7 @@ int ComparisonInputsAdvanced::size() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ComparisonInputsAdvanced::addInput(int unionOperator, const QString arrayName, int compOperator, double compValue) +void ComparisonInputsAdvanced::addInput(int unionOperator, const QString& arrayName, int compOperator, double compValue) { ComparisonValue::Pointer v = ComparisonValue::New(); v->setUnionOperator(unionOperator); diff --git a/Source/SIMPLib/Filtering/ComparisonInputsAdvanced.h b/Source/SIMPLib/Filtering/ComparisonInputsAdvanced.h index f77c8ea6e9..53704ae9fc 100644 --- a/Source/SIMPLib/Filtering/ComparisonInputsAdvanced.h +++ b/Source/SIMPLib/Filtering/ComparisonInputsAdvanced.h @@ -1,51 +1,48 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once #include -#include #include -#include #include #include -#include "SIMPLib/Common/Constants.h" #include "SIMPLib/SIMPLib.h" - +#include "SIMPLib/Common/Constants.h" #include "SIMPLib/Filtering/AbstractComparison.h" /** @@ -59,19 +56,18 @@ class SIMPLib_EXPORT ComparisonInputsAdvanced : public QObject { Q_OBJECT // clang-format off - - PYB11_CREATE_BINDINGS(ComparisonInputsAdvanced) - + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ComparisonInputsAdvanced) PYB11_CREATION() - PYB11_PROPERTY(QVector Inputs READ getInputs) - PYB11_PROPERTY(QString DataContainerName READ getDataContainerName WRITE setDataContainerName) + PYB11_PROPERTY(DataArrayPath DataContainerName READ getDataContainerName WRITE setDataContainerName) PYB11_PROPERTY(QString AttributeMatrixName READ getAttributeMatrixName WRITE setAttributeMatrixName) - - PYB11_METHOD(void addInput OVERLOAD int,unionOperator const.QString,arrayName int,compOperator double,compValue) + PYB11_METHOD(void addInput OVERLOAD int,unionOperator const.QString.&,arrayName int,compOperator double,compValue) PYB11_METHOD(void addInput OVERLOAD int,unionOperator bool,invertComparison QVector,comparisons) PYB11_METHOD(void addInput OVERLOAD AbstractComparison::Pointer,input) PYB11_METHOD(int size) + PYB11_END_BINDINGS() + // End Python bindings declarations // clang-format on public: @@ -87,13 +83,13 @@ class SIMPLib_EXPORT ComparisonInputsAdvanced : public QObject int size(); /** - * @brief Adds a new input to the list of comparisons - * @param unionOperator - * @param arrayName - * @param compOperator - * @param compValue - */ - void addInput(int unionOperator, const QString arrayName, int compOperator, double compValue); + * @brief Adds a new input to the list of comparisons + * @param unionOperator + * @param arrayName + * @param compOperator + * @param compValue + */ + void addInput(int unionOperator, const QString& arrayName, int compOperator, double compValue); /** * @brief Adds a new input to the list of comparisons @@ -141,8 +137,8 @@ class SIMPLib_EXPORT ComparisonInputsAdvanced : public QObject QString getAttributeMatrixName(); /** - * @brief Returns the DataArrayPath to the selected AttributeMatrix - */ + * @brief Returns the DataArrayPath to the selected AttributeMatrix + */ DataArrayPath getAttributeMatrixPath(); /** @@ -195,7 +191,7 @@ class SIMPLib_EXPORT ComparisonInputsAdvanced : public QObject void setInvert(bool invert); /** - * @brief Loads data from json + * @brief Loads data from json * @param obj */ void readJson(QJsonObject obj); @@ -215,4 +211,3 @@ class SIMPLib_EXPORT ComparisonInputsAdvanced : public QObject }; Q_DECLARE_METATYPE(ComparisonInputsAdvanced) - diff --git a/Source/SIMPLib/Filtering/ComparisonSet.cpp b/Source/SIMPLib/Filtering/ComparisonSet.cpp index ebf9320c60..7b36a64c1a 100644 --- a/Source/SIMPLib/Filtering/ComparisonSet.cpp +++ b/Source/SIMPLib/Filtering/ComparisonSet.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ComparisonSet.h" @@ -58,7 +58,7 @@ ComparisonSet::~ComparisonSet() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ComparisonSet::writeJson(QJsonObject& json) +void ComparisonSet::writeJson(QJsonObject& json) const { json["Union Operator"] = m_unionOperator; json["Invert Comparison"] = m_invertComparison; @@ -251,3 +251,28 @@ bool ComparisonSet::renameDataArrayPath(DataArrayPath::RenameType renamePath) return updated; } + +// ----------------------------------------------------------------------------- +ComparisonSet::Pointer ComparisonSet::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +ComparisonSet::Pointer ComparisonSet::New() +{ + Pointer sharedPtr(new(ComparisonSet)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString ComparisonSet::getNameOfClass() const +{ + return QString("ComparisonSet"); +} + +// ----------------------------------------------------------------------------- +QString ComparisonSet::ClassName() +{ + return QString("ComparisonSet"); +} diff --git a/Source/SIMPLib/Filtering/ComparisonSet.h b/Source/SIMPLib/Filtering/ComparisonSet.h index 5a1fc4ed0b..31901496ff 100644 --- a/Source/SIMPLib/Filtering/ComparisonSet.h +++ b/Source/SIMPLib/Filtering/ComparisonSet.h @@ -1,128 +1,149 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include "AbstractComparison.h" #include /** -* @brief The ComparisonSet class is used by ComparisonInputsAdvanced to group ComparisonValues -* as a single entity to apply union operators or invert the resulting comparison of the group. -*/ + * @brief The ComparisonSet class is used by ComparisonInputsAdvanced to group ComparisonValues + * as a single entity to apply union operators or invert the resulting comparison of the group. + */ class SIMPLib_EXPORT ComparisonSet : public AbstractComparison { using AbstractComparisonPtr = AbstractComparison::Pointer; + // Start Python bindings declarations // clang-format off - PYB11_CREATE_BINDINGS(ComparisonSet SUPERCLASS AbstractComparison) - PYB11_CREATION() + PYB11_BEGIN_BINDINGS(ComparisonSet SUPERCLASS AbstractComparison) + PYB11_SHARED_POINTERS(ComparisonSet) + PYB11_STATIC_NEW_MACRO(ComparisonSet) PYB11_PROPERTY(QVector Comparisons READ getComparisons WRITE setComparisons) PYB11_PROPERTY(bool InvertComparison READ getInvertComparison WRITE setInvertComparison) PYB11_PROPERTY(int UnionOperator READ getUnionOperator WRITE setUnionOperator) - PYB11_METHOD(void addComparison ARGS AbstractComparisonPtr,comparison) - PYB11_METHOD(void insertComparison ARGS int,index AbstractComparisonPtr,comparison) + PYB11_METHOD(void addComparison ARGS comparison) + PYB11_METHOD(void insertComparison ARGS index comparison) + PYB11_END_BINDINGS() // clang-format on + // End Python bindings declarations + public: - SIMPL_SHARED_POINTERS(ComparisonSet) - SIMPL_STATIC_NEW_MACRO(ComparisonSet) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ComparisonSet, AbstractComparison) + using Self = ComparisonSet; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for ComparisonSet + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ComparisonSet + */ + static QString ClassName(); ~ComparisonSet() override; /** - * @brief Write ComparisonSet to JSon - * @param json - */ - void writeJson(QJsonObject& json) override; + * @brief Write ComparisonSet to JSon + * @param json + */ + void writeJson(QJsonObject& json) const override; /** - * @brief Read ComparisonSet from JSon - * @param json - */ + * @brief Read ComparisonSet from JSon + * @param json + */ bool readJson(QJsonObject& json) override; /** - * @brief Returns whether or not the results from the comparison have their values flipped - * @return - */ + * @brief Returns whether or not the results from the comparison have their values flipped + * @return + */ bool getInvertComparison(); /** - * @brief Return the comparisons contained by the ComparisonSet - * @return - */ + * @brief Return the comparisons contained by the ComparisonSet + * @return + */ QVector getComparisons(); /** - * @brief Specifies whether or not the results from the comparison should have their values flipped - * @param invert - */ + * @brief Specifies whether or not the results from the comparison should have their values flipped + * @param invert + */ void setInvertComparison(bool invert); /** - * @brief Changes the comparisons used by the ComparisonSet to a new set - * @param comparisonValues - */ + * @brief Changes the comparisons used by the ComparisonSet to a new set + * @param comparisonValues + */ void setComparisons(QVector comparisonValues); /** - * @brief Adds a new comparison to the end of the ComparisonSet - * @param comparison - */ + * @brief Adds a new comparison to the end of the ComparisonSet + * @param comparison + */ void addComparison(AbstractComparison::Pointer comparison); /** - * @brief Adds a new comparison to the ComparisonSet at the given index - * @param index - * @param comparison - */ + * @brief Adds a new comparison to the ComparisonSet at the given index + * @param index + * @param comparison + */ void insertComparison(int index, AbstractComparison::Pointer comparison); /** - * @brief Returns whether or not the ComparisonSet contains any ComparisonValues - * @return - */ + * @brief Returns whether or not the ComparisonSet contains any ComparisonValues + * @return + */ bool hasComparisonValue(); /** - * @brief Returns any ComparisonValues contained within the ComparisonSet - * @return - */ + * @brief Returns any ComparisonValues contained within the ComparisonSet + * @return + */ QVector getComparisonValues(); /** - * @brief Checks the comparison's DataArray options based on the renamed path. Returns true if the comparison was changed - * @param renamePath - * @return - */ + * @brief Checks the comparison's DataArray options based on the renamed path. Returns true if the comparison was changed + * @param renamePath + * @return + */ bool renameDataArrayPath(DataArrayPath::RenameType renamePath) override; protected: @@ -130,5 +151,6 @@ class SIMPLib_EXPORT ComparisonSet : public AbstractComparison QVector m_comparisons; ComparisonSet(); -}; +private: +}; diff --git a/Source/SIMPLib/Filtering/ComparisonValue.cpp b/Source/SIMPLib/Filtering/ComparisonValue.cpp index 9d69cf533d..089c6b6e2f 100644 --- a/Source/SIMPLib/Filtering/ComparisonValue.cpp +++ b/Source/SIMPLib/Filtering/ComparisonValue.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ComparisonValue.h" @@ -55,7 +55,7 @@ ComparisonValue::~ComparisonValue() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ComparisonValue::writeJson(QJsonObject& json) +void ComparisonValue::writeJson(QJsonObject& json) const { json["Union Operator"] = m_unionOperator; json["Attribute Array Name"] = m_attributeArrayName; @@ -174,3 +174,28 @@ bool ComparisonValue::renameDataArrayPath(DataArrayPath::RenameType renamePath) return false; } + +// ----------------------------------------------------------------------------- +ComparisonValue::Pointer ComparisonValue::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +ComparisonValue::Pointer ComparisonValue::New() +{ + Pointer sharedPtr(new(ComparisonValue)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString ComparisonValue::getNameOfClass() const +{ + return QString("ComparisonValue"); +} + +// ----------------------------------------------------------------------------- +QString ComparisonValue::ClassName() +{ + return QString("ComparisonValue"); +} diff --git a/Source/SIMPLib/Filtering/ComparisonValue.h b/Source/SIMPLib/Filtering/ComparisonValue.h index ccf27d745b..6fd502fd6d 100644 --- a/Source/SIMPLib/Filtering/ComparisonValue.h +++ b/Source/SIMPLib/Filtering/ComparisonValue.h @@ -1,129 +1,150 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include #include "SIMPLib/Filtering/AbstractComparison.h" #include "SIMPLib/Filtering/ComparisonSet.h" /** -* @brief The ComparisonValue class is used to store comparison operators, values, and DataArray names -* to be used for ComparisonInputsAdvanced -*/ + * @brief The ComparisonValue class is used to store comparison operators, values, and DataArray names + * to be used for ComparisonInputsAdvanced + */ class SIMPLib_EXPORT ComparisonValue : public AbstractComparison { - PYB11_CREATE_BINDINGS(ComparisonValue SUPERCLASS AbstractComparison) - PYB11_CREATION() + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(ComparisonValue SUPERCLASS AbstractComparison) + PYB11_SHARED_POINTERS(ComparisonValue) + PYB11_STATIC_NEW_MACRO(ComparisonValue) PYB11_PROPERTY(QString AttributeArrayName READ getAttributeArrayName WRITE setAttributeArrayName) PYB11_PROPERTY(int CompOperator READ getCompOperator WRITE setCompOperator) PYB11_PROPERTY(double CompValue READ getCompValue WRITE setCompValue) PYB11_PROPERTY(ComparisonSet::Pointer ParentSet READ getParentSet WRITE setParentSet) PYB11_PROPERTY(int UnionOperator READ getUnionOperator WRITE setUnionOperator) + PYB11_END_BINDINGS() + // End Python bindings declarations + public: - SIMPL_SHARED_POINTERS(ComparisonValue) - SIMPL_STATIC_NEW_MACRO(ComparisonValue) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ComparisonValue, AbstractComparison) + using Self = ComparisonValue; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for ComparisonValue + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ComparisonValue + */ + static QString ClassName(); ~ComparisonValue() override; /** - * @brief Writes the ComparisonValue to JSon - * @param json - */ - void writeJson(QJsonObject& json) override; + * @brief Writes the ComparisonValue to JSon + * @param json + */ + void writeJson(QJsonObject& json) const override; /** - * @brief Reads the ComparisonValue from JSon - * @param json - */ + * @brief Reads the ComparisonValue from JSon + * @param json + */ bool readJson(QJsonObject& json) override; /** - * @brief Returns the AttributeArray name - * @return - */ + * @brief Returns the AttributeArray name + * @return + */ QString getAttributeArrayName(); /** - * @brief Returns the comparison operator used - * @return - */ + * @brief Returns the comparison operator used + * @return + */ int getCompOperator(); /** - * @brief Returns the value used by the ComparisonValue - */ + * @brief Returns the value used by the ComparisonValue + */ double getCompValue(); /** - * @brief Sets the AttributeArrayName used - * @param name - */ + * @brief Sets the AttributeArrayName used + * @param name + */ void setAttributeArrayName(QString name); /** - * @brief Sets the comparison operator used - * @param compOperator - */ + * @brief Sets the comparison operator used + * @param compOperator + */ void setCompOperator(int compOperator); /** - * @brief Sets the value used by the comparison - * @param value - */ + * @brief Sets the value used by the comparison + * @param value + */ void setCompValue(double value); /** - * @brief Returns the parent ComparisonSet - * @return - */ + * @brief Returns the parent ComparisonSet + * @return + */ ComparisonSet::Pointer getParentSet(); /** - * @brief Changes the parent ComparisonSet - * @param parentSet - */ + * @brief Changes the parent ComparisonSet + * @param parentSet + */ void setParentSet(ComparisonSet::Pointer parentSet); /** - * @brief Checks the comparison's DataArray options based on the renamed path. Returns true if the comparison was changed - * @param renamePath - * @return - */ + * @brief Checks the comparison's DataArray options based on the renamed path. Returns true if the comparison was changed + * @param renamePath + * @return + */ bool renameDataArrayPath(DataArrayPath::RenameType renamePath) override; protected: @@ -134,5 +155,6 @@ class SIMPLib_EXPORT ComparisonValue : public AbstractComparison ComparisonSet::Pointer m_parentSet; ComparisonValue(); -}; +private: +}; diff --git a/Source/SIMPLib/Filtering/CoreConstants.h b/Source/SIMPLib/Filtering/CoreConstants.h index 2f95915f14..7123273493 100644 --- a/Source/SIMPLib/Filtering/CoreConstants.h +++ b/Source/SIMPLib/Filtering/CoreConstants.h @@ -35,24 +35,22 @@ #include /** -* @brief This namespace is used to define some Constants for the plugin itself. -*/ + * @brief This namespace is used to define some Constants for the plugin itself. + */ namespace CoreConstants { - const QString CorePluginFile("CorePlugin"); - const QString CorePluginDisplayName("Core"); - const QString CoreBaseName("Core"); -} +const QString CorePluginFile("CorePlugin"); +const QString CorePluginDisplayName("Core"); +const QString CoreBaseName("Core"); +} // namespace CoreConstants /** -* @brief Use this namespace to define any custom GUI widgets that collect FilterParameters -* for a filter. Do NOT define general reusable widgets here. -*/ + * @brief Use this namespace to define any custom GUI widgets that collect FilterParameters + * for a filter. Do NOT define general reusable widgets here. + */ namespace FilterParameterWidgetType { - /* const QString SomeCustomWidget("SomeCustomWidget"); */ +/* const QString SomeCustomWidget("SomeCustomWidget"); */ } - - diff --git a/Source/SIMPLib/Filtering/CorePlugin.cpp b/Source/SIMPLib/Filtering/CorePlugin.cpp index 6b5105694e..5d7ba99eba 100644 --- a/Source/SIMPLib/Filtering/CorePlugin.cpp +++ b/Source/SIMPLib/Filtering/CorePlugin.cpp @@ -34,18 +34,19 @@ #include #include +#include +#include "SIMPLib/SIMPLibVersion.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Filtering/CoreConstants.h" #include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Filtering/FilterManager.h" -#include "SIMPLib/SIMPLibVersion.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- CorePlugin::CorePlugin() -: m_Version(SIMPLib::Version::Package()) +: m_Version(SIMPLib::Version::Complete()) , m_CompatibilityVersion(SIMPLib::Version::Package()) , m_Vendor("OpenSource") , m_URL("http://www.bluequartz.net") diff --git a/Source/SIMPLib/Filtering/CorePlugin.h b/Source/SIMPLib/Filtering/CorePlugin.h index a31d0285de..59cebaa143 100644 --- a/Source/SIMPLib/Filtering/CorePlugin.h +++ b/Source/SIMPLib/Filtering/CorePlugin.h @@ -46,144 +46,140 @@ */ class CorePlugin : public QObject, public ISIMPLibPlugin { - Q_OBJECT - Q_INTERFACES(ISIMPLibPlugin) - Q_PLUGIN_METADATA(IID "net.bluequartz.dream3d.CorePlugin") - - - public: - CorePlugin(); - ~CorePlugin() override; - /** - * @brief Returns the name of the plugin that appears on the file system. - * - * Note that if the build is a debug build there will be a _Plugin postfix - * to the filename. - */ - QString getPluginFileName() override; - - /** - * @brief getPluginDisplayName The name that should be used for human facing - * labels and display strings - * @return - */ - QString getPluginDisplayName() override; - - /** - * @brief getPluginBaseName The Name of the plugin. - * - * This typically will NOT have the Plugin suffix. - * @return - */ - QString getPluginBaseName() override; - - /** - * @brief Returns the version - */ - QString getVersion() override; - - /** - * @brief Returns the compatibility version - */ - QString getCompatibilityVersion() override; - - /** - * @brief Returns the name of the vendor - */ - QString getVendor() override; - - /** - * @brief Returns the URL of the plugin - */ - QString getURL() override; - - /** - * @brief Returns the location of the plugin - */ - QString getLocation() override; - - /** - * @brief Returns the description of the plugin - */ - QString getDescription() override; - - /** - * @brief Returns the copyright of the plugin - */ - QString getCopyright() override; - - /** - * @brief Returns the license of the plugin - */ - QString getLicense() override; - - /** - * @brief Returns the filters of the plugin - */ - QList getFilters() override; - - /** - * @brief Returns the third party licenses of the plugin - */ - QMap getThirdPartyLicenses() override; - - /** - * @brief Returns the load status of the plugin - */ - bool getDidLoad() override; - - /** - * @brief Sets the load status of the plugin - */ - void setDidLoad(bool didLoad) override; - - /** - * @brief Sets the location of the plugin on the file system. - * This is required so that we can cache the file path information - * as the plugin is loaded. - */ - void setLocation(QString filePath) override; - - /** - * @brief Register all the filters with the FilterWidgetFactory - */ - void registerFilterWidgets(FilterWidgetManager* fwm) override; - - /** - * @brief This registers the filters that this plugin implements with the Filter Manager that is passed in - * @param fm The FilterManager to register the filters into. - */ - void registerFilters(FilterManager* fm) override; - - - /** - * @brief Writes the settings in the input gui to the Application's preference file - * @param prefs A valid QSettings pointer. - */ - void writeSettings(QSettings& prefs) override; - - /** - * @brief Reads the settings from the Application's preference file and sets - * the input GUI widgets accordingly. - * @param prefs - */ - void readSettings(QSettings& prefs) override; - - private: - QString m_Version; - QString m_CompatibilityVersion; - QString m_Vendor; - QString m_URL; - QString m_Location; - QString m_Copyright; - QList m_Filters; - bool m_DidLoad; - - public: - CorePlugin(const CorePlugin&) = delete; // Copy Constructor Not Implemented - CorePlugin(CorePlugin&&) = delete; // Move Constructor Not Implemented - CorePlugin& operator=(const CorePlugin&) = delete; // Copy Assignment Not Implemented - CorePlugin& operator=(CorePlugin&&) = delete; // Move Assignment Not Implemented + Q_OBJECT + Q_INTERFACES(ISIMPLibPlugin) + Q_PLUGIN_METADATA(IID "net.bluequartz.dream3d.CorePlugin") + +public: + CorePlugin(); + ~CorePlugin() override; + /** + * @brief Returns the name of the plugin that appears on the file system. + * + * Note that if the build is a debug build there will be a _Plugin postfix + * to the filename. + */ + QString getPluginFileName() override; + + /** + * @brief getPluginDisplayName The name that should be used for human facing + * labels and display strings + * @return + */ + QString getPluginDisplayName() override; + + /** + * @brief getPluginBaseName The Name of the plugin. + * + * This typically will NOT have the Plugin suffix. + * @return + */ + QString getPluginBaseName() override; + + /** + * @brief Returns the version + */ + QString getVersion() override; + + /** + * @brief Returns the compatibility version + */ + QString getCompatibilityVersion() override; + + /** + * @brief Returns the name of the vendor + */ + QString getVendor() override; + + /** + * @brief Returns the URL of the plugin + */ + QString getURL() override; + + /** + * @brief Returns the location of the plugin + */ + QString getLocation() override; + + /** + * @brief Returns the description of the plugin + */ + QString getDescription() override; + + /** + * @brief Returns the copyright of the plugin + */ + QString getCopyright() override; + + /** + * @brief Returns the license of the plugin + */ + QString getLicense() override; + + /** + * @brief Returns the filters of the plugin + */ + QList getFilters() override; + + /** + * @brief Returns the third party licenses of the plugin + */ + QMap getThirdPartyLicenses() override; + + /** + * @brief Returns the load status of the plugin + */ + bool getDidLoad() override; + + /** + * @brief Sets the load status of the plugin + */ + void setDidLoad(bool didLoad) override; + + /** + * @brief Sets the location of the plugin on the file system. + * This is required so that we can cache the file path information + * as the plugin is loaded. + */ + void setLocation(QString filePath) override; + + /** + * @brief Register all the filters with the FilterWidgetFactory + */ + void registerFilterWidgets(FilterWidgetManager* fwm) override; + + /** + * @brief This registers the filters that this plugin implements with the Filter Manager that is passed in + * @param fm The FilterManager to register the filters into. + */ + void registerFilters(FilterManager* fm) override; + + /** + * @brief Writes the settings in the input gui to the Application's preference file + * @param prefs A valid QSettings pointer. + */ + void writeSettings(QSettings& prefs) override; + + /** + * @brief Reads the settings from the Application's preference file and sets + * the input GUI widgets accordingly. + * @param prefs + */ + void readSettings(QSettings& prefs) override; + +private: + QString m_Version; + QString m_CompatibilityVersion; + QString m_Vendor; + QString m_URL; + QString m_Location; + QString m_Copyright; + QList m_Filters; + bool m_DidLoad; + +public: + CorePlugin(const CorePlugin&) = delete; // Copy Constructor Not Implemented + CorePlugin(CorePlugin&&) = delete; // Move Constructor Not Implemented + CorePlugin& operator=(const CorePlugin&) = delete; // Copy Assignment Not Implemented + CorePlugin& operator=(CorePlugin&&) = delete; // Move Assignment Not Implemented }; - - diff --git a/Source/SIMPLib/Filtering/FilterFactory.hpp b/Source/SIMPLib/Filtering/FilterFactory.hpp old mode 100755 new mode 100644 index 7ebce8bcfe..143d67b4d4 --- a/Source/SIMPLib/Filtering/FilterFactory.hpp +++ b/Source/SIMPLib/Filtering/FilterFactory.hpp @@ -1,52 +1,78 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/Filtering/IFilterFactory.hpp" -#include "SIMPLib/SIMPLib.h" -template class FilterFactory : public IFilterFactory +template +class FilterFactory : public IFilterFactory { public: - SIMPL_SHARED_POINTERS(FilterFactory) - SIMPL_TYPE_MACRO_SUPER(FilterFactory, IFilterFactory) - SIMPL_STATIC_NEW_MACRO(FilterFactory) + using Self = FilterFactory; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer() + { + return Pointer(static_cast(nullptr)); + } + + /** + * @brief Returns the name of the class for AbstractMessage + */ + QString getNameOfClass() const override + { + return QString("FilterFactory"); + } + /** + * @brief Returns the name of the class for AbstractMessage + */ + static QString ClassName() + { + return QString("FilterFactory"); + } + static Pointer New() + { + Pointer sharedPtr(new(Self)); + return sharedPtr; + } /** * @brief Creates a new for this filter. The Calling method MUST set * a parent OR take responsibility for deleting this object. @@ -87,7 +113,12 @@ template class FilterFactory : public IFilterFactory { return m_CompiledLibraryName; } - + + QString getFilterHtmlSummary() const override + { + return m_HtmlSummary; + } + QUuid getUuid() const override { return m_Uuid; @@ -104,6 +135,7 @@ template class FilterFactory : public IFilterFactory m_BrandingString = w->getBrandingString(); m_CompiledLibraryName = w->getCompiledLibraryName(); m_Uuid = w->getUuid(); + m_HtmlSummary = w->generateHtmlSummary(); } private: @@ -113,8 +145,12 @@ template class FilterFactory : public IFilterFactory QString m_HumanName; QString m_BrandingString; QString m_CompiledLibraryName; + QString m_HtmlSummary; QUuid m_Uuid; - FilterFactory(const FilterFactory&); // Copy Constructor Not Implemented - void operator=(const FilterFactory&); // Move assignment Not Implemented +public: + FilterFactory(const FilterFactory&) = delete; // Copy Constructor Not Implemented + FilterFactory(FilterFactory&&) = delete; // Move Constructor Not Implemented + FilterFactory& operator=(const FilterFactory&) = delete; // Copy Assignment Not Implemented + FilterFactory& operator=(FilterFactory&&) = delete; // Move Assignment Not Implemented }; diff --git a/Source/SIMPLib/Filtering/FilterManager.cpp b/Source/SIMPLib/Filtering/FilterManager.cpp index bcc61512f9..3ead63dccf 100644 --- a/Source/SIMPLib/Filtering/FilterManager.cpp +++ b/Source/SIMPLib/Filtering/FilterManager.cpp @@ -1,43 +1,48 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "FilterManager.h" -#include "SIMPLib/Filtering/FilterFactory.hpp" -#include "SIMPLib/Filtering/CorePlugin.h" +#include +#include +#include +#include + +#include "SIMPLib/Filtering/CorePlugin.h" +#include "SIMPLib/Filtering/FilterFactory.hpp" #include "SIMPLib/Plugin/SIMPLPluginConstants.h" FilterManager* FilterManager::s_Self = nullptr; @@ -105,7 +110,7 @@ FilterManager::Collection FilterManager::getFactories() const void FilterManager::printFactoryNames() const { QList keys = m_Factories.keys(); - for(auto const key : keys) + for(const auto& key : keys) { qDebug() << "Name: " << key << "\n"; } @@ -146,14 +151,48 @@ FilterManager::Collection FilterManager::getFactories(const QString& groupName, return groupFactories; } +// ----------------------------------------------------------------------------- +bool FilterManager::contains(const QUuid& uuid) const +{ + return m_UuidFactories.contains(uuid); +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FilterManager::addFilterFactory(const QString& name, IFilterFactory::Pointer factory) { // std::cout << this << " - Registering Filter: " << name.toStdString() << std::endl; + QUuid uuid = factory->getUuid(); + + if(uuid.isNull()) + { + throw std::runtime_error(QString("%1 (%2) has an invalid uuid").arg(name, factory->getCompiledLibraryName()).toStdString()); + } + + if(name.isEmpty()) + { + throw std::runtime_error("Attempted to add a filter with an empty name"); + } + + if(m_UuidFactories.contains(uuid)) + { + IFilterFactory::Pointer existingFactory = m_UuidFactories[uuid]; + throw std::runtime_error(QString("Attempted to add %1 (%2), but %3 (%4) has the same uuid") + .arg(name, factory->getCompiledLibraryName(), existingFactory->getFilterClassName(), existingFactory->getCompiledLibraryName()) + .toStdString()); + } + + if(m_Factories.contains(name)) + { + IFilterFactory::Pointer existingFactory = m_Factories[name]; + throw std::runtime_error(QString("Attempted to add %1 (%2), but %3 (%4) has the same name") + .arg(name, factory->getCompiledLibraryName(), existingFactory->getFilterClassName(), existingFactory->getCompiledLibraryName()) + .toStdString()); + } + m_Factories[name] = factory; - m_UuidFactories[factory->getUuid()] = factory; + m_UuidFactories[uuid] = factory; } // ----------------------------------------------------------------------------- @@ -211,7 +250,6 @@ IFilterFactory::Pointer FilterManager::getFactoryFromClassName(const QString& fi return IFilterFactory::NullPointer(); } - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -249,13 +287,13 @@ IFilterFactory::Pointer FilterManager::getFactoryFromHumanName(const QString& hu QJsonArray FilterManager::toJsonArray() const { QJsonArray filterArray; - + FilterManager::Collection factories = getFactories(); for(auto factory : factories) { AbstractFilter::Pointer filter = factory->create(); QJsonObject filtJson; - + filtJson[SIMPL::JSON::Name] = filter->getHumanLabel(); filtJson[SIMPL::JSON::ClassName] = filter->getNameOfClass(); filtJson[SIMPL::JSON::Uuid] = filter->getUuid().toString(); @@ -263,8 +301,70 @@ QJsonArray FilterManager::toJsonArray() const filtJson[SIMPL::JSON::Version] = filter->getFilterVersion(); filtJson[SIMPL::JSON::GroupName] = filter->getGroupName(); filtJson[SIMPL::JSON::SubGroupName] = filter->getSubGroupName(); - + filterArray.append(filtJson); } return filterArray; } + +// ----------------------------------------------------------------------------- +QString FilterManager::getNameOfClass() const +{ + return QString("FilterManager"); +} + +// ----------------------------------------------------------------------------- +QString FilterManager::ClassName() +{ + return QString("FilterManager"); +} + +// ----------------------------------------------------------------------------- +bool FilterManager::removeFilterFactory(const QUuid& uuid) +{ + if(!m_UuidFactories.contains(uuid)) + { + return false; + } + + QString filterName = m_UuidFactories[uuid]->getFilterClassName(); + + m_Factories.remove(filterName); + m_UuidFactories.remove(uuid); +#ifdef SIMPL_EMBED_PYTHON + m_PythonUuids.remove(uuid); +#endif + + return true; +} + +#ifdef SIMPL_EMBED_PYTHON +// ----------------------------------------------------------------------------- +QSet FilterManager::pythonFilterUuids() const +{ + return m_PythonUuids; +} + +// ----------------------------------------------------------------------------- +void FilterManager::addPythonFilterFactory(const QString& name, IFilterFactory::Pointer factory) +{ + addFilterFactory(name, factory); + m_PythonUuids.insert(factory->getUuid()); +} + +// ----------------------------------------------------------------------------- +void FilterManager::clearPythonFilterFactories() +{ + QSet pythonUuids = m_PythonUuids; + for(const QUuid& uuid : pythonUuids) + { + removeFilterFactory(uuid); + } +} + +// ----------------------------------------------------------------------------- +bool FilterManager::isPythonFilter(const QUuid& uuid) const +{ + return m_PythonUuids.contains(uuid); +} +#endif diff --git a/Source/SIMPLib/Filtering/FilterManager.h b/Source/SIMPLib/Filtering/FilterManager.h old mode 100755 new mode 100644 index fe86d471df..f3e0a75e44 --- a/Source/SIMPLib/Filtering/FilterManager.h +++ b/Source/SIMPLib/Filtering/FilterManager.h @@ -1,49 +1,52 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include #include #include #include #include -#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/IFilterFactory.hpp" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/IFilterFactory.hpp" + +#ifdef SIMPL_EMBED_PYTHON +#include +#endif /** * @brief The FilterManager class manages instances of filters and is mainly used to instantiate @@ -53,7 +56,14 @@ class SIMPLib_EXPORT FilterManager { public: - SIMPL_TYPE_MACRO(FilterManager) + /** + * @brief Returns the name of the class for FilterManager + */ + QString getNameOfClass() const; + /** + * @brief Returns the name of the class for FilterManager + */ + static QString ClassName(); virtual ~FilterManager(); @@ -62,7 +72,7 @@ class SIMPLib_EXPORT FilterManager typedef QMap UuidCollection; typedef QMapIterator UuidCollectionIterator; - + /** * @brief Static instance to retrieve the global instance of this class * @return @@ -109,6 +119,13 @@ class SIMPLib_EXPORT FilterManager */ Collection getFactories(const QString& groupName, const QString& subGroupName); + /** + * @brief Returns true if it contains a filter factory with the given UUID + * @param uuid + * @return + */ + bool contains(const QUuid& uuid) const; + /** * @brief Adds a Factory that creates QFilters * @param name @@ -116,6 +133,13 @@ class SIMPLib_EXPORT FilterManager */ void addFilterFactory(const QString& name, IFilterFactory::Pointer factory); + /** + * @brief Removes the given filter factory by UUID. Returns true if successful + * @param uuid + * @return + */ + bool removeFilterFactory(const QUuid& uuid); + /** * @brief getGroupNames Returns the uniqe set of group names for all the filters * @return @@ -134,7 +158,7 @@ class SIMPLib_EXPORT FilterManager * @param filterName * @return */ - IFilterFactory::Pointer getFactoryFromClassName(const QString& filterName) const; + IFilterFactory::Pointer getFactoryFromClassName(const QString& filterName) const; /** * @brief getFactoryFromClassName Returns a FilterFactory for a given filter @@ -142,28 +166,59 @@ class SIMPLib_EXPORT FilterManager * @return */ IFilterFactory::Pointer getFactoryFromUuid(const QUuid& uuid) const; - + /** * @brief getFactoryFromClassNameHumanName For a given human label, the FilterFactory is given * @param humanName * @return */ IFilterFactory::Pointer getFactoryFromHumanName(const QString& humanName); - + /** * @brief This will return a QJsonArray object that contains information about * all available filters - * @return + * @return */ QJsonArray toJsonArray() const; +#ifdef SIMPL_EMBED_PYTHON + /** + * @brief Adds a factory that creates Python filters + * @param name + * @param factory + */ + void addPythonFilterFactory(const QString& name, IFilterFactory::Pointer factory); + + /** + * @brief Returns set of Python filter uuids + * @return + */ + QSet pythonFilterUuids() const; + + /** + * @brief Returns true if the given uuid is for a Python filter + * @param uuid + * @return + */ + bool isPythonFilter(const QUuid& uuid) const; + + /** + * @brief Clears all Python filters + */ + void clearPythonFilterFactories(); +#endif + protected: FilterManager(); private: Collection m_Factories; UuidCollection m_UuidFactories; - + +#ifdef SIMPL_EMBED_PYTHON + QSet m_PythonUuids; +#endif + static FilterManager* s_Self; public: @@ -172,4 +227,3 @@ class SIMPLib_EXPORT FilterManager FilterManager& operator=(const FilterManager&) = delete; // Copy Assignment Not Implemented FilterManager& operator=(FilterManager&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/Filtering/FilterPipeline.cpp b/Source/SIMPLib/Filtering/FilterPipeline.cpp index cd7655a6cf..16e7f12d66 100644 --- a/Source/SIMPLib/Filtering/FilterPipeline.cpp +++ b/Source/SIMPLib/Filtering/FilterPipeline.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,20 +35,69 @@ #include "FilterPipeline.h" -#include "SIMPLib/CoreFilters/EmptyFilter.h" -#include "SIMPLib/Filtering/FilterFactory.hpp" -#include "SIMPLib/Filtering/FilterManager.h" +#include +#include "SIMPLib/Common/Constants.h" #include "SIMPLib/CoreFilters/DataContainerReader.h" +#include "SIMPLib/CoreFilters/EmptyFilter.h" #include "SIMPLib/DataContainers/DataContainerArray.h" +#include "SIMPLib/DataContainers/RenameDataPath.h" +#include "SIMPLib/Filtering/BadFilter.h" +#include "SIMPLib/Filtering/FilterFactory.hpp" +#include "SIMPLib/Filtering/FilterManager.h" +#include "SIMPLib/Messages/AbstractMessageHandler.h" +#include "SIMPLib/Messages/FilterErrorMessage.h" +#include "SIMPLib/Messages/FilterProgressMessage.h" +#include "SIMPLib/Messages/FilterStatusMessage.h" +#include "SIMPLib/Messages/FilterWarningMessage.h" +#include "SIMPLib/Messages/PipelineErrorMessage.h" +#include "SIMPLib/Messages/PipelineProgressMessage.h" +#include "SIMPLib/Messages/PipelineStatusMessage.h" +#include "SIMPLib/Messages/PipelineWarningMessage.h" #include "SIMPLib/Utilities/StringOperations.h" +#define RENAME_ENABLED 1 + +/** + * @brief This message handler is used by FilterPipeline to re-emit filter progress messages as pipeline progress messages + */ +class FilterPipelineMessageHandler : public AbstractMessageHandler +{ +public: + explicit FilterPipelineMessageHandler(FilterPipeline* pipeline) + : m_Pipeline(pipeline) + { + } + + /** + * @brief Converts filter progress messages into pipeline progress messages. This enables the overall pipeline + * progress to update along with the filter's progress updates + */ + void processMessage(const FilterProgressMessage* msg) const override + { + int filterProgress = msg->getProgressValue(); + float filterProgressStep = (1.0f / m_Pipeline->size()) * filterProgress / 100.0f; + int pipelineProgress = static_cast((static_cast(msg->getPipelineIndex()) / (m_Pipeline->size()) + filterProgressStep) * 100.0f); + m_Pipeline->notifyProgressMessage(pipelineProgress, ""); + } + +private: + FilterPipeline* m_Pipeline = nullptr; +}; + +class PipelineIdleException : public std::exception +{ + const char* what() const noexcept + { + return "A pipeline that was finishing execution was marked as in the idle state."; + } +}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- FilterPipeline::FilterPipeline() -: m_ErrorCondition(0) -, m_PipelineName("") +: m_PipelineName("") , m_Dca(nullptr) { } @@ -61,7 +110,7 @@ FilterPipeline::~FilterPipeline() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString FilterPipeline::getName() +QString FilterPipeline::getName() const { return m_PipelineName; } @@ -74,7 +123,7 @@ void FilterPipeline::setName(const QString& newName) QString oldName = m_PipelineName; m_PipelineName = newName; - emit pipelineNameChanged(oldName, newName); + Q_EMIT pipelineNameChanged(oldName, newName); } // ----------------------------------------------------------------------------- @@ -122,7 +171,7 @@ QJsonObject FilterPipeline::toJson() } else { - AbstractFilter::Pointer badFilter = AbstractFilter::New(); + AbstractFilter::Pointer badFilter = BadFilter::New(); QJsonObject badFilterJson = badFilter->toJson(); badFilterJson["Unknown Filter"] = "ERROR: Filter instance was nullptr within the FilterPipeline instance. Report this error to the DREAM3D Developers"; @@ -194,7 +243,10 @@ void FilterPipeline::fromJson(const QJsonObject& json, IObserver* obs) // Store FilterManager FilterManager* filtManager = FilterManager::Instance(); FilterFactory::Pointer emptyFilterFactory = FilterFactory::New(); - filtManager->addFilterFactory("EmptyFilter", emptyFilterFactory); + if(!filtManager->contains(emptyFilterFactory->getUuid())) + { + filtManager->addFilterFactory("EmptyFilter", emptyFilterFactory); + } QJsonObject builderObj = json[SIMPL::Settings::PipelineBuilderGroup].toObject(); int filterCount = builderObj[SIMPL::Settings::NumFilters].toInt(); @@ -271,8 +323,8 @@ void FilterPipeline::fromJson(const QJsonObject& json, IObserver* obs) Possible reasons include a name change of the filter, plugin not loading or a simple spelling mistake? A \ blank filter has been inserted in its place. Possible error message is: %1") .arg(filterName); - PipelineMessage pm(filterName, ss, -66066, PipelineMessage::MessageType::Error); - pm.setPrefix("JsonFilterParametersReader::ReadPipelineFromFile()"); + QString prefix = "JsonFilterParametersReader::ReadPipelineFromFile()"; + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New(getName(), ss, -66066); obs->processPipelineMessage(pm); } } @@ -287,10 +339,6 @@ void FilterPipeline::cancel() if(m_State != FilterPipeline::State::Executing) { // We cannot cancel a pipeline that is not executing - setErrorCondition(-201); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss; if(m_State == FilterPipeline::State::Idle) { @@ -304,9 +352,7 @@ void FilterPipeline::cancel() { ss = QObject::tr("Pipeline '%1' could not be canceled.").arg(getName()); } - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-201, ss); return; } @@ -324,7 +370,7 @@ DataContainerArray::Pointer FilterPipeline::run() { m_Dca = execute(); - emit pipelineFinished(); + Q_EMIT pipelineFinished(); return m_Dca; } @@ -337,20 +383,14 @@ bool FilterPipeline::pushFront(const AbstractFilter::Pointer& f) if(m_State != FilterPipeline::State::Idle) { // Do not allow anyone to add filters to a pipeline that is not idle - setErrorCondition(-202); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Filter '%1' could not be added to pipeline '%2' because the pipeline is already executing.").arg(f->getHumanLabel()).arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-202, ss); return false; } m_Pipeline.push_front(f); updatePrevNextFilters(); - emit pipelineWasEdited(); + Q_EMIT pipelineWasEdited(); return true; } // ----------------------------------------------------------------------------- @@ -361,22 +401,16 @@ bool FilterPipeline::popFront() if(m_State != FilterPipeline::State::Idle) { // Do not allow anyone to remove filters from a pipeline that is not idle - setErrorCondition(-203); - AbstractFilter::Pointer f = m_Pipeline.front(); - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Filter '%1' could not be removed from pipeline '%2' because the pipeline is already executing.").arg(f->getHumanLabel()).arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-203, ss); return false; } m_Pipeline.pop_front(); updatePrevNextFilters(); - emit pipelineWasEdited(); + Q_EMIT pipelineWasEdited(); return true; } // ----------------------------------------------------------------------------- @@ -387,20 +421,14 @@ bool FilterPipeline::pushBack(const AbstractFilter::Pointer& f) if(m_State != FilterPipeline::State::Idle) { // Do not allow anyone to add filters to a pipeline that is not idle - setErrorCondition(-204); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Filter '%1' could not be added to pipeline '%2' because the pipeline is already executing.").arg(f->getHumanLabel()).arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-204, ss); return false; } m_Pipeline.push_back(f); updatePrevNextFilters(); - emit pipelineWasEdited(); + Q_EMIT pipelineWasEdited(); return true; } // ----------------------------------------------------------------------------- @@ -411,22 +439,16 @@ bool FilterPipeline::popBack() if(m_State != FilterPipeline::State::Idle) { // Do not allow anyone to remove filters from a pipeline that is not idle - setErrorCondition(-205); - AbstractFilter::Pointer f = m_Pipeline.back(); - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Filter '%1' could not be removed from pipeline '%2' because the pipeline is already executing.").arg(f->getHumanLabel()).arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-205, ss); return false; } m_Pipeline.pop_back(); updatePrevNextFilters(); - emit pipelineWasEdited(); + Q_EMIT pipelineWasEdited(); return true; } // ----------------------------------------------------------------------------- @@ -437,14 +459,8 @@ bool FilterPipeline::insert(size_t index, const AbstractFilter::Pointer& f) if(m_State != FilterPipeline::State::Idle) { // Do not allow anyone to add filters to a pipeline that is not idle - setErrorCondition(-206); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Filter '%1' could not be added to pipeline '%2' because the pipeline is already executing.").arg(f->getHumanLabel()).arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-206, ss); return false; } @@ -455,7 +471,7 @@ bool FilterPipeline::insert(size_t index, const AbstractFilter::Pointer& f) } m_Pipeline.insert(it, f); updatePrevNextFilters(); - emit pipelineWasEdited(); + Q_EMIT pipelineWasEdited(); return true; } // ----------------------------------------------------------------------------- @@ -466,16 +482,10 @@ bool FilterPipeline::erase(size_t index) if(m_State != FilterPipeline::State::Idle) { // Do not allow anyone to remove filters from a pipeline that is not idle - setErrorCondition(-207); - AbstractFilter::Pointer f = m_Pipeline[index]; - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Filter '%1' could not be removed from pipeline '%2' because the pipeline is already executing.").arg(f->getHumanLabel()).arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-207, ss); return false; } @@ -486,7 +496,7 @@ bool FilterPipeline::erase(size_t index) } m_Pipeline.erase(it); updatePrevNextFilters(); - emit pipelineWasEdited(); + Q_EMIT pipelineWasEdited(); return true; } // ----------------------------------------------------------------------------- @@ -497,14 +507,8 @@ bool FilterPipeline::clear() if(m_State != FilterPipeline::State::Idle) { // We cannot clear a pipeline that is not idle - setErrorCondition(-208); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Pipeline '%1' could not be cleared because it is executing.").arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-208, ss); return false; } @@ -514,7 +518,7 @@ bool FilterPipeline::clear() filter->setNextFilter(AbstractFilter::NullPointer()); } m_Pipeline.clear(); - emit pipelineWasEdited(); + Q_EMIT pipelineWasEdited(); return true; } // ----------------------------------------------------------------------------- @@ -540,14 +544,8 @@ AbstractFilter::Pointer FilterPipeline::removeFirstFilterByName(const QString& n if(m_State != FilterPipeline::State::Idle) { // Do not allow anyone to remove filters from a pipeline that is not idle - setErrorCondition(-209); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Filter '%1' could not be removed from pipeline '%2' because the pipeline is already executing.").arg(name).arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-209, ss); return AbstractFilter::NullPointer(); } @@ -562,7 +560,7 @@ AbstractFilter::Pointer FilterPipeline::removeFirstFilterByName(const QString& n } } updatePrevNextFilters(); - emit pipelineWasEdited(); + Q_EMIT pipelineWasEdited(); return f; } @@ -621,12 +619,66 @@ void FilterPipeline::updatePrevNextFilters() } } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterPipeline::setErrorCondition(int code, const QString& messageText) +{ + m_ErrorCode = code; + PipelineErrorMessage::Pointer pm = PipelineErrorMessage::New(getName(), messageText, code); + Q_EMIT messageGenerated(pm); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterPipeline::notifyStatusMessage(const QString& messageText) const +{ + PipelineStatusMessage::Pointer pm = PipelineStatusMessage::New(getName(), messageText); + Q_EMIT messageGenerated(pm); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterPipeline::setWarningCondition(int code, const QString& messageText) +{ + m_WarningCode = code; + PipelineWarningMessage::Pointer pm = PipelineWarningMessage::New(getName(), messageText, code); + Q_EMIT messageGenerated(pm); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterPipeline::notifyProgressMessage(int progress, const QString& messageText) const +{ + PipelineProgressMessage::Pointer pm = PipelineProgressMessage::New(getName(), messageText, progress); + Q_EMIT messageGenerated(pm); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterPipeline::clearErrorCode() +{ + m_ErrorCode = 0; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterPipeline::clearWarningCode() +{ + m_WarningCode = 0; +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FilterPipeline::addMessageReceiver(QObject* obj) { - connect(this, SIGNAL(pipelineGeneratedMessage(const PipelineMessage&)), obj, SLOT(processPipelineMessage(const PipelineMessage&))); + connect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), obj, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); m_MessageReceivers.push_back(obj); } @@ -635,30 +687,55 @@ void FilterPipeline::addMessageReceiver(QObject* obj) // ----------------------------------------------------------------------------- void FilterPipeline::removeMessageReceiver(QObject* obj) { - disconnect(this, SIGNAL(pipelineGeneratedMessage(const PipelineMessage&)), obj, SLOT(processPipelineMessage(const PipelineMessage&))); + disconnect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), obj, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); + m_MessageReceivers.removeAll(obj); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterPipeline::addObserver(Observer* obj) +{ + connect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), obj, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); + m_MessageReceivers.push_back(obj); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void FilterPipeline::removeObserver(Observer* obj) +{ + disconnect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), obj, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); m_MessageReceivers.removeAll(obj); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FilterPipeline::connectFilterNotifications(QObject* filter) +void FilterPipeline::connectFilterNotifications(AbstractFilter* filter) { for(const auto& messageReceiver : m_MessageReceivers) { - connect(filter, SIGNAL(filterGeneratedMessage(const PipelineMessage&)), messageReceiver, SLOT(processPipelineMessage(const PipelineMessage&))); + connect(filter, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), messageReceiver, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); } + + connect(filter, &AbstractFilter::messageGenerated, [=](AbstractMessage::Pointer msg) { + FilterPipelineMessageHandler msgHandler(this); + msg->visit(&msgHandler); + }); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void FilterPipeline::disconnectFilterNotifications(QObject* filter) +void FilterPipeline::disconnectFilterNotifications(AbstractFilter* filter) { for(const auto& messageReceiver : m_MessageReceivers) { - disconnect(filter, SIGNAL(filterGeneratedMessage(const PipelineMessage&)), messageReceiver, SLOT(processPipelineMessage(const PipelineMessage&))); + disconnect(filter, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), messageReceiver, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); } + + disconnect(filter, &AbstractFilter::messageGenerated, nullptr, nullptr); } // ----------------------------------------------------------------------------- @@ -669,96 +746,87 @@ int FilterPipeline::preflightPipeline() if(m_State != FilterPipeline::State::Idle) { // We cannot preflight a pipeline that is not idle - setErrorCondition(-203); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Pipeline '%1' could not be preflighted because it is already executing.").arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); - return getErrorCondition(); + int err = -203; + setErrorCondition(err, ss); + return err; } // Create the DataContainer object DataContainerArray::Pointer dca = DataContainerArray::New(); - setErrorCondition(0); + clearErrorCode(); int preflightError = 0; DataArrayPath::RenameContainer renamedPaths; - DataArrayPath::RenameContainer filterRenamedPaths; // Start looping through each filter in the Pipeline and preflight everything - // for(FilterContainerType::iterator filter = m_Pipeline.begin(); filter != m_Pipeline.end(); ++filter) for(const auto& filter : m_Pipeline) { // Do not preflight disabled filters if(filter->getEnabled()) { - // Update renamed paths before getting old created paths - DataContainerArray::Pointer oldDca = filter->getDataContainerArray(); - oldDca->renameDataArrayPaths(filterRenamedPaths); - filter->setDataContainerArray(oldDca); - filter->renameDataArrayPaths(filterRenamedPaths); - - std::list oldCreatedPaths = filter->getCreatedPaths(); - + filter->setDataContainerArray(dca->deepCopy(true)); +#if RENAME_ENABLED + // Avoid renaming filters as soon as they are added to the pipeline + if(filter->property("HasRenameValues").toBool()) + { + filter->renameDataArrayPaths(renamedPaths); + RenameDataPath::CalculateRenamedPaths(filter, renamedPaths); + } + else + { + filter->setProperty("HasRenameValues", true); + } +#endif filter->setDataContainerArray(dca); - filter->renameDataArrayPaths(renamedPaths); setCurrentFilter(filter); connectFilterNotifications(filter.get()); + filter->clearRenamedPaths(); filter->preflight(); disconnectFilterNotifications(filter.get()); filter->setCancel(false); // Reset the cancel flag - preflightError |= filter->getErrorCondition(); + preflightError |= filter->getErrorCode(); filter->setDataContainerArray(dca->deepCopy(false)); - std::list currentCreatedPaths = filter->getCreatedPaths(); - - // Check if an existing renamed path was created by this filter - for(const DataArrayPath& createdPath : currentCreatedPaths) +#if RENAME_ENABLED + // Check if an existing renamed path was deleted by this filter + const std::list deletedPaths = filter->getDeletedPaths(); + for(const DataArrayPath& deletedPath : deletedPaths) { - // Filter Parameter changes for(const DataArrayPath::RenameType& rename : renamedPaths) { - DataArrayPath originalPath; - DataArrayPath renamePath; - std::tie(originalPath, renamePath) = rename; - if(originalPath == createdPath) + const DataArrayPath& originalPath = rename.first; + // const DataArrayPath& renamePath = std::get<1>(rename); + if(originalPath == deletedPath) { - renamedPaths.remove(rename); + const auto iter = std::find(renamedPaths.begin(), renamedPaths.end(), rename); + renamedPaths.erase(iter); break; } } - // Rename Filters - for(const DataArrayPath::RenameType& rename : filterRenamedPaths) + } + // Filter renamed existing DataArrayPaths + const DataArrayPath::RenameContainer newRenamePaths = filter->getRenamedPaths(); + for(const DataArrayPath::RenameType& newRename : newRenamePaths) + { + // Loop through all existing rename paths and update as appropriate + for(auto iter = renamedPaths.cbegin(); iter != renamedPaths.cend(); ++iter) { - DataArrayPath originalPath; - DataArrayPath renamePath; - std::tie(originalPath, renamePath) = rename; - if(originalPath == createdPath) + const auto& existingRename = (*iter); + const auto updatedRenameOpt = DataArrayPath::CreateLinkingRename(existingRename, newRename); + if(true == updatedRenameOpt.first) { - filterRenamedPaths.remove(rename); - break; + // Remove the old rename, insert the updated one, and update the iterator + renamedPaths.insert(iter, updatedRenameOpt.second); } } + // Add the new rename path + renamedPaths.push_back(newRename); } - - DataArrayPath::RenameContainer newRenamedPaths = DataArrayPath::CheckForRenamedPaths(oldDca, dca, oldCreatedPaths, currentCreatedPaths); - for(const DataArrayPath::RenameType& renameType : newRenamedPaths) - { - renamedPaths.push_back(renameType); - } - - // Filter renamed existing DataArrayPaths - DataArrayPath::RenameContainer hardRenamePaths = filter->getRenamedPaths(); - for(const DataArrayPath::RenameType& renameType : hardRenamePaths) - { - renamedPaths.push_back(renameType); - filterRenamedPaths.push_back(renameType); - } +#endif } +#if RENAME_ENABLED else { // Some widgets require the updated path to be valid before it can be set in the widget @@ -766,17 +834,16 @@ int FilterPipeline::preflightPipeline() filter->renameDataArrayPaths(renamedPaths); // Undo filter renaming - DataArrayPath::RenameContainer filterRenamedPaths = filter->getRenamedPaths(); - for(DataArrayPath::RenameType renameType : filterRenamedPaths) + const DataArrayPath::RenameContainer filterRenamedPaths = filter->getRenamedPaths(); + for(const DataArrayPath::RenameType& renameType : filterRenamedPaths) { - DataArrayPath oldPath; - DataArrayPath newPath; - std::tie(oldPath, newPath) = renameType; - renameType = std::make_pair(newPath, oldPath); + const DataArrayPath& oldPath = renameType.first; + const DataArrayPath& newPath = renameType.second; - renamedPaths.push_back(renameType); + renamedPaths.push_back(std::make_pair(newPath, oldPath)); } } +#endif } setCurrentFilter(AbstractFilter::NullPointer()); @@ -787,18 +854,20 @@ int FilterPipeline::preflightPipeline() // // ----------------------------------------------------------------------------- DataContainerArray::Pointer FilterPipeline::execute() +{ + return execute(DataContainerArray::New()); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +DataContainerArray::Pointer FilterPipeline::execute(DataContainerArray::Pointer dca) { if(m_State != FilterPipeline::State::Idle) { // We cannot execute a pipeline that is not idle - setErrorCondition(-200); - - PipelineMessage progValue; - progValue.setType(PipelineMessage::MessageType::Error); QString ss = QObject::tr("Pipeline '%1' could not be executed because it is already executing.").arg(getName()); - progValue.setText(ss); - progValue.setCode(getErrorCondition()); - emit pipelineGeneratedMessage(progValue); + setErrorCondition(-200, ss); disconnectSignalsSlots(); return DataContainerArray::NullPointer(); @@ -812,51 +881,42 @@ DataContainerArray::Pointer FilterPipeline::execute() m_State = FilterPipeline::State::Executing; - m_Dca = DataContainerArray::New(); + m_Dca = dca; + QDateTime now = QDateTime::currentDateTime(); + QString msg; + QTextStream out(&msg); + out << "Pipline Start: " << now.toString(Qt::ISODate); + notifyStatusMessage(msg); // Start looping through the Pipeline - float progress = 0.0f; - - PipelineMessage progValue("", "", 0, PipelineMessage::MessageType::ProgressValue, -1); for(const auto& filt : m_Pipeline) { - progress = progress + 1.0f; - progValue.setType(PipelineMessage::MessageType::ProgressValue); - progValue.setProgressValue(static_cast(progress / (m_Pipeline.size() + 1) * 100.0f)); - emit pipelineGeneratedMessage(progValue); - - QString ss = QObject::tr("[%1/%2] %3 ").arg(progress).arg(m_Pipeline.size()).arg(filt->getHumanLabel()); + int filtIndex = filt->getPipelineIndex(); + QString ss = QObject::tr("[%1/%2] %3").arg(filtIndex + 1).arg(m_Pipeline.size()).arg(filt->getHumanLabel()); + notifyStatusMessage(ss); - progValue.setType(PipelineMessage::MessageType::StatusMessage); - progValue.setText(ss); - emit pipelineGeneratedMessage(progValue); - emit filt->filterInProgress(filt.get()); + Q_EMIT filt->filterInProgress(filt.get()); // Do not execute disabled filters if(filt->getEnabled()) { - filt->setMessagePrefix(ss); + // filt->setMessagePrefix(ss); connectFilterNotifications(filt.get()); filt->setDataContainerArray(m_Dca); setCurrentFilter(filt); filt->execute(); disconnectFilterNotifications(filt.get()); filt->setDataContainerArray(DataContainerArray::NullPointer()); - err = filt->getErrorCondition(); + err = filt->getErrorCode(); if(err < 0) { - setErrorCondition(err); - progValue.setFilterClassName(filt->getNameOfClass()); - progValue.setFilterHumanLabel(filt->getHumanLabel()); - progValue.setType(PipelineMessage::MessageType::Error); - progValue.setProgressValue(100); - ss = QObject::tr("[%1/%2] %3 caused an error during execution.").arg(progress).arg(m_Pipeline.size()).arg(filt->getHumanLabel()); - progValue.setText(ss); - progValue.setPipelineIndex(filt->getPipelineIndex()); - progValue.setCode(filt->getErrorCondition()); - emit pipelineGeneratedMessage(progValue); - emit filt->filterCompleted(filt.get()); - emit pipelineFinished(); + ss = QObject::tr("[%1/%2] %3 caused an error during execution.").arg(filtIndex + 1).arg(m_Pipeline.size()).arg(filt->getHumanLabel()); + setErrorCondition(err, ss); + + notifyProgressMessage(100, ""); + + Q_EMIT filt->filterCompleted(filt.get()); + Q_EMIT pipelineFinished(); disconnectSignalsSlots(); m_State = FilterPipeline::State::Idle; m_ExecutionResult = FilterPipeline::ExecutionResult::Failed; @@ -872,38 +932,35 @@ DataContainerArray::Pointer FilterPipeline::execute() } // Emit that the filter is completed for those objects that care, even the disabled ones. - emit filt->filterCompleted(filt.get()); + Q_EMIT filt->filterCompleted(filt.get()); + + notifyProgressMessage(static_cast(static_cast(filtIndex + 1) / (m_Pipeline.size()) * 100.0f), ""); } + now = QDateTime::currentDateTime(); + msg.clear(); + out << "Pipline End: " << now.toString(Qt::ISODate); + notifyStatusMessage(msg); disconnectSignalsSlots(); - PipelineMessage completeMessage("", "", 0, PipelineMessage::MessageType::StatusMessage, -1); - if(m_State == FilterPipeline::State::Canceling) + switch(m_State) { - completeMessage.setText("Pipeline Canceled"); + case FilterPipeline::State::Canceling: m_ExecutionResult = FilterPipeline::ExecutionResult::Canceled; - } - else if(m_State == FilterPipeline::State::Executing) - { - completeMessage.setText("Pipeline Complete"); + notifyStatusMessage("Pipeline Canceled"); + break; + case FilterPipeline::State::Executing: m_ExecutionResult = FilterPipeline::ExecutionResult::Completed; + notifyStatusMessage("Pipeline Complete"); + break; + case FilterPipeline::State::Idle: + throw PipelineIdleException(); + break; } - else - { - // This should never get here - completeMessage.setText("Unsupported Pipeline Execution Result"); - emit pipelineGeneratedMessage(completeMessage); - - setErrorCondition(-210); - completeMessage.setType(PipelineMessage::MessageType::Error); - completeMessage.setCode(getErrorCondition()); - } - - emit pipelineGeneratedMessage(completeMessage); m_State = FilterPipeline::State::Idle; - emit pipelineFinished(); + Q_EMIT pipelineFinished(); return m_Dca; } @@ -974,3 +1031,64 @@ DataContainerArray::Pointer FilterPipeline::getDataContainerArray() { return m_Dca; } + +// ----------------------------------------------------------------------------- +FilterPipeline::Pointer FilterPipeline::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString FilterPipeline::getNameOfClass() const +{ + return QString("FilterPipeline"); +} + +// ----------------------------------------------------------------------------- +QString FilterPipeline::ClassName() +{ + return QString("FilterPipeline"); +} + +// ----------------------------------------------------------------------------- +FilterPipeline::Pointer FilterPipeline::New() +{ + Pointer sharedPtr(new(FilterPipeline)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +void FilterPipeline::setCurrentFilter(const AbstractFilter::Pointer& value) +{ + m_CurrentFilter = value; +} + +// ----------------------------------------------------------------------------- +AbstractFilter::Pointer FilterPipeline::getCurrentFilter() const +{ + return m_CurrentFilter; +} + +// ----------------------------------------------------------------------------- +FilterPipeline::ExecutionResult FilterPipeline::getExecutionResult() const +{ + return m_ExecutionResult; +} + +// ----------------------------------------------------------------------------- +FilterPipeline::State FilterPipeline::getState() const +{ + return m_State; +} + +// ----------------------------------------------------------------------------- +int FilterPipeline::getErrorCode() const +{ + return m_ErrorCode; +} + +// ----------------------------------------------------------------------------- +int FilterPipeline::getWarningCode() const +{ + return m_WarningCode; +} diff --git a/Source/SIMPLib/Filtering/FilterPipeline.h b/Source/SIMPLib/Filtering/FilterPipeline.h index 9fb402a346..b2c88c7fb4 100755 --- a/Source/SIMPLib/Filtering/FilterPipeline.h +++ b/Source/SIMPLib/Filtering/FilterPipeline.h @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -35,18 +35,22 @@ #pragma once +#include + #include #include #include #include #include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Observer.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/Filtering/AbstractFilter.h" -#include "SIMPLib/SIMPLib.h" class IObserver; +class FilterPipelineMessageHandler; +class DataContainerArray; +using DataContainerArrayShPtrType = std::shared_ptr; /** * @class FilterPipeline FilterPipeline.h DREAM3DLib/Common/FilterPipeline.h @@ -57,18 +61,21 @@ class IObserver; * @date Sep 28, 2011 * @version 1.0 */ -class SIMPLib_EXPORT FilterPipeline : public QObject +class SIMPLib_EXPORT FilterPipeline : public Observable { Q_OBJECT - PYB11_CREATE_BINDINGS(FilterPipeline) - PYB11_PROPERTY(int ErrorCondition READ getErrorCondition WRITE setErrorCondition) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(FilterPipeline) + PYB11_SHARED_POINTERS(FilterPipeline) + PYB11_STATIC_NEW_MACRO(FilterPipeline) + PYB11_PROPERTY(int ErrorCode READ getErrorCode) + PYB11_PROPERTY(int WarningCode READ getWarningCode) PYB11_PROPERTY(AbstractFilter CurrentFilter READ getCurrentFilter WRITE setCurrentFilter) PYB11_PROPERTY(State State READ getState) PYB11_PROPERTY(ExecutionResult ExecutionResult READ getExecutionResult) PYB11_PROPERTY(QString Name READ getName WRITE setName) - - PYB11_METHOD(DataContainerArray::Pointer run) + PYB11_METHOD(DataContainerArrayShPtrType run) PYB11_METHOD(void preflightPipeline) PYB11_METHOD(bool pushFront ARGS AbstractFilter) PYB11_METHOD(bool pushBack ARGS AbstractFilter) @@ -77,14 +84,36 @@ class SIMPLib_EXPORT FilterPipeline : public QObject PYB11_METHOD(bool clear) PYB11_METHOD(size_t size) PYB11_METHOD(bool empty) + PYB11_METHOD(void clearErrorCode) + PYB11_METHOD(void clearWarningCode) + PYB11_METHOD(void addObserver ARGS Observer) + PYB11_METHOD(void removeObserver ARGS Observer) + PYB11_END_BINDINGS() + // End Python bindings declarations public: - SIMPL_SHARED_POINTERS(FilterPipeline) - SIMPL_TYPE_MACRO(FilterPipeline) - SIMPL_STATIC_NEW_MACRO(FilterPipeline) + using Self = FilterPipeline; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for FilterPipeline + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for FilterPipeline + */ + static QString ClassName(); + + static Pointer New(); ~FilterPipeline() override; + friend FilterPipelineMessageHandler; + enum class State : unsigned int { Idle, @@ -102,10 +131,39 @@ class SIMPLib_EXPORT FilterPipeline : public QObject typedef QList FilterContainerType; - SIMPL_GET_PROPERTY(FilterPipeline::ExecutionResult, ExecutionResult) - SIMPL_GET_PROPERTY(FilterPipeline::State, State) - SIMPL_INSTANCE_PROPERTY(int, ErrorCondition) - SIMPL_INSTANCE_PROPERTY(AbstractFilter::Pointer, CurrentFilter) + /** + * @brief Getter property for ExecutionResult + * @return Value of ExecutionResult + */ + FilterPipeline::ExecutionResult getExecutionResult() const; + + /** + * @brief Getter property for State + * @return Value of State + */ + FilterPipeline::State getState() const; + + /** + * @brief Getter property for ErrorCode + * @return Value of ErrorCode + */ + int getErrorCode() const; + + /** + * @brief Getter property for WarningCode + * @return Value of WarningCode + */ + int getWarningCode() const; + + /** + * @brief Setter property for CurrentFilter + */ + void setCurrentFilter(const AbstractFilter::Pointer& value); + /** + * @brief Getter property for CurrentFilter + * @return Value of CurrentFilter + */ + AbstractFilter::Pointer getCurrentFilter() const; /** * @brief Returns true if the pipeline is executing @@ -129,7 +187,12 @@ class SIMPLib_EXPORT FilterPipeline : public QObject * @brief A pure virtual function that gets called from the "run()" method. Subclasses * are expected to create a concrete implementation of this method. */ - virtual DataContainerArray::Pointer execute(); + virtual DataContainerArrayShPtrType execute(); + + /** + * @brief An execute method using an existing data container array + */ + DataContainerArrayShPtrType execute(DataContainerArrayShPtrType dca); /** * @brief This will preflight the pipeline and report any errors that would occur during @@ -152,7 +215,7 @@ class SIMPLib_EXPORT FilterPipeline : public QObject virtual FilterContainerType& getFilterContainer(); - virtual DataContainerArray::Pointer getDataContainerArray(); + virtual DataContainerArrayShPtrType getDataContainerArray(); /** * @brief @@ -164,17 +227,58 @@ class SIMPLib_EXPORT FilterPipeline : public QObject /** * @brief This method adds a QObject based class that is capable of being connected with the following signals from * AbstractFilter: - * @li processPipelineMessage(PipelineMessage&) - * @param obj Class that implements needed processPipelineMessage(PipelineMessage&) method + * @li processPipelineMessage(const AbstractMessage::Pointer &) + * @param obj Class that implements needed processPipelineMessage(const AbstractMessage::Pointer &) method */ void addMessageReceiver(QObject* obj); void removeMessageReceiver(QObject* obj); - void connectFilterNotifications(QObject* filter); - void disconnectFilterNotifications(QObject* filter); + void addObserver(Observer* obj); + + void removeObserver(Observer* obj); + + void connectFilterNotifications(AbstractFilter* filter); + void disconnectFilterNotifications(AbstractFilter* filter); + + QString getName() const; + + /** + * @brief setErrorCondition + * @param code + * @param messageText + */ + void setErrorCondition(int code, const QString& messageText) override; + + /** + * @brief setWarningCondition + * @param code + * @param messageText + */ + void setWarningCondition(int code, const QString& messageText) override; + + /** + * @brief notifyStatusMessage + * @param messageText + */ + void notifyStatusMessage(const QString& messageText) const override; - QString getName(); + /** + * @brief notifyProgressMessage + * @param progress + * @param messageText + */ + void notifyProgressMessage(int progress, const QString& messageText) const override; + + /** + * @brief clearErrorCondition + */ + void clearErrorCode(); + + /** + * @brief clearWarningCondition + */ + void clearWarningCode(); /** * @brief This method returns a deep copy of the FilterPipeline and all its filters @@ -200,12 +304,12 @@ class SIMPLib_EXPORT FilterPipeline : public QObject */ static Pointer FromJson(const QJsonObject& json, IObserver* obs = nullptr); -public slots: +public Q_SLOTS: /** * @brief This method is called to start the pipeline for a plugin */ - virtual DataContainerArray::Pointer run(); + virtual DataContainerArrayShPtrType run(); /** * @brief cancel @@ -219,8 +323,8 @@ public slots: void updatePrevNextFilters(); -signals: - void pipelineGeneratedMessage(const PipelineMessage& message); +Q_SIGNALS: + // void messageGenerated(AbstractMessage::Pointer message); /** * @brief This method is emitted from the pipeline and signals a pipeline pause @@ -251,6 +355,8 @@ public slots: void pipelineNameChanged(QString oldName, QString newName); private: + AbstractFilter::Pointer m_CurrentFilter = {}; + FilterContainerType m_Pipeline; QString m_PipelineName; @@ -259,7 +365,10 @@ public slots: QVector m_MessageReceivers; - DataContainerArray::Pointer m_Dca; + DataContainerArrayShPtrType m_Dca; + + int m_ErrorCode = 0; + int m_WarningCode = 0; void connectSignalsSlots(); void disconnectSignalsSlots(); @@ -270,3 +379,4 @@ public slots: FilterPipeline& operator=(const FilterPipeline&) = delete; // Copy Assignment Not Implemented FilterPipeline& operator=(FilterPipeline&&) = delete; // Move Assignment Not Implemented }; +Q_DECLARE_METATYPE(FilterPipeline::Pointer); diff --git a/Source/SIMPLib/Filtering/IFilterFactory.hpp b/Source/SIMPLib/Filtering/IFilterFactory.hpp old mode 100755 new mode 100644 index 48a073c0ce..91cd505923 --- a/Source/SIMPLib/Filtering/IFilterFactory.hpp +++ b/Source/SIMPLib/Filtering/IFilterFactory.hpp @@ -1,45 +1,44 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" -#include "SIMPLib/Filtering/AbstractFilter.h" #include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Filtering/AbstractFilter.h" /** * @brief This class serves as a base class to create Factory classes that can @@ -48,95 +47,95 @@ class IFilterFactory { public: - SIMPL_SHARED_POINTERS(IFilterFactory) - SIMPL_TYPE_MACRO(IFilterFactory) + using Self = IFilterFactory; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; - virtual ~IFilterFactory() = default; + static Pointer NullPointer() + { + return nullptr; + } - /** @brief This function should NEVER get called. The subclass should ALWAYS implement - * this method so we are going to crash the program. + /** + * @brief Returns the name of the class for AbstractMessage */ - virtual AbstractFilter::Pointer create() const + virtual QString getNameOfClass() const { - Q_ASSERT(false); - return AbstractFilter::NullPointer(); + return ClassName(); } /** - * @brief getFilterClassName - * @return + * @brief Returns the name of the class for AbstractMessage */ - virtual QString getFilterClassName() const + static QString ClassName() { - Q_ASSERT(false); - return ""; + return "IFilterFactory"; } - + + virtual ~IFilterFactory() = default; + + /** + * @brief This function should NEVER get called. The subclass should ALWAYS implement + * this method so we are going to crash the program. + */ + virtual AbstractFilter::Pointer create() const = 0; + + /** + * @brief getFilterClassName + * @return + */ + virtual QString getFilterClassName() const = 0; + /** * @brief getFilterGroup - * @return + * @return */ - virtual QString getFilterGroup() const - { - Q_ASSERT(false); - return ""; - } - + virtual QString getFilterGroup() const = 0; + /** * @brief getFilterSubGroup - * @return + * @return */ - virtual QString getFilterSubGroup() const - { - Q_ASSERT(false); - return ""; - } - + virtual QString getFilterSubGroup() const = 0; + /** * @brief getFilterHumanLabel - * @return + * @return */ - virtual QString getFilterHumanLabel() const - { - Q_ASSERT(false); - return ""; - } + virtual QString getFilterHumanLabel() const = 0; /** * @brief getBrandingString - * @return + * @return */ - virtual QString getBrandingString() const - { - Q_ASSERT(false); - return ""; - } + virtual QString getBrandingString() const = 0; /** * @brief getCompiledLibraryName - * @return + * @return */ - virtual QString getCompiledLibraryName() const - { - Q_ASSERT(false); - return ""; - } - + virtual QString getCompiledLibraryName() const = 0; + + /** + * @brief getFilterHtmlSummary + * @return + */ + virtual QString getFilterHtmlSummary() const = 0; + /** * @brief getUuid - * @return + * @return */ - virtual QUuid getUuid() const - { - Q_ASSERT(false); - return QUuid(); - } + virtual QUuid getUuid() const = 0; protected: IFilterFactory() = default; -private: - IFilterFactory(const IFilterFactory&); // Copy Constructor Not Implemented - void operator=(const IFilterFactory&); // Move assignment Not Implemented +public: + IFilterFactory(const IFilterFactory&) = delete; // Copy Constructor Not Implemented + IFilterFactory(IFilterFactory&&) = delete; // Move Constructor Not Implemented + IFilterFactory& operator=(const IFilterFactory&) = delete; // Copy Assignment Not Implemented + IFilterFactory& operator=(IFilterFactory&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/Filtering/QMetaObjectUtilities.cpp b/Source/SIMPLib/Filtering/QMetaObjectUtilities.cpp index 9f80d454cc..bbc86ac82b 100644 --- a/Source/SIMPLib/Filtering/QMetaObjectUtilities.cpp +++ b/Source/SIMPLib/Filtering/QMetaObjectUtilities.cpp @@ -1,51 +1,51 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "QMetaObjectUtilities.h" #include +#include +#include #include -#include #include "SIMPLib/Common/EnsembleInfo.h" -#include "SIMPLib/Common/PipelineMessage.h" #include "SIMPLib/CoreFilters/CreateDataArray.h" #include "SIMPLib/DataContainers/DataArrayPath.h" #include "SIMPLib/DataContainers/DataContainerArrayProxy.h" -#include "SIMPLib/FilterParameters/AxisAngleFilterParameter.h" +#include "SIMPLib/FilterParameters/AxisAngleInput.h" #include "SIMPLib/FilterParameters/DynamicTableData.h" #include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h" #include "SIMPLib/FilterParameters/IntVec3FilterParameter.h" @@ -53,27 +53,28 @@ #include "SIMPLib/FilterParameters/RangeFilterParameter.h" #include "SIMPLib/Filtering/ComparisonInputs.h" #include "SIMPLib/Filtering/ComparisonInputsAdvanced.h" +#include "SIMPLib/Filtering/FilterPipeline.h" // These Streams need to be implemented so that our 3 Element Vectors can be read/write to disk/prefs files -QDataStream& operator<<(QDataStream& out, const IntVec3_t& v) +QDataStream& operator<<(QDataStream& out, const IntVec3Type& v) { - out << v.x << v.y << v.z; + out << v[0] << v[1] << v[2]; return out; } -QDataStream& operator>>(QDataStream& in, IntVec3_t& v) +QDataStream& operator>>(QDataStream& in, IntVec3Type& v) { - in >> v.x >> v.y >> v.z; + in >> v[0] >> v[1] >> v[2]; return in; } -QDataStream& operator<<(QDataStream& out, const FloatVec3_t& v) +QDataStream& operator<<(QDataStream& out, const FloatVec3Type& v) { - out << v.x << v.y << v.z; + out << v[0] << v[1] << v[2]; return out; } -QDataStream& operator>>(QDataStream& in, FloatVec3_t& v) +QDataStream& operator>>(QDataStream& in, FloatVec3Type& v) { - in >> v.x >> v.y >> v.z; + in >> v[0] >> v[1] >> v[2]; return in; } @@ -145,21 +146,39 @@ QMetaObjectUtilities::~QMetaObjectUtilities() = default; // ----------------------------------------------------------------------------- void QMetaObjectUtilities::RegisterMetaTypes() { + using VectString = std::vector; + qRegisterMetaType("AbstractMessage::Pointer"); qRegisterMetaType("DataContainerArrayProxy"); qRegisterMetaType("DataArrayPath"); - qRegisterMetaType("AxisAngleInput_t"); + qRegisterMetaType("AxisAngleInput"); qRegisterMetaType("ComparisonInput_t"); qRegisterMetaType("ComparisonInputs"); qRegisterMetaType("ComparisonInputsAdvanced"); qRegisterMetaType("DataContainerArrayProxy"); - qRegisterMetaType("IntVec3_t"); - qRegisterMetaType("FloatVec3_t"); - qRegisterMetaType("PipelineMessage"); + qRegisterMetaType("IntVec3Type"); + qRegisterMetaType("FloatVec3Type"); qRegisterMetaType("FPRangePair"); qRegisterMetaType("DynamicTableData"); qRegisterMetaType("PhaseType::Types"); - qRegisterMetaTypeStreamOperators("IntVec3_t"); - qRegisterMetaTypeStreamOperators("FloatVec3_t"); + qRegisterMetaType("VectString"); + qRegisterMetaType>("FloatVec2Type"); + qRegisterMetaType>("FloatVec3Type"); + qRegisterMetaType>("FloatVec4Type"); + qRegisterMetaType>("FloatVec6Type"); + qRegisterMetaType>("FloatVec7Type"); + + qRegisterMetaType>("IntVec2Type"); + qRegisterMetaType>("IntVec3Type"); + qRegisterMetaType>("IntVec4Type"); + qRegisterMetaType>("IntVec6Type"); + qRegisterMetaType>("IntVec7Type"); + + qRegisterMetaType>("SizeVec2Type"); + qRegisterMetaType>("SizeVec3Type"); + qRegisterMetaType>("SizeVec4Type"); + qRegisterMetaType>("SizeVec6Type"); + qRegisterMetaType>("SizeVec7Type"); + qRegisterMetaTypeStreamOperators("PhaseType::Types"); qRegisterMetaTypeStreamOperators("EnsembleInfo"); } diff --git a/Source/SIMPLib/Filtering/QMetaObjectUtilities.h b/Source/SIMPLib/Filtering/QMetaObjectUtilities.h old mode 100755 new mode 100644 index c4c423c53b..e377224e2e --- a/Source/SIMPLib/Filtering/QMetaObjectUtilities.h +++ b/Source/SIMPLib/Filtering/QMetaObjectUtilities.h @@ -1,43 +1,40 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include -#include - #include "SIMPLib/SIMPLib.h" class SIMPLib_EXPORT QMetaObjectUtilities @@ -51,9 +48,8 @@ class SIMPLib_EXPORT QMetaObjectUtilities QMetaObjectUtilities(); public: - QMetaObjectUtilities(const QMetaObjectUtilities&) = delete; // Copy Constructor Not Implemented - QMetaObjectUtilities(QMetaObjectUtilities&&) = delete; // Move Constructor Not Implemented + QMetaObjectUtilities(const QMetaObjectUtilities&) = delete; // Copy Constructor Not Implemented + QMetaObjectUtilities(QMetaObjectUtilities&&) = delete; // Move Constructor Not Implemented QMetaObjectUtilities& operator=(const QMetaObjectUtilities&) = delete; // Copy Assignment Not Implemented QMetaObjectUtilities& operator=(QMetaObjectUtilities&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/Filtering/SourceList.cmake b/Source/SIMPLib/Filtering/SourceList.cmake index fef8ac33fb..3527261e6a 100755 --- a/Source/SIMPLib/Filtering/SourceList.cmake +++ b/Source/SIMPLib/Filtering/SourceList.cmake @@ -6,6 +6,7 @@ set(SUBDIR_NAME Filtering) set(SIMPLib_${SUBDIR_NAME}_Moc_HDRS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractDecisionFilter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractFilter.h + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/BadFilter.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ComparisonInputs.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ComparisonInputsAdvanced.h ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/FilterPipeline.h @@ -35,6 +36,7 @@ set(SIMPLib_${SUBDIR_NAME}_SRCS ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractComparison.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractDecisionFilter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/AbstractFilter.cpp + ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/BadFilter.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ComparisonInputs.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ComparisonInputsAdvanced.cpp ${SIMPLib_SOURCE_DIR}/${SUBDIR_NAME}/ComparisonSet.cpp diff --git a/Source/SIMPLib/Filtering/Testing/Cxx/FilterPipelineTest.cpp b/Source/SIMPLib/Filtering/Testing/Cxx/FilterPipelineTest.cpp index 9ded57da01..9c97e1b66c 100644 --- a/Source/SIMPLib/Filtering/Testing/Cxx/FilterPipelineTest.cpp +++ b/Source/SIMPLib/Filtering/Testing/Cxx/FilterPipelineTest.cpp @@ -1,51 +1,47 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + #include -#include -#include //#include "Applications/DREAM3D/DREAM3DApplication.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Observer.h" #include "SIMPLib/Filtering/FilterManager.h" #include "SIMPLib/Filtering/FilterPipeline.h" #include "SIMPLib/Plugin/ISIMPLibPlugin.h" -#include "SIMPLib/SIMPLib.h" #ifdef SIMPL_BUILD_TEST_FILTERS #include "SIMPLib/TestFilters/ArraySelectionExample.h" @@ -55,6 +51,7 @@ #include "SIMPLib/TestFilters/ThresholdExample.h" #endif +#include "SIMPLib/DataContainers/DataContainer.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" diff --git a/Source/SIMPLib/Filtering/ThresholdFilterHelper.cpp b/Source/SIMPLib/Filtering/ThresholdFilterHelper.cpp index 3884adc31a..6bbdd542e2 100644 --- a/Source/SIMPLib/Filtering/ThresholdFilterHelper.cpp +++ b/Source/SIMPLib/Filtering/ThresholdFilterHelper.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "ThresholdFilterHelper.h" @@ -54,23 +54,31 @@ ThresholdFilterHelper::~ThresholdFilterHelper() = default; // // ----------------------------------------------------------------------------- #define FILTER_DATA_HELPER(dType, ops, Type) \ - if(dType.compare(#Type) == 0) \ + if(dType == #Type) \ { \ if(ops == SIMPL::Comparison::Operator_LessThan) \ + { \ filterDataLessThan(input); \ + } \ else if(ops == SIMPL::Comparison::Operator_GreaterThan) \ + { \ filterDataGreaterThan(input); \ + } \ else if(ops == SIMPL::Comparison::Operator_Equal) \ + { \ filterDataEqualTo(input); \ + } \ else if(ops == SIMPL::Comparison::Operator_NotEqual) \ + { \ filterDataNotEqualTo(input); \ + } \ return 1; \ } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int ThresholdFilterHelper::execute(IDataArray* input, IDataArray* output) +int ThresholdFilterHelper::execute(const IDataArray::Pointer& input, IDataArray* output) { if(nullptr == input) { @@ -79,52 +87,53 @@ int ThresholdFilterHelper::execute(IDataArray* input, IDataArray* output) m_Output->initializeWithZeros(); QString dType = input->getTypeAsString(); - FILTER_DATA_HELPER(dType, comparisonOperator, float); - FILTER_DATA_HELPER(dType, comparisonOperator, double); + FILTER_DATA_HELPER(dType, comparisonOperator, float) + FILTER_DATA_HELPER(dType, comparisonOperator, double) - FILTER_DATA_HELPER(dType, comparisonOperator, int8_t); - FILTER_DATA_HELPER(dType, comparisonOperator, uint8_t); -#if CMP_TYPE_CHAR_IS_SIGNED - FILTER_DATA_HELPER(dType, comparisonOperator, char); -#else - FILTER_DATA_HELPER(dType, comparisonOperator, char); -#endif - FILTER_DATA_HELPER(dType, comparisonOperator, signed char); - FILTER_DATA_HELPER(dType, comparisonOperator, unsigned char); + FILTER_DATA_HELPER(dType, comparisonOperator, int8_t) + FILTER_DATA_HELPER(dType, comparisonOperator, uint8_t) + //#if CMP_TYPE_CHAR_IS_SIGNED + // FILTER_DATA_HELPER(dType, comparisonOperator, char); + //#else + // FILTER_DATA_HELPER(dType, comparisonOperator, char); + //#endif + // FILTER_DATA_HELPER(dType, comparisonOperator, signed char) + // FILTER_DATA_HELPER(dType, comparisonOperator, unsigned char) - FILTER_DATA_HELPER(dType, comparisonOperator, int16_t); - FILTER_DATA_HELPER(dType, comparisonOperator, short); - FILTER_DATA_HELPER(dType, comparisonOperator, signed short); - FILTER_DATA_HELPER(dType, comparisonOperator, uint16_t); - FILTER_DATA_HELPER(dType, comparisonOperator, unsigned short); + FILTER_DATA_HELPER(dType, comparisonOperator, int16_t) + // FILTER_DATA_HELPER(dType, comparisonOperator, short) + // FILTER_DATA_HELPER(dType, comparisonOperator, signed short) + FILTER_DATA_HELPER(dType, comparisonOperator, uint16_t) + // FILTER_DATA_HELPER(dType, comparisonOperator, unsigned short) - FILTER_DATA_HELPER(dType, comparisonOperator, int32_t); - FILTER_DATA_HELPER(dType, comparisonOperator, uint32_t); -#if(CMP_SIZEOF_INT == 4) - FILTER_DATA_HELPER(dType, comparisonOperator, int); - FILTER_DATA_HELPER(dType, comparisonOperator, signed int); - FILTER_DATA_HELPER(dType, comparisonOperator, unsigned int); -#endif + FILTER_DATA_HELPER(dType, comparisonOperator, int32_t) + FILTER_DATA_HELPER(dType, comparisonOperator, uint32_t) + //#if(CMP_SIZEOF_INT == 4) + // FILTER_DATA_HELPER(dType, comparisonOperator, int) + // FILTER_DATA_HELPER(dType, comparisonOperator, signed int) + // FILTER_DATA_HELPER(dType, comparisonOperator, unsigned int) + //#endif -#if(CMP_SIZEOF_LONG == 4) - FILTER_DATA_HELPER(dType, comparisonOperator, long int); - FILTER_DATA_HELPER(dType, comparisonOperator, signed long int); - FILTER_DATA_HELPER(dType, comparisonOperator, unsigned long int); -#elif(CMP_SIZEOF_LONG == 8) - FILTER_DATA_HELPER(dType, comparisonOperator, long int); - FILTER_DATA_HELPER(dType, comparisonOperator, signed long int); - FILTER_DATA_HELPER(dType, comparisonOperator, unsigned long int); -#endif + //#if(CMP_SIZEOF_LONG == 4) + // FILTER_DATA_HELPER(dType, comparisonOperator, long int) + // FILTER_DATA_HELPER(dType, comparisonOperator, signed long int) + // FILTER_DATA_HELPER(dType, comparisonOperator, unsigned long int) + //#elif(CMP_SIZEOF_LONG == 8) + // FILTER_DATA_HELPER(dType, comparisonOperator, long int) + // FILTER_DATA_HELPER(dType, comparisonOperator, signed long int) + // FILTER_DATA_HELPER(dType, comparisonOperator, unsigned long int) + //#endif -#if(CMP_SIZEOF_LONG_LONG == 8) - FILTER_DATA_HELPER(dType, comparisonOperator, long long int); - FILTER_DATA_HELPER(dType, comparisonOperator, signed long long int); - FILTER_DATA_HELPER(dType, comparisonOperator, unsigned long long int); -#endif - FILTER_DATA_HELPER(dType, comparisonOperator, int64_t); - FILTER_DATA_HELPER(dType, comparisonOperator, uint64_t); + //#if(CMP_SIZEOF_LONG_LONG == 8) + // FILTER_DATA_HELPER(dType, comparisonOperator, long long int) + // FILTER_DATA_HELPER(dType, comparisonOperator, signed long long int) + // FILTER_DATA_HELPER(dType, comparisonOperator, unsigned long long int) + //#endif - FILTER_DATA_HELPER(dType, comparisonOperator, bool); + FILTER_DATA_HELPER(dType, comparisonOperator, int64_t) + FILTER_DATA_HELPER(dType, comparisonOperator, uint64_t) + + FILTER_DATA_HELPER(dType, comparisonOperator, bool) return -1; } diff --git a/Source/SIMPLib/Filtering/ThresholdFilterHelper.h b/Source/SIMPLib/Filtering/ThresholdFilterHelper.h old mode 100755 new mode 100644 index 47154ca28a..d17fa03463 --- a/Source/SIMPLib/Filtering/ThresholdFilterHelper.h +++ b/Source/SIMPLib/Filtering/ThresholdFilterHelper.h @@ -1,45 +1,45 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataArrays/IDataArray.h" #include "SIMPLib/DataArrays/IDataArrayFilter.h" -#include "SIMPLib/SIMPLib.h" /** * @brief The ThresholdFilterHelper class @@ -54,11 +54,14 @@ class SIMPLib_EXPORT ThresholdFilterHelper : public IDataArrayFilter /** * */ - template void filterDataLessThan(IDataArray* m_Input) + template + void filterDataLessThan(const IDataArray::Pointer& m_Input) { size_t m_NumValues = m_Input->getNumberOfTuples(); T v = static_cast(comparisonValue); - T* data = IDataArray::SafeReinterpretCast*, T*>(m_Input); + using DataArrayType = DataArray; + typename DataArrayType::Pointer dataPtr = std::dynamic_pointer_cast(m_Input); + T* data = dataPtr->getTuplePointer(0); for(size_t i = 0; i < m_NumValues; ++i) { bool b = (data[i] < v); @@ -69,11 +72,14 @@ class SIMPLib_EXPORT ThresholdFilterHelper : public IDataArrayFilter /** * */ - template void filterDataGreaterThan(IDataArray* m_Input) + template + void filterDataGreaterThan(const IDataArray::Pointer& m_Input) { size_t m_NumValues = m_Input->getNumberOfTuples(); T v = static_cast(comparisonValue); - T* data = IDataArray::SafeReinterpretCast*, T*>(m_Input); + using DataArrayType = DataArray; + typename DataArrayType::Pointer dataPtr = std::dynamic_pointer_cast(m_Input); + T* data = dataPtr->getTuplePointer(0); for(size_t i = 0; i < m_NumValues; ++i) { bool b = (data[i] > v); @@ -84,11 +90,14 @@ class SIMPLib_EXPORT ThresholdFilterHelper : public IDataArrayFilter /** * */ - template void filterDataEqualTo(IDataArray* m_Input) + template + void filterDataEqualTo(const IDataArray::Pointer& m_Input) { size_t m_NumValues = m_Input->getNumberOfTuples(); T v = static_cast(comparisonValue); - T* data = IDataArray::SafeReinterpretCast*, T*>(m_Input); + using DataArrayType = DataArray; + typename DataArrayType::Pointer dataPtr = std::dynamic_pointer_cast(m_Input); + T* data = dataPtr->getTuplePointer(0); for(size_t i = 0; i < m_NumValues; ++i) { bool b = (data[i] == v); @@ -97,13 +106,16 @@ class SIMPLib_EXPORT ThresholdFilterHelper : public IDataArrayFilter } /** - * - */ - template void filterDataNotEqualTo(IDataArray* m_Input) + * + */ + template + void filterDataNotEqualTo(const IDataArray::Pointer& m_Input) { size_t m_NumValues = m_Input->getNumberOfTuples(); T v = static_cast(comparisonValue); - T* data = IDataArray::SafeReinterpretCast*, T*>(m_Input); + using DataArrayType = DataArray; + typename DataArrayType::Pointer dataPtr = std::dynamic_pointer_cast(m_Input); + T* data = dataPtr->getTuplePointer(0); for(size_t i = 0; i < m_NumValues; ++i) { bool b = (data[i] != v); @@ -112,12 +124,12 @@ class SIMPLib_EXPORT ThresholdFilterHelper : public IDataArrayFilter } /** - * @brief execute - * @param input - * @param output - * @return - */ - int execute(IDataArray* input, IDataArray* output); + * @brief execute + * @param input + * @param output + * @return + */ + int execute(const IDataArray::Pointer& input, IDataArray* output); private: SIMPL::Comparison::Enumeration comparisonOperator; @@ -125,9 +137,8 @@ class SIMPLib_EXPORT ThresholdFilterHelper : public IDataArrayFilter BoolArrayType* m_Output; public: - ThresholdFilterHelper(const ThresholdFilterHelper&) = delete; // Copy Constructor Not Implemented - ThresholdFilterHelper(ThresholdFilterHelper&&) = delete; // Move Constructor Not Implemented + ThresholdFilterHelper(const ThresholdFilterHelper&) = delete; // Copy Constructor Not Implemented + ThresholdFilterHelper(ThresholdFilterHelper&&) = delete; // Move Constructor Not Implemented ThresholdFilterHelper& operator=(const ThresholdFilterHelper&) = delete; // Copy Assignment Not Implemented ThresholdFilterHelper& operator=(ThresholdFilterHelper&&) = delete; // Move Assignment Not Implemented }; - diff --git a/Source/SIMPLib/Geometry/CompositeTransformContainer.cpp b/Source/SIMPLib/Geometry/CompositeTransformContainer.cpp index 94bbc8e1e0..382c988679 100644 --- a/Source/SIMPLib/Geometry/CompositeTransformContainer.cpp +++ b/Source/SIMPLib/Geometry/CompositeTransformContainer.cpp @@ -1,35 +1,35 @@ /* ============================================================================ -* Copyright (c) 2009-2018 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-15-D-5231 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2018 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CompositeTransformContainer.h" @@ -37,6 +37,7 @@ #include "H5Support/H5ScopedSentinel.h" #include "H5Support/QH5Lite.h" #include "H5Support/QH5Utilities.h" + #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Geometry/TransformContainer.h" @@ -62,7 +63,7 @@ int CompositeTransformContainer::writeTransformContainerToHDF5(hid_t parentId, c { return -1; } - H5ScopedGroupSentinel gSentinel(&transformContainerId, false); + H5ScopedGroupSentinel gSentinel(transformContainerId, false); err = QH5Lite::writeStringAttribute(parentId, transformContainerName.c_str(), SIMPL::Geometry::TransformContainerTypeName, SIMPL::Geometry::CompositeTransformContainer); if(err < 0) @@ -93,7 +94,7 @@ int CompositeTransformContainer::readTransformContainerFromHDF5(hid_t parentId, { return -1; } - H5ScopedGroupSentinel gSentinel(&transformContainerGrpId, false); + H5ScopedGroupSentinel gSentinel(transformContainerGrpId, false); hsize_t idx = 0; H5Gget_num_objs(transformContainerGrpId, &idx); @@ -154,4 +155,40 @@ CompositeTransformContainer& CompositeTransformContainer::operator=(const Compos void CompositeTransformContainer::addTransformContainer(ITransformContainer::Pointer transformContainer) { this->m_TransformContainers.push_back(transformContainer); -} \ No newline at end of file +} +// ----------------------------------------------------------------------------- +CompositeTransformContainer::Pointer CompositeTransformContainer::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +CompositeTransformContainer::Pointer CompositeTransformContainer::New() +{ + Pointer sharedPtr(new(CompositeTransformContainer)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString CompositeTransformContainer::getNameOfClass() const +{ + return QString("CompositeTransformContainer"); +} + +// ----------------------------------------------------------------------------- +QString CompositeTransformContainer::ClassName() +{ + return QString("CompositeTransformContainer"); +} + +// ----------------------------------------------------------------------------- +void CompositeTransformContainer::setTransformContainers(const std::vector& value) +{ + m_TransformContainers = value; +} + +// ----------------------------------------------------------------------------- +std::vector CompositeTransformContainer::getTransformContainers() const +{ + return m_TransformContainers; +} diff --git a/Source/SIMPLib/Geometry/CompositeTransformContainer.h b/Source/SIMPLib/Geometry/CompositeTransformContainer.h index e99a143ab9..fb7acce27a 100644 --- a/Source/SIMPLib/Geometry/CompositeTransformContainer.h +++ b/Source/SIMPLib/Geometry/CompositeTransformContainer.h @@ -1,54 +1,83 @@ /* ============================================================================ -* Copyright (c) 2009-2018 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-15-D-5231 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2018 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Geometry/ITransformContainer.h" -#include "SIMPLib/SIMPLib.h" +#include + +#include "H5Support/H5SupportTypeDefs.h" -#include "H5Support/H5Lite.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Geometry/ITransformContainer.h" class SIMPLib_EXPORT CompositeTransformContainer : public ITransformContainer { public: - SIMPL_SHARED_POINTERS(CompositeTransformContainer) - SIMPL_STATIC_NEW_MACRO(CompositeTransformContainer) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(CompositeTransformContainer, ITransformContainer) + using Self = CompositeTransformContainer; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for CompositeTransformContainer + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for CompositeTransformContainer + */ + static QString ClassName(); + CompositeTransformContainer(); ~CompositeTransformContainer() override; CompositeTransformContainer& operator=(const CompositeTransformContainer&); int writeTransformContainerToHDF5(hid_t parentId, const std::string& transformContainerName) override; int readTransformContainerFromHDF5(hid_t parentId, bool metaDataOnly, const std::string& transformContainerName) override; - SIMPL_INSTANCE_PROPERTY(std::vector, TransformContainers) + /** + * @brief Setter property for TransformContainers + */ + void setTransformContainers(const std::vector& value); + /** + * @brief Getter property for TransformContainers + * @return Value of TransformContainers + */ + std::vector getTransformContainers() const; + void addTransformContainer(ITransformContainer::Pointer transformContainer); + +private: + std::vector m_TransformContainers = {}; }; diff --git a/Source/SIMPLib/Geometry/DerivativeHelpers.cpp b/Source/SIMPLib/Geometry/DerivativeHelpers.cpp index 47e96e3435..c58fd1458a 100644 --- a/Source/SIMPLib/Geometry/DerivativeHelpers.cpp +++ b/Source/SIMPLib/Geometry/DerivativeHelpers.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* ============================================================================ * DerivativeHelpers re-implements the exterior derivative calculations @@ -54,26 +54,25 @@ #include #include -#include "SIMPLib/Math/GeometryMath.h" -#include "SIMPLib/Math/MatrixMath.h" - #include "SIMPLib/Geometry/EdgeGeom.h" #include "SIMPLib/Geometry/HexahedralGeom.h" #include "SIMPLib/Geometry/QuadGeom.h" #include "SIMPLib/Geometry/TetrahedralGeom.h" #include "SIMPLib/Geometry/TriangleGeom.h" +#include "SIMPLib/Math/GeometryMath.h" +#include "SIMPLib/Math/MatrixMath.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DerivativeHelpers::EdgeDeriv::operator()(EdgeGeom* edges, int64_t edgeId, double values[2], double derivs[3]) +void DerivativeHelpers::EdgeDeriv::operator()(EdgeGeom* edges, size_t edgeId, double values[2], double derivs[3]) { float vert0_f[3] = {0.0f, 0.0f, 0.0f}; float vert1_f[3] = {0.0f, 0.0f, 0.0f}; double vert0[3] = {0.0, 0.0, 0.0}; double vert1[3] = {0.0, 0.0, 0.0}; double delta[3] = {0.0, 0.0, 0.0}; - int64_t verts[2] = {0, 0}; + size_t verts[2] = {0, 0}; edges->getVertsAtEdge(edgeId, verts); edges->getCoords(verts[0], vert0_f); @@ -103,7 +102,7 @@ void DerivativeHelpers::EdgeDeriv::operator()(EdgeGeom* edges, int64_t edgeId, d // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DerivativeHelpers::TriangleDeriv::operator()(TriangleGeom* triangles, int64_t triId, double values[3], double derivs[3]) +void DerivativeHelpers::TriangleDeriv::operator()(TriangleGeom* triangles, size_t triId, double values[3], double derivs[3]) { float vert0_f[3] = {0.0f, 0.0f, 0.0f}; float vert1_f[3] = {0.0f, 0.0f, 0.0f}; @@ -124,7 +123,7 @@ void DerivativeHelpers::TriangleDeriv::operator()(TriangleGeom* triangles, int64 double sum[2] = {0.0, 0.0}; double dBydx = 0.0; double dBydy = 0.0; - int64_t verts[3] = {0, 0, 0}; + size_t verts[3] = {0, 0, 0}; triangles->getVertsAtTri(triId, verts); triangles->getCoords(verts[0], vert0_f); @@ -206,7 +205,7 @@ void DerivativeHelpers::TriangleDeriv::operator()(TriangleGeom* triangles, int64 // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DerivativeHelpers::QuadDeriv::operator()(QuadGeom* quads, int64_t quadId, double values[4], double derivs[3]) +void DerivativeHelpers::QuadDeriv::operator()(QuadGeom* quads, size_t quadId, double values[4], double derivs[3]) { float vert0_f[3] = {0.0f, 0.0f, 0.0f}; float vert1_f[3] = {0.0f, 0.0f, 0.0f}; @@ -232,7 +231,7 @@ void DerivativeHelpers::QuadDeriv::operator()(QuadGeom* quads, int64_t quadId, d double sum[2] = {0.0, 0.0}; double dBydx = 0.0; double dBydy = 0.0; - int64_t verts[4] = {0, 0, 0, 0}; + size_t verts[4] = {0, 0, 0, 0}; quads->getVertsAtQuad(quadId, verts); quads->getCoords(verts[0], vert0_f); @@ -336,10 +335,10 @@ void DerivativeHelpers::QuadDeriv::operator()(QuadGeom* quads, int64_t quadId, d // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DerivativeHelpers::TetDeriv::operator()(TetrahedralGeom* tets, int64_t tetId, double values[4], double derivs[3]) +void DerivativeHelpers::TetDeriv::operator()(TetrahedralGeom* tets, size_t tetId, double values[4], double derivs[3]) { double shapeFunctions[12] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - int64_t verts[4] = {0, 0, 0, 0}; + size_t verts[4] = {0, 0, 0, 0}; double sum[3] = {0.0, 0.0, 0.0}; tets->getShapeFunctions(nullptr, shapeFunctions); @@ -397,11 +396,10 @@ void DerivativeHelpers::TetDeriv::operator()(TetrahedralGeom* tets, int64_t tetI // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void DerivativeHelpers::HexDeriv::operator()(HexahedralGeom* hexas, int64_t hexId, double values[8], double derivs[3]) +void DerivativeHelpers::HexDeriv::operator()(HexahedralGeom* hexas, size_t hexId, double values[8], double derivs[3]) { - double shapeFunctions[24] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - int64_t verts[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + double shapeFunctions[24] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + size_t verts[8] = {0, 0, 0, 0, 0, 0, 0, 0}; double sum[3] = {0.0, 0.0, 0.0}; double pCoords[3] = {0.0, 0.0, 0.0}; @@ -411,7 +409,7 @@ void DerivativeHelpers::HexDeriv::operator()(HexahedralGeom* hexas, int64_t hexI // Compute 3x3 Jacobian from vertex coordinates and tet shape functions, // then find the inverse Jacobian using Eigen double jPtr[9] = { - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, }; hexas->getVertsAtHex(hexId, verts); diff --git a/Source/SIMPLib/Geometry/DerivativeHelpers.h b/Source/SIMPLib/Geometry/DerivativeHelpers.h old mode 100755 new mode 100644 index 52bfab8825..c7fdc6d4ef --- a/Source/SIMPLib/Geometry/DerivativeHelpers.h +++ b/Source/SIMPLib/Geometry/DerivativeHelpers.h @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once @@ -44,7 +44,6 @@ #include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataArrays/DataArray.hpp" - class EdgeGeom; class TriangleGeom; class QuadGeom; @@ -52,14 +51,14 @@ class TetrahedralGeom; class HexahedralGeom; /** -* @brief This file contains a namespace with classes for computing derivatives on IGeometry objects -*/ + * @brief This file contains a namespace with classes for computing derivatives on IGeometry objects + */ namespace DerivativeHelpers { - /** - * @brief TriJacobian - */ +/** + * @brief TriJacobian + */ using TriangleJacobian = Eigen::Matrix; /** @@ -80,48 +79,43 @@ using HexJacobian = Eigen::Matrix; class EdgeDeriv { public: - void operator()(EdgeGeom* edges, int64_t edgeId, double values[2], double derivs[3]); - }; - - /** - * @brief The TriangleDeriv class - */ - class TriangleDeriv - { - public: - - void operator()(TriangleGeom* triangles, int64_t triId, double values[3], double derivs[3]); - }; - - /** - * @brief The QuadDeriv class - */ - class QuadDeriv - { - public: - - void operator()(QuadGeom* quads, int64_t quadId, double values[4], double derivs[3]); - }; - - /** - * @brief The TetDeriv class - */ - class TetDeriv - { - public: - - void operator()(TetrahedralGeom* tets, int64_t tetId, double values[4], double derivs[3]); - }; - - /** - * @brief The HexDeriv class - */ - class HexDeriv - { - public: - - void operator()(HexahedralGeom* hexas, int64_t hexId, double values[8], double derivs[3]); - }; - -} + void operator()(EdgeGeom* edges, size_t edgeId, double values[2], double derivs[3]); +}; + +/** + * @brief The TriangleDeriv class + */ +class TriangleDeriv +{ +public: + void operator()(TriangleGeom* triangles, size_t triId, double values[3], double derivs[3]); +}; + +/** + * @brief The QuadDeriv class + */ +class QuadDeriv +{ +public: + void operator()(QuadGeom* quads, size_t quadId, double values[4], double derivs[3]); +}; + +/** + * @brief The TetDeriv class + */ +class TetDeriv +{ +public: + void operator()(TetrahedralGeom* tets, size_t tetId, double values[4], double derivs[3]); +}; + +/** + * @brief The HexDeriv class + */ +class HexDeriv +{ +public: + void operator()(HexahedralGeom* hexas, size_t hexId, double values[8], double derivs[3]); +}; +} // namespace DerivativeHelpers diff --git a/Source/SIMPLib/Geometry/EdgeGeom.cpp b/Source/SIMPLib/Geometry/EdgeGeom.cpp index e3abe98160..66576bc9d6 100644 --- a/Source/SIMPLib/Geometry/EdgeGeom.cpp +++ b/Source/SIMPLib/Geometry/EdgeGeom.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* ============================================================================ * EdgeGeom re-implements code from the following vtk modules: @@ -44,17 +44,12 @@ * EdgeGeom::findDerivatives * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include "SIMPLib/Geometry/EdgeGeom.h" - -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS -#include -#include -#include -#include -#endif +#include #include "SIMPLib/Geometry/DerivativeHelpers.h" +#include "SIMPLib/Geometry/EdgeGeom.h" #include "SIMPLib/Geometry/GeometryHelpers.h" +#include "SIMPLib/Utilities/ParallelDataAlgorithm.h" /** * @brief The FindEdgeDerivativesImpl class implements a threaded algorithm that computes the @@ -63,7 +58,7 @@ class FindEdgeDerivativesImpl { public: - FindEdgeDerivativesImpl(EdgeGeom* edges, DoubleArrayType::Pointer field, DoubleArrayType::Pointer derivs) + FindEdgeDerivativesImpl(EdgeGeom* edges, const DoubleArrayType::Pointer& field, const DoubleArrayType::Pointer& derivs) : m_Edges(edges) , m_Field(field) , m_Derivatives(derivs) @@ -71,23 +66,23 @@ class FindEdgeDerivativesImpl } virtual ~FindEdgeDerivativesImpl() = default; - void compute(int64_t start, int64_t end) const + void compute(size_t start, size_t end) const { int32_t cDims = m_Field->getNumberOfComponents(); double* fieldPtr = m_Field->getPointer(0); double* derivsPtr = m_Derivatives->getPointer(0); double values[2] = {0.0, 0.0}; double derivs[3] = {0.0, 0.0, 0.0}; - int64_t verts[2] = {0, 0}; + size_t verts[2] = {0, 0}; - int64_t counter = 0; - int64_t totalElements = m_Edges->getNumberOfEdges(); - int64_t progIncrement = static_cast(totalElements / 100); + size_t counter = 0; + size_t totalElements = m_Edges->getNumberOfEdges(); + size_t progIncrement = static_cast(totalElements / 100); - for(int64_t i = start; i < end; i++) + for(size_t i = start; i < end; i++) { m_Edges->getVertsAtEdge(i, verts); - for(int32_t j = 0; j < cDims; j++) + for(size_t j = 0; j < cDims; j++) { for(size_t k = 0; k < 2; k++) { @@ -108,12 +103,11 @@ class FindEdgeDerivativesImpl } } -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - void operator()(const tbb::blocked_range& r) const + void operator()(const SIMPLRange& range) const { - compute(r.begin(), r.end()); + compute(range.min(), range.max()); } -#endif + private: EdgeGeom* m_Edges; DoubleArrayType::Pointer m_Field; @@ -128,9 +122,6 @@ EdgeGeom::EdgeGeom() m_GeometryTypeName = SIMPL::Geometry::EdgeGeometry; m_GeometryType = IGeometry::Type::Edge; m_XdmfGridType = SIMPL::XdmfGridType::PolyData; - m_MessagePrefix = ""; - m_MessageTitle = ""; - m_MessageLabel = ""; m_UnitDimensionality = 1; m_SpatialDimensionality = 3; m_VertexList = EdgeGeom::CreateSharedVertexList(0); @@ -150,7 +141,7 @@ EdgeGeom::~EdgeGeom() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EdgeGeom::Pointer EdgeGeom::CreateGeometry(int64_t numEdges, SharedVertexList::Pointer vertices, const QString& name, bool allocate) +EdgeGeom::Pointer EdgeGeom::CreateGeometry(size_t numEdges, SharedVertexList::Pointer vertices, const QString& name, bool allocate) { if(name.isEmpty()) { @@ -202,14 +193,14 @@ void EdgeGeom::initializeWithZeros() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void EdgeGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) +void EdgeGeom::addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) { - if(data->getType() != AttributeMatrix::Type::Vertex || data->getType() != AttributeMatrix::Type::Edge) + if(data->getType() != AttributeMatrix::Type::Vertex && data->getType() != AttributeMatrix::Type::Edge) { // EdgeGeom can only accept vertex or edge Attribute Matrices return; } - if(data->getType() == AttributeMatrix::Type::Vertex && static_cast(data->getNumberOfTuples()) != getNumberOfVertices()) + if(data->getType() == AttributeMatrix::Type::Vertex && static_cast(data->getNumberOfTuples()) != getNumberOfVertices()) { return; } @@ -217,17 +208,17 @@ void EdgeGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer { return; } - if(data->getName().compare(name) != 0) - { - data->setName(name); - } - m_AttributeMatrices[name] = data; + // if(data->getName().compare(name) != 0) + //{ + // data->setName(name); + //} + m_AttributeMatrices[data->getName()] = data; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -size_t EdgeGeom::getNumberOfElements() +size_t EdgeGeom::getNumberOfElements() const { return m_EdgeList->getNumberOfTuples(); } @@ -238,7 +229,7 @@ size_t EdgeGeom::getNumberOfElements() int EdgeGeom::findElementsContainingVert() { m_EdgesContainingVert = ElementDynamicList::New(); - GeometryHelpers::Connectivity::FindElementsContainingVert(m_EdgeList, m_EdgesContainingVert, getNumberOfVertices()); + GeometryHelpers::Connectivity::FindElementsContainingVert(m_EdgeList, m_EdgesContainingVert, getNumberOfVertices()); if(m_EdgesContainingVert.get() == nullptr) { return -1; @@ -249,7 +240,7 @@ int EdgeGeom::findElementsContainingVert() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ElementDynamicList::Pointer EdgeGeom::getElementsContainingVert() +ElementDynamicList::Pointer EdgeGeom::getElementsContainingVert() const { return m_EdgesContainingVert; } @@ -285,7 +276,7 @@ int EdgeGeom::findElementNeighbors() } } m_EdgeNeighbors = ElementDynamicList::New(); - err = GeometryHelpers::Connectivity::FindElementNeighbors(m_EdgeList, m_EdgesContainingVert, m_EdgeNeighbors, IGeometry::Type::Edge); + err = GeometryHelpers::Connectivity::FindElementNeighbors(m_EdgeList, m_EdgesContainingVert, m_EdgeNeighbors, IGeometry::Type::Edge); if(m_EdgeNeighbors.get() == nullptr) { err = -1; @@ -296,7 +287,7 @@ int EdgeGeom::findElementNeighbors() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ElementDynamicList::Pointer EdgeGeom::getElementNeighbors() +ElementDynamicList::Pointer EdgeGeom::getElementNeighbors() const { return m_EdgeNeighbors; } @@ -322,9 +313,9 @@ void EdgeGeom::deleteElementNeighbors() // ----------------------------------------------------------------------------- int EdgeGeom::findElementCentroids() { - QVector cDims(1, 3); - m_EdgeCentroids = FloatArrayType::CreateArray(getNumberOfElements(), cDims, SIMPL::StringConstants::EdgeCentroids); - GeometryHelpers::Topology::FindElementCentroids(m_EdgeList, m_VertexList, m_EdgeCentroids); + std::vector cDims(1, 3); + m_EdgeCentroids = FloatArrayType::CreateArray(getNumberOfElements(), cDims, SIMPL::StringConstants::EdgeCentroids, true); + GeometryHelpers::Topology::FindElementCentroids(m_EdgeList, m_VertexList, m_EdgeCentroids); if(m_EdgeCentroids.get() == nullptr) { return -1; @@ -335,7 +326,7 @@ int EdgeGeom::findElementCentroids() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatArrayType::Pointer EdgeGeom::getElementCentroids() +FloatArrayType::Pointer EdgeGeom::getElementCentroids() const { return m_EdgeCentroids; } @@ -361,13 +352,13 @@ void EdgeGeom::deleteElementCentroids() // ----------------------------------------------------------------------------- int EdgeGeom::findElementSizes() { - m_EdgeSizes = FloatArrayType::CreateArray(getNumberOfElements(), SIMPL::StringConstants::EdgeLengths); + m_EdgeSizes = FloatArrayType::CreateArray(getNumberOfElements(), SIMPL::StringConstants::EdgeLengths, true); float* sizes = m_EdgeSizes->getPointer(0); float vert0[3] = {0.0f, 0.0f, 0.0f}; float vert1[3] = {0.0f, 0.0f, 0.0f}; - for(int64_t i = 0; i < getNumberOfEdges(); i++) + for(size_t i = 0; i < getNumberOfEdges(); i++) { getVertCoordsAtEdge(i, vert0, vert1); float length = 0.0f; @@ -384,7 +375,7 @@ int EdgeGeom::findElementSizes() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatArrayType::Pointer EdgeGeom::getElementSizes() +FloatArrayType::Pointer EdgeGeom::getElementSizes() const { return m_EdgeSizes; } @@ -408,7 +399,7 @@ void EdgeGeom::deleteElementSizes() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void EdgeGeom::getParametricCenter(double pCoords[3]) +void EdgeGeom::getParametricCenter(double pCoords[3]) const { pCoords[0] = 0.5; pCoords[1] = 0.0; @@ -418,7 +409,7 @@ void EdgeGeom::getParametricCenter(double pCoords[3]) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void EdgeGeom::getShapeFunctions(double pCoords[3], double* shape) +void EdgeGeom::getShapeFunctions(double pCoords[3], double* shape) const { (void)pCoords; @@ -432,35 +423,22 @@ void EdgeGeom::getShapeFunctions(double pCoords[3], double* shape) void EdgeGeom::findDerivatives(DoubleArrayType::Pointer field, DoubleArrayType::Pointer derivatives, Observable* observable) { m_ProgressCounter = 0; - int64_t numEdges = getNumberOfEdges(); + size_t numEdges = getNumberOfEdges(); if(observable != nullptr) { - connect(this, SIGNAL(filterGeneratedMessage(const PipelineMessage&)), observable, SLOT(broadcastPipelineMessage(const PipelineMessage&))); + connect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), observable, SLOT(processDerivativesMessage(const AbstractMessage::Pointer&))); } -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - tbb::task_scheduler_init init; - bool doParallel = true; -#endif - -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - if(doParallel) - { - tbb::parallel_for(tbb::blocked_range(0, numEdges), FindEdgeDerivativesImpl(this, field, derivatives), tbb::auto_partitioner()); - } - else -#endif - { - FindEdgeDerivativesImpl serial(this, field, derivatives); - serial.compute(0, numEdges); - } + ParallelDataAlgorithm dataAlg; + dataAlg.setRange(0, numEdges); + dataAlg.execute(FindEdgeDerivativesImpl(this, field, derivatives)); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int EdgeGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf)) +int EdgeGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf)) const { herr_t err = 0; @@ -503,7 +481,7 @@ int EdgeGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf) if(m_EdgeNeighbors.get() != nullptr) { size_t numEdges = static_cast(getNumberOfEdges()); - err = GeometryHelpers::GeomIO::WriteDynamicListToHDF5(parentId, m_EdgeNeighbors, numEdges, SIMPL::StringConstants::EdgeNeighbors); + err = GeometryHelpers::GeomIO::WriteDynamicListToHDF5(parentId, m_EdgeNeighbors, numEdges, SIMPL::StringConstants::EdgeNeighbors); if(err < 0) { return err; @@ -513,7 +491,7 @@ int EdgeGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf) if(m_EdgesContainingVert.get() != nullptr) { size_t numVerts = static_cast(getNumberOfVertices()); - err = GeometryHelpers::GeomIO::WriteDynamicListToHDF5(parentId, m_EdgesContainingVert, numVerts, SIMPL::StringConstants::EdgesContainingVert); + err = GeometryHelpers::GeomIO::WriteDynamicListToHDF5(parentId, m_EdgesContainingVert, numVerts, SIMPL::StringConstants::EdgesContainingVert); if(err < 0) { return err; @@ -526,7 +504,7 @@ int EdgeGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int EdgeGeom::writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) +int EdgeGeom::writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) const { herr_t err = 0; @@ -579,24 +557,30 @@ int EdgeGeom::writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString EdgeGeom::getInfoString(SIMPL::InfoStringFormat format) +QString EdgeGeom::getInfoString(SIMPL::InfoStringFormat format) const { - QString info; - QTextStream ss(&info); - if(format == SIMPL::HtmlFormat) { - ss << "Geometry Info"; - ss << "Type" << TypeToString(getGeometryType()) << ""; - ss << R"(Units)" << LengthUnitToString(getUnits()) << ""; - ss << "Number of Edges" << getNumberOfEdges() << ""; - ss << "Number of Vertices" << getNumberOfVertices() << ""; - ss << ""; - } - else - { + return getToolTipGenerator().generateHTML(); } - return info; + + return QString(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +ToolTipGenerator EdgeGeom::getToolTipGenerator() const +{ + ToolTipGenerator toolTipGen; + + toolTipGen.addTitle("Geometry Info"); + toolTipGen.addValue("Type", TypeToString(getGeometryType())); + toolTipGen.addValue("Units", LengthUnitToString(getUnits())); + toolTipGen.addValue("Number of Edges", QString::number(getNumberOfEdges())); + toolTipGen.addValue("Number of Vertices", QString::number(getNumberOfVertices())); + + return toolTipGen; } // ----------------------------------------------------------------------------- @@ -606,7 +590,9 @@ int EdgeGeom::readGeometryFromHDF5(hid_t parentId, bool preflight) { herr_t err = 0; SharedVertexList::Pointer vertices = GeometryHelpers::GeomIO::ReadListFromHDF5(SIMPL::Geometry::SharedVertexList, parentId, preflight, err); - SharedEdgeList::Pointer edges = GeometryHelpers::GeomIO::ReadListFromHDF5(SIMPL::Geometry::SharedEdgeList, parentId, preflight, err); + + SharedEdgeList::Pointer edges = GeometryHelpers::GeomIO::ReadMeshIndexListFromHDF5(SIMPL::Geometry::SharedEdgeList, parentId, preflight, err); + if(edges.get() == nullptr || vertices.get() == nullptr) { return -1; @@ -623,13 +609,13 @@ int EdgeGeom::readGeometryFromHDF5(hid_t parentId, bool preflight) { return -1; } - ElementDynamicList::Pointer edgeNeighbors = GeometryHelpers::GeomIO::ReadDynamicListFromHDF5(SIMPL::StringConstants::EdgeNeighbors, parentId, numEdges, preflight, err); + ElementDynamicList::Pointer edgeNeighbors = GeometryHelpers::GeomIO::ReadDynamicListFromHDF5(SIMPL::StringConstants::EdgeNeighbors, parentId, numEdges, preflight, err); if(err < 0 && err != -2) { return -1; } ElementDynamicList::Pointer edgesContainingVert = - GeometryHelpers::GeomIO::ReadDynamicListFromHDF5(SIMPL::StringConstants::EdgesContainingVert, parentId, numVerts, preflight, err); + GeometryHelpers::GeomIO::ReadDynamicListFromHDF5(SIMPL::StringConstants::EdgesContainingVert, parentId, numVerts, preflight, err); if(err < 0 && err != -2) { return -1; @@ -648,7 +634,7 @@ int EdgeGeom::readGeometryFromHDF5(hid_t parentId, bool preflight) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IGeometry::Pointer EdgeGeom::deepCopy(bool forceNoAllocate) +IGeometry::Pointer EdgeGeom::deepCopy(bool forceNoAllocate) const { SharedVertexList::Pointer verts = std::dynamic_pointer_cast((getVertices().get() == nullptr) ? nullptr : getVertices()->deepCopy(forceNoAllocate)); SharedEdgeList::Pointer edges = std::dynamic_pointer_cast((getEdges().get() == nullptr) ? nullptr : getEdges()->deepCopy(forceNoAllocate)); @@ -680,3 +666,28 @@ IGeometry::Pointer EdgeGeom::deepCopy(bool forceNoAllocate) #define GEOM_CLASS_NAME EdgeGeom #include "SIMPLib/Geometry/SharedEdgeOps.cpp" #include "SIMPLib/Geometry/SharedVertexOps.cpp" + +// ----------------------------------------------------------------------------- +EdgeGeom::Pointer EdgeGeom::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +EdgeGeom::Pointer EdgeGeom::New() +{ + Pointer sharedPtr(new(EdgeGeom)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString EdgeGeom::getNameOfClass() const +{ + return QString("EdgeGeom"); +} + +// ----------------------------------------------------------------------------- +QString EdgeGeom::ClassName() +{ + return QString("EdgeGeom"); +} diff --git a/Source/SIMPLib/Geometry/EdgeGeom.h b/Source/SIMPLib/Geometry/EdgeGeom.h index 96c3998acd..975b6404e9 100644 --- a/Source/SIMPLib/Geometry/EdgeGeom.h +++ b/Source/SIMPLib/Geometry/EdgeGeom.h @@ -1,41 +1,46 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + +#include + +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/Geometry/IGeometry.h" /** @@ -44,29 +49,41 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry { // clang-format off - PYB11_CREATE_BINDINGS(EdgeGeom SUPERCLASS IGeometry) - - PYB11_CREATION(CreateGeometry ARGS int64_t SharedVertexList::Pointer QString bool) - PYB11_CREATION(CreateGeometry ARGS SharedEdgeList::Pointer SharedVertexList::Pointer QString) - + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(EdgeGeom SUPERCLASS IGeometry) + PYB11_SHARED_POINTERS(EdgeGeom) + PYB11_STATIC_NEW_MACRO(EdgeGeom) PYB11_METHOD(void setVertices SharedVertexList::Pointer,vertices) PYB11_METHOD(SharedVertexList::Pointer getVertices) - PYB11_METHOD(void setEdges SharedEdgeList::Pointer,edges) PYB11_METHOD(SharedEdgeList::Pointer getEdges) - - PYB11_METHOD(void setCoords int64_t,vertId float,coords[3]) - PYB11_METHOD(void getCoords int64_t,vertId float,coords[3]) - - PYB11_METHOD(int64_t getNumberOfVertices) - PYB11_METHOD(int64_t getNumberOfEdges) + PYB11_METHOD(void setCoords size_t,vertId float,coords[3]) + PYB11_METHOD(void getCoords size_t,vertId float,coords[3]) + PYB11_METHOD(size_t getNumberOfVertices) + PYB11_METHOD(size_t getNumberOfEdges) PYB11_METHOD(size_t getNumberOfElements) + PYB11_END_BINDINGS() + // End Python bindings declarations // clang-format on public: - SIMPL_SHARED_POINTERS(EdgeGeom) - SIMPL_STATIC_NEW_MACRO(EdgeGeom) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(EdgeGeom, Observable) + using Self = EdgeGeom; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for EdgeGeom + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for EdgeGeom + */ + static QString ClassName(); ~EdgeGeom() override; @@ -77,7 +94,7 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @param name * @return */ - static Pointer CreateGeometry(int64_t numEdges, SharedVertexList::Pointer vertices, const QString& name, bool allocate = true); + static Pointer CreateGeometry(size_t numEdges, SharedVertexList::Pointer vertices, const QString& name, bool allocate = true); /** * @brief CreateGeometry @@ -97,13 +114,13 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @param numVertices * @return */ - static SharedVertexList::Pointer CreateSharedVertexList(int64_t numVertices, bool allocate = true); + static SharedVertexList::Pointer CreateSharedVertexList(size_t numVertices, bool allocate = true); /** * @brief resizeVertexList * @param newNumVertices */ - void resizeVertexList(int64_t newNumVertices); + void resizeVertexList(size_t newNumVertices); /** * @brief setVertices @@ -115,34 +132,34 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @brief getVertices * @return */ - SharedVertexList::Pointer getVertices(); + SharedVertexList::Pointer getVertices() const; /** * @brief setCoords * @param vertId * @param coords */ - void setCoords(int64_t vertId, float coords[3]); + void setCoords(size_t vertId, float coords[3]); /** * @brief getCoords * @param vertId * @param coords */ - void getCoords(int64_t vertId, float coords[3]); + void getCoords(size_t vertId, float coords[3]) const; /** * @brief getVertexPointer * @param i * @return */ - float* getVertexPointer(int64_t i); + float* getVertexPointer(size_t i) const; /** * @brief getNumberOfVertices * @return */ - int64_t getNumberOfVertices(); + size_t getNumberOfVertices() const; // ----------------------------------------------------------------------------- // Inherited from SharedEdgeOps @@ -153,13 +170,13 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @param numEdges * @return */ - static SharedEdgeList::Pointer CreateSharedEdgeList(int64_t numEdges, bool allocate = true); + static SharedEdgeList::Pointer CreateSharedEdgeList(size_t numEdges, bool allocate = true); /** * @brief resizeEdgeList * @param newNumEdges */ - void resizeEdgeList(int64_t newNumEdges); + void resizeEdgeList(size_t newNumEdges); /** * @brief setEdges @@ -171,21 +188,21 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @brief getEdges * @return */ - SharedEdgeList::Pointer getEdges(); + SharedEdgeList::Pointer getEdges() const; /** * @brief setVerts * @param edgeId * @param verts */ - void setVertsAtEdge(int64_t edgeId, int64_t verts[2]); + void setVertsAtEdge(size_t edgeId, size_t verts[2]); /** * @brief getVerts * @param edgeId * @param verts */ - void getVertsAtEdge(int64_t edgeId, int64_t verts[2]); + void getVertsAtEdge(size_t edgeId, size_t verts[2]) const; /** * @brief getVertCoordsAtEdge @@ -193,20 +210,20 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @param vert1 * @param vert2 */ - void getVertCoordsAtEdge(int64_t edgeId, float vert1[3], float vert2[3]); + void getVertCoordsAtEdge(size_t edgeId, float vert1[3], float vert2[3]) const; /** * @brief getEdgePointer * @param i * @return */ - int64_t* getEdgePointer(int64_t i); + size_t* getEdgePointer(size_t i) const; /** * @brief getNumberOfEdges * @return */ - int64_t getNumberOfEdges(); + size_t getNumberOfEdges() const; // ----------------------------------------------------------------------------- // Inherited from IGeometry @@ -221,7 +238,7 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @brief getNumberOfElements * @return */ - size_t getNumberOfElements() override; + size_t getNumberOfElements() const override; /** * @brief findElementSizes @@ -233,7 +250,7 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @brief getElementSizes * @return */ - FloatArrayType::Pointer getElementSizes() override; + FloatArrayType::Pointer getElementSizes() const override; /** * @brief deleteElementSizes @@ -250,7 +267,7 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @brief getElementsContainingVert * @return */ - ElementDynamicList::Pointer getElementsContainingVert() override; + ElementDynamicList::Pointer getElementsContainingVert() const override; /** * @brief deleteElementsContainingVert @@ -267,7 +284,7 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @brief getElementNeighbors * @return */ - ElementDynamicList::Pointer getElementNeighbors() override; + ElementDynamicList::Pointer getElementNeighbors() const override; /** * @brief deleteElementNeighbors @@ -284,7 +301,7 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @brief getElementCentroids * @return */ - FloatArrayType::Pointer getElementCentroids() override; + FloatArrayType::Pointer getElementCentroids() const override; /** * @brief deleteElementCentroids @@ -295,14 +312,14 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @brief getParametricCenter * @param pCoords */ - void getParametricCenter(double pCoords[3]) override; + void getParametricCenter(double pCoords[3]) const override; /** * @brief getShapeFunctions * @param pCoords * @param shape */ - void getShapeFunctions(double pCoords[3], double* shape) override; + void getShapeFunctions(double pCoords[3], double* shape) const override; /** * @brief findDerivatives @@ -316,7 +333,14 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @return Returns a formatted string that contains general infomation about * the instance of the object. */ - QString getInfoString(SIMPL::InfoStringFormat format) override; + QString getInfoString(SIMPL::InfoStringFormat format) const override; + + /** + * @brief Returns a ToolTipGenerator for creating HTML tooltip tables + * with values populated to match the geometry. + * @return + */ + ToolTipGenerator getToolTipGenerator() const override; /** * @brief writeGeometryToHDF5 @@ -324,7 +348,7 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @param writeXdmf * @return */ - int writeGeometryToHDF5(hid_t parentId, bool writeXdmf) override; + int writeGeometryToHDF5(hid_t parentId, bool writeXdmf) const override; /** * @brief writeXdmf @@ -333,7 +357,7 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @param hdfFileName * @return */ - int writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) override; + int writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) const override; /** * @brief readGeometryFromHDF5 @@ -347,12 +371,12 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry * @brief deepCopy * @return */ - IGeometry::Pointer deepCopy(bool forceNoAllocate = false) override; + IGeometry::Pointer deepCopy(bool forceNoAllocate = false) const override; /** - * @brief addAttributeMatrix + * @brief addOrReplaceAttributeMatrix */ - void addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; + void addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; protected: EdgeGeom(); @@ -397,6 +421,3 @@ class SIMPLib_EXPORT EdgeGeom : public IGeometry EdgeGeom& operator=(const EdgeGeom&) = delete; // Copy Assignment Not Implemented EdgeGeom& operator=(EdgeGeom&&) = delete; // Move Assignment Not Implemented }; - - - diff --git a/Source/SIMPLib/Geometry/GeometryHelpers.cpp b/Source/SIMPLib/Geometry/GeometryHelpers.cpp index aad34ced95..b625ad150f 100644 --- a/Source/SIMPLib/Geometry/GeometryHelpers.cpp +++ b/Source/SIMPLib/Geometry/GeometryHelpers.cpp @@ -34,5 +34,73 @@ namespace GeometryHelpers { +// ----------------------------------------------------------------------------- +MeshIndexArrayType::Pointer GeomIO::ReadMeshIndexListFromHDF5(const QString& listName, hid_t parentId, bool preflight, herr_t& err) +{ + MeshIndexArrayType::Pointer meshIndex = MeshIndexArrayType::NullPointer(); + + // In versions of DREAM3D before 6.6, the index list was stored as a Int64_t type, versions starting with 6.6 now store + // the list as a size_t (UInt64_t). So we need to try each type: + Int64ArrayType::Pointer tempInt64 = GeometryHelpers::GeomIO::ReadListFromHDF5(listName, parentId, preflight, err); + if(tempInt64.get() != nullptr) + { + meshIndex = SharedEdgeList::WrapPointer(reinterpret_cast(tempInt64->data()), tempInt64->getNumberOfTuples(), tempInt64->getComponentDimensions(), tempInt64->getName(), true); + // Release the ownership of the memory from TempTris and essentially pass it to tris. + tempInt64->releaseOwnership(); + } + else // Reading as a Int64 didn't work which means the data _should_ be a UInt64_t (size_t) + { +#ifdef Q_OS_MACOS + // Mac OS will fail the dynamic cast from unsigned long ling (Uint64_t) to unsigned long (size_t) so we use the proper + // type from the hdf5 file for macOS. + UInt64ArrayType::Pointer tempUInt64 = GeometryHelpers::GeomIO::ReadListFromHDF5(listName, parentId, preflight, err); +#else + MeshIndexArrayType::Pointer tempUInt64 = GeometryHelpers::GeomIO::ReadListFromHDF5(listName, parentId, preflight, err); +#endif + if(tempUInt64.get() != nullptr) + { + meshIndex = SharedEdgeList::WrapPointer(reinterpret_cast(tempUInt64->data()), tempUInt64->getNumberOfTuples(), tempUInt64->getComponentDimensions(), tempUInt64->getName(), true); + // Release the ownership of the memory from TempTris and essentially pass it to tris. + tempUInt64->releaseOwnership(); + } + } + + return meshIndex; +} + +// ----------------------------------------------------------------------------- +int GeomIO::ReadMetaDataFromHDF5(hid_t parentId, const IGeometry::Pointer& geometry) +{ + herr_t err = 0; + unsigned int spatialDims = 0; + QString geomName = ""; + err = QH5Lite::readScalarAttribute(parentId, SIMPL::Geometry::Geometry, SIMPL::Geometry::SpatialDimensionality, spatialDims); + if(err < 0) + { + return err; + } + err = QH5Lite::readStringAttribute(parentId, SIMPL::Geometry::Geometry, SIMPL::Geometry::GeometryName, geomName); + if(err < 0) + { + return err; + } + geometry->setSpatialDimensionality(spatialDims); + geometry->setName(geomName); + return 1; } + +// ----------------------------------------------------------------------------- +int GeomIO::WriteListToHDF5(hid_t parentId, const IDataArray::Pointer& list) +{ + herr_t err = 0; + if(list->getNumberOfTuples() == 0) + { + return err; + } + std::vector tDims(1, list->getNumberOfTuples()); + err = list->writeH5Data(parentId, tDims); + return err; +} + +} // namespace GeometryHelpers diff --git a/Source/SIMPLib/Geometry/GeometryHelpers.h b/Source/SIMPLib/Geometry/GeometryHelpers.h old mode 100755 new mode 100644 index 9c4c68db74..681dcd7b99 --- a/Source/SIMPLib/Geometry/GeometryHelpers.h +++ b/Source/SIMPLib/Geometry/GeometryHelpers.h @@ -33,12 +33,13 @@ #include #include +#include #include #include -#include "H5Support/QH5Lite.h" #include "H5Support/H5ScopedErrorHandler.h" +#include "H5Support/QH5Lite.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/DataArrays/DataArray.hpp" @@ -47,9 +48,12 @@ #include "SIMPLib/Math/GeometryMath.h" #include "SIMPLib/Math/MatrixMath.h" +class IDataArray; +using IDataArrayShPtrType = std::shared_ptr; + /** -* @brief This file contains a namespace with classes for manipulating IGeometry objects -*/ + * @brief This file contains a namespace with classes for manipulating IGeometry objects + */ namespace GeometryHelpers { @@ -64,17 +68,19 @@ class GeomIO /** * @brief ReadMeshFromHDF5 - * @param listName - * @param parentId - * @param preflight + * @param listName The name of the DataSet + * @param parentId The HDF5 + * @param preflight Are we in preflight mode. If TRUE then the underlying memory for the array will *not* be allocated + * @param err Any error that occured. * @return */ - template static typename ListType::Pointer ReadListFromHDF5(const QString& listName, hid_t parentId, bool preflight, herr_t& err) + template + static typename ListType::Pointer ReadListFromHDF5(const QString& listName, hid_t parentId, bool preflight, herr_t& err) { QVector dims; H5T_class_t type_class; size_t type_size; - IDataArray::Pointer mesh = IDataArray::NullPointer(); + IDataArrayShPtrType mesh = IDataArray::NullPointer(); H5ScopedErrorHandler errorHandler; err = QH5Lite::getDatasetInfo(parentId, listName, dims, type_class, type_size); if(err < 0) @@ -91,32 +97,23 @@ class GeomIO return std::dynamic_pointer_cast(mesh); } + /** + * @brief ReadIndexListFromHDF5 + * @param listName The name of the DataSet + * @param parentId The HDF5 + * @param preflight Are we in preflight mode. If TRUE then the underlying memory for the array will *not* be allocated + * @param err Any error that occured. + * @return + */ + static MeshIndexArrayType::Pointer ReadMeshIndexListFromHDF5(const QString& listName, hid_t parentId, bool preflight, herr_t& err); + /** * @brief ReadMetaDataFromHDF5 * @param parentId * @param geometry * @return */ - static int ReadMetaDataFromHDF5(hid_t parentId, IGeometry::Pointer geometry) - { - herr_t err = 0; - unsigned int spatialDims = 0; - QString geomName = ""; - err = QH5Lite::readScalarAttribute(parentId, SIMPL::Geometry::Geometry, SIMPL::Geometry::SpatialDimensionality, spatialDims); - if(err < 0) - { - return err; - } - err = QH5Lite::readStringAttribute(parentId, SIMPL::Geometry::Geometry, SIMPL::Geometry::GeometryName, geomName); - if(err < 0) - { - return err; - } - geometry->setSpatialDimensionality(spatialDims); - geometry->setName(geomName); - - return 1; - } + static int ReadMetaDataFromHDF5(hid_t parentId, const IGeometry::Pointer& geometry); /** * @brief WriteListToHDF5 @@ -124,17 +121,7 @@ class GeomIO * @param list * @return */ - static int WriteListToHDF5(hid_t parentId, IDataArray::Pointer list) - { - herr_t err = 0; - if(list->getNumberOfTuples() == 0) - { - return err; - } - QVector tDims(1, list->getNumberOfTuples()); - err = list->writeH5Data(parentId, tDims); - return err; - } + static int WriteListToHDF5(hid_t parentId, const IDataArray::Pointer& list); /** * @brief ReadDynamicListFromHDF5 @@ -158,7 +145,7 @@ class GeomIO err = -2; return dynamicList = DynamicListArray::NullPointer(); } - if(preflight == true) + if(preflight) { if(err < 0) { @@ -187,7 +174,8 @@ class GeomIO * @param name * @return */ - template static int WriteDynamicListToHDF5(hid_t parentId, typename DynamicListArray::Pointer dynamicList, size_t numElems, const QString& name) + template + static int WriteDynamicListToHDF5(hid_t parentId, typename DynamicListArray::Pointer dynamicList, size_t numElems, const QString& name) { herr_t err = 0; if(numElems == 0) @@ -242,7 +230,8 @@ class Connectivity * @param dynamicList * @param numVerts */ - template static void FindElementsContainingVert(typename DataArray::Pointer elemList, typename DynamicListArray::Pointer dynamicList, size_t numVerts) + template + static void FindElementsContainingVert(typename DataArray::Pointer elemList, typename DynamicListArray::Pointer dynamicList, size_t numVerts) { size_t numElems = elemList->getNumberOfTuples(); size_t numVertsPerElem = elemList->getNumberOfComponents(); @@ -252,7 +241,7 @@ class Connectivity size_t elemId = 0; // Fill out lists with number of references to cells - typename DataArray::Pointer linkLocPtr = DataArray::CreateArray(numVerts, "_INTERNAL_USE_ONLY_Vertices"); + typename DataArray::Pointer linkLocPtr = DataArray::CreateArray(numVerts, std::string("_INTERNAL_USE_ONLY_Vertices"), true); linkLocPtr->initializeWithValue(0); K* linkLoc = linkLocPtr->getPointer(0); K* verts = nullptr; @@ -339,7 +328,7 @@ class Connectivity dynamicList->allocateLists(linkCount); // Allocate an array of bools that we use each iteration so that we don't put duplicates into the array - typename DataArray::Pointer visitedPtr = DataArray::CreateArray(numElems, "_INTERNAL_USE_ONLY_Visited"); + typename DataArray::Pointer visitedPtr = DataArray::CreateArray(numElems, std::string("_INTERNAL_USE_ONLY_Visited"), true); visitedPtr->initializeWithValue(false); bool* visited = visitedPtr->getPointer(0); @@ -418,7 +407,8 @@ class Connectivity * @param elemList * @param edgeList */ - template static void Find2DElementEdges(typename DataArray::Pointer elemList, typename DataArray::Pointer edgeList) + template + static void Find2DElementEdges(typename DataArray::Pointer elemList, typename DataArray::Pointer edgeList) { size_t numElems = elemList->getNumberOfTuples(); size_t numVertsPerElem = elemList->getNumberOfComponents(); @@ -466,7 +456,7 @@ class Connectivity } typename std::set>::iterator setIter; - edgeList->resize(edgeSet.size()); + edgeList->resizeTuples(edgeSet.size()); T* uEdges = edgeList->getPointer(0); T index = 0; @@ -483,7 +473,8 @@ class Connectivity * @param tetList * @param edgeList */ - template static void FindTetEdges(typename DataArray::Pointer tetList, typename DataArray::Pointer edgeList) + template + static void FindTetEdges(typename DataArray::Pointer tetList, typename DataArray::Pointer edgeList) { size_t numElems = tetList->getNumberOfTuples(); @@ -511,7 +502,7 @@ class Connectivity } typename std::set>::iterator setIter; - edgeList->resize(edgeSet.size()); + edgeList->resizeTuples(edgeSet.size()); T* uEdges = edgeList->getPointer(0); T index = 0; @@ -524,11 +515,12 @@ class Connectivity } /** - * @brief FindHexEdges - * @param hexList - * @param edgeList - */ - template static void FindHexEdges(typename DataArray::Pointer hexList, typename DataArray::Pointer edgeList) + * @brief FindHexEdges + * @param hexList + * @param edgeList + */ + template + static void FindHexEdges(typename DataArray::Pointer hexList, typename DataArray::Pointer edge_List) { size_t numElems = hexList->getNumberOfTuples(); @@ -549,13 +541,12 @@ class Connectivity std::vector edge6 = {verts[2], verts[6]}; std::vector edge7 = {verts[3], verts[7]}; - std::vector edge8 = {verts[4], verts[5]}; - std::vector edge9 = {verts[5], verts[6]}; + std::vector edge8 = {verts[4], verts[5]}; + std::vector edge9 = {verts[5], verts[6]}; std::vector edge10 = {verts[6], verts[7]}; std::vector edge11 = {verts[7], verts[4]}; - std::list> edgeList = {edge0, edge1, edge2, edge3, edge4, edge5, - edge6, edge7, edge8, edge9, edge10, edge11}; + std::list> edgeList = {edge0, edge1, edge2, edge3, edge4, edge5, edge6, edge7, edge8, edge9, edge10, edge11}; for(auto&& uEdge : edgeList) { @@ -566,8 +557,8 @@ class Connectivity } typename std::set>::iterator setIter; - edgeList->resize(edgeSet.size()); - T* uEdges = edgeList->getPointer(0); + edge_List->resizeTuples(edgeSet.size()); + T* uEdges = edge_List->getPointer(0); T index = 0; for(setIter = edgeSet.begin(); setIter != edgeSet.end(); ++setIter) @@ -583,7 +574,8 @@ class Connectivity * @param tetList * @param edgeList */ - template static void FindTetFaces(typename DataArray::Pointer tetList, typename DataArray::Pointer faceList) + template + static void FindTetFaces(typename DataArray::Pointer tetList, typename DataArray::Pointer faceList) { size_t numElems = tetList->getNumberOfTuples(); @@ -609,7 +601,7 @@ class Connectivity } typename std::set>::iterator setIter; - faceList->resize(faceSet.size()); + faceList->resizeTuples(faceSet.size()); T* uFaces = faceList->getPointer(0); T index = 0; @@ -623,11 +615,12 @@ class Connectivity } /** - * @brief FindHexFaces - * @param hexList - * @param edgeList - */ - template static void FindHexFaces(typename DataArray::Pointer hexList, typename DataArray::Pointer faceList) + * @brief FindHexFaces + * @param hexList + * @param edgeList + */ + template + static void FindHexFaces(typename DataArray::Pointer hexList, typename DataArray::Pointer faceList) { size_t numElems = hexList->getNumberOfTuples(); @@ -656,7 +649,7 @@ class Connectivity } typename std::set>::iterator setIter; - faceList->resize(faceSet.size()); + faceList->resizeTuples(faceSet.size()); T* uFaces = faceList->getPointer(0); T index = 0; @@ -675,7 +668,8 @@ class Connectivity * @param elemList * @param edgeList */ - template static void Find2DUnsharedEdges(typename DataArray::Pointer elemList, typename DataArray::Pointer edgeList) + template + static void Find2DUnsharedEdges(typename DataArray::Pointer elemList, typename DataArray::Pointer edgeList) { size_t numElems = elemList->getNumberOfTuples(); size_t numVertsPerElem = elemList->getNumberOfComponents(); @@ -736,7 +730,7 @@ class Connectivity } } - edgeList->resize(edgeMap.size()); + edgeList->resizeTuples(edgeMap.size()); T* bEdges = edgeList->getPointer(0); T index = 0; @@ -749,11 +743,12 @@ class Connectivity } /** - * @brief FindUnsharedTetEdges - * @param tetList - * @param edgeList - */ - template static void FindUnsharedTetEdges(typename DataArray::Pointer tetList, typename DataArray::Pointer edgeList) + * @brief FindUnsharedTetEdges + * @param tetList + * @param edgeList + */ + template + static void FindUnsharedTetEdges(typename DataArray::Pointer tetList, typename DataArray::Pointer edgeList) { size_t numElems = tetList->getNumberOfTuples(); @@ -794,7 +789,7 @@ class Connectivity } } - edgeList->resize(edgeMap.size()); + edgeList->resizeTuples(edgeMap.size()); T* bEdges = edgeList->getPointer(0); T index = 0; @@ -807,11 +802,12 @@ class Connectivity } /** - * @brief FindUnsharedHexEdges - * @param hexList - * @param edgeList - */ - template static void FindUnsharedHexEdges(typename DataArray::Pointer hexList, typename DataArray::Pointer edgeList) + * @brief FindUnsharedHexEdges + * @param hexList + * @param edgeList + */ + template + static void FindUnsharedHexEdges(typename DataArray::Pointer& hexList, typename DataArray::Pointer& edge_List) { size_t numElems = hexList->getNumberOfTuples(); @@ -837,8 +833,7 @@ class Connectivity std::vector edge10 = {verts[6], verts[7]}; std::vector edge11 = {verts[7], verts[4]}; - std::list> edgeList = {edge0, edge1, edge2, edge3, edge4, edge5, - edge6, edge7, edge8, edge9, edge10, edge11}; + std::list> edgeList = {edge0, edge1, edge2, edge3, edge4, edge5, edge6, edge7, edge8, edge9, edge10, edge11}; for(auto&& uEdge : edgeList) { @@ -862,8 +857,8 @@ class Connectivity } } - edgeList->resize(edgeMap.size()); - T* bEdges = edgeList->getPointer(0); + edge_List->resizeTuples(edgeMap.size()); + T* bEdges = edge_List->getPointer(0); T index = 0; for(mapIter = edgeMap.begin(); mapIter != edgeMap.end(); ++mapIter) @@ -879,7 +874,8 @@ class Connectivity * @param tetList * @param edgeList */ - template static void FindUnsharedTetFaces(typename DataArray::Pointer tetList, typename DataArray::Pointer faceList) + template + static void FindUnsharedTetFaces(typename DataArray::Pointer tetList, typename DataArray::Pointer faceList) { size_t numElems = tetList->getNumberOfTuples(); @@ -918,7 +914,7 @@ class Connectivity } } - faceList->resize(faceMap.size()); + faceList->resizeTuples(faceMap.size()); T* uFaces = faceList->getPointer(0); T index = 0; @@ -932,11 +928,12 @@ class Connectivity } /** - * @brief FindUnsharedHexFaces - * @param hexList - * @param edgeList - */ - template static void FindUnsharedHexFaces(typename DataArray::Pointer hexList, typename DataArray::Pointer faceList) + * @brief FindUnsharedHexFaces + * @param hexList + * @param edgeList + */ + template + static void FindUnsharedHexFaces(typename DataArray::Pointer hexList, typename DataArray::Pointer faceList) { size_t numElems = hexList->getNumberOfTuples(); @@ -978,7 +975,7 @@ class Connectivity } } - faceList->resize(faceMap.size()); + faceList->resizeTuples(faceMap.size()); T* uFaces = faceList->getPointer(0); T index = 0; @@ -1008,7 +1005,8 @@ class Topology * @param vertices * @param elementCentroids */ - template static void FindElementCentroids(typename DataArray::Pointer elemList, FloatArrayType::Pointer vertices, FloatArrayType::Pointer centroids) + template + static void FindElementCentroids(typename DataArray::Pointer elemList, FloatArrayType::Pointer vertices, FloatArrayType::Pointer centroids) { size_t numElems = elemList->getNumberOfTuples(); size_t numVertsPerElem = elemList->getNumberOfComponents(); @@ -1038,7 +1036,8 @@ class Topology * @param vertices * @param areas */ - template static void Find2DElementAreas(typename DataArray::Pointer elemList, FloatArrayType::Pointer vertices, FloatArrayType::Pointer areas) + template + static void Find2DElementAreas(typename DataArray::Pointer elemList, FloatArrayType::Pointer vertices, FloatArrayType::Pointer areas) { float nx, ny, nz; int32_t projection; @@ -1086,18 +1085,15 @@ class Topology switch(projection) { - case 0: - { + case 0: { area += coordinates[3 * ((j + 1) % numVertsPerElem) + 1] * (coordinates[3 * ((j + 2) % numVertsPerElem) + 2] - coordinates[3 * j + 2]); continue; } - case 1: - { + case 1: { area += coordinates[3 * ((j + 1) % numVertsPerElem) + 0] * (coordinates[3 * ((j + 2) % numVertsPerElem) + 2] - coordinates[3 * j + 2]); continue; } - case 2: - { + case 2: { area += coordinates[3 * ((j + 1) % numVertsPerElem) + 0] * (coordinates[3 * ((j + 2) % numVertsPerElem) + 1] - coordinates[3 * j + 1]); continue; } @@ -1106,18 +1102,15 @@ class Topology switch(projection) { - case 0: - { + case 0: { area /= (2.0f * nx); break; } - case 1: - { + case 1: { area /= (2.0f * ny); break; } - case 2: - { + case 2: { area /= (2.0f * nz); } } @@ -1131,7 +1124,8 @@ class Topology * @param vertices * @param volumes */ - template static void FindTetVolumes(typename DataArray::Pointer tetList, FloatArrayType::Pointer vertices, FloatArrayType::Pointer volumes) + template + static void FindTetVolumes(typename DataArray::Pointer tetList, FloatArrayType::Pointer vertices, FloatArrayType::Pointer volumes) { size_t numTets = tetList->getNumberOfTuples(); float* vertex = vertices->getPointer(0); @@ -1154,12 +1148,13 @@ class Topology } /** - * @brief FindHexVolumes - * @param hexList - * @param vertices - * @param volumes - */ - template static void FindHexVolumes(typename DataArray::Pointer hexList, FloatArrayType::Pointer vertices, FloatArrayType::Pointer volumes) + * @brief FindHexVolumes + * @param hexList + * @param vertices + * @param volumes + */ + template + static void FindHexVolumes(typename DataArray::Pointer hexList, FloatArrayType::Pointer vertices, FloatArrayType::Pointer volumes) { size_t numHexas = hexList->getNumberOfTuples(); float* vertex = vertices->getPointer(0); @@ -1212,7 +1207,7 @@ class Topology float vertMatrix[3][3] = {{vert1[0] - vert0[0], vert2[0] - vert0[0], vert3[0] - vert0[0]}, {vert1[1] - vert0[1], vert2[1] - vert0[1], vert3[1] - vert0[1]}, - {vert1[2] - vert0[2], vert2[2] - vert0[2], vert3[2] - vert0[2]}}; + {vert1[2] - vert0[2], vert2[2] - vert0[2], vert3[2] - vert0[2]}}; volume += (MatrixMath::Determinant3x3(vertMatrix) / 6.0f); } @@ -1222,87 +1217,104 @@ class Topology } /** - * @brief FindTetJacobians - * @param tetList - * @param vertices - * @param jacobians - */ - template static void FindTetJacobians(typename DataArray::Pointer tetList, FloatArrayType::Pointer vertices, FloatArrayType::Pointer jacobians) + * @brief FindTetJacobians + * @param tetList + * @param vertices + * @param jacobians + */ + template + static void FindTetJacobians(typename DataArray::Pointer tetList, FloatArrayType::Pointer vertices, FloatArrayType::Pointer jacobians) { - size_t numTets = tetList->getNumberOfTuples(); - float* vertex = vertices->getPointer(0); - float* jacobianPtr = jacobians->getPointer(0); - - for (size_t i = 0; i < numTets; i++) - { - T* tet = tetList->getTuplePointer(i); - //get vert positions - float vert0[3] = { vertex[3 * tet[0] + 0], vertex[3 * tet[0] + 1], vertex[3 * tet[0] + 2] }; - float vert1[3] = { vertex[3 * tet[1] + 0], vertex[3 * tet[1] + 1], vertex[3 * tet[1] + 2] }; - float vert2[3] = { vertex[3 * tet[2] + 0], vertex[3 * tet[2] + 1], vertex[3 * tet[2] + 2] }; - float vert3[3] = { vertex[3 * tet[3] + 0], vertex[3 * tet[3] + 1], vertex[3 * tet[3] + 2] }; - //build jacobian matrix - float vertMatrix[3][3] = { { vert1[0] - vert0[0], vert2[0] - vert0[0], vert3[0] - vert0[0] }, - { vert1[1] - vert0[1], vert2[1] - vert0[1], vert3[1] - vert0[1] }, - { vert1[2] - vert0[2], vert2[2] - vert0[2], vert3[2] - vert0[2] } }; - //find jacobian, which is determinant of the jacobian matrix - jacobianPtr[i] = MatrixMath::Determinant3x3(vertMatrix); - } + size_t numTets = tetList->getNumberOfTuples(); + float* vertex = vertices->getPointer(0); + float* jacobianPtr = jacobians->getPointer(0); + + for(size_t i = 0; i < numTets; i++) + { + T* tet = tetList->getTuplePointer(i); + // get vert positions + float vert0[3] = {vertex[3 * tet[0] + 0], vertex[3 * tet[0] + 1], vertex[3 * tet[0] + 2]}; + float vert1[3] = {vertex[3 * tet[1] + 0], vertex[3 * tet[1] + 1], vertex[3 * tet[1] + 2]}; + float vert2[3] = {vertex[3 * tet[2] + 0], vertex[3 * tet[2] + 1], vertex[3 * tet[2] + 2]}; + float vert3[3] = {vertex[3 * tet[3] + 0], vertex[3 * tet[3] + 1], vertex[3 * tet[3] + 2]}; + // build jacobian matrix + float vertMatrix[3][3] = {{vert1[0] - vert0[0], vert2[0] - vert0[0], vert3[0] - vert0[0]}, + {vert1[1] - vert0[1], vert2[1] - vert0[1], vert3[1] - vert0[1]}, + {vert1[2] - vert0[2], vert2[2] - vert0[2], vert3[2] - vert0[2]}}; + // find jacobian, which is determinant of the jacobian matrix + jacobianPtr[i] = MatrixMath::Determinant3x3(vertMatrix); + } } /** - * @brief FindTetMinDihedralAngles - * @param tetList - * @param vertices - * @param minAngles - */ - template static void FindTetMinDihedralAngles(typename DataArray::Pointer tetList, FloatArrayType::Pointer vertices, FloatArrayType::Pointer minAngles) + * @brief FindTetMinDihedralAngles + * @param tetList + * @param vertices + * @param minAngles + */ + template + static void FindTetMinDihedralAngles(typename DataArray::Pointer tetList, FloatArrayType::Pointer vertices, FloatArrayType::Pointer minAngles) { - size_t numTets = tetList->getNumberOfTuples(); - float* vertex = vertices->getPointer(0); - float* minAnglesPtr = minAngles->getPointer(0); - - for (size_t i = 0; i < numTets; i++) - { - T* tet = tetList->getTuplePointer(i); - //get vert positions - float vert0[3] = { vertex[3 * tet[0] + 0], vertex[3 * tet[0] + 1], vertex[3 * tet[0] + 2] }; - float vert1[3] = { vertex[3 * tet[1] + 0], vertex[3 * tet[1] + 1], vertex[3 * tet[1] + 2] }; - float vert2[3] = { vertex[3 * tet[2] + 0], vertex[3 * tet[2] + 1], vertex[3 * tet[2] + 2] }; - float vert3[3] = { vertex[3 * tet[3] + 0], vertex[3 * tet[3] + 1], vertex[3 * tet[3] + 2] }; - //find 5 edges needed to find 4 face normals - float v10[3] = { (vert1[0] - vert0[0]), (vert1[1] - vert0[1]), (vert1[2] - vert0[2]) }; - float v20[3] = { (vert2[0] - vert0[0]), (vert2[1] - vert0[1]), (vert2[2] - vert0[2]) }; - float v30[3] = { (vert3[0] - vert0[0]), (vert3[1] - vert0[1]), (vert3[2] - vert0[2]) }; - float v21[3] = { (vert2[0] - vert1[0]), (vert2[1] - vert1[1]), (vert2[2] - vert1[2]) }; - float v31[3] = { (vert3[0] - vert1[0]), (vert3[1] - vert1[1]), (vert3[2] - vert1[2]) }; - //find 4 face-to-face normals - float norm1[3] = { (v10[1] * v20[2] - v10[2] * v20[1]), (v10[2] * v20[0] - v10[0] * v20[2]), (v10[0] * v20[1] - v10[1] * v20[0]) }; - float norm2[3] = { (v30[1] * v10[2] - v30[2] * v10[1]), (v30[2] * v10[0] - v30[0] * v10[2]), (v30[0] * v10[1] - v30[1] * v10[0]) }; - float norm3[3] = { (v20[1] * v30[2] - v20[2] * v30[1]), (v20[2] * v30[0] - v20[0] * v30[2]), (v20[0] * v30[1] - v20[1] * v30[0]) }; - float norm4[3] = { (v31[1] * v21[2] - v31[2] * v21[1]), (v31[2] * v21[0] - v31[0] * v21[2]), (v31[0] * v21[1] - v31[1] * v21[0]) }; - //find the magnitudes of each normal - float norm1mag = sqrtf(norm1[0] * norm1[0] + norm1[1] * norm1[1] + norm1[2] * norm1[2]); - float norm2mag = sqrtf(norm2[0] * norm2[0] + norm2[1] * norm2[1] + norm2[2] * norm2[2]); - float norm3mag = sqrtf(norm3[0] * norm3[0] + norm3[1] * norm3[1] + norm3[2] * norm3[2]); - float norm4mag = sqrtf(norm4[0] * norm4[0] + norm4[1] * norm4[1] + norm4[2] * norm4[2]); - //find angles between faces - float ang1 = (norm1[0] * norm2[0] + norm1[1] * norm2[1] + norm1[2] * norm2[2]) / (norm1mag * norm2mag); - float ang2 = (norm1[0] * norm3[0] + norm1[1] * norm3[1] + norm1[2] * norm3[2]) / (norm1mag * norm3mag); - float ang3 = (norm1[0] * norm4[0] + norm1[1] * norm4[1] + norm1[2] * norm4[2]) / (norm1mag * norm4mag); - float ang4 = (norm2[0] * norm3[0] + norm2[1] * norm3[1] + norm2[2] * norm3[2]) / (norm2mag * norm3mag); - float ang5 = (norm2[0] * norm4[0] + norm2[1] * norm4[1] + norm2[2] * norm4[2]) / (norm2mag * norm4mag); - float ang6 = (norm3[0] * norm4[0] + norm3[1] * norm4[1] + norm3[2] * norm4[2]) / (norm3mag * norm4mag); - //find the maximum ang value, which will be the minimum angle after the acos - float minAng = ang1; - if (ang2 > minAng) { minAng = ang2; } - if (ang3 > minAng) { minAng = ang3; } - if (ang4 > minAng) { minAng = ang4; } - if (ang5 > minAng) { minAng = ang5; } - if (ang6 > minAng) { minAng = ang6; } - - minAnglesPtr[i] = SIMPLib::Constants::k_180OverPi * acosf(minAng); - } + size_t numTets = tetList->getNumberOfTuples(); + float* vertex = vertices->getPointer(0); + float* minAnglesPtr = minAngles->getPointer(0); + + for(size_t i = 0; i < numTets; i++) + { + T* tet = tetList->getTuplePointer(i); + // get vert positions + float vert0[3] = {vertex[3 * tet[0] + 0], vertex[3 * tet[0] + 1], vertex[3 * tet[0] + 2]}; + float vert1[3] = {vertex[3 * tet[1] + 0], vertex[3 * tet[1] + 1], vertex[3 * tet[1] + 2]}; + float vert2[3] = {vertex[3 * tet[2] + 0], vertex[3 * tet[2] + 1], vertex[3 * tet[2] + 2]}; + float vert3[3] = {vertex[3 * tet[3] + 0], vertex[3 * tet[3] + 1], vertex[3 * tet[3] + 2]}; + // find 5 edges needed to find 4 face normals + float v10[3] = {(vert1[0] - vert0[0]), (vert1[1] - vert0[1]), (vert1[2] - vert0[2])}; + float v20[3] = {(vert2[0] - vert0[0]), (vert2[1] - vert0[1]), (vert2[2] - vert0[2])}; + float v30[3] = {(vert3[0] - vert0[0]), (vert3[1] - vert0[1]), (vert3[2] - vert0[2])}; + float v21[3] = {(vert2[0] - vert1[0]), (vert2[1] - vert1[1]), (vert2[2] - vert1[2])}; + float v31[3] = {(vert3[0] - vert1[0]), (vert3[1] - vert1[1]), (vert3[2] - vert1[2])}; + // find 4 face-to-face normals + float norm1[3] = {(v10[1] * v20[2] - v10[2] * v20[1]), (v10[2] * v20[0] - v10[0] * v20[2]), (v10[0] * v20[1] - v10[1] * v20[0])}; + float norm2[3] = {(v30[1] * v10[2] - v30[2] * v10[1]), (v30[2] * v10[0] - v30[0] * v10[2]), (v30[0] * v10[1] - v30[1] * v10[0])}; + float norm3[3] = {(v20[1] * v30[2] - v20[2] * v30[1]), (v20[2] * v30[0] - v20[0] * v30[2]), (v20[0] * v30[1] - v20[1] * v30[0])}; + float norm4[3] = {(v31[1] * v21[2] - v31[2] * v21[1]), (v31[2] * v21[0] - v31[0] * v21[2]), (v31[0] * v21[1] - v31[1] * v21[0])}; + // find the magnitudes of each normal + float norm1mag = sqrtf(norm1[0] * norm1[0] + norm1[1] * norm1[1] + norm1[2] * norm1[2]); + float norm2mag = sqrtf(norm2[0] * norm2[0] + norm2[1] * norm2[1] + norm2[2] * norm2[2]); + float norm3mag = sqrtf(norm3[0] * norm3[0] + norm3[1] * norm3[1] + norm3[2] * norm3[2]); + float norm4mag = sqrtf(norm4[0] * norm4[0] + norm4[1] * norm4[1] + norm4[2] * norm4[2]); + // find angles between faces + float ang1 = (norm1[0] * norm2[0] + norm1[1] * norm2[1] + norm1[2] * norm2[2]) / (norm1mag * norm2mag); + float ang2 = (norm1[0] * norm3[0] + norm1[1] * norm3[1] + norm1[2] * norm3[2]) / (norm1mag * norm3mag); + float ang3 = (norm1[0] * norm4[0] + norm1[1] * norm4[1] + norm1[2] * norm4[2]) / (norm1mag * norm4mag); + float ang4 = (norm2[0] * norm3[0] + norm2[1] * norm3[1] + norm2[2] * norm3[2]) / (norm2mag * norm3mag); + float ang5 = (norm2[0] * norm4[0] + norm2[1] * norm4[1] + norm2[2] * norm4[2]) / (norm2mag * norm4mag); + float ang6 = (norm3[0] * norm4[0] + norm3[1] * norm4[1] + norm3[2] * norm4[2]) / (norm3mag * norm4mag); + // find the maximum ang value, which will be the minimum angle after the acos + float minAng = ang1; + if(ang2 > minAng) + { + minAng = ang2; + } + if(ang3 > minAng) + { + minAng = ang3; + } + if(ang4 > minAng) + { + minAng = ang4; + } + if(ang5 > minAng) + { + minAng = ang5; + } + if(ang6 > minAng) + { + minAng = ang6; + } + + minAnglesPtr[i] = SIMPLib::Constants::k_180OverPiD * acosf(minAng); + } } }; @@ -1321,7 +1333,8 @@ class Generic * @param inVertexArray * @param outElemArray */ - template static void AverageVertexArrayValues(typename DataArray::Pointer elemList, typename DataArray::Pointer inVertexArray, DataArray::Pointer outElemArray) + template + static void AverageVertexArrayValues(typename DataArray::Pointer elemList, typename DataArray::Pointer inVertexArray, DataArray::Pointer outElemArray) { Q_ASSERT(outElemArray->getComponentDimensions() == inVertexArray->getComponentDimensions()); Q_ASSERT(elemList->getNumberOfTuples() == outElemArray->getNumberOfTuples()); @@ -1438,5 +1451,4 @@ class Generic } } }; -} - +} // namespace GeometryHelpers diff --git a/Source/SIMPLib/Geometry/HexahedralGeom.cpp b/Source/SIMPLib/Geometry/HexahedralGeom.cpp index b36d8766a5..7f331bc135 100644 --- a/Source/SIMPLib/Geometry/HexahedralGeom.cpp +++ b/Source/SIMPLib/Geometry/HexahedralGeom.cpp @@ -9,17 +9,12 @@ * HexahedralGeom::findDerivatives * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include "SIMPLib/Geometry/HexahedralGeom.h" - -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS -#include -#include -#include -#include -#endif +#include #include "SIMPLib/Geometry/DerivativeHelpers.h" #include "SIMPLib/Geometry/GeometryHelpers.h" +#include "SIMPLib/Geometry/HexahedralGeom.h" +#include "SIMPLib/Utilities/ParallelDataAlgorithm.h" /** * @brief The FindHexDerivativesImpl class implements a threaded algorithm that computes the @@ -28,7 +23,7 @@ class FindHexDerivativesImpl { public: - FindHexDerivativesImpl(HexahedralGeom* hexas, DoubleArrayType::Pointer field, DoubleArrayType::Pointer derivs) + FindHexDerivativesImpl(HexahedralGeom* hexas, const DoubleArrayType::Pointer& field, const DoubleArrayType::Pointer& derivs) : m_Hexas(hexas) , m_Field(field) , m_Derivatives(derivs) @@ -36,23 +31,23 @@ class FindHexDerivativesImpl } virtual ~FindHexDerivativesImpl() = default; - void compute(int64_t start, int64_t end) const + void compute(size_t start, size_t end) const { int32_t cDims = m_Field->getNumberOfComponents(); double* fieldPtr = m_Field->getPointer(0); double* derivsPtr = m_Derivatives->getPointer(0); double values[8] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; double derivs[3] = {0.0, 0.0, 0.0}; - int64_t verts[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + size_t verts[8] = {0, 0, 0, 0, 0, 0, 0, 0}; - int64_t counter = 0; - int64_t totalElements = m_Hexas->getNumberOfHexas(); - int64_t progIncrement = static_cast(totalElements / 100); + size_t counter = 0; + size_t totalElements = m_Hexas->getNumberOfHexas(); + size_t progIncrement = static_cast(totalElements / 100); - for(int64_t i = start; i < end; i++) + for(size_t i = start; i < end; i++) { m_Hexas->getVertsAtHex(i, verts); - for(int32_t j = 0; j < cDims; j++) + for(size_t j = 0; j < cDims; j++) { for(size_t k = 0; k < 8; k++) { @@ -73,12 +68,11 @@ class FindHexDerivativesImpl } } -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - void operator()(const tbb::blocked_range& r) const + void operator()(const SIMPLRange& range) const { - compute(r.begin(), r.end()); + compute(range.min(), range.max()); } -#endif + private: HexahedralGeom* m_Hexas; DoubleArrayType::Pointer m_Field; @@ -93,9 +87,6 @@ HexahedralGeom::HexahedralGeom() m_GeometryTypeName = SIMPL::Geometry::HexahedralGeometry; m_GeometryType = IGeometry::Type::Hexahedral; m_XdmfGridType = SIMPL::XdmfGridType::PolyData; - m_MessagePrefix = ""; - m_MessageTitle = ""; - m_MessageLabel = ""; m_UnitDimensionality = 3; m_SpatialDimensionality = 3; m_VertexList = HexahedralGeom::CreateSharedVertexList(0); @@ -119,7 +110,7 @@ HexahedralGeom::~HexahedralGeom() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -HexahedralGeom::Pointer HexahedralGeom::CreateGeometry(int64_t numHexas, SharedVertexList::Pointer vertices, const QString& name, bool allocate) +HexahedralGeom::Pointer HexahedralGeom::CreateGeometry(size_t numHexas, const SharedVertexList::Pointer& vertices, const QString& name, bool allocate) { if(name.isEmpty()) { @@ -137,7 +128,7 @@ HexahedralGeom::Pointer HexahedralGeom::CreateGeometry(int64_t numHexas, SharedV // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -HexahedralGeom::Pointer HexahedralGeom::CreateGeometry(SharedHexList::Pointer hexas, SharedVertexList::Pointer vertices, const QString& name) +HexahedralGeom::Pointer HexahedralGeom::CreateGeometry(const SharedHexList::Pointer& hexas, const SharedVertexList::Pointer& vertices, const QString& name) { if(name.isEmpty()) { @@ -171,24 +162,23 @@ void HexahedralGeom::initializeWithZeros() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void HexahedralGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) +void HexahedralGeom::addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) { - if(data->getType() != AttributeMatrix::Type::Vertex - || data->getType() != AttributeMatrix::Type::Edge - || data->getType() != AttributeMatrix::Type::Face || data->getType() != AttributeMatrix::Type::Cell) + if((data->getType() != AttributeMatrix::Type::Vertex && data->getType() != AttributeMatrix::Type::Edge && data->getType() != AttributeMatrix::Type::Face) || + data->getType() != AttributeMatrix::Type::Cell) { // HexahedralGeom can only accept vertex, edge, face or cell Attribute Matrices return; } - if(data->getType() == AttributeMatrix::Type::Vertex && static_cast(data->getNumberOfTuples()) != getNumberOfVertices()) + if(data->getType() == AttributeMatrix::Type::Vertex && static_cast(data->getNumberOfTuples()) != getNumberOfVertices()) { return; } - if(data->getType() == AttributeMatrix::Type::Edge && static_cast(data->getNumberOfTuples()) != getNumberOfEdges()) + if(data->getType() == AttributeMatrix::Type::Edge && static_cast(data->getNumberOfTuples()) != getNumberOfEdges()) { return; } - if(data->getType() == AttributeMatrix::Type::Face && static_cast(data->getNumberOfTuples()) != getNumberOfQuads()) + if(data->getType() == AttributeMatrix::Type::Face && static_cast(data->getNumberOfTuples()) != getNumberOfQuads()) { return; } @@ -196,17 +186,17 @@ void HexahedralGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Po { return; } - if(data->getName().compare(name) != 0) - { - data->setName(name); - } - m_AttributeMatrices[name] = data; + // if(data->getName().compare(name) != 0) + //{ + // data->setName(name); + //} + m_AttributeMatrices[data->getName()] = data; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -size_t HexahedralGeom::getNumberOfElements() +size_t HexahedralGeom::getNumberOfElements() const { return m_HexList->getNumberOfTuples(); } @@ -216,8 +206,8 @@ size_t HexahedralGeom::getNumberOfElements() // ----------------------------------------------------------------------------- int HexahedralGeom::findEdges() { - m_EdgeList = CreateSharedEdgeList(0); - GeometryHelpers::Connectivity::FindHexEdges(m_HexList, m_EdgeList); + m_EdgeList = CreateSharedEdgeList(0, false); + GeometryHelpers::Connectivity::FindHexEdges(m_HexList, m_EdgeList); if(m_EdgeList.get() == nullptr) { return -1; @@ -238,8 +228,8 @@ void HexahedralGeom::deleteEdges() // ----------------------------------------------------------------------------- int HexahedralGeom::findFaces() { - m_QuadList = CreateSharedQuadList(0); - GeometryHelpers::Connectivity::FindHexFaces(m_HexList, m_QuadList); + m_QuadList = CreateSharedQuadList(0, false); + GeometryHelpers::Connectivity::FindHexFaces(m_HexList, m_QuadList); if(m_QuadList.get() == nullptr) { return -1; @@ -261,7 +251,7 @@ void HexahedralGeom::deleteFaces() int HexahedralGeom::findElementsContainingVert() { m_HexasContainingVert = ElementDynamicList::New(); - GeometryHelpers::Connectivity::FindElementsContainingVert(m_HexList, m_HexasContainingVert, getNumberOfVertices()); + GeometryHelpers::Connectivity::FindElementsContainingVert(m_HexList, m_HexasContainingVert, getNumberOfVertices()); if(m_HexasContainingVert.get() == nullptr) { return -1; @@ -272,7 +262,7 @@ int HexahedralGeom::findElementsContainingVert() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ElementDynamicList::Pointer HexahedralGeom::getElementsContainingVert() +ElementDynamicList::Pointer HexahedralGeom::getElementsContainingVert() const { return m_HexasContainingVert; } @@ -308,7 +298,7 @@ int HexahedralGeom::findElementNeighbors() } } m_HexNeighbors = ElementDynamicList::New(); - err = GeometryHelpers::Connectivity::FindElementNeighbors(m_HexList, m_HexasContainingVert, m_HexNeighbors, IGeometry::Type::Hexahedral); + err = GeometryHelpers::Connectivity::FindElementNeighbors(m_HexList, m_HexasContainingVert, m_HexNeighbors, IGeometry::Type::Hexahedral); if(m_HexNeighbors.get() == nullptr) { return -1; @@ -319,7 +309,7 @@ int HexahedralGeom::findElementNeighbors() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ElementDynamicList::Pointer HexahedralGeom::getElementNeighbors() +ElementDynamicList::Pointer HexahedralGeom::getElementNeighbors() const { return m_HexNeighbors; } @@ -345,9 +335,9 @@ void HexahedralGeom::deleteElementNeighbors() // ----------------------------------------------------------------------------- int HexahedralGeom::findElementCentroids() { - QVector cDims(1, 3); - m_HexCentroids = FloatArrayType::CreateArray(getNumberOfHexas(), cDims, SIMPL::StringConstants::HexCentroids); - GeometryHelpers::Topology::FindElementCentroids(m_HexList, m_VertexList, m_HexCentroids); + std::vector cDims(1, 3); + m_HexCentroids = FloatArrayType::CreateArray(getNumberOfHexas(), cDims, SIMPL::StringConstants::HexCentroids, true); + GeometryHelpers::Topology::FindElementCentroids(m_HexList, m_VertexList, m_HexCentroids); if(m_HexCentroids.get() == nullptr) { return -1; @@ -358,7 +348,7 @@ int HexahedralGeom::findElementCentroids() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatArrayType::Pointer HexahedralGeom::getElementCentroids() +FloatArrayType::Pointer HexahedralGeom::getElementCentroids() const { return m_HexCentroids; } @@ -379,15 +369,15 @@ void HexahedralGeom::deleteElementCentroids() m_HexCentroids = FloatArrayType::NullPointer(); } - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int HexahedralGeom::findElementSizes() { - QVector cDims(1, 1); - m_HexSizes = FloatArrayType::CreateArray(getNumberOfHexas(), cDims, SIMPL::StringConstants::HexVolumes); - GeometryHelpers::Topology::FindHexVolumes(m_HexList, m_VertexList, m_HexSizes); + std::vector cDims(1, 1); + size_t numHexs = getNumberOfHexas(); + m_HexSizes = FloatArrayType::CreateArray(numHexs, cDims, SIMPL::StringConstants::HexVolumes, (numHexs != 0)); + GeometryHelpers::Topology::FindHexVolumes(m_HexList, m_VertexList, m_HexSizes); if(m_HexSizes.get() == nullptr) { return -1; @@ -398,7 +388,7 @@ int HexahedralGeom::findElementSizes() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatArrayType::Pointer HexahedralGeom::getElementSizes() +FloatArrayType::Pointer HexahedralGeom::getElementSizes() const { return m_HexSizes; } @@ -424,9 +414,9 @@ void HexahedralGeom::deleteElementSizes() // ----------------------------------------------------------------------------- int HexahedralGeom::findUnsharedEdges() { - QVector cDims(1, 2); - m_UnsharedEdgeList = SharedEdgeList::CreateArray(0, cDims, SIMPL::Geometry::UnsharedEdgeList); - GeometryHelpers::Connectivity::FindUnsharedHexEdges(m_HexList, m_UnsharedEdgeList); + std::vector cDims(1, 2); + m_UnsharedEdgeList = SharedEdgeList::CreateArray(0, cDims, SIMPL::Geometry::UnsharedEdgeList, false); + GeometryHelpers::Connectivity::FindUnsharedHexEdges(m_HexList, m_UnsharedEdgeList); if(m_UnsharedEdgeList.get() == nullptr) { return -1; @@ -437,7 +427,7 @@ int HexahedralGeom::findUnsharedEdges() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -SharedEdgeList::Pointer HexahedralGeom::getUnsharedEdges() +SharedEdgeList::Pointer HexahedralGeom::getUnsharedEdges() const { return m_UnsharedEdgeList; } @@ -463,9 +453,9 @@ void HexahedralGeom::deleteUnsharedEdges() // ----------------------------------------------------------------------------- int HexahedralGeom::findUnsharedFaces() { - QVector cDims(1, 4); - m_UnsharedQuadList = SharedQuadList::CreateArray(0, cDims, SIMPL::Geometry::UnsharedFaceList); - GeometryHelpers::Connectivity::FindUnsharedHexFaces(m_HexList, m_UnsharedQuadList); + std::vector cDims(1, 4); + m_UnsharedQuadList = SharedQuadList::CreateArray(0, cDims, SIMPL::Geometry::UnsharedFaceList, false); + GeometryHelpers::Connectivity::FindUnsharedHexFaces(m_HexList, m_UnsharedQuadList); if(m_UnsharedQuadList.get() == nullptr) { return -1; @@ -476,7 +466,7 @@ int HexahedralGeom::findUnsharedFaces() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -SharedQuadList::Pointer HexahedralGeom::getUnsharedFaces() +SharedQuadList::Pointer HexahedralGeom::getUnsharedFaces() const { return m_UnsharedQuadList; } @@ -500,7 +490,7 @@ void HexahedralGeom::deleteUnsharedFaces() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void HexahedralGeom::getParametricCenter(double pCoords[3]) +void HexahedralGeom::getParametricCenter(double pCoords[3]) const { pCoords[0] = 0.5; pCoords[1] = 0.5; @@ -510,7 +500,7 @@ void HexahedralGeom::getParametricCenter(double pCoords[3]) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void HexahedralGeom::getShapeFunctions(double pCoords[3], double* shape) +void HexahedralGeom::getShapeFunctions(double pCoords[3], double* shape) const { double rm = 0.0; double sm = 0.0; @@ -557,35 +547,22 @@ void HexahedralGeom::getShapeFunctions(double pCoords[3], double* shape) void HexahedralGeom::findDerivatives(DoubleArrayType::Pointer field, DoubleArrayType::Pointer derivatives, Observable* observable) { m_ProgressCounter = 0; - int64_t numHexas = getNumberOfHexas(); + size_t numHexas = getNumberOfHexas(); if(observable != nullptr) { - connect(this, SIGNAL(filterGeneratedMessage(const PipelineMessage&)), observable, SLOT(broadcastPipelineMessage(const PipelineMessage&))); + connect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), observable, SLOT(processDerivativesMessage(const AbstractMessage::Pointer&))); } -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - tbb::task_scheduler_init init; - bool doParallel = true; -#endif - -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - if(doParallel) - { - tbb::parallel_for(tbb::blocked_range(0, numHexas), FindHexDerivativesImpl(this, field, derivatives), tbb::auto_partitioner()); - } - else -#endif - { - FindHexDerivativesImpl serial(this, field, derivatives); - serial.compute(0, numHexas); - } + ParallelDataAlgorithm dataAlg; + dataAlg.setRange(0, numHexas); + dataAlg.execute(FindHexDerivativesImpl(this, field, derivatives)); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int HexahedralGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf)) +int HexahedralGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf)) const { herr_t err = 0; @@ -664,7 +641,7 @@ int HexahedralGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writ if(m_HexNeighbors.get() != nullptr) { size_t numHexas = getNumberOfHexas(); - err = GeometryHelpers::GeomIO::WriteDynamicListToHDF5(parentId, m_HexNeighbors, numHexas, SIMPL::StringConstants::HexNeighbors); + err = GeometryHelpers::GeomIO::WriteDynamicListToHDF5(parentId, m_HexNeighbors, numHexas, SIMPL::StringConstants::HexNeighbors); if(err < 0) { return err; @@ -674,7 +651,7 @@ int HexahedralGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writ if(m_HexasContainingVert.get() != nullptr) { size_t numVerts = getNumberOfVertices(); - err = GeometryHelpers::GeomIO::WriteDynamicListToHDF5(parentId, m_HexasContainingVert, numVerts, SIMPL::StringConstants::HexasContainingVert); + err = GeometryHelpers::GeomIO::WriteDynamicListToHDF5(parentId, m_HexasContainingVert, numVerts, SIMPL::StringConstants::HexasContainingVert); if(err < 0) { return err; @@ -687,7 +664,7 @@ int HexahedralGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writ // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int HexahedralGeom::writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) +int HexahedralGeom::writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) const { herr_t err = 0; @@ -740,23 +717,30 @@ int HexahedralGeom::writeXdmf(QTextStream& out, QString dcName, QString hdfFileN // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString HexahedralGeom::getInfoString(SIMPL::InfoStringFormat format) +QString HexahedralGeom::getInfoString(SIMPL::InfoStringFormat format) const { - QString info; - QTextStream ss(&info); - if(format == SIMPL::HtmlFormat) { - ss << "Geometry Info"; - ss << "Type" << TypeToString(getGeometryType()) << ""; - ss << R"(Units)" << LengthUnitToString(getUnits()) << ""; - ss << "Number of Hexahedra" << getNumberOfHexas() << ""; - ss << "Number of Vertices" << getNumberOfVertices() << ""; + return getToolTipGenerator().generateHTML(); } - else - { - } - return info; + + return QString(); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +ToolTipGenerator HexahedralGeom::getToolTipGenerator() const +{ + ToolTipGenerator toolTipGen; + + toolTipGen.addTitle("Geometry Info"); + toolTipGen.addValue("Type", TypeToString(getGeometryType())); + toolTipGen.addValue("Units", LengthUnitToString(getUnits())); + toolTipGen.addValue("Number of Hexahedra", QString::number(getNumberOfHexas())); + toolTipGen.addValue("Number of Vertices", QString::number(getNumberOfVertices())); + + return toolTipGen; } // ----------------------------------------------------------------------------- @@ -766,29 +750,35 @@ int HexahedralGeom::readGeometryFromHDF5(hid_t parentId, bool preflight) { herr_t err = 0; SharedVertexList::Pointer vertices = GeometryHelpers::GeomIO::ReadListFromHDF5(SIMPL::Geometry::SharedVertexList, parentId, preflight, err); - SharedHexList::Pointer hexas = GeometryHelpers::GeomIO::ReadListFromHDF5(SIMPL::Geometry::SharedHexList, parentId, preflight, err); + + MeshIndexArrayType::Pointer hexas = GeometryHelpers::GeomIO::ReadMeshIndexListFromHDF5(SIMPL::Geometry::SharedHexList, parentId, preflight, err); if(hexas.get() == nullptr || vertices.get() == nullptr) { return -1; } + size_t numHexas = hexas->getNumberOfTuples(); size_t numVerts = vertices->getNumberOfTuples(); - SharedQuadList::Pointer quads = GeometryHelpers::GeomIO::ReadListFromHDF5(SIMPL::Geometry::SharedQuadList, parentId, preflight, err); + + MeshIndexArrayType::Pointer quads = GeometryHelpers::GeomIO::ReadMeshIndexListFromHDF5(SIMPL::Geometry::SharedQuadList, parentId, preflight, err); if(err < 0 && err != -2) { return -1; } - SharedQuadList::Pointer bQuads = GeometryHelpers::GeomIO::ReadListFromHDF5(SIMPL::Geometry::UnsharedFaceList, parentId, preflight, err); + + MeshIndexArrayType::Pointer bQuads = GeometryHelpers::GeomIO::ReadMeshIndexListFromHDF5(SIMPL::Geometry::UnsharedFaceList, parentId, preflight, err); if(err < 0 && err != -2) { return -1; } - SharedEdgeList::Pointer edges = GeometryHelpers::GeomIO::ReadListFromHDF5(SIMPL::Geometry::SharedEdgeList, parentId, preflight, err); + + MeshIndexArrayType::Pointer edges = GeometryHelpers::GeomIO::ReadMeshIndexListFromHDF5(SIMPL::Geometry::SharedEdgeList, parentId, preflight, err); if(err < 0 && err != -2) { return -1; } - SharedEdgeList::Pointer bEdges = GeometryHelpers::GeomIO::ReadListFromHDF5(SIMPL::Geometry::UnsharedEdgeList, parentId, preflight, err); + + MeshIndexArrayType::Pointer bEdges = GeometryHelpers::GeomIO::ReadMeshIndexListFromHDF5(SIMPL::Geometry::UnsharedEdgeList, parentId, preflight, err); if(err < 0 && err != -2) { return -1; @@ -803,12 +793,13 @@ int HexahedralGeom::readGeometryFromHDF5(hid_t parentId, bool preflight) { return -1; } - ElementDynamicList::Pointer hexNeighbors = GeometryHelpers::GeomIO::ReadDynamicListFromHDF5(SIMPL::StringConstants::HexNeighbors, parentId, numHexas, preflight, err); + ElementDynamicList::Pointer hexNeighbors = GeometryHelpers::GeomIO::ReadDynamicListFromHDF5(SIMPL::StringConstants::HexNeighbors, parentId, numHexas, preflight, err); if(err < 0 && err != -2) { return -1; } - ElementDynamicList::Pointer hexasContainingVert = GeometryHelpers::GeomIO::ReadDynamicListFromHDF5(SIMPL::StringConstants::HexasContainingVert, parentId, numVerts, preflight, err); + ElementDynamicList::Pointer hexasContainingVert = + GeometryHelpers::GeomIO::ReadDynamicListFromHDF5(SIMPL::StringConstants::HexasContainingVert, parentId, numVerts, preflight, err); if(err < 0 && err != -2) { return -1; @@ -831,7 +822,7 @@ int HexahedralGeom::readGeometryFromHDF5(hid_t parentId, bool preflight) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IGeometry::Pointer HexahedralGeom::deepCopy(bool forceNoAllocate) +IGeometry::Pointer HexahedralGeom::deepCopy(bool forceNoAllocate) const { SharedHexList::Pointer hexas = std::dynamic_pointer_cast((getHexahedra().get() == nullptr) ? nullptr : getHexahedra()->deepCopy(forceNoAllocate)); SharedVertexList::Pointer verts = std::dynamic_pointer_cast((getVertices().get() == nullptr) ? nullptr : getVertices()->deepCopy(forceNoAllocate)); @@ -873,3 +864,28 @@ IGeometry::Pointer HexahedralGeom::deepCopy(bool forceNoAllocate) #include "SIMPLib/Geometry/SharedHexOps.cpp" #include "SIMPLib/Geometry/SharedQuadOps.cpp" #include "SIMPLib/Geometry/SharedVertexOps.cpp" + +// ----------------------------------------------------------------------------- +HexahedralGeom::Pointer HexahedralGeom::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +HexahedralGeom::Pointer HexahedralGeom::New() +{ + Pointer sharedPtr(new(HexahedralGeom)); + return sharedPtr; +} + +// ----------------------------------------------------------------------------- +QString HexahedralGeom::getNameOfClass() const +{ + return QString("HexahedralGeom"); +} + +// ----------------------------------------------------------------------------- +QString HexahedralGeom::ClassName() +{ + return QString("HexahedralGeom"); +} diff --git a/Source/SIMPLib/Geometry/HexahedralGeom.h b/Source/SIMPLib/Geometry/HexahedralGeom.h index 048f40bde5..8f837c4795 100644 --- a/Source/SIMPLib/Geometry/HexahedralGeom.h +++ b/Source/SIMPLib/Geometry/HexahedralGeom.h @@ -1,7 +1,12 @@ #ifndef _hexahedralgeom_h_ #define _hexahedralgeom_h_ -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include + +#include + +#include "SIMPLib/DataArrays/DataArray.hpp" +#include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/Geometry/IGeometry3D.h" /** @@ -9,551 +14,568 @@ */ class SIMPLib_EXPORT HexahedralGeom : public IGeometry3D { - public: - - SIMPL_SHARED_POINTERS(HexahedralGeom) - SIMPL_STATIC_NEW_MACRO(HexahedralGeom) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(HexahedralGeom, Observable) - - ~HexahedralGeom() override; - - /** - * @brief CreateGeometry - * @param numHexas - * @param vertices - * @param name - * @return - */ - static Pointer CreateGeometry(int64_t numHexas, SharedVertexList::Pointer vertices, const QString& name, bool allocate = true); - - /** - * @brief CreateGeometry - * @param hexas - * @param vertices - * @param name - * @return - */ - static Pointer CreateGeometry(SharedHexList::Pointer hexas, SharedVertexList::Pointer vertices, const QString& name); - -// ----------------------------------------------------------------------------- -// Inherited from SharedVertexOps -// ----------------------------------------------------------------------------- - - /** - * @brief CreateSharedVertexList - * @param numVertices - * @return - */ - static SharedVertexList::Pointer CreateSharedVertexList(int64_t numVertices, bool allocate = true); - -// ----------------------------------------------------------------------------- -// Inherited from SharedEdgeOps -// ----------------------------------------------------------------------------- - - /** - * @brief CreateSharedEdgeList - * @param numEdges - * @return - */ - static SharedEdgeList::Pointer CreateSharedEdgeList(int64_t numEdges, bool allocate = true); - -// ----------------------------------------------------------------------------- -// Inherited from SharedQuadOps -// ----------------------------------------------------------------------------- - - /** - * @brief CreateSharedQuadLost - * @param numQuads - * @return - */ - static SharedQuadList::Pointer CreateSharedQuadList(int64_t numQuads, bool allocate = true); - - /** - * @brief resizeQuadList - * @param newNumQuads - */ - void resizeQuadList(int64_t newNumQuads); - - /** - * @brief setQuads - * @param quads - */ - void setQuads(SharedQuadList::Pointer quads); - - /** - * @brief getQuads - * @return - */ - SharedQuadList::Pointer getQuads(); - - /** - * @brief setVertsAtQuad - * @param quadId - * @param verts - */ - void setVertsAtQuad(int64_t quadId, int64_t verts[4]); - - /** - * @brief getVertsAtQuad - * @param quadId - * @param verts - */ - void getVertsAtQuad(int64_t quadId, int64_t verts[4]); - - /** - * @brief getVertCoordsAtQuad - * @param quadId - * @param vert1 - * @param vert2 - * @param vert3 - * @param vert4 - */ - void getVertCoordsAtQuad(int64_t quadId, float vert1[3], float vert2[3], float vert3[3], float vert4[3]); - - /** - * @brief getPointer - * @param i - * @return - */ - int64_t* getQuadPointer(int64_t i); - - /** - * @brief getNumberOfQuads - * @return - */ - int64_t getNumberOfQuads(); - -// ----------------------------------------------------------------------------- -// Inherited from SharedHexOps -// ----------------------------------------------------------------------------- - - /** - * @brief CreateSharedHexList - * @param numTets - * @return - */ - static SharedHexList::Pointer CreateSharedHexList(int64_t numHexas, bool allocate = true); - - /** - * @brief resizeHexList - * @param newNumHexas - */ - void resizeHexList(int64_t newNumHexas); - - /** - * @brief setHexahedra - * @param tets - */ - void setHexahedra(SharedHexList::Pointer hexas); - - /** - * @brief getHexahedra - * @return - */ - SharedHexList::Pointer getHexahedra(); - - /** - * @brief setVertsAtHex - * @param hexId - * @param verts - */ - void setVertsAtHex(int64_t hexId, int64_t verts[7]); - - /** - * @brief getVertsAtHex - * @param hexId - * @param verts - */ - void getVertsAtHex(int64_t hexId, int64_t verts[7]); - - /** - * @brief getVertCoordsAtHex - * @param hexId - * @param vert1 - * @param vert2 - * @param vert3 - * @param vert4 - * @param vert5 - * @param vert6 - */ - void getVertCoordsAtHex(int64_t hexId, float vert1[3], float vert2[3], float vert3[3], float vert4[3], float vert5[3], float vert6[3], float vert7[3], float vert8[3]); - - /** - * @brief getHexPointer - * @param i - * @return - */ - int64_t* getHexPointer(int64_t i); - - /** - * @brief getNumberOfHexas - * @return - */ - int64_t getNumberOfHexas(); - -// ----------------------------------------------------------------------------- -// Inherited from IGeometry -// ----------------------------------------------------------------------------- - - /** - * @brief initializeWithZeros - */ - void initializeWithZeros() override; - - /** - * @brief getNumberOfElements - * @return - */ - size_t getNumberOfElements() override; - - /** - * @brief findElementSizes - * @return - */ - int findElementSizes() override; - - /** - * @brief getElementSizes - * @return - */ - FloatArrayType::Pointer getElementSizes() override; - - /** - * @brief deleteElementSizes - */ - void deleteElementSizes() override; - - /** - * @brief findElementsContainingVert - * @return - */ - int findElementsContainingVert() override; - - /** - * @brief getElementsContainingVert - * @return - */ - ElementDynamicList::Pointer getElementsContainingVert() override; - - /** - * @brief deleteElementsContainingVert - */ - void deleteElementsContainingVert() override; - - /** - * @brief findElementNeighbors - * @return - */ - int findElementNeighbors() override; - - /** - * @brief getElementNeighbors - * @return - */ - ElementDynamicList::Pointer getElementNeighbors() override; - - /** - * @brief deleteElementNeighbors - */ - void deleteElementNeighbors() override; - - /** - * @brief findElementCentroids - * @return - */ - int findElementCentroids() override; - - /** - * @brief getElementCentroids - * @return - */ - FloatArrayType::Pointer getElementCentroids() override; - - /** - * @brief deleteElementCentroids - */ - void deleteElementCentroids() override; - - /** - * @brief getParametricCenter - * @param pCoords - */ - void getParametricCenter(double pCoords[3]) override; - - /** - * @brief getShapeFunctions - * @param pCoords - * @param shape - */ - void getShapeFunctions(double pCoords[3], double* shape) override; - - /** - * @brief findDerivatives - * @param field - * @param derivatives - */ - void findDerivatives(DoubleArrayType::Pointer field, DoubleArrayType::Pointer derivatives, Observable* observable = nullptr) override; - - /** - * @brief getInfoString - * @return Returns a formatted string that contains general infomation about - * the instance of the object. - */ - QString getInfoString(SIMPL::InfoStringFormat format) override; - - /** - * @brief writeGeometryToHDF5 - * @param parentId - * @param writeXdmf - * @return - */ - int writeGeometryToHDF5(hid_t parentId, bool writeXdmf) override; - - /** - * @brief writeXdmf - * @param out - * @param dcName - * @param hdfFileName - * @return - */ - int writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) override; - - /** - * @brief readGeometryFromHDF5 - * @param parentId - * @param preflight - * @return - */ - int readGeometryFromHDF5(hid_t parentId, bool preflight) override; - - /** - * @brief deepCopy - * @return - */ - IGeometry::Pointer deepCopy(bool forceNoAllocate = false) override; - - /** - * @brief addAttributeMatrix - */ - void addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; - -// ----------------------------------------------------------------------------- -// Inherited from IGeometry3D -// ----------------------------------------------------------------------------- - - /** - * @brief resizeVertexList - * @param newNumVertices - */ - void resizeVertexList(int64_t newNumVertices) override; - - /** - * @brief setVertices - * @param vertices - */ - void setVertices(SharedVertexList::Pointer vertices) override; - - /** - * @brief getVertices - * @return - */ - SharedVertexList::Pointer getVertices() override; - - /** - * @brief setCoords - * @param vertId - * @param coords - */ - void setCoords(int64_t vertId, float coords[3]) override; - - /** - * @brief getCoords - * @param vertId - * @param coords - */ - void getCoords(int64_t vertId, float coords[3]) override; - - /** - * @brief getVertexPointer - * @param i - * @return - */ - float* getVertexPointer(int64_t i) override; - - /** - * @brief getNumberOfVertices - * @return - */ - int64_t getNumberOfVertices() override; - - /** - * @brief resizeEdgeList - * @param newNumEdges - */ - void resizeEdgeList(int64_t newNumEdges) override; - - /** - * @brief getEdges - * @return - */ - SharedEdgeList::Pointer getEdges() override; - - /** - * @brief setVerts - * @param edgeId - * @param verts - */ - void setVertsAtEdge(int64_t edgeId, int64_t verts[2]) override; - - /** - * @brief getVerts - * @param edgeId - * @param verts - */ - void getVertsAtEdge(int64_t edgeId, int64_t verts[2]) override; - - /** - * @brief getVertCoordsAtEdge - * @param edgeId - * @param vert1 - * @param vert2 - */ - void getVertCoordsAtEdge(int64_t edgeId, float vert1[3], float vert2[3]) override; - - /** - * @brief getEdgePointer - * @param i - * @return - */ - int64_t* getEdgePointer(int64_t i) override; - - /** - * @brief getNumberOfEdges - * @return - */ - int64_t getNumberOfEdges() override; - - /** - * @brief findElementEdges - * @return - */ - int findEdges() override; - - /** - * @brief deleteElementEdges - */ - void deleteEdges() override; - - /** - * @brief findFaces - * @return - */ - int findFaces() override; - - /** - * @brief deleteFaces - */ - void deleteFaces() override; - - /** - * @brief findUnsharedEdges - */ - int findUnsharedEdges() override; - - /** - * @brief getUnsharedEdges - * @return - */ - SharedEdgeList::Pointer getUnsharedEdges() override; - - /** - * @brief deleteUnsharedEdges - */ - void deleteUnsharedEdges() override; - - /** - * @brief findUnsharedFaces - */ - int findUnsharedFaces() override; - - /** - * @brief getUnsharedFaces - * @return - */ - SharedEdgeList::Pointer getUnsharedFaces() override; - - /** - * @brief deleteUnsharedFaces - */ - void deleteUnsharedFaces() override; - - protected: - - HexahedralGeom(); - - /** - * @brief setElementsContainingVert - * @param elementsContainingVert - */ - void setElementsContainingVert(ElementDynamicList::Pointer elementsContainingVert) override; - - /** - * @brief setElementNeighbors - * @param elementNeighbors - */ - void setElementNeighbors(ElementDynamicList::Pointer elementNeighbors) override; - - /** - * @brief setElementCentroids - * @param elementCentroids - */ - void setElementCentroids(FloatArrayType::Pointer elementCentroids) override; - - /** - * @brief setElementSizes - * @param elementSizes - */ - void setElementSizes(FloatArrayType::Pointer elementSizes) override; - - /** - * @brief setEdges - * @param edges - */ - void setEdges(SharedEdgeList::Pointer edges) override; - - /** - * @brief setUnsharedEdges - * @param bEdgeList - */ - void setUnsharedEdges(SharedEdgeList::Pointer bEdgeList) override; - - /** - * @brief setUnsharedFaces - * @param bFaceList - */ - void setUnsharedFaces(SharedFaceList::Pointer bFaceList) override; - - private: - SharedVertexList::Pointer m_VertexList; - SharedEdgeList::Pointer m_EdgeList; - SharedEdgeList::Pointer m_UnsharedEdgeList; - SharedQuadList::Pointer m_QuadList; - SharedQuadList::Pointer m_UnsharedQuadList; - SharedHexList::Pointer m_HexList; - ElementDynamicList::Pointer m_HexasContainingVert; - ElementDynamicList::Pointer m_HexNeighbors; - FloatArrayType::Pointer m_HexCentroids; - FloatArrayType::Pointer m_HexSizes; - - friend class FindHexDerivativesImpl; - - public: - HexahedralGeom(const HexahedralGeom&) = delete; // Copy Constructor Not Implemented - HexahedralGeom(HexahedralGeom&&) = delete; // Move Constructor Not Implemented - HexahedralGeom& operator=(const HexahedralGeom&) = delete; // Copy Assignment Not Implemented - HexahedralGeom& operator=(HexahedralGeom&&) = delete; // Move Assignment Not Implemented +public: + using Self = HexahedralGeom; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + static Pointer New(); + + /** + * @brief Returns the name of the class for HexahedralGeom + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for HexahedralGeom + */ + static QString ClassName(); + + ~HexahedralGeom() override; + + /** + * @brief CreateGeometry + * @param numHexas + * @param vertices + * @param name + * @return + */ + static Pointer CreateGeometry(size_t numHexas, const SharedVertexList::Pointer& vertices, const QString& name, bool allocate = true); + + /** + * @brief CreateGeometry + * @param hexas + * @param vertices + * @param name + * @return + */ + static Pointer CreateGeometry(const SharedHexList::Pointer& hexas, const SharedVertexList::Pointer& vertices, const QString& name); + + // ----------------------------------------------------------------------------- + // Inherited from SharedVertexOps + // ----------------------------------------------------------------------------- + + /** + * @brief CreateSharedVertexList + * @param numVertices + * @return + */ + static SharedVertexList::Pointer CreateSharedVertexList(size_t numVertices, bool allocate = true); + + // ----------------------------------------------------------------------------- + // Inherited from SharedEdgeOps + // ----------------------------------------------------------------------------- + + /** + * @brief CreateSharedEdgeList + * @param numEdges + * @return + */ + static SharedEdgeList::Pointer CreateSharedEdgeList(size_t numEdges, bool allocate = true); + + // ----------------------------------------------------------------------------- + // Inherited from SharedQuadOps + // ----------------------------------------------------------------------------- + + /** + * @brief CreateSharedQuadLost + * @param numQuads + * @return + */ + static SharedQuadList::Pointer CreateSharedQuadList(size_t numQuads, bool allocate = true); + + /** + * @brief resizeQuadList + * @param newNumQuads + */ + void resizeQuadList(size_t newNumQuads); + + /** + * @brief setQuads + * @param quads + */ + void setQuads(SharedQuadList::Pointer quads); + + /** + * @brief getQuads + * @return + */ + SharedQuadList::Pointer getQuads() const; + + /** + * @brief setVertsAtQuad + * @param quadId + * @param verts + */ + void setVertsAtQuad(size_t quadId, size_t verts[4]); + + /** + * @brief getVertsAtQuad + * @param quadId + * @param verts + */ + void getVertsAtQuad(size_t quadId, size_t verts[4]) const; + + /** + * @brief getVertCoordsAtQuad + * @param quadId + * @param vert1 + * @param vert2 + * @param vert3 + * @param vert4 + */ + void getVertCoordsAtQuad(size_t quadId, float vert1[3], float vert2[3], float vert3[3], float vert4[3]) const; + + /** + * @brief getPointer + * @param i + * @return + */ + size_t* getQuadPointer(size_t i) const; + + /** + * @brief getNumberOfQuads + * @return + */ + size_t getNumberOfQuads() const; + + // ----------------------------------------------------------------------------- + // Inherited from SharedHexOps + // ----------------------------------------------------------------------------- + + /** + * @brief CreateSharedHexList + * @param numTets + * @return + */ + static SharedHexList::Pointer CreateSharedHexList(size_t numHexas, bool allocate = true); + + /** + * @brief resizeHexList + * @param newNumHexas + */ + void resizeHexList(size_t newNumHexas); + + /** + * @brief setHexahedra + * @param tets + */ + void setHexahedra(SharedHexList::Pointer hexas); + + /** + * @brief getHexahedra + * @return + */ + SharedHexList::Pointer getHexahedra() const; + + /** + * @brief setVertsAtHex + * @param hexId + * @param verts + */ + void setVertsAtHex(size_t hexId, size_t verts[7]); + + /** + * @brief getVertsAtHex + * @param hexId + * @param verts + */ + void getVertsAtHex(size_t hexId, size_t verts[7]) const; + + /** + * @brief getVertCoordsAtHex + * @param hexId + * @param vert1 + * @param vert2 + * @param vert3 + * @param vert4 + * @param vert5 + * @param vert6 + */ + void getVertCoordsAtHex(size_t hexId, float vert1[3], float vert2[3], float vert3[3], float vert4[3], float vert5[3], float vert6[3], float vert7[3], float vert8[3]) const; + + /** + * @brief getHexPointer + * @param i + * @return + */ + size_t* getHexPointer(size_t i) const; + + /** + * @brief getNumberOfHexas + * @return + */ + size_t getNumberOfHexas() const; + + // ----------------------------------------------------------------------------- + // Inherited from IGeometry + // ----------------------------------------------------------------------------- + + /** + * @brief initializeWithZeros + */ + void initializeWithZeros() override; + + /** + * @brief getNumberOfElements + * @return + */ + size_t getNumberOfElements() const override; + + /** + * @brief findElementSizes + * @return + */ + int findElementSizes() override; + + /** + * @brief getElementSizes + * @return + */ + FloatArrayType::Pointer getElementSizes() const override; + + /** + * @brief deleteElementSizes + */ + void deleteElementSizes() override; + + /** + * @brief findElementsContainingVert + * @return + */ + int findElementsContainingVert() override; + + /** + * @brief getElementsContainingVert + * @return + */ + ElementDynamicList::Pointer getElementsContainingVert() const override; + + /** + * @brief deleteElementsContainingVert + */ + void deleteElementsContainingVert() override; + + /** + * @brief findElementNeighbors + * @return + */ + int findElementNeighbors() override; + + /** + * @brief getElementNeighbors + * @return + */ + ElementDynamicList::Pointer getElementNeighbors() const override; + + /** + * @brief deleteElementNeighbors + */ + void deleteElementNeighbors() override; + + /** + * @brief findElementCentroids + * @return + */ + int findElementCentroids() override; + + /** + * @brief getElementCentroids + * @return + */ + FloatArrayType::Pointer getElementCentroids() const override; + + /** + * @brief deleteElementCentroids + */ + void deleteElementCentroids() override; + + /** + * @brief getParametricCenter + * @param pCoords + */ + void getParametricCenter(double pCoords[3]) const override; + + /** + * @brief getShapeFunctions + * @param pCoords + * @param shape + */ + void getShapeFunctions(double pCoords[3], double* shape) const override; + + /** + * @brief findDerivatives + * @param field + * @param derivatives + */ + void findDerivatives(DoubleArrayType::Pointer field, DoubleArrayType::Pointer derivatives, Observable* observable = nullptr) override; + + /** + * @brief getInfoString + * @return Returns a formatted string that contains general infomation about + * the instance of the object. + */ + QString getInfoString(SIMPL::InfoStringFormat format) const override; + + /** + * @brief Returns a ToolTipGenerator for creating HTML tooltip tables + * with values populated to match the geometry. + * @return + */ + ToolTipGenerator getToolTipGenerator() const override; + + /** + * @brief writeGeometryToHDF5 + * @param parentId + * @param writeXdmf + * @return + */ + int writeGeometryToHDF5(hid_t parentId, bool writeXdmf) const override; + + /** + * @brief writeXdmf + * @param out + * @param dcName + * @param hdfFileName + * @return + */ + int writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) const override; + + /** + * @brief readGeometryFromHDF5 + * @param parentId + * @param preflight + * @return + */ + int readGeometryFromHDF5(hid_t parentId, bool preflight) override; + + /** + * @brief deepCopy + * @return + */ + IGeometry::Pointer deepCopy(bool forceNoAllocate = false) const override; + + /** + * @brief addOrReplaceAttributeMatrix + */ + void addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) override; + + // ----------------------------------------------------------------------------- + // Inherited from IGeometry3D + // ----------------------------------------------------------------------------- + + /** + * @brief resizeVertexList + * @param newNumVertices + */ + void resizeVertexList(size_t newNumVertices) override; + + /** + * @brief setVertices + * @param vertices + */ + void setVertices(SharedVertexList::Pointer vertices) override; + + /** + * @brief getVertices + * @return + */ + SharedVertexList::Pointer getVertices() const override; + + /** + * @brief setCoords + * @param vertId + * @param coords + */ + void setCoords(size_t vertId, float coords[3]) override; + + /** + * @brief getCoords + * @param vertId + * @param coords + */ + void getCoords(size_t vertId, float coords[3]) const override; + + /** + * @brief getVertexPointer + * @param i + * @return + */ + float* getVertexPointer(size_t i) const override; + + /** + * @brief getNumberOfVertices + * @return + */ + size_t getNumberOfVertices() const override; + + /** + * @brief resizeEdgeList + * @param newNumEdges + */ + void resizeEdgeList(size_t newNumEdges) override; + + /** + * @brief getEdges + * @return + */ + SharedEdgeList::Pointer getEdges() const override; + + /** + * @brief setVerts + * @param edgeId + * @param verts + */ + void setVertsAtEdge(size_t edgeId, size_t verts[2]) override; + + /** + * @brief getVerts + * @param edgeId + * @param verts + */ + void getVertsAtEdge(size_t edgeId, size_t verts[2]) const override; + + /** + * @brief getVertCoordsAtEdge + * @param edgeId + * @param vert1 + * @param vert2 + */ + void getVertCoordsAtEdge(size_t edgeId, float vert1[3], float vert2[3]) const override; + + /** + * @brief getEdgePointer + * @param i + * @return + */ + size_t* getEdgePointer(size_t i) const override; + + /** + * @brief getNumberOfEdges + * @return + */ + size_t getNumberOfEdges() const override; + + /** + * @brief findElementEdges + * @return + */ + int findEdges() override; + + /** + * @brief deleteElementEdges + */ + void deleteEdges() override; + + /** + * @brief findFaces + * @return + */ + int findFaces() override; + + /** + * @brief deleteFaces + */ + void deleteFaces() override; + + /** + * @brief findUnsharedEdges + */ + int findUnsharedEdges() override; + + /** + * @brief getUnsharedEdges + * @return + */ + SharedEdgeList::Pointer getUnsharedEdges() const override; + + /** + * @brief deleteUnsharedEdges + */ + void deleteUnsharedEdges() override; + + /** + * @brief findUnsharedFaces + */ + int findUnsharedFaces() override; + + /** + * @brief getUnsharedFaces + * @return + */ + SharedEdgeList::Pointer getUnsharedFaces() const override; + + /** + * @brief deleteUnsharedFaces + */ + void deleteUnsharedFaces() override; + +protected: + HexahedralGeom(); + + /** + * @brief setElementsContainingVert + * @param elementsContainingVert + */ + void setElementsContainingVert(ElementDynamicList::Pointer elementsContainingVert) override; + + /** + * @brief setElementNeighbors + * @param elementNeighbors + */ + void setElementNeighbors(ElementDynamicList::Pointer elementNeighbors) override; + + /** + * @brief setElementCentroids + * @param elementCentroids + */ + void setElementCentroids(FloatArrayType::Pointer elementCentroids) override; + + /** + * @brief setElementSizes + * @param elementSizes + */ + void setElementSizes(FloatArrayType::Pointer elementSizes) override; + + /** + * @brief setEdges + * @param edges + */ + void setEdges(SharedEdgeList::Pointer edges) override; + + /** + * @brief setUnsharedEdges + * @param bEdgeList + */ + void setUnsharedEdges(SharedEdgeList::Pointer bEdgeList) override; + + /** + * @brief setUnsharedFaces + * @param bFaceList + */ + void setUnsharedFaces(SharedFaceList::Pointer bFaceList) override; + +private: + SharedVertexList::Pointer m_VertexList; + SharedEdgeList::Pointer m_EdgeList; + SharedEdgeList::Pointer m_UnsharedEdgeList; + SharedQuadList::Pointer m_QuadList; + SharedQuadList::Pointer m_UnsharedQuadList; + SharedHexList::Pointer m_HexList; + ElementDynamicList::Pointer m_HexasContainingVert; + ElementDynamicList::Pointer m_HexNeighbors; + FloatArrayType::Pointer m_HexCentroids; + FloatArrayType::Pointer m_HexSizes; + + friend class FindHexDerivativesImpl; + +public: + HexahedralGeom(const HexahedralGeom&) = delete; // Copy Constructor Not Implemented + HexahedralGeom(HexahedralGeom&&) = delete; // Move Constructor Not Implemented + HexahedralGeom& operator=(const HexahedralGeom&) = delete; // Copy Assignment Not Implemented + HexahedralGeom& operator=(HexahedralGeom&&) = delete; // Move Assignment Not Implemented }; - #endif /* _hexahedralgeom_h_ */ - diff --git a/Source/SIMPLib/Geometry/IGeometry.cpp b/Source/SIMPLib/Geometry/IGeometry.cpp index ee93a1227e..66b53dd384 100644 --- a/Source/SIMPLib/Geometry/IGeometry.cpp +++ b/Source/SIMPLib/Geometry/IGeometry.cpp @@ -26,7 +26,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * The code contained herein was partially funded by the followig contracts: + * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 @@ -36,18 +36,14 @@ #include "SIMPLib/Geometry/IGeometry.h" #include "H5Support/H5ScopedSentinel.h" #include "H5Support/QH5Utilities.h" +#include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/Geometry/CompositeTransformContainer.h" #include "SIMPLib/Geometry/TransformContainer.h" // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IGeometry::IGeometry() -: m_TimeValue(0.0f) -, m_EnableTimeSeries(false) -, m_Units(LengthUnit::Unspecified) -{ -} +IGeometry::IGeometry() = default; // ----------------------------------------------------------------------------- // @@ -376,6 +372,45 @@ QString IGeometry::LengthUnitToString(IGeometry::LengthUnit t) return SIMPL::Geometry::k_Unknown; } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::vector IGeometry::GetAllLengthUnitStrings() +{ + std::vector lengthUnits; + + lengthUnits.push_back(SIMPL::Geometry::k_Yoctometer); // ("Yoctometer"); + lengthUnits.push_back(SIMPL::Geometry::k_Zeptometer); // ("Zeptometer"); + lengthUnits.push_back(SIMPL::Geometry::k_Attometer); // ("Attometer"); + lengthUnits.push_back(SIMPL::Geometry::k_Femtometer); // ("Femtometer"); + lengthUnits.push_back(SIMPL::Geometry::k_Picometer); // ("Picometer"); + lengthUnits.push_back(SIMPL::Geometry::k_Nanometer); // ("Nanometer"); + lengthUnits.push_back(SIMPL::Geometry::k_Micrometer); // ("Micrometer"); + lengthUnits.push_back(SIMPL::Geometry::k_Millimeter); // ("Millimeter"); + lengthUnits.push_back(SIMPL::Geometry::k_Centimeter); // ("Centimeter"); + lengthUnits.push_back(SIMPL::Geometry::k_Decimeter); // ("Decimeter"); + lengthUnits.push_back(SIMPL::Geometry::k_Meter); // ("Meter"); + lengthUnits.push_back(SIMPL::Geometry::k_Decameter); // ("Decameter"); + lengthUnits.push_back(SIMPL::Geometry::k_Hectometer); // ("Hectometer"); + lengthUnits.push_back(SIMPL::Geometry::k_Kilometer); // ("Kilometer"); + lengthUnits.push_back(SIMPL::Geometry::k_Megameter); // ("Megameter"); + lengthUnits.push_back(SIMPL::Geometry::k_Gigameter); // ("Gigameter"); + lengthUnits.push_back(SIMPL::Geometry::k_Terameter); // ("Terameter"); + lengthUnits.push_back(SIMPL::Geometry::k_Petameter); // ("Petameter"); + lengthUnits.push_back(SIMPL::Geometry::k_Exameter); // ("Exameter"); + lengthUnits.push_back(SIMPL::Geometry::k_Zettameter); // ("Zettameter"); + lengthUnits.push_back(SIMPL::Geometry::k_Yottameter); // ("Yottameter"); + lengthUnits.push_back(SIMPL::Geometry::k_Angstrom); // ("Angstrom"); + lengthUnits.push_back(SIMPL::Geometry::k_Mil); // ("Mil"); + lengthUnits.push_back(SIMPL::Geometry::k_Inch); // ("Inch"); + lengthUnits.push_back(SIMPL::Geometry::k_Foot); // ("Foot"); + lengthUnits.push_back(SIMPL::Geometry::k_Mile); // ("Mile"); + lengthUnits.push_back(SIMPL::Geometry::k_Fathom); // ("Fathom"); + lengthUnits.push_back(SIMPL::Geometry::k_Unspecified); // ("Unspecified"); + lengthUnits.push_back(SIMPL::Geometry::k_Unknown); // ("Unknown"); + return lengthUnits; +} + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -387,7 +422,7 @@ void IGeometry::setName(const QString& name) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString IGeometry::getName() +QString IGeometry::getName() const { return m_Name; } @@ -395,7 +430,7 @@ QString IGeometry::getName() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -IGeometry::Type IGeometry::getGeometryType() +IGeometry::Type IGeometry::getGeometryType() const { return m_GeometryType; } @@ -403,7 +438,7 @@ IGeometry::Type IGeometry::getGeometryType() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -QString IGeometry::getGeometryTypeAsString() +QString IGeometry::getGeometryTypeAsString() const { return m_GeometryTypeName; } @@ -422,9 +457,9 @@ void IGeometry::sendThreadSafeProgressMessage(int64_t counter, int64_t max) if(m_ProgressCounter > prog) { - int64_t progressInt = static_cast((static_cast(m_ProgressCounter) / max) * 100.0f); - QString ss = m_MessageTitle + QObject::tr(" || %1% Complete").arg(progressInt); - notifyStatusMessage(m_MessagePrefix, m_MessageLabel, ss); + int64_t progressInt = static_cast((static_cast(m_ProgressCounter) / max) * 100.0); + QString ss = QObject::tr("%1% Complete").arg(progressInt); + notifyStatusMessage(ss); prog += progIncrement; } @@ -434,55 +469,7 @@ void IGeometry::sendThreadSafeProgressMessage(int64_t counter, int64_t max) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void IGeometry::setMessagePrefix(const QString& name) -{ - m_MessagePrefix = name; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString IGeometry::getMessagePrefix() -{ - return m_MessagePrefix; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void IGeometry::setMessageTitle(const QString& title) -{ - m_MessageTitle = title; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString IGeometry::getMessageTitle() -{ - return m_MessageTitle; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void IGeometry::setMessageLabel(const QString& label) -{ - m_MessageLabel = label; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -QString IGeometry::getMessageLabel() -{ - return m_MessageLabel; -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -unsigned int IGeometry::getXdmfGridType() +unsigned int IGeometry::getXdmfGridType() const { return m_XdmfGridType; } @@ -490,7 +477,7 @@ unsigned int IGeometry::getXdmfGridType() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -unsigned int IGeometry::getUnitDimensionality() +unsigned int IGeometry::getUnitDimensionality() const { return m_UnitDimensionality; } @@ -506,7 +493,7 @@ void IGeometry::setSpatialDimensionality(unsigned int spatialDims) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -unsigned int IGeometry::getSpatialDimensionality() +unsigned int IGeometry::getSpatialDimensionality() const { return m_SpatialDimensionality; } @@ -514,10 +501,9 @@ unsigned int IGeometry::getSpatialDimensionality() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -AttributeMatrix::Pointer IGeometry::getAttributeMatrix(const QString& name) +AttributeMatrix::Pointer IGeometry::getAttributeMatrix(const QString& name) const { - AttributeMatrixMap_t::iterator it; - it = m_AttributeMatrices.find(name); + AttributeMatrixMap_t::const_iterator it = m_AttributeMatrices.find(name); if(it == m_AttributeMatrices.end()) { return AttributeMatrix::NullPointer(); @@ -530,8 +516,7 @@ AttributeMatrix::Pointer IGeometry::getAttributeMatrix(const QString& name) // ----------------------------------------------------------------------------- AttributeMatrix::Pointer IGeometry::removeAttributeMatrix(const QString& name) { - QMap::iterator it; - it = m_AttributeMatrices.find(name); + AttributeMatrixMap_t::iterator it = m_AttributeMatrices.find(name); if(it == m_AttributeMatrices.end()) { // DO NOT return a NullPointer for any reason other than "Attribute Matrix was not found" @@ -545,7 +530,7 @@ AttributeMatrix::Pointer IGeometry::removeAttributeMatrix(const QString& name) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int IGeometry::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf)) +int IGeometry::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf)) const { herr_t err = 0; if(m_TransformContainer) @@ -557,12 +542,15 @@ int IGeometry::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf return err; } +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- int IGeometry::readGeometryFromHDF5(hid_t parentId, bool preflight) { herr_t err = 0; std::string transformTypeName = SIMPL::Geometry::UnknownTransformContainer.toStdString(); - QString transformName = QString::number(0).toLatin1().data(); + QString transformName = SIMPL::Geometry::TransformContainerGroup.toLatin1().data(); err = H5Lite::readStringAttribute(parentId, transformName.toLatin1().data(), SIMPL::Geometry::TransformContainerTypeName.toLatin1().data(), transformTypeName); // No transform information found. if(err < 0) @@ -597,3 +585,69 @@ int IGeometry::readGeometryFromHDF5(hid_t parentId, bool preflight) return err; } + +// ----------------------------------------------------------------------------- +IGeometry::Pointer IGeometry::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString IGeometry::getNameOfClass() const +{ + return QString("IGeometry"); +} + +// ----------------------------------------------------------------------------- +QString IGeometry::ClassName() +{ + return QString("IGeometry"); +} + +// ----------------------------------------------------------------------------- +void IGeometry::setTimeValue(float value) +{ + m_TimeValue = value; +} + +// ----------------------------------------------------------------------------- +float IGeometry::getTimeValue() const +{ + return m_TimeValue; +} + +// ----------------------------------------------------------------------------- +void IGeometry::setEnableTimeSeries(bool value) +{ + m_EnableTimeSeries = value; +} + +// ----------------------------------------------------------------------------- +bool IGeometry::getEnableTimeSeries() const +{ + return m_EnableTimeSeries; +} + +// ----------------------------------------------------------------------------- +void IGeometry::setTransformContainer(const ITransformContainer::Pointer& value) +{ + m_TransformContainer = value; +} + +// ----------------------------------------------------------------------------- +ITransformContainer::Pointer IGeometry::getTransformContainer() const +{ + return m_TransformContainer; +} + +// ----------------------------------------------------------------------------- +void IGeometry::setUnits(const IGeometry::LengthUnit& value) +{ + m_Units = value; +} + +// ----------------------------------------------------------------------------- +IGeometry::LengthUnit IGeometry::getUnits() const +{ + return m_Units; +} diff --git a/Source/SIMPLib/Geometry/IGeometry.h b/Source/SIMPLib/Geometry/IGeometry.h index 233e5a8eb6..9cddac4704 100644 --- a/Source/SIMPLib/Geometry/IGeometry.h +++ b/Source/SIMPLib/Geometry/IGeometry.h @@ -1,65 +1,78 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include +#include +#include +#include + #include #include #include +#include +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/Observable.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/DataArrays/DataArray.hpp" #include "SIMPLib/DataArrays/DynamicListArray.hpp" -#include "SIMPLib/DataContainers/AttributeMatrix.h" #include "SIMPLib/Geometry/ITransformContainer.h" -#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Utilities/ToolTipGenerator.h" -class QTextStream; +class AttributeMatrix; +using AttributeMatrixShPtrType = std::shared_ptr; // ----------------------------------------------------------------------------- // Typedefs // ----------------------------------------------------------------------------- +using MeshIndexType = size_t; +using MeshIndexArrayType = DataArray; using SharedVertexList = FloatArrayType; -using SharedEdgeList = Int64ArrayType; -using SharedTriList = Int64ArrayType; -using SharedQuadList = Int64ArrayType; -using SharedTetList = Int64ArrayType; -using SharedHexList = Int64ArrayType; -using SharedFaceList = Int64ArrayType; -using ElementDynamicList = UInt16Int64DynamicListArray; +using SharedEdgeList = MeshIndexArrayType; +using SharedTriList = MeshIndexArrayType; +using SharedQuadList = MeshIndexArrayType; +using SharedTetList = MeshIndexArrayType; +using SharedHexList = MeshIndexArrayType; +using SharedFaceList = MeshIndexArrayType; +using ElementDynamicList = DynamicListArray; + +/** + * @brief Macro to silence compiler warnings for unused parameters in methods. + */ +#define SIMPL_NOT_USED(x) /** * @brief The IGeometry class @@ -67,446 +80,474 @@ using ElementDynamicList = UInt16Int64DynamicListArray; class SIMPLib_EXPORT IGeometry : public Observable { // This line MUST be first when exposing a class and properties to Python - PYB11_CREATE_BINDINGS(IGeometry) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(IGeometry) + PYB11_SHARED_POINTERS(IGeometry) PYB11_ENUMERATION(Type) PYB11_ENUMERATION(VtkCellType) - + PYB11_ENUMERATION(LengthUnit) PYB11_PROPERTY(QString Name READ getName WRITE setName) PYB11_METHOD(Type getGeometryType) PYB11_METHOD(QString getGeometryTypeAsString) PYB11_METHOD(QString getInfoString ARGS formatType) - PYB11_PROPERTY(QString MessagePrefix READ getMessagePrefix WRITE setMessagePrefix) - PYB11_PROPERTY(QString MessageTitle READ getMessageTitle WRITE setMessageTitle) - PYB11_PROPERTY(QString MessageLabel READ getMessageLabel WRITE setMessageLabel) PYB11_METHOD(uint32_t getXdmfGridType) PYB11_METHOD(uint32_t getUnitDimensionality) PYB11_PROPERTY(uint32_t SpatialDimensionality READ getSpatialDimensionality WRITE setSpatialDimensionality) PYB11_METHOD(Pointer deepCopy ARGS forceNoAllocate) PYB11_METHOD(void initializeWithZeros) - PYB11_METHOD(void addAttributeMatrix ARGS Name AttributeMatrix) + PYB11_METHOD(void addOrReplaceAttributeMatrix ARGS Name AttributeMatrix) PYB11_METHOD(AttributeMatrix getAttributeMatrix ARGS Name) PYB11_METHOD(AttributeMatrix removeAttributeMatrix ARGS Name) - - public: - SIMPL_SHARED_POINTERS(IGeometry) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(IGeometry, Observable) - - IGeometry(); - ~IGeometry() override; - - using EnumType = unsigned int; - - /** - * @brief The VtkCellType enum - */ - enum class VtkCellType : EnumType - { - Image = 11, - RectGrid = 11, - Vertex = 1, - Edge = 3, - Triangle = 5, - Quad = 9, - Tetrahedral = 10, - Hexahedral = 12, - Unknown = 999, - Any = 4294967295U - }; - - /** - * @ brief The Type enum - */ - enum class Type : EnumType - { - Image, - RectGrid, - Vertex, - Edge, - Triangle, - Quad, - Tetrahedral, - Hexahedral, - Unknown = 999, - Any = 4294967295U - }; - - enum class LengthUnit : EnumType - { - Yoctometer, - Zeptometer, - Attometer, - Femtometer, - Picometer, - Nanometer, - Micrometer, - Millimeter, - Centimeter, - Decimeter, - Meter, - Decameter, - Hectometer, - Kilometer, - Megameter, - Gigameter, - Terameter, - Petameter, - Exameter, - Zettameter, - Yottameter, - Angstrom, - Mil, - Inch, - Foot, - Mile, - Fathom, - Unspecified = 100U, - Unknown = 101U - }; - - using VtkCellTypes = QVector ; - using Types = QVector; - - /** - * @brief AttributeMatrixMap_t - */ - using AttributeMatrixMap_t = QMap; - - /** - * @brief stringToType - * @param str - * @return - */ - static IGeometry::Type StringToType(const QString& str); - - /** - * @brief typeToString - * @param t - * @return - */ - static QString TypeToString(IGeometry::Type t); - - /** - * @brief stringToLengthUnit - * @param str - * @return - */ - static IGeometry::LengthUnit StringToLengthUnit(const QString& str); - - /** - * @brief lengthUnitToString - * @param t - * @return - */ - static QString LengthUnitToString(IGeometry::LengthUnit t); - - SIMPL_INSTANCE_PROPERTY(float, TimeValue) - SIMPL_INSTANCE_PROPERTY(bool, EnableTimeSeries) - SIMPL_INSTANCE_PROPERTY(ITransformContainer::Pointer, TransformContainer) - SIMPL_INSTANCE_PROPERTY(LengthUnit, Units) - - // ----------------------------------------------------------------------------- - // Connectivity - // ----------------------------------------------------------------------------- - - /** - * @brief findElementsContainingVert - * @return - */ - virtual int findElementsContainingVert() = 0; - - /** - * @brief getElementsContainingVert - * @return - */ - virtual ElementDynamicList::Pointer getElementsContainingVert() = 0; - - /** - * @brief deleteElementsContainingVert - */ - virtual void deleteElementsContainingVert() = 0; - - /** - * @brief findElementNeighbors - * @return - */ - virtual int findElementNeighbors() = 0; - - /** - * @brief getElementNeighbors - * @return - */ - virtual ElementDynamicList::Pointer getElementNeighbors() = 0; - - /** - * @brief deleteElementNeighbors - */ - virtual void deleteElementNeighbors() = 0; - -// ----------------------------------------------------------------------------- -// Topology -// ----------------------------------------------------------------------------- - - /** - * @brief getNumberOfElements - * @return - */ - virtual size_t getNumberOfElements() = 0; - - /** - * @brief findElementSizes - * @return - */ - virtual int findElementSizes() = 0; - - /** - * @brief getElementSizes - * @return - */ - virtual FloatArrayType::Pointer getElementSizes() = 0; - - /** - * @brief deleteElementSizes - */ - virtual void deleteElementSizes() = 0; - - /** - * @brief findElementCentroids - * @return - */ - virtual int findElementCentroids() = 0; - - /** - * @brief getElementCentroids - * @return - */ - virtual FloatArrayType::Pointer getElementCentroids() = 0; - - /** - * @brief deleteElementCentroids - */ - virtual void deleteElementCentroids() = 0; - - /** - * @brief getParametricCenter - * @param pCoords - */ - virtual void getParametricCenter(double pCoords[3]) = 0; - - /** - * @brief getShapeFunctions - * @param pCoords - * @param derivs - */ - virtual void getShapeFunctions(double pCoords[3], double* shape) = 0; - - /** - * @brief findDerivatives - * @param field - * @param derivatives - */ - virtual void findDerivatives(DoubleArrayType::Pointer field, DoubleArrayType::Pointer derivatives, Observable* observable) = 0; - -// ----------------------------------------------------------------------------- -// Generic -// ----------------------------------------------------------------------------- - - /** - * @brief setName - * @param name - */ - virtual void setName(const QString& name) final; - - /** - * @brief getName - * @return - */ - virtual QString getName() final; - - /** - * @brief getGeometryType - * @return - */ - virtual Type getGeometryType() final; - - /** - * @brief getGeometryTypeAsString - * @return - */ - virtual QString getGeometryTypeAsString() final; - - /** - * @brief getInfoString - * @return Returns a formatted string that contains general infomation about - * the instance of the object. - */ - virtual QString getInfoString(SIMPL::InfoStringFormat) = 0; - - /** - * @brief setMessagePrefix - * @param prefix - */ - virtual void setMessagePrefix(const QString& prefix) final; - - /** - * @brief getMessagePrefix - * @return - */ - virtual QString getMessagePrefix() final; - - /** - * @brief setMessageTitle - * @param title - */ - virtual void setMessageTitle(const QString& title) final; - - /** - * @brief getMessageTitle - * @return - */ - virtual QString getMessageTitle() final; - - /** - * @brief setMessageLabel - * @param label - */ - virtual void setMessageLabel(const QString& label) final; - - /** - * @brief getMessageLabel - * @return - */ - virtual QString getMessageLabel() final; - - /** - * @brief getXdmfGridType - * @return - */ - virtual unsigned int getXdmfGridType() final; - - /** - * @brief getUnitDimensionality - * @return - */ - virtual unsigned int getUnitDimensionality() final; - - /** - * @brief setSpatialDimensionality - * @param spatialDims - */ - virtual void setSpatialDimensionality(unsigned int spatialDims) final; - - /** - * @brief getSpatialDimensionality - * @return - */ - virtual unsigned int getSpatialDimensionality() final; - - /** - * @brief writeGeometryToHDF5 - * @param parentId - * @param writeXdmf - * @return - */ - virtual int writeGeometryToHDF5(hid_t parentId, bool writeXdmf) = 0; - - /** - * @brief writeXdmf - * @param out - * @param dcName - * @param hdfFileName - * @return - */ - virtual int writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) = 0; - - /** - * @brief readGeometryFromHDF5 - * @param parentId - * @param preflight - * @return - */ - virtual int readGeometryFromHDF5(hid_t parentId, bool preflight) = 0; - - /** - * @brief deepCopy - * @return - */ - virtual Pointer deepCopy(bool forceNoAllocate = false) = 0; - - /** - * @brief initializeWithZeros - */ - virtual void initializeWithZeros() = 0; - - /** - * @brief addAttributeMatrix - */ - virtual void addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) = 0; - - /** - * @brief getAttributeMatrix - * @param name - * @return - */ - virtual AttributeMatrix::Pointer getAttributeMatrix(const QString& name) final; - - /** - * @brief removeAttributeMatrix - * @param name - * @return - */ - virtual AttributeMatrix::Pointer removeAttributeMatrix(const QString& name) final; - - protected: - QString m_Name; - QString m_GeometryTypeName; - QString m_MessagePrefix; - QString m_MessageTitle; - QString m_MessageLabel; - Type m_GeometryType = Type::Unknown; - unsigned int m_XdmfGridType = SIMPL::XdmfGridType::UnknownGrid; - unsigned int m_UnitDimensionality = 0; - unsigned int m_SpatialDimensionality = 0; - - AttributeMatrixMap_t m_AttributeMatrices; - - QMutex m_Mutex; - int64_t m_ProgressCounter; - - /** - * @brief sendThreadSafeProgressMessage - * @param counter - * @param max - */ - virtual void sendThreadSafeProgressMessage(int64_t counter, int64_t max) final; - - /** - * @brief setElementsContaingVert - * @param elementsContaingVert - */ - virtual void setElementsContainingVert(ElementDynamicList::Pointer elementsContainingVert) = 0; - - /** - * @brief setElementNeighbors - * @param elementNeighbors - */ - virtual void setElementNeighbors(ElementDynamicList::Pointer elementsNeighbors) = 0; - - /** - * @brief setElementCentroids - * @param elementCentroids - */ - virtual void setElementCentroids(FloatArrayType::Pointer elementCentroids) = 0; - - /** - * @brief setElementSizes - * @param elementSizes - */ - virtual void setElementSizes(FloatArrayType::Pointer elementSizes) = 0; - - public: - IGeometry(const IGeometry&) = delete; // Copy Constructor Not Implemented - IGeometry(IGeometry&&) = delete; // Move Constructor Not Implemented - IGeometry& operator=(const IGeometry&) = delete; // Copy Assignment Not Implemented - IGeometry& operator=(IGeometry&&) = delete; // Move Assignment Not Implemented + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = IGeometry; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for IGeometry + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for IGeometry + */ + static QString ClassName(); + + IGeometry(); + ~IGeometry() override; + + using EnumType = uint32_t; + + /** + * @brief The VtkCellType enum + */ + enum class VtkCellType : EnumType + { + Image = 11, + RectGrid = 11, + Vertex = 1, + Edge = 3, + Triangle = 5, + Quad = 9, + Tetrahedral = 10, + Hexahedral = 12, + Unknown = 999, + Any = 4294967295U + }; + + /** + * @ brief The Type enum + */ + enum class Type : EnumType + { + Image, + RectGrid, + Vertex, + Edge, + Triangle, + Quad, + Tetrahedral, + Hexahedral, + Unknown = 999, + Any = 4294967295U + }; + + enum class LengthUnit : EnumType + { + Yoctometer, + Zeptometer, + Attometer, + Femtometer, + Picometer, + Nanometer, + Micrometer, + Millimeter, + Centimeter, + Decimeter, + Meter, + Decameter, + Hectometer, + Kilometer, + Megameter, + Gigameter, + Terameter, + Petameter, + Exameter, + Zettameter, + Yottameter, + Angstrom, + Mil, + Inch, + Foot, + Mile, + Fathom, + Unspecified = 100U, + Unknown = 101U + }; + + using VtkCellTypes = std::vector; + using Types = std::vector; + + /** + * @brief AttributeMatrixMap_t + */ + using AttributeMatrixMap_t = QMap; + + /** + * @brief stringToType + * @param str + * @return + */ + static IGeometry::Type StringToType(const QString& str); + + /** + * @brief typeToString + * @param t + * @return + */ + static QString TypeToString(IGeometry::Type t); + + /** + * @brief stringToLengthUnit + * @param str + * @return + */ + static IGeometry::LengthUnit StringToLengthUnit(const QString& str); + + /** + * @brief lengthUnitToString + * @param t + * @return + */ + static QString LengthUnitToString(IGeometry::LengthUnit t); + + /** + * @brief GetAllLengthUnitStrings Returns all the Length Units as a vector of strings. This would be suitable to display as a list to a user. + * @return + */ + static std::vector GetAllLengthUnitStrings(); + + /** + * @brief Setter property for TimeValue + */ + void setTimeValue(float value); + /** + * @brief Getter property for TimeValue + * @return Value of TimeValue + */ + float getTimeValue() const; + + /** + * @brief Setter property for EnableTimeSeries + */ + void setEnableTimeSeries(bool value); + /** + * @brief Getter property for EnableTimeSeries + * @return Value of EnableTimeSeries + */ + bool getEnableTimeSeries() const; + + /** + * @brief Setter property for TransformContainer + */ + void setTransformContainer(const ITransformContainer::Pointer& value); + /** + * @brief Getter property for TransformContainer + * @return Value of TransformContainer + */ + ITransformContainer::Pointer getTransformContainer() const; + + /** + * @brief Setter property for Units + */ + void setUnits(const IGeometry::LengthUnit& value); + /** + * @brief Getter property for Units + * @return Value of Units + */ + IGeometry::LengthUnit getUnits() const; + + // ----------------------------------------------------------------------------- + // Connectivity + // ----------------------------------------------------------------------------- + + /** + * @brief findElementsContainingVert + * @return + */ + virtual int findElementsContainingVert() = 0; + + /** + * @brief getElementsContainingVert + * @return + */ + virtual ElementDynamicList::Pointer getElementsContainingVert() const = 0; + + /** + * @brief deleteElementsContainingVert + */ + virtual void deleteElementsContainingVert() = 0; + + /** + * @brief findElementNeighbors + * @return + */ + virtual int findElementNeighbors() = 0; + + /** + * @brief getElementNeighbors + * @return + */ + virtual ElementDynamicList::Pointer getElementNeighbors() const = 0; + + /** + * @brief deleteElementNeighbors + */ + virtual void deleteElementNeighbors() = 0; + + // ----------------------------------------------------------------------------- + // Topology + // ----------------------------------------------------------------------------- + + /** + * @brief getNumberOfElements + * @return + */ + virtual size_t getNumberOfElements() const = 0; + + /** + * @brief findElementSizes + * @return + */ + virtual int findElementSizes() = 0; + + /** + * @brief getElementSizes + * @return + */ + virtual FloatArrayType::Pointer getElementSizes() const = 0; + + /** + * @brief deleteElementSizes + */ + virtual void deleteElementSizes() = 0; + + /** + * @brief findElementCentroids + * @return + */ + virtual int findElementCentroids() = 0; + + /** + * @brief getElementCentroids + * @return + */ + virtual FloatArrayType::Pointer getElementCentroids() const = 0; + + /** + * @brief deleteElementCentroids + */ + virtual void deleteElementCentroids() = 0; + + /** + * @brief getParametricCenter + * @param pCoords + */ + virtual void getParametricCenter(double pCoords[3]) const = 0; + + /** + * @brief getShapeFunctions + * @param pCoords + * @param derivs + */ + virtual void getShapeFunctions(double pCoords[3], double* shape) const = 0; + + /** + * @brief findDerivatives + * @param field + * @param derivatives + */ + virtual void findDerivatives(DoubleArrayType::Pointer field, DoubleArrayType::Pointer derivatives, Observable* observable) = 0; + + // ----------------------------------------------------------------------------- + // Generic + // ----------------------------------------------------------------------------- + + /** + * @brief setName + * @param name + */ + virtual void setName(const QString& name) final; + + /** + * @brief getName + * @return + */ + virtual QString getName() const final; + + /** + * @brief getGeometryType + * @return + */ + virtual Type getGeometryType() const final; + + /** + * @brief getGeometryTypeAsString + * @return + */ + virtual QString getGeometryTypeAsString() const final; + + /** + * @brief getInfoString + * @return Returns a formatted string that contains general infomation about + * the instance of the object. + */ + virtual QString getInfoString(SIMPL::InfoStringFormat) const = 0; + + /** + * @brief Returns a ToolTipGenerator for creating HTML tooltip tables + * with values populated to match the geometry. + * @return + */ + virtual ToolTipGenerator getToolTipGenerator() const = 0; + + /** + * @brief getXdmfGridType + * @return + */ + virtual unsigned int getXdmfGridType() const final; + + /** + * @brief getUnitDimensionality + * @return + */ + virtual unsigned int getUnitDimensionality() const final; + + /** + * @brief setSpatialDimensionality + * @param spatialDims + */ + virtual void setSpatialDimensionality(unsigned int spatialDims) final; + + /** + * @brief getSpatialDimensionality + * @return + */ + virtual unsigned int getSpatialDimensionality() const final; + + /** + * @brief writeGeometryToHDF5 + * @param parentId + * @param writeXdmf + * @return + */ + virtual int writeGeometryToHDF5(hid_t parentId, bool writeXdmf) const = 0; + + /** + * @brief writeXdmf + * @param out + * @param dcName + * @param hdfFileName + * @return + */ + virtual int writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) const = 0; + + /** + * @brief readGeometryFromHDF5 + * @param parentId + * @param preflight + * @return + */ + virtual int readGeometryFromHDF5(hid_t parentId, bool preflight) = 0; + + /** + * @brief deepCopy + * @return + */ + virtual Pointer deepCopy(bool forceNoAllocate = false) const = 0; + + /** + * @brief initializeWithZeros + */ + virtual void initializeWithZeros() = 0; + + /** + * @brief addOrReplaceAttributeMatrix + */ + virtual void addOrReplaceAttributeMatrix(const QString& name, AttributeMatrixShPtrType data) = 0; + + /** + * @brief getAttributeMatrix + * @param name + * @return + */ + virtual AttributeMatrixShPtrType getAttributeMatrix(const QString& name) const final; + + /** + * @brief removeAttributeMatrix + * @param name + * @return + */ + virtual AttributeMatrixShPtrType removeAttributeMatrix(const QString& name) final; + +protected: + /** + * @brief sendThreadSafeProgressMessage + * @param counter + * @param max + */ + virtual void sendThreadSafeProgressMessage(int64_t counter, int64_t max) final; + + /** + * @brief setElementsContaingVert + * @param elementsContaingVert + */ + virtual void setElementsContainingVert(ElementDynamicList::Pointer elementsContainingVert) = 0; + + /** + * @brief setElementNeighbors + * @param elementNeighbors + */ + virtual void setElementNeighbors(ElementDynamicList::Pointer elementsNeighbors) = 0; + + /** + * @brief setElementCentroids + * @param elementCentroids + */ + virtual void setElementCentroids(FloatArrayType::Pointer elementCentroids) = 0; + + /** + * @brief setElementSizes + * @param elementSizes + */ + virtual void setElementSizes(FloatArrayType::Pointer elementSizes) = 0; + +public: + IGeometry(const IGeometry&) = delete; // Copy Constructor Not Implemented + IGeometry(IGeometry&&) = delete; // Move Constructor Not Implemented + IGeometry& operator=(const IGeometry&) = delete; // Copy Assignment Not Implemented + IGeometry& operator=(IGeometry&&) = delete; // Move Assignment Not Implemented + +protected: + QString m_GeometryTypeName; + Type m_GeometryType = Type::Unknown; + unsigned int m_XdmfGridType = SIMPL::XdmfGridType::UnknownGrid; + unsigned int m_UnitDimensionality = 0; + unsigned int m_SpatialDimensionality = 0; + int64_t m_ProgressCounter = 0; + AttributeMatrixMap_t m_AttributeMatrices; + +private: + float m_TimeValue = 0.0f; + bool m_EnableTimeSeries = false; + ITransformContainer::Pointer m_TransformContainer = {}; + IGeometry::LengthUnit m_Units = LengthUnit::Unspecified; + QString m_Name; + QMutex m_Mutex; }; diff --git a/Source/SIMPLib/Geometry/IGeometry2D.cpp b/Source/SIMPLib/Geometry/IGeometry2D.cpp index 3fcb8bf827..aafb9afffd 100644 --- a/Source/SIMPLib/Geometry/IGeometry2D.cpp +++ b/Source/SIMPLib/Geometry/IGeometry2D.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "SIMPLib/Geometry/IGeometry2D.h" @@ -44,3 +44,21 @@ IGeometry2D::IGeometry2D() = default; // // ----------------------------------------------------------------------------- IGeometry2D::~IGeometry2D() = default; + +// ----------------------------------------------------------------------------- +IGeometry2D::Pointer IGeometry2D::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString IGeometry2D::getNameOfClass() const +{ + return QString("IGeometry2D"); +} + +// ----------------------------------------------------------------------------- +QString IGeometry2D::ClassName() +{ + return QString("IGeometry2D"); +} diff --git a/Source/SIMPLib/Geometry/IGeometry2D.h b/Source/SIMPLib/Geometry/IGeometry2D.h old mode 100755 new mode 100644 index 0516b810e7..da96a43e76 --- a/Source/SIMPLib/Geometry/IGeometry2D.h +++ b/Source/SIMPLib/Geometry/IGeometry2D.h @@ -1,42 +1,43 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" #include "SIMPLib/Geometry/IGeometry.h" /** @@ -44,170 +45,183 @@ */ class SIMPLib_EXPORT IGeometry2D : public IGeometry { - PYB11_CREATE_BINDINGS(IGeometry2D SUPERCLASS IGeometry) - - public: - SIMPL_SHARED_POINTERS(IGeometry2D) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(IGeometry2D, Observable) - - IGeometry2D(); - ~IGeometry2D() override; - -// ----------------------------------------------------------------------------- -// Inherited from SharedVertexOps -// ----------------------------------------------------------------------------- - - /** - * @brief resizeVertexList - * @param newNumVertices - */ - virtual void resizeVertexList(int64_t newNumVertices) = 0; - - /** - * @brief setVertices - * @param vertices - */ - virtual void setVertices(SharedVertexList::Pointer vertices) = 0; - - /** - * @brief getVertices - * @return - */ - virtual SharedVertexList::Pointer getVertices() = 0; - - /** - * @brief setCoords - * @param vertId - * @param coords - */ - virtual void setCoords(int64_t vertId, float coords[3]) = 0; - - /** - * @brief getCoords - * @param vertId - * @param coords - */ - virtual void getCoords(int64_t vertId, float coords[3]) = 0; - - /** - * @brief getVertexPointer - * @param i - * @return - */ - virtual float* getVertexPointer(int64_t i) = 0; - - /** - * @brief getNumberOfVertices - * @return - */ - virtual int64_t getNumberOfVertices() = 0; - -// ----------------------------------------------------------------------------- -// Inherited from SharedEdgeOps -// ----------------------------------------------------------------------------- - - /** - * @brief resizeEdgeList - * @param newNumEdges - */ - virtual void resizeEdgeList(int64_t newNumEdges) = 0; - - /** - * @brief getEdges - * @return - */ - virtual SharedEdgeList::Pointer getEdges() = 0; - - /** - * @brief setVerts - * @param edgeId - * @param verts - */ - virtual void setVertsAtEdge(int64_t edgeId, int64_t verts[2]) = 0; - - /** - * @brief getVerts - * @param edgeId - * @param verts - */ - virtual void getVertsAtEdge(int64_t edgeId, int64_t verts[2]) = 0; - - /** - * @brief getVertCoordsAtEdge - * @param edgeId - * @param vert1 - * @param vert2 - */ - virtual void getVertCoordsAtEdge(int64_t edgeId, float vert1[3], float vert2[3]) = 0; - - /** - * @brief getEdgePointer - * @param i - * @return - */ - virtual int64_t* getEdgePointer(int64_t i) = 0; - - /** - * @brief getNumberOfEdges - * @return - */ - virtual int64_t getNumberOfEdges() = 0; - - -// ----------------------------------------------------------------------------- -// Connectivity -// ----------------------------------------------------------------------------- - - /** - * @brief findElementEdges - * @return - */ - virtual int findEdges() = 0; - - /** - * @brief deleteElementEdges - */ - virtual void deleteEdges() = 0; - -// ----------------------------------------------------------------------------- -// Topology -// ----------------------------------------------------------------------------- - - /** - * @brief findUnsharedEdges - */ - virtual int findUnsharedEdges() = 0; - - /** - * @brief getUnsharedEdges - * @return - */ - virtual SharedEdgeList::Pointer getUnsharedEdges() = 0; - - /** - * @brief deleteUnsharedEdges - */ - virtual void deleteUnsharedEdges() = 0; - - protected: - - /** - * @brief setEdges - * @param edges - */ - virtual void setEdges(SharedEdgeList::Pointer edges) = 0; - - /** - * @brief setUnsharedEdges - * @param bEdgeList - */ - virtual void setUnsharedEdges(SharedEdgeList::Pointer bEdgeList) = 0; - - public: - IGeometry2D(const IGeometry2D&) = delete; // Copy Constructor Not Implemented - IGeometry2D(IGeometry2D&&) = delete; // Move Constructor Not Implemented - IGeometry2D& operator=(const IGeometry2D&) = delete; // Copy Assignment Not Implemented - IGeometry2D& operator=(IGeometry2D&&) = delete; // Move Assignment Not Implemented + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(IGeometry2D SUPERCLASS IGeometry) + PYB11_SHARED_POINTERS(IGeometry2D) + PYB11_END_BINDINGS() + // End Python bindings declarations + +public: + using Self = IGeometry2D; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for IGeometry2D + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for IGeometry2D + */ + static QString ClassName(); + + IGeometry2D(); + ~IGeometry2D() override; + + // ----------------------------------------------------------------------------- + // Inherited from SharedVertexOps + // ----------------------------------------------------------------------------- + + /** + * @brief resizeVertexList + * @param newNumVertices + */ + virtual void resizeVertexList(size_t newNumVertices) = 0; + + /** + * @brief setVertices + * @param vertices + */ + virtual void setVertices(SharedVertexList::Pointer vertices) = 0; + + /** + * @brief getVertices + * @return + */ + virtual SharedVertexList::Pointer getVertices() const = 0; + + /** + * @brief setCoords + * @param vertId + * @param coords + */ + virtual void setCoords(size_t vertId, float coords[3]) = 0; + + /** + * @brief getCoords + * @param vertId + * @param coords + */ + virtual void getCoords(size_t vertId, float coords[3]) const = 0; + + /** + * @brief getVertexPointer + * @param i + * @return + */ + virtual float* getVertexPointer(size_t i) const = 0; + + /** + * @brief getNumberOfVertices + * @return + */ + virtual size_t getNumberOfVertices() const = 0; + + // ----------------------------------------------------------------------------- + // Inherited from SharedEdgeOps + // ----------------------------------------------------------------------------- + + /** + * @brief resizeEdgeList + * @param newNumEdges + */ + virtual void resizeEdgeList(size_t newNumEdges) = 0; + + /** + * @brief getEdges + * @return + */ + virtual SharedEdgeList::Pointer getEdges() const = 0; + + /** + * @brief setVerts + * @param edgeId + * @param verts + */ + virtual void setVertsAtEdge(size_t edgeId, size_t verts[2]) = 0; + + /** + * @brief getVerts + * @param edgeId + * @param verts + */ + virtual void getVertsAtEdge(size_t edgeId, size_t verts[2]) const = 0; + + /** + * @brief getVertCoordsAtEdge + * @param edgeId + * @param vert1 + * @param vert2 + */ + virtual void getVertCoordsAtEdge(size_t edgeId, float vert1[3], float vert2[3]) const = 0; + + /** + * @brief getEdgePointer + * @param i + * @return + */ + virtual size_t* getEdgePointer(size_t i) const = 0; + + /** + * @brief getNumberOfEdges + * @return + */ + virtual size_t getNumberOfEdges() const = 0; + + // ----------------------------------------------------------------------------- + // Connectivity + // ----------------------------------------------------------------------------- + + /** + * @brief findElementEdges + * @return + */ + virtual int findEdges() = 0; + + /** + * @brief deleteElementEdges + */ + virtual void deleteEdges() = 0; + + // ----------------------------------------------------------------------------- + // Topology + // ----------------------------------------------------------------------------- + + /** + * @brief findUnsharedEdges + */ + virtual int findUnsharedEdges() = 0; + + /** + * @brief getUnsharedEdges + * @return + */ + virtual SharedEdgeList::Pointer getUnsharedEdges() const = 0; + + /** + * @brief deleteUnsharedEdges + */ + virtual void deleteUnsharedEdges() = 0; + +protected: + /** + * @brief setEdges + * @param edges + */ + virtual void setEdges(SharedEdgeList::Pointer edges) = 0; + + /** + * @brief setUnsharedEdges + * @param bEdgeList + */ + virtual void setUnsharedEdges(SharedEdgeList::Pointer bEdgeList) = 0; + +public: + IGeometry2D(const IGeometry2D&) = delete; // Copy Constructor Not Implemented + IGeometry2D(IGeometry2D&&) = delete; // Move Constructor Not Implemented + IGeometry2D& operator=(const IGeometry2D&) = delete; // Copy Assignment Not Implemented + IGeometry2D& operator=(IGeometry2D&&) = delete; // Move Assignment Not Implemented }; - - diff --git a/Source/SIMPLib/Geometry/IGeometry3D.cpp b/Source/SIMPLib/Geometry/IGeometry3D.cpp index 49ca9f4f24..e65a077c8c 100644 --- a/Source/SIMPLib/Geometry/IGeometry3D.cpp +++ b/Source/SIMPLib/Geometry/IGeometry3D.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "SIMPLib/Geometry/IGeometry3D.h" @@ -44,3 +44,21 @@ IGeometry3D::IGeometry3D() = default; // // ----------------------------------------------------------------------------- IGeometry3D::~IGeometry3D() = default; + +// ----------------------------------------------------------------------------- +IGeometry3D::Pointer IGeometry3D::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString IGeometry3D::getNameOfClass() const +{ + return QString("IGeometry3D"); +} + +// ----------------------------------------------------------------------------- +QString IGeometry3D::ClassName() +{ + return QString("IGeometry3D"); +} diff --git a/Source/SIMPLib/Geometry/IGeometry3D.h b/Source/SIMPLib/Geometry/IGeometry3D.h old mode 100755 new mode 100644 index 17578d5a13..cd7996b91f --- a/Source/SIMPLib/Geometry/IGeometry3D.h +++ b/Source/SIMPLib/Geometry/IGeometry3D.h @@ -1,42 +1,43 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include + #include "SIMPLib/SIMPLib.h" -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" #include "SIMPLib/Common/Constants.h" #include "SIMPLib/Geometry/IGeometry.h" @@ -45,201 +46,212 @@ */ class SIMPLib_EXPORT IGeometry3D : public IGeometry { - public: - SIMPL_SHARED_POINTERS(IGeometry3D) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(IGeometry3D, Observable) - - IGeometry3D(); - ~IGeometry3D() override; - -// ----------------------------------------------------------------------------- -// Inherited from SharedVertexOps -// ----------------------------------------------------------------------------- - - /** - * @brief resizeVertexList - * @param newNumVertices - */ - virtual void resizeVertexList(int64_t newNumVertices) = 0; - - /** - * @brief setVertices - * @param vertices - */ - virtual void setVertices(SharedVertexList::Pointer vertices) = 0; - - /** - * @brief getVertices - * @return - */ - virtual SharedVertexList::Pointer getVertices() = 0; - - /** - * @brief setCoords - * @param vertId - * @param coords - */ - virtual void setCoords(int64_t vertId, float coords[3]) = 0; - - /** - * @brief getCoords - * @param vertId - * @param coords - */ - virtual void getCoords(int64_t vertId, float coords[3]) = 0; - - /** - * @brief getVertexPointer - * @param i - * @return - */ - virtual float* getVertexPointer(int64_t i) = 0; - - /** - * @brief getNumberOfVertices - * @return - */ - virtual int64_t getNumberOfVertices() = 0; - -// ----------------------------------------------------------------------------- -// Inherited from SharedEdgeOps -// ----------------------------------------------------------------------------- - - /** - * @brief resizeEdgeList - * @param newNumEdges - */ - virtual void resizeEdgeList(int64_t newNumEdges) = 0; - - /** - * @brief getEdges - * @return - */ - virtual SharedEdgeList::Pointer getEdges() = 0; - - /** - * @brief setVerts - * @param edgeId - * @param verts - */ - virtual void setVertsAtEdge(int64_t edgeId, int64_t verts[2]) = 0; - - /** - * @brief getVerts - * @param edgeId - * @param verts - */ - virtual void getVertsAtEdge(int64_t edgeId, int64_t verts[2]) = 0; - - /** - * @brief getVertCoordsAtEdge - * @param edgeId - * @param vert1 - * @param vert2 - */ - virtual void getVertCoordsAtEdge(int64_t edgeId, float vert1[3], float vert2[3]) = 0; - - /** - * @brief getEdgePointer - * @param i - * @return - */ - virtual int64_t* getEdgePointer(int64_t i) = 0; - - /** - * @brief getNumberOfEdges - * @return - */ - virtual int64_t getNumberOfEdges() = 0; - - -// ----------------------------------------------------------------------------- -// Connectivity -// ----------------------------------------------------------------------------- - - /** - * @brief findElementEdges - * @return - */ - virtual int findEdges() = 0; - - /** - * @brief deleteElementEdges - */ - virtual void deleteEdges() = 0; - - /** - * @brief findFaces - * @return - */ - virtual int findFaces() = 0; - - /** - * @brief deleteFaces - */ - virtual void deleteFaces() = 0; - -// ----------------------------------------------------------------------------- -// Topology -// ----------------------------------------------------------------------------- - - /** - * @brief findUnsharedEdges - */ - virtual int findUnsharedEdges() = 0; - - /** - * @brief getUnsharedEdges - * @return - */ - virtual SharedEdgeList::Pointer getUnsharedEdges() = 0; - - /** - * @brief deleteUnsharedEdges - */ - virtual void deleteUnsharedEdges() = 0; - - /** - * @brief findUnsharedFaces - */ - virtual int findUnsharedFaces() = 0; - - /** - * @brief getUnsharedFaces - * @return - */ - virtual SharedEdgeList::Pointer getUnsharedFaces() = 0; - - /** - * @brief deleteUnsharedFaces - */ - virtual void deleteUnsharedFaces() = 0; - - protected: - - /** - * @brief setEdges - * @param edges - */ - virtual void setEdges(SharedEdgeList::Pointer edges) = 0; - - /** - * @brief setUnsharedEdges - * @param bEdgeList - */ - virtual void setUnsharedEdges(SharedEdgeList::Pointer bEdgeList) = 0; - - /** - * @brief setUnsharedFaces - * @param bFaceList - */ - virtual void setUnsharedFaces(SharedFaceList::Pointer bFaceList) = 0; - - public: - IGeometry3D(const IGeometry3D&) = delete; // Copy Constructor Not Implemented - IGeometry3D(IGeometry3D&&) = delete; // Move Constructor Not Implemented - IGeometry3D& operator=(const IGeometry3D&) = delete; // Copy Assignment Not Implemented - IGeometry3D& operator=(IGeometry3D&&) = delete; // Move Assignment Not Implemented +public: + using Self = IGeometry3D; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for IGeometry3D + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for IGeometry3D + */ + static QString ClassName(); + + IGeometry3D(); + ~IGeometry3D() override; + + // ----------------------------------------------------------------------------- + // Inherited from SharedVertexOps + // ----------------------------------------------------------------------------- + + /** + * @brief resizeVertexList + * @param newNumVertices + */ + virtual void resizeVertexList(size_t newNumVertices) = 0; + + /** + * @brief setVertices + * @param vertices + */ + virtual void setVertices(SharedVertexList::Pointer vertices) = 0; + + /** + * @brief getVertices + * @return + */ + virtual SharedVertexList::Pointer getVertices() const = 0; + + /** + * @brief setCoords + * @param vertId + * @param coords + */ + virtual void setCoords(size_t vertId, float coords[3]) = 0; + + /** + * @brief getCoords + * @param vertId + * @param coords + */ + virtual void getCoords(size_t vertId, float coords[3]) const = 0; + + /** + * @brief getVertexPointer + * @param i + * @return + */ + virtual float* getVertexPointer(size_t i) const = 0; + + /** + * @brief getNumberOfVertices + * @return + */ + virtual size_t getNumberOfVertices() const = 0; + + // ----------------------------------------------------------------------------- + // Inherited from SharedEdgeOps + // ----------------------------------------------------------------------------- + + /** + * @brief resizeEdgeList + * @param newNumEdges + */ + virtual void resizeEdgeList(size_t newNumEdges) = 0; + + /** + * @brief getEdges + * @return + */ + virtual SharedEdgeList::Pointer getEdges() const = 0; + + /** + * @brief setVerts + * @param edgeId + * @param verts + */ + virtual void setVertsAtEdge(size_t edgeId, size_t verts[2]) = 0; + + /** + * @brief getVerts + * @param edgeId + * @param verts + */ + virtual void getVertsAtEdge(size_t edgeId, size_t verts[2]) const = 0; + + /** + * @brief getVertCoordsAtEdge + * @param edgeId + * @param vert1 + * @param vert2 + */ + virtual void getVertCoordsAtEdge(size_t edgeId, float vert1[3], float vert2[3]) const = 0; + + /** + * @brief getEdgePointer + * @param i + * @return + */ + virtual size_t* getEdgePointer(size_t i) const = 0; + + /** + * @brief getNumberOfEdges + * @return + */ + virtual size_t getNumberOfEdges() const = 0; + + // ----------------------------------------------------------------------------- + // Connectivity + // ----------------------------------------------------------------------------- + + /** + * @brief findElementEdges + * @return + */ + virtual int findEdges() = 0; + + /** + * @brief deleteElementEdges + */ + virtual void deleteEdges() = 0; + + /** + * @brief findFaces + * @return + */ + virtual int findFaces() = 0; + + /** + * @brief deleteFaces + */ + virtual void deleteFaces() = 0; + + // ----------------------------------------------------------------------------- + // Topology + // ----------------------------------------------------------------------------- + + /** + * @brief findUnsharedEdges + */ + virtual int findUnsharedEdges() = 0; + + /** + * @brief getUnsharedEdges + * @return + */ + virtual SharedEdgeList::Pointer getUnsharedEdges() const = 0; + + /** + * @brief deleteUnsharedEdges + */ + virtual void deleteUnsharedEdges() = 0; + + /** + * @brief findUnsharedFaces + */ + virtual int findUnsharedFaces() = 0; + + /** + * @brief getUnsharedFaces + * @return + */ + virtual SharedEdgeList::Pointer getUnsharedFaces() const = 0; + + /** + * @brief deleteUnsharedFaces + */ + virtual void deleteUnsharedFaces() = 0; + +protected: + /** + * @brief setEdges + * @param edges + */ + virtual void setEdges(SharedEdgeList::Pointer edges) = 0; + + /** + * @brief setUnsharedEdges + * @param bEdgeList + */ + virtual void setUnsharedEdges(SharedEdgeList::Pointer bEdgeList) = 0; + + /** + * @brief setUnsharedFaces + * @param bFaceList + */ + virtual void setUnsharedFaces(SharedFaceList::Pointer bFaceList) = 0; + +public: + IGeometry3D(const IGeometry3D&) = delete; // Copy Constructor Not Implemented + IGeometry3D(IGeometry3D&&) = delete; // Move Constructor Not Implemented + IGeometry3D& operator=(const IGeometry3D&) = delete; // Copy Assignment Not Implemented + IGeometry3D& operator=(IGeometry3D&&) = delete; // Move Assignment Not Implemented + +private: }; - - diff --git a/Source/SIMPLib/Geometry/IGeometryGrid.cpp b/Source/SIMPLib/Geometry/IGeometryGrid.cpp index 78b6795aa3..749c791a87 100644 --- a/Source/SIMPLib/Geometry/IGeometryGrid.cpp +++ b/Source/SIMPLib/Geometry/IGeometryGrid.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "SIMPLib/Geometry/IGeometryGrid.h" @@ -44,3 +44,21 @@ IGeometryGrid::IGeometryGrid() = default; // // ----------------------------------------------------------------------------- IGeometryGrid::~IGeometryGrid() = default; + +// ----------------------------------------------------------------------------- +IGeometryGrid::Pointer IGeometryGrid::NullPointer() +{ + return Pointer(static_cast(nullptr)); +} + +// ----------------------------------------------------------------------------- +QString IGeometryGrid::getNameOfClass() const +{ + return QString("IGeometryGrid"); +} + +// ----------------------------------------------------------------------------- +QString IGeometryGrid::ClassName() +{ + return QString("IGeometryGrid"); +} diff --git a/Source/SIMPLib/Geometry/IGeometryGrid.h b/Source/SIMPLib/Geometry/IGeometryGrid.h index 3cf0c95cb9..3a962da49a 100644 --- a/Source/SIMPLib/Geometry/IGeometryGrid.h +++ b/Source/SIMPLib/Geometry/IGeometryGrid.h @@ -1,98 +1,108 @@ -/* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once +#include +#include #include -#include "SIMPLib/Common/SIMPLibSetGetMacros.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/SIMPLArray.hpp" #include "SIMPLib/Geometry/IGeometry.h" -namespace SIMPL -{ -using Tuple3FVec = std::tuple; -using Tuple6FVec = std::tuple; -using Tuple3SVec = std::tuple; -} - /** * @brief The IGeometryGrid class extends IGeometry for grid type geometries */ class SIMPLib_EXPORT IGeometryGrid : public IGeometry { // This class needs to be wrapped so Python/Pybind11 can do the proper casting - PYB11_CREATE_BINDINGS(IGeometryGrid SUPERCLASS IGeometry) + // Start Python bindings declarations + PYB11_BEGIN_BINDINGS(IGeometryGrid SUPERCLASS IGeometry) + PYB11_SHARED_POINTERS(IGeometryGrid) + PYB11_END_BINDINGS() + // End Python bindings declarations - public: - SIMPL_SHARED_POINTERS(IGeometryGrid) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(IGeometryGrid, Observable) +public: + using Self = IGeometryGrid; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); - IGeometryGrid(); - ~IGeometryGrid() override; - - virtual void setDimensions(size_t dims[3]) = 0; - virtual void setDimensions(size_t a, size_t b, size_t c) = 0; - virtual void setDimensions(const SIMPL::Tuple3SVec& dims) = 0; + /** + * @brief Returns the name of the class for IGeometryGrid + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for IGeometryGrid + */ + static QString ClassName(); - virtual SIMPL::Tuple3SVec getDimensions() const = 0; + IGeometryGrid(); + ~IGeometryGrid() override; - virtual size_t getXPoints() = 0; - virtual size_t getYPoints() = 0; - virtual size_t getZPoints() = 0; - - virtual void getPlaneCoords(size_t idx[3], float coords[3]) = 0; - virtual void getPlaneCoords(size_t x, size_t y, size_t z, float coords[3]) = 0; - virtual void getPlaneCoords(size_t idx, float coords[3]) = 0; - - virtual void getPlaneCoords(size_t idx[3], double coords[3]) = 0; - virtual void getPlaneCoords(size_t x, size_t y, size_t z, double coords[3]) = 0; - virtual void getPlaneCoords(size_t idx, double coords[3]) = 0; + virtual void setDimensions(const SizeVec3Type& dims) = 0; + virtual SizeVec3Type getDimensions() const = 0; - virtual void getCoords(size_t idx[3], float coords[3]) = 0; - virtual void getCoords(size_t x, size_t y, size_t z, float coords[3]) = 0; - virtual void getCoords(size_t idx, float coords[3]) = 0; - - virtual void getCoords(size_t idx[3], double coords[3]) = 0; - virtual void getCoords(size_t x, size_t y, size_t z, double coords[3]) = 0; - virtual void getCoords(size_t idx, double coords[3]) = 0; + virtual size_t getXPoints() const = 0; + virtual size_t getYPoints() const = 0; + virtual size_t getZPoints() const = 0; - public: - IGeometryGrid(const IGeometryGrid&) = delete; // Copy Constructor Not Implemented - IGeometryGrid(IGeometryGrid&&) = delete; // Move Constructor Not Implemented - IGeometryGrid& operator=(const IGeometryGrid&) = delete; // Copy Assignment Not Implemented - IGeometryGrid& operator=(IGeometryGrid&&) = delete; // Move Assignment Not Implemented -}; + virtual void getPlaneCoords(size_t idx[3], float coords[3]) const = 0; + virtual void getPlaneCoords(size_t x, size_t y, size_t z, float coords[3]) const = 0; + virtual void getPlaneCoords(size_t idx, float coords[3]) const = 0; + + virtual void getPlaneCoords(size_t idx[3], double coords[3]) const = 0; + virtual void getPlaneCoords(size_t x, size_t y, size_t z, double coords[3]) const = 0; + virtual void getPlaneCoords(size_t idx, double coords[3]) const = 0; + virtual void getCoords(size_t idx[3], float coords[3]) const = 0; + virtual void getCoords(size_t x, size_t y, size_t z, float coords[3]) const = 0; + virtual void getCoords(size_t idx, float coords[3]) const = 0; + virtual void getCoords(size_t idx[3], double coords[3]) const = 0; + virtual void getCoords(size_t x, size_t y, size_t z, double coords[3]) const = 0; + virtual void getCoords(size_t idx, double coords[3]) const = 0; + + virtual std::optional getIndex(float xCoord, float yCoord, float zCoord) const = 0; + virtual std::optional getIndex(double xCoord, double yCoord, double zCoord) const = 0; + +public: + IGeometryGrid(const IGeometryGrid&) = delete; // Copy Constructor Not Implemented + IGeometryGrid(IGeometryGrid&&) = delete; // Move Constructor Not Implemented + IGeometryGrid& operator=(const IGeometryGrid&) = delete; // Copy Assignment Not Implemented + IGeometryGrid& operator=(IGeometryGrid&&) = delete; // Move Assignment Not Implemented +}; diff --git a/Source/SIMPLib/FilterParameters/FloatVec2.h b/Source/SIMPLib/Geometry/ITransformContainer.cpp similarity index 65% rename from Source/SIMPLib/FilterParameters/FloatVec2.h rename to Source/SIMPLib/Geometry/ITransformContainer.cpp index 36fb54b44b..f6b73cc071 100644 --- a/Source/SIMPLib/FilterParameters/FloatVec2.h +++ b/Source/SIMPLib/Geometry/ITransformContainer.cpp @@ -1,5 +1,5 @@ /* ============================================================================ - * Copyright (c) 2019 BlueQuartz Software, LLC + * Copyright (c) 2009-2018 BlueQuartz Software, LLC * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -26,37 +26,30 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#pragma once +#include "ITransformContainer.h" + +ITransformContainer::ITransformContainer() = default; -#include +ITransformContainer::~ITransformContainer() = default; -typedef struct +// ----------------------------------------------------------------------------- +ITransformContainer::Pointer ITransformContainer::NullPointer() { - float x; - float y; - float z; - void FloatVec2(const float& xx, const float& yy) - { - x = xx; - y = yy; - } - void writeJson(QJsonObject& json) - { - json["x"] = static_cast(x); - json["y"] = static_cast(y); - } + return Pointer(static_cast(nullptr)); +} - bool readJson(QJsonObject& json) - { - if(json["x"].isDouble() && json["y"].isDouble()) - { - x = static_cast(json["x"].toDouble()); - y = static_cast(json["y"].toDouble()); - return true; - } - return false; - } -} FloatVec2_t; +// ----------------------------------------------------------------------------- +QString ITransformContainer::getNameOfClass() const +{ + return QString("ITransformContainer"); +} -Q_DECLARE_METATYPE(FloatVec2_t) +// ----------------------------------------------------------------------------- +QString ITransformContainer::ClassName() +{ + return QString("ITransformContainer"); +} diff --git a/Source/SIMPLib/Geometry/ITransformContainer.h b/Source/SIMPLib/Geometry/ITransformContainer.h index e974813db4..46551a3928 100644 --- a/Source/SIMPLib/Geometry/ITransformContainer.h +++ b/Source/SIMPLib/Geometry/ITransformContainer.h @@ -1,48 +1,74 @@ /* ============================================================================ -* Copyright (c) 2009-2018 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-15-D-5231 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2018 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-15-D-5231 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include "SIMPLib/Common/Observable.h" -#include "SIMPLib/SIMPLib.h" +#include + +#include "H5Support/H5SupportTypeDefs.h" -#include "H5Support/H5Lite.h" +#include "SIMPLib/SIMPLib.h" +#include "SIMPLib/Common/Observable.h" class SIMPLib_EXPORT ITransformContainer : public Observable { public: - SIMPL_SHARED_POINTERS(ITransformContainer) - SIMPL_TYPE_MACRO_SUPER_OVERRIDE(ITransformContainer, Observable) + using Self = ITransformContainer; + using Pointer = std::shared_ptr; + using ConstPointer = std::shared_ptr; + using WeakPointer = std::weak_ptr; + using ConstWeakPointer = std::weak_ptr; + static Pointer NullPointer(); + + /** + * @brief Returns the name of the class for ITransformContainer + */ + QString getNameOfClass() const override; + /** + * @brief Returns the name of the class for ITransformContainer + */ + static QString ClassName(); + + ITransformContainer(); + ~ITransformContainer() override; + virtual int writeTransformContainerToHDF5(hid_t parentId, const std::string& transformContainerName) = 0; virtual int readTransformContainerFromHDF5(hid_t parentId, bool metaDataOnly, const std::string& transformContainerName) = 0; - ~ITransformContainer() override = default; + +public: + ITransformContainer(const ITransformContainer&) = delete; // Copy Constructor Not Implemented + ITransformContainer(ITransformContainer&&) = delete; // Move Constructor Not Implemented + ITransformContainer& operator=(const ITransformContainer&) = delete; // Copy Assignment Not Implemented + ITransformContainer& operator=(ITransformContainer&&) = delete; // Move Assignment Not Implemented + +private: }; diff --git a/Source/SIMPLib/Geometry/ImageGeom.cpp b/Source/SIMPLib/Geometry/ImageGeom.cpp index af99e4a6c3..706d37da4c 100644 --- a/Source/SIMPLib/Geometry/ImageGeom.cpp +++ b/Source/SIMPLib/Geometry/ImageGeom.cpp @@ -1,37 +1,37 @@ /* ============================================================================ -* Copyright (c) 2009-2016 BlueQuartz Software, LLC -* -* Redistribution and use in source and binary forms, with or without modification, -* are permitted provided that the following conditions are met: -* -* Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* Redistributions in binary form must reproduce the above copyright notice, this -* list of conditions and the following disclaimer in the documentation and/or -* other materials provided with the distribution. -* -* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its -* contributors may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The code contained herein was partially funded by the followig contracts: -* United States Air Force Prime Contract FA8650-07-D-5800 -* United States Air Force Prime Contract FA8650-10-D-5210 -* United States Prime Contract Navy N00173-07-C-2068 -* -* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + * Copyright (c) 2009-2016 BlueQuartz Software, LLC + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The code contained herein was partially funded by the following contracts: + * United States Air Force Prime Contract FA8650-07-D-5800 + * United States Air Force Prime Contract FA8650-10-D-5210 + * United States Prime Contract Navy N00173-07-C-2068 + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* ============================================================================ * ImageGeom re-implements code from the following vtk modules: @@ -43,18 +43,16 @@ * ImageGeom::findDerivatives * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include "SIMPLib/Geometry/ImageGeom.h" +#include + +#include -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS -#include -#include -#include -#include -#endif +#include "SIMPLib/Geometry/ImageGeom.h" #include "H5Support/H5Lite.h" #include "SIMPLib/Geometry/GeometryHelpers.h" #include "SIMPLib/HDF5/VTKH5Constants.h" +#include "SIMPLib/Utilities/ParallelData3DAlgorithm.h" /** * @brief The FindImageDerivativesImpl class implements a threaded algorithm that computes the @@ -63,7 +61,7 @@ class FindImageDerivativesImpl { public: - FindImageDerivativesImpl(ImageGeom* image, DoubleArrayType::Pointer field, DoubleArrayType::Pointer derivs) + FindImageDerivativesImpl(ImageGeom* image, const DoubleArrayType::Pointer& field, const DoubleArrayType::Pointer& derivs) : m_Image(image) , m_Field(field) , m_Derivatives(derivs) @@ -90,8 +88,7 @@ class FindImageDerivativesImpl std::vector dValuesdEta(numComps); std::vector dValuesdZeta(numComps); - size_t dims[3] = {0, 0, 0}; - std::tie(dims[0], dims[1], dims[2]) = m_Image->getDimensions(); + SizeVec3Type dims = m_Image->getDimensions(); int64_t counter = 0; size_t totalElements = m_Image->getNumberOfElements(); @@ -106,19 +103,19 @@ class FindImageDerivativesImpl // Xi derivatives (X) if(dims[0] == 1) { - findValuesForFiniteDifference(TwoDimensional, XDirection, x, y, z, dims, xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); + findValuesForFiniteDifference(TwoDimensional, XDirection, x, y, z, dims.data(), xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); } else if(x == 0) { - findValuesForFiniteDifference(LeftSide, XDirection, x, y, z, dims, xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); + findValuesForFiniteDifference(LeftSide, XDirection, x, y, z, dims.data(), xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); } else if(x == (dims[0] - 1)) { - findValuesForFiniteDifference(RightSide, XDirection, x, y, z, dims, xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); + findValuesForFiniteDifference(RightSide, XDirection, x, y, z, dims.data(), xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); } else { - findValuesForFiniteDifference(Centered, XDirection, x, y, z, dims, xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); + findValuesForFiniteDifference(Centered, XDirection, x, y, z, dims.data(), xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); } xxi = factor * (xp[0] - xm[0]); @@ -132,19 +129,19 @@ class FindImageDerivativesImpl // Eta derivatives (Y) if(dims[1] == 1) { - findValuesForFiniteDifference(TwoDimensional, YDirection, x, y, z, dims, xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); + findValuesForFiniteDifference(TwoDimensional, YDirection, x, y, z, dims.data(), xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); } else if(y == 0) { - findValuesForFiniteDifference(LeftSide, YDirection, x, y, z, dims, xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); + findValuesForFiniteDifference(LeftSide, YDirection, x, y, z, dims.data(), xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); } else if(y == (dims[1] - 1)) { - findValuesForFiniteDifference(RightSide, YDirection, x, y, z, dims, xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); + findValuesForFiniteDifference(RightSide, YDirection, x, y, z, dims.data(), xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); } else { - findValuesForFiniteDifference(Centered, YDirection, x, y, z, dims, xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); + findValuesForFiniteDifference(Centered, YDirection, x, y, z, dims.data(), xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); } xeta = factor * (xp[0] - xm[0]); @@ -158,19 +155,19 @@ class FindImageDerivativesImpl // Zeta derivatives (Z) if(dims[2] == 1) { - findValuesForFiniteDifference(TwoDimensional, ZDirection, x, y, z, dims, xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); + findValuesForFiniteDifference(TwoDimensional, ZDirection, x, y, z, dims.data(), xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); } else if(z == 0) { - findValuesForFiniteDifference(LeftSide, ZDirection, x, y, z, dims, xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); + findValuesForFiniteDifference(LeftSide, ZDirection, x, y, z, dims.data(), xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); } else if(z == (dims[2] - 1)) { - findValuesForFiniteDifference(RightSide, ZDirection, x, y, z, dims, xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); + findValuesForFiniteDifference(RightSide, ZDirection, x, y, z, dims.data(), xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); } else { - findValuesForFiniteDifference(Centered, ZDirection, x, y, z, dims, xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); + findValuesForFiniteDifference(Centered, ZDirection, x, y, z, dims.data(), xp, xm, factor, numComps, plusValues, minusValues, fieldPtr); } xzeta = factor * (xp[0] - xm[0]); @@ -208,7 +205,7 @@ class FindImageDerivativesImpl // Compute the actual derivatives index = (z * dims[1] * dims[0]) + (y * dims[0]) + x; - for(int32_t i = 0; i < numComps; i++) + for(size_t i = 0; i < numComps; i++) { derivsPtr[index * numComps * 3 + i * 3] = xix * dValuesdXi[i] + etax * dValuesdEta[i] + zetax * dValuesdZeta[i]; @@ -228,14 +225,12 @@ class FindImageDerivativesImpl } } -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - void operator()(const tbb::blocked_range3d& r) const + void operator()(const SIMPLRange3D& r) const { - compute(r.pages().begin(), r.pages().end(), r.rows().begin(), r.rows().end(), r.cols().begin(), r.cols().end()); + compute(r[0], r[1], r[2], r[3], r[4], r[5]); } -#endif - void computeIndices(int32_t differenceType, int32_t directionType, size_t& index1, size_t& index2, size_t dims[3], size_t x, size_t y, size_t z, double xp[3], double xm[3]) const + void computeIndices(int32_t differenceType, int32_t directionType, size_t& index1, size_t& index2, const size_t dims[3], size_t x, size_t y, size_t z, double xp[3], double xm[3]) const { size_t tmpIndex1 = 0; @@ -243,8 +238,7 @@ class FindImageDerivativesImpl switch(directionType) { - case XDirection: - { + case XDirection: { if(differenceType == LeftSide) { index1 = (z * dims[1] * dims[0]) + (y * dims[0]) + (x + 1); @@ -272,8 +266,7 @@ class FindImageDerivativesImpl } break; } - case YDirection: - { + case YDirection: { if(differenceType == LeftSide) { index1 = (z * dims[1] * dims[0]) + ((y + 1) * dims[0]) + x; @@ -301,8 +294,7 @@ class FindImageDerivativesImpl } break; } - case ZDirection: - { + case ZDirection: { if(differenceType == LeftSide) { index1 = ((z + 1) * dims[1] * dims[0]) + (y * dims[0]) + x; @@ -330,15 +322,14 @@ class FindImageDerivativesImpl } break; } - default: - { + default: { break; } } } void findValuesForFiniteDifference(int32_t differenceType, int32_t directionType, size_t x, size_t y, size_t z, size_t dims[3], double xp[3], double xm[3], double& factor, int32_t numComps, - std::vector& plusValues, std::vector& minusValues, double* field) const + std::vector& plusValues, std::vector& minusValues, const double* field) const { size_t index1 = 0; size_t index2 = 0; @@ -398,24 +389,17 @@ class FindImageDerivativesImpl // // ----------------------------------------------------------------------------- ImageGeom::ImageGeom() +: m_Spacing(1.0f, 1.0f, 1.0f) +, m_Origin(0.0f, 0.0f, 0.0f) { m_GeometryTypeName = SIMPL::Geometry::ImageGeometry; m_GeometryType = IGeometry::Type::Image; m_XdmfGridType = SIMPL::XdmfGridType::RectilinearGrid; - m_MessagePrefix = ""; - m_MessageTitle = ""; - m_MessageLabel = ""; m_UnitDimensionality = 3; m_SpatialDimensionality = 3; m_Dimensions[0] = 0; m_Dimensions[1] = 0; m_Dimensions[2] = 0; - m_Resolution[0] = 1.0f; - m_Resolution[1] = 1.0f; - m_Resolution[2] = 1.0f; - m_Origin[0] = 0.0f; - m_Origin[1] = 0.0f; - m_Origin[2] = 0.0f; m_VoxelSizes = FloatArrayType::NullPointer(); m_ProgressCounter = 0; } @@ -443,47 +427,98 @@ ImageGeom::Pointer ImageGeom::CreateGeometry(const QString& name) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -//void ImageGeom::getBoundingBox(float &xMin, float &xMax, float &yMin, float &yMax, float &zMin, float &zMax) -//{ -// xMin = m_Origin[0]; -// xMax = m_Origin[0] + (m_Dimensions[0] * m_Resolution[0]); -// yMin = m_Origin[1]; -// yMax = m_Origin[1] + (m_Dimensions[1] * m_Resolution[1]); -// zMin = m_Origin[2]; -// zMax = m_Origin[2] + (m_Dimensions[2] * m_Resolution[2]); -//} +FloatVec3Type ImageGeom::getSpacing() const +{ + return m_Spacing; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ImageGeom::setSpacing(const FloatVec3Type& spacing) +{ + m_Spacing = spacing; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ImageGeom::setSpacing(float x, float y, float z) +{ + m_Spacing[0] = x; + m_Spacing[1] = y; + m_Spacing[2] = z; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +FloatVec3Type ImageGeom::getOrigin() const +{ + return m_Origin; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ImageGeom::setOrigin(const FloatVec3Type& origin) +{ + m_Origin = origin; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +void ImageGeom::setOrigin(float x, float y, float z) +{ + m_Origin[0] = x; + m_Origin[1] = y; + m_Origin[2] = z; +} + +SizeVec3Type ImageGeom::getDimensions() const +{ + return m_Dimensions; +} + +void ImageGeom::setDimensions(const SizeVec3Type& dims) +{ + m_Dimensions = dims; +} + +void ImageGeom::setDimensions(size_t x, size_t y, size_t z) +{ + m_Dimensions[0] = x; + m_Dimensions[1] = y; + m_Dimensions[2] = z; +} // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ImageGeom::getBoundingBox(float* boundingBox) { - boundingBox[0] = m_Origin[0]; - boundingBox[1] = m_Origin[0] + (m_Dimensions[0] * m_Resolution[0]); - boundingBox[2] = m_Origin[1]; - boundingBox[3] = m_Origin[1] + (m_Dimensions[1] * m_Resolution[1]); - boundingBox[4] = m_Origin[2]; - boundingBox[5] = m_Origin[2] + (m_Dimensions[2] * m_Resolution[2]); + boundingBox[0] = m_Origin[0]; + boundingBox[1] = m_Origin[0] + (m_Dimensions[0] * m_Spacing[0]); + boundingBox[2] = m_Origin[1]; + boundingBox[3] = m_Origin[1] + (m_Dimensions[1] * m_Spacing[1]); + boundingBox[4] = m_Origin[2]; + boundingBox[5] = m_Origin[2] + (m_Dimensions[2] * m_Spacing[2]); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -SIMPL::Tuple6FVec ImageGeom::getBoundingBox() +FloatVec6Type ImageGeom::getBoundingBox() const { - return std::make_tuple(m_Origin[0], - m_Origin[0] + (m_Dimensions[0] * m_Resolution[0]), - m_Origin[1], - m_Origin[1] + (m_Dimensions[1] * m_Resolution[1]), - m_Origin[2], - m_Origin[2] + (m_Dimensions[2] * m_Resolution[2]) - ); + return FloatVec6Type(m_Origin[0], m_Origin[0] + (m_Dimensions[0] * m_Spacing[0]), m_Origin[1], m_Origin[1] + (m_Dimensions[1] * m_Spacing[1]), m_Origin[2], + m_Origin[2] + (m_Dimensions[2] * m_Spacing[2])); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -size_t ImageGeom::getXPoints() +size_t ImageGeom::getXPoints() const { return m_Dimensions[0]; } @@ -491,15 +526,15 @@ size_t ImageGeom::getXPoints() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -size_t ImageGeom::getYPoints() -{ +size_t ImageGeom::getYPoints() const +{ return m_Dimensions[1]; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -size_t ImageGeom::getZPoints() +size_t ImageGeom::getZPoints() const { return m_Dimensions[2]; } @@ -507,137 +542,161 @@ size_t ImageGeom::getZPoints() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::getPlaneCoords(size_t idx[3], float coords[3]) +void ImageGeom::getPlaneCoords(size_t idx[3], float coords[3]) const { - coords[0] = idx[0] * m_Resolution[0] + m_Origin[0]; - coords[1] = idx[1] * m_Resolution[1] + m_Origin[1]; - coords[2] = idx[2] * m_Resolution[2] + m_Origin[2]; + coords[0] = idx[0] * m_Spacing[0] + m_Origin[0]; + coords[1] = idx[1] * m_Spacing[1] + m_Origin[1]; + coords[2] = idx[2] * m_Spacing[2] + m_Origin[2]; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::getPlaneCoords(size_t x, size_t y, size_t z, float coords[3]) +void ImageGeom::getPlaneCoords(size_t x, size_t y, size_t z, float coords[3]) const { - coords[0] = x * m_Resolution[0] + m_Origin[0]; - coords[1] = y * m_Resolution[1] + m_Origin[1]; - coords[2] = z * m_Resolution[2] + m_Origin[2]; + coords[0] = x * m_Spacing[0] + m_Origin[0]; + coords[1] = y * m_Spacing[1] + m_Origin[1]; + coords[2] = z * m_Spacing[2] + m_Origin[2]; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::getPlaneCoords(size_t idx, float coords[3]) +void ImageGeom::getPlaneCoords(size_t idx, float coords[3]) const { size_t column = idx % m_Dimensions[0]; size_t row = (idx / m_Dimensions[0]) % m_Dimensions[1]; size_t plane = idx / (m_Dimensions[0] * m_Dimensions[1]); - coords[0] = column * m_Resolution[0] + m_Origin[0]; - coords[1] = row * m_Resolution[1] + m_Origin[1]; - coords[2] = plane * m_Resolution[2] + m_Origin[2]; + coords[0] = column * m_Spacing[0] + m_Origin[0]; + coords[1] = row * m_Spacing[1] + m_Origin[1]; + coords[2] = plane * m_Spacing[2] + m_Origin[2]; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::getPlaneCoords(size_t idx[3], double coords[3]) +void ImageGeom::getPlaneCoords(size_t idx[3], double coords[3]) const { - coords[0] = static_cast(idx[0] * m_Resolution[0] + m_Origin[0]); - coords[1] = static_cast(idx[1] * m_Resolution[1] + m_Origin[1]); - coords[2] = static_cast(idx[2] * m_Resolution[2] + m_Origin[2]); + coords[0] = static_cast(idx[0]) * m_Spacing[0] + m_Origin[0]; + coords[1] = static_cast(idx[1]) * m_Spacing[1] + m_Origin[1]; + coords[2] = static_cast(idx[2]) * m_Spacing[2] + m_Origin[2]; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::getPlaneCoords(size_t x, size_t y, size_t z, double coords[3]) +void ImageGeom::getPlaneCoords(size_t x, size_t y, size_t z, double coords[3]) const { - coords[0] = static_cast(x * m_Resolution[0] + m_Origin[0]); - coords[1] = static_cast(y * m_Resolution[1] + m_Origin[1]); - coords[2] = static_cast(z * m_Resolution[2] + m_Origin[2]); + coords[0] = static_cast(x) * m_Spacing[0] + m_Origin[0]; + coords[1] = static_cast(y) * m_Spacing[1] + m_Origin[1]; + coords[2] = static_cast(z) * m_Spacing[2] + m_Origin[2]; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::getPlaneCoords(size_t idx, double coords[3]) +void ImageGeom::getPlaneCoords(size_t idx, double coords[3]) const { size_t column = idx % m_Dimensions[0]; size_t row = (idx / m_Dimensions[0]) % m_Dimensions[1]; size_t plane = idx / (m_Dimensions[0] * m_Dimensions[1]); - coords[0] = static_cast(column * m_Resolution[0] + m_Origin[0]); - coords[1] = static_cast(row * m_Resolution[1] + m_Origin[1]); - coords[2] = static_cast(plane * m_Resolution[2] + m_Origin[2]); + coords[0] = static_cast(column) * m_Spacing[0] + m_Origin[0]; + coords[1] = static_cast(row) * m_Spacing[1] + m_Origin[1]; + coords[2] = static_cast(plane) * m_Spacing[2] + m_Origin[2]; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::getCoords(size_t idx[3], float coords[3]) +void ImageGeom::getCoords(size_t idx[3], float coords[3]) const { - coords[0] = idx[0] * m_Resolution[0] + m_Origin[0] + (0.5f * m_Resolution[0]); - coords[1] = idx[1] * m_Resolution[1] + m_Origin[1] + (0.5f * m_Resolution[1]); - coords[2] = idx[2] * m_Resolution[2] + m_Origin[2] + (0.5f * m_Resolution[2]); + coords[0] = idx[0] * m_Spacing[0] + m_Origin[0] + (0.5f * m_Spacing[0]); + coords[1] = idx[1] * m_Spacing[1] + m_Origin[1] + (0.5f * m_Spacing[1]); + coords[2] = idx[2] * m_Spacing[2] + m_Origin[2] + (0.5f * m_Spacing[2]); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::getCoords(size_t x, size_t y, size_t z, float coords[3]) +void ImageGeom::getCoords(size_t x, size_t y, size_t z, float coords[3]) const { - coords[0] = x * m_Resolution[0] + m_Origin[0] + (0.5f * m_Resolution[0]); - coords[1] = y * m_Resolution[1] + m_Origin[1] + (0.5f * m_Resolution[1]); - coords[2] = z * m_Resolution[2] + m_Origin[2] + (0.5f * m_Resolution[2]); + coords[0] = x * m_Spacing[0] + m_Origin[0] + (0.5f * m_Spacing[0]); + coords[1] = y * m_Spacing[1] + m_Origin[1] + (0.5f * m_Spacing[1]); + coords[2] = z * m_Spacing[2] + m_Origin[2] + (0.5f * m_Spacing[2]); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::getCoords(size_t idx, float coords[3]) +void ImageGeom::getCoords(size_t idx, float coords[3]) const { size_t column = idx % m_Dimensions[0]; size_t row = (idx / m_Dimensions[0]) % m_Dimensions[1]; size_t plane = idx / (m_Dimensions[0] * m_Dimensions[1]); - coords[0] = column * m_Resolution[0] + m_Origin[0] + (0.5f * m_Resolution[0]); - coords[1] = row * m_Resolution[1] + m_Origin[1] + (0.5f * m_Resolution[1]); - coords[2] = plane * m_Resolution[2] + m_Origin[2] + (0.5f * m_Resolution[2]); + coords[0] = column * m_Spacing[0] + m_Origin[0] + (0.5f * m_Spacing[0]); + coords[1] = row * m_Spacing[1] + m_Origin[1] + (0.5f * m_Spacing[1]); + coords[2] = plane * m_Spacing[2] + m_Origin[2] + (0.5f * m_Spacing[2]); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::getCoords(size_t idx[3], double coords[3]) +void ImageGeom::getCoords(size_t idx[3], double coords[3]) const { - coords[0] = static_cast(idx[0] * m_Resolution[0] + m_Origin[0] + (0.5f * m_Resolution[0])); - coords[1] = static_cast(idx[1] * m_Resolution[1] + m_Origin[1] + (0.5f * m_Resolution[1])); - coords[2] = static_cast(idx[2] * m_Resolution[2] + m_Origin[2] + (0.5f * m_Resolution[2])); + coords[0] = static_cast(idx[0]) * m_Spacing[0] + m_Origin[0] + (0.5 * m_Spacing[0]); + coords[1] = static_cast(idx[1]) * m_Spacing[1] + m_Origin[1] + (0.5 * m_Spacing[1]); + coords[2] = static_cast(idx[2]) * m_Spacing[2] + m_Origin[2] + (0.5 * m_Spacing[2]); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::getCoords(size_t x, size_t y, size_t z, double coords[3]) +void ImageGeom::getCoords(size_t x, size_t y, size_t z, double coords[3]) const { - coords[0] = static_cast(x * m_Resolution[0] + m_Origin[0] + (0.5f * m_Resolution[0])); - coords[1] = static_cast(y * m_Resolution[1] + m_Origin[1] + (0.5f * m_Resolution[1])); - coords[2] = static_cast(z * m_Resolution[2] + m_Origin[2] + (0.5f * m_Resolution[2])); + coords[0] = static_cast(x) * m_Spacing[0] + m_Origin[0] + (0.5 * m_Spacing[0]); + coords[1] = static_cast(y) * m_Spacing[1] + m_Origin[1] + (0.5 * m_Spacing[1]); + coords[2] = static_cast(z) * m_Spacing[2] + m_Origin[2] + (0.5 * m_Spacing[2]); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::getCoords(size_t idx, double coords[3]) +void ImageGeom::getCoords(size_t idx, double coords[3]) const { size_t column = idx % m_Dimensions[0]; size_t row = (idx / m_Dimensions[0]) % m_Dimensions[1]; size_t plane = idx / (m_Dimensions[0] * m_Dimensions[1]); - coords[0] = static_cast(column * m_Resolution[0] + m_Origin[0] + (0.5f * m_Resolution[0])); - coords[1] = static_cast(row * m_Resolution[1] + m_Origin[1] + (0.5f * m_Resolution[1])); - coords[2] = static_cast(plane * m_Resolution[2] + m_Origin[2] + (0.5f * m_Resolution[2])); + coords[0] = static_cast(column) * m_Spacing[0] + m_Origin[0] + (0.5 * m_Spacing[0]); + coords[1] = static_cast(row) * m_Spacing[1] + m_Origin[1] + (0.5 * m_Spacing[1]); + coords[2] = static_cast(plane) * m_Spacing[2] + m_Origin[2] + (0.5 * m_Spacing[2]); +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::optional ImageGeom::getIndex(float xCoord, float yCoord, float zCoord) const +{ + size_t x = (xCoord - (0.5f * m_Spacing[0]) - m_Origin[0]) / m_Spacing[0]; + size_t y = (yCoord - (0.5f * m_Spacing[1]) - m_Origin[1]) / m_Spacing[1]; + size_t z = (zCoord - (0.5f * m_Spacing[2]) - m_Origin[2]) / m_Spacing[2]; + + return (m_Dimensions[1] * m_Dimensions[0] * z) + (m_Dimensions[0] * y) + x; +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +std::optional ImageGeom::getIndex(double xCoord, double yCoord, double zCoord) const +{ + size_t x = (xCoord - (0.5 * m_Spacing[0]) - m_Origin[0]) / m_Spacing[0]; + size_t y = (yCoord - (0.5 * m_Spacing[1]) - m_Origin[1]) / m_Spacing[1]; + size_t z = (zCoord - (0.5 * m_Spacing[2]) - m_Origin[2]) / m_Spacing[2]; + + return (m_Dimensions[1] * m_Dimensions[0] * z) + (m_Dimensions[0] * y) + x; } // ----------------------------------------------------------------------------- @@ -648,7 +707,7 @@ void ImageGeom::initializeWithZeros() for(size_t i = 0; i < 3; i++) { m_Dimensions[i] = 0; - m_Resolution[i] = 1.0f; + m_Spacing[i] = 1.0f; m_Origin[i] = 0.0f; } } @@ -656,7 +715,7 @@ void ImageGeom::initializeWithZeros() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) +void ImageGeom::addOrReplaceAttributeMatrix(const QString& name, AttributeMatrix::Pointer data) { if(data->getType() != AttributeMatrix::Type::Cell) { @@ -667,17 +726,17 @@ void ImageGeom::addAttributeMatrix(const QString& name, AttributeMatrix::Pointer { return; } - if(data->getName().compare(name) != 0) - { - data->setName(name); - } + // if(data->getName().compare(name) != 0) + //{ + // data->setName(name); + //} m_AttributeMatrices[name] = data; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -size_t ImageGeom::getNumberOfElements() +size_t ImageGeom::getNumberOfElements() const { return (m_Dimensions[0] * m_Dimensions[1] * m_Dimensions[2]); } @@ -693,7 +752,7 @@ int ImageGeom::findElementsContainingVert() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ElementDynamicList::Pointer ImageGeom::getElementsContainingVert() +ElementDynamicList::Pointer ImageGeom::getElementsContainingVert() const { return ElementDynamicList::NullPointer(); } @@ -723,7 +782,7 @@ int ImageGeom::findElementNeighbors() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ElementDynamicList::Pointer ImageGeom::getElementNeighbors() +ElementDynamicList::Pointer ImageGeom::getElementNeighbors() const { return ElementDynamicList::NullPointer(); } @@ -753,7 +812,7 @@ int ImageGeom::findElementCentroids() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatArrayType::Pointer ImageGeom::getElementCentroids() +FloatArrayType::Pointer ImageGeom::getElementCentroids() const { return FloatArrayType::NullPointer(); } @@ -777,14 +836,13 @@ void ImageGeom::deleteElementCentroids() // ----------------------------------------------------------------------------- int ImageGeom::findElementSizes() { - float res[3] = {0.0f, 0.0f, 0.0f}; - std::tie(res[0], res[1], res[2]) = getResolution(); + FloatVec3Type res = getSpacing(); if(res[0] <= 0.0f || res[1] <= 0.0f || res[2] <= 0.0f) { return -1; } - m_VoxelSizes = FloatArrayType::CreateArray(getNumberOfElements(), SIMPL::StringConstants::VoxelSizes); + m_VoxelSizes = FloatArrayType::CreateArray(getNumberOfElements(), SIMPL::StringConstants::VoxelSizes, true); m_VoxelSizes->initializeWithValue(res[0] * res[1] * res[2]); return 1; } @@ -792,7 +850,7 @@ int ImageGeom::findElementSizes() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -FloatArrayType::Pointer ImageGeom::getElementSizes() +FloatArrayType::Pointer ImageGeom::getElementSizes() const { return m_VoxelSizes; } @@ -816,7 +874,7 @@ void ImageGeom::deleteElementSizes() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::getParametricCenter(double pCoords[3]) +void ImageGeom::getParametricCenter(double pCoords[3]) const { pCoords[0] = 0.5; pCoords[1] = 0.5; @@ -826,7 +884,7 @@ void ImageGeom::getParametricCenter(double pCoords[3]) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ImageGeom::getShapeFunctions(double pCoords[3], double* shape) +void ImageGeom::getShapeFunctions(double pCoords[3], double* shape) const { double rm = 0.0; double sm = 0.0; @@ -873,52 +931,35 @@ void ImageGeom::getShapeFunctions(double pCoords[3], double* shape) void ImageGeom::findDerivatives(DoubleArrayType::Pointer field, DoubleArrayType::Pointer derivatives, Observable* observable) { m_ProgressCounter = 0; - size_t dims[3] = {0, 0, 0}; - std::tie(dims[0], dims[1], dims[2]) = getDimensions(); + SizeVec3Type dims = getDimensions(); if(observable != nullptr) { - connect(this, SIGNAL(filterGeneratedMessage(const PipelineMessage&)), observable, SLOT(broadcastPipelineMessage(const PipelineMessage&))); + connect(this, SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), observable, SLOT(processDerivativesMessage(const AbstractMessage::Pointer&))); } -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - tbb::task_scheduler_init init; - bool doParallel = true; -#endif - -#ifdef SIMPL_USE_PARALLEL_ALGORITHMS - - size_t grain = dims[2] == 1 ? 1 : dims[2] / tbb::task_scheduler_init::default_num_threads(); + size_t grain = dims[2] == 1 ? 1 : dims[2] / std::thread::hardware_concurrency(); if(grain == 0) // This can happen if dims[2] > number of processors { grain = 1; } - if(doParallel) - { - tbb::parallel_for(tbb::blocked_range3d(0, dims[2], grain, 0, dims[1], dims[1], 0, dims[0], dims[0]), - FindImageDerivativesImpl(this, field, derivatives), tbb::auto_partitioner()); - } - else -#endif - { - FindImageDerivativesImpl serial(this, field, derivatives); - serial.compute(0, dims[2], 0, dims[1], 0, dims[0]); - } + ParallelData3DAlgorithm dataAlg; + dataAlg.setRange(dims[2], dims[1], dims[0]); + dataAlg.setGrain(grain); + dataAlg.execute(FindImageDerivativesImpl(this, field, derivatives)); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int ImageGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf)) +int ImageGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf)) const { herr_t err = 0; int64_t volDims[3] = {static_cast(getXPoints()), static_cast(getYPoints()), static_cast(getZPoints())}; - float spacing[3] = {0.0f, 0.0f, 0.0f}; - std::tie(spacing[0], spacing[1], spacing[2]) = getResolution(); - float origin[3] = {0.0f, 0.0f, 0.0f}; - std::tie(origin[0], origin[1], origin[2]) = getOrigin(); + FloatVec3Type spacing = getSpacing(); + FloatVec3Type origin = getOrigin(); int32_t rank = 1; hsize_t dims[1] = {3}; @@ -928,12 +969,12 @@ int ImageGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf { return err; } - err = H5Lite::writePointerDataset(parentId, H5_ORIGIN, rank, dims, origin); + err = H5Lite::writePointerDataset(parentId, H5_ORIGIN, rank, dims, origin.data()); if(err < 0) { return err; } - err = H5Lite::writePointerDataset(parentId, H5_SPACING, rank, dims, spacing); + err = H5Lite::writePointerDataset(parentId, H5_SPACING, rank, dims, spacing.data()); if(err < 0) { return err; @@ -955,23 +996,21 @@ int ImageGeom::writeGeometryToHDF5(hid_t parentId, bool SIMPL_NOT_USED(writeXdmf // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int ImageGeom::writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) +int ImageGeom::writeXdmf(QTextStream& out, QString dcName, QString hdfFileName) const { herr_t err = 0; int64_t volDims[3] = {static_cast(getXPoints()), static_cast(getYPoints()), static_cast(getZPoints())}; - float spacing[3] = {0.0f, 0.0f, 0.0f}; - std::tie(spacing[0], spacing[1], spacing[2]) = getResolution(); - float origin[3] = {0.0f, 0.0f, 0.0f}; - std::tie(origin[0], origin[1], origin[2]) = getOrigin(); + FloatVec3Type spacing = getSpacing(); + FloatVec3Type origin = getOrigin(); out << " " << "\n"; - out << " " + out << " )" << "\n"; if(getEnableTimeSeries()) { - out << "