diff --git a/.clang-tidy b/.clang-tidy index cfd481ce7c054887907ec5036cd458cd8dd0a441..46a1264c861113ed551a72d71d53890d78748e9d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -67,6 +67,7 @@ readability-*,\ -readability-make-member-function-const,\ -readability-named-parameter,\ -readability-non-const-parameter,\ +-readability-redundant-access-specifiers,\ -readability-redundant-control-flow,\ -readability-uppercase-literal-suffix,\ " diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 71b511b0f6869bc10bba8eb4b9ee057aa77a6f9e..5a092893ae4ef4fdcad3b2d167fe4d3a0a6e9de1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,6 +45,7 @@ test:fedora33: extends: - .fedora33 - .cmake_test_linux + - .cmake_test_artifacts - .linux_test_tags - .run_automatically dependencies: @@ -64,6 +65,7 @@ test:fedora33-vtk-python3: extends: - .fedora33_vtk_python3 - .cmake_test_linux + - .cmake_test_artifacts - .linux_test_tags - .run_automatically dependencies: @@ -83,6 +85,7 @@ test:fedora33-paraview: extends: - .fedora33_paraview - .cmake_test_linux + - .cmake_test_artifacts - .linux_test_tags - .run_automatically dependencies: @@ -102,6 +105,7 @@ test:fedora33-nodata: extends: - .fedora33_nodata - .cmake_test_linux + - .cmake_test_artifacts - .linux_test_tags - .run_automatically dependencies: @@ -109,25 +113,6 @@ test:fedora33-nodata: needs: - build:fedora33-nodata -build:fedora33-vtk-python2: - extends: - - .fedora33_vtk_python2 - - .cmake_build_linux - - .cmake_build_artifacts - - .linux_builder_tags - - .run_automatically - -test:fedora33-vtk-python2: - extends: - - .fedora33_vtk_python2 - - .cmake_test_linux - - .linux_test_tags - - .run_automatically - dependencies: - - build:fedora33-vtk-python2 - needs: - - build:fedora33-vtk-python2 - ## Lint builds build:fedora33-asan: @@ -142,6 +127,7 @@ test:fedora33-asan: extends: - .fedora33_asan - .cmake_memcheck_linux + - .cmake_test_artifacts - .linux_test_priv_tags - .run_automatically dependencies: @@ -161,6 +147,7 @@ test:fedora33-ubsan: extends: - .fedora33_ubsan - .cmake_memcheck_linux + - .cmake_test_artifacts - .linux_test_priv_tags - .run_automatically dependencies: @@ -171,7 +158,7 @@ test:fedora33-ubsan: build:fedora33-tidy: extends: - .fedora33_tidy - - .cmake_build_linux_tidy + - .cmake_build_linux - .cmake_build_artifacts - .linux_builder_tags - .run_automatically @@ -211,24 +198,45 @@ analyze:fedora33-coverage: ## Build and test -build:macos-plain: +build:macos-arm64: + extends: + - .macos_arm64 + - .cmake_build_macos + - .cmake_build_artifacts + - .macos_arm64_builder_tags + - .run_automatically + +test:macos-arm64: + extends: + - .macos_arm64 + - .cmake_test_macos + - .cmake_test_artifacts + - .macos_arm64_builder_tags + - .run_automatically + dependencies: + - build:macos-arm64 + needs: + - build:macos-arm64 + +build:macos-x86_64: extends: - - .macos_plain + - .macos_x86_64 - .cmake_build_macos - .cmake_build_artifacts - .macos_builder_tags - .run_automatically -test:macos-plain: +test:macos-x86_64: extends: - - .macos_plain + - .macos_x86_64 - .cmake_test_macos + - .cmake_test_artifacts - .macos_builder_tags - .run_automatically dependencies: - - build:macos-plain + - build:macos-x86_64 needs: - - build:macos-plain + - build:macos-x86_64 # Windows @@ -246,6 +254,7 @@ test:windows-vs2019-ninja: extends: - .windows_vs2019_ninja - .cmake_test_windows + - .cmake_test_artifacts - .windows_builder_tags - .run_automatically dependencies: diff --git a/.gitlab/artifacts.yml b/.gitlab/artifacts.yml index 664ed3610dd9a12adf7dd0c4315326ce3f3ba311..a7c3c45852936ce9df3317a63bff703d86a5174f 100644 --- a/.gitlab/artifacts.yml +++ b/.gitlab/artifacts.yml @@ -58,9 +58,19 @@ # CDash files. - build/DartConfiguration.tcl +.cmake_test_artifacts: + artifacts: + expire_in: 1d + reports: + junit: + - build/junit.xml + .cmake_coverage_artifacts: artifacts: expire_in: 1d + reports: + junit: + - build/junit.xml paths: # Generated headers. # XXX(globbing): Can be simplified with support from diff --git a/.gitlab/ci/cdash-groups.json b/.gitlab/ci/cdash-groups.json index c8a2fdf1766ab139d8a42d70842b8876d4a1461c..8907e88fae7e1e2a0d2bf70e531d3e3ed28cf1fa 100644 --- a/.gitlab/ci/cdash-groups.json +++ b/.gitlab/ci/cdash-groups.json @@ -38,17 +38,17 @@ { "group": "release", "site": "gitlab-ci", - "buildname": "fedora33_vtk_python2" + "buildname": "fedora33_vtk_python3" }, { "group": "release", "site": "gitlab-ci", - "buildname": "fedora33_vtk_python3" + "buildname": "macos_arm64" }, { "group": "release", "site": "gitlab-ci", - "buildname": "macos_plain" + "buildname": "macos_x86_64" }, { "group": "release", diff --git a/.gitlab/ci/cmake.ps1 b/.gitlab/ci/cmake.ps1 index 6b5086312566a5f4a5fa7f5398bfe7e99b5f8c6f..5d01e3f9e336c06f702a93c63e16a8d3cb44d67e 100755 --- a/.gitlab/ci/cmake.ps1 +++ b/.gitlab/ci/cmake.ps1 @@ -1,13 +1,13 @@ $erroractionpreference = "stop" -$version = "3.19.4" -$sha256sum = "24B03DAF75CE59B542DA38C829FE6944D3BF7CF99AFAA8225CF29F7876823899" -$filename = "cmake-$version-win64-x64" +$version = "3.21.0" +$sha256sum = "C7B88C907A753F4EC86E43DDC89F91F70BF1B011859142F7F29E6D51EA4ABB3C" +$filename = "cmake-$version-windows-x86_64" $tarball = "$filename.zip" $outdir = $pwd.Path $outdir = "$outdir\.gitlab" -$ProgressPreference = "SilentlyContinue" +$ProgressPreference = 'SilentlyContinue' Invoke-WebRequest -Uri "https://github.com/Kitware/CMake/releases/download/v$version/$tarball" -OutFile "$outdir\$tarball" $hash = Get-FileHash "$outdir\$tarball" -Algorithm SHA256 if ($hash.Hash -ne $sha256sum) { diff --git a/.gitlab/ci/cmake.sh b/.gitlab/ci/cmake.sh index be09d14a0bfa6ce03aa892e7013210cbe339399a..1547e30aa246c3d387c39a1992f3e9fc4ebc47fd 100755 --- a/.gitlab/ci/cmake.sh +++ b/.gitlab/ci/cmake.sh @@ -2,20 +2,18 @@ set -e -readonly version="3.19.4" +readonly version="3.21.0" case "$( uname -s )" in Linux) shatool="sha256sum" - sha256sum="ff23e1f53c53e8ef1fa87568345031d86c504e53efb52fa487db0b8e0ee4d3ff" - platform="Linux" - arch="x86_64" + sha256sum="d54ef6909f519740bc85cec07ff54574cd1e061f9f17357d9ace69f61c6291ce" + platform="linux-x86_64" ;; Darwin) shatool="shasum -a 256" - sha256sum="eb1f52996632c1e71a1051c9e2c30cc8df869fb5a213b1a0d3b202744c6c5758" - platform="macos" - arch="universal" + sha256sum="c1c6f19dfc9c658a48b5aed22806595b2337bb3aedb71ab826552f74f568719f" + platform="macos-universal" ;; *) echo "Unrecognized platform $( uname -s )" @@ -25,9 +23,8 @@ esac readonly shatool readonly sha256sum readonly platform -readonly arch -readonly filename="cmake-$version-$platform-$arch" +readonly filename="cmake-$version-$platform" readonly tarball="$filename.tar.gz" cd .gitlab diff --git a/.gitlab/ci/configure_fedora33_tidy.cmake b/.gitlab/ci/configure_fedora33_tidy.cmake index e27d5d5250a98f086f3d81af35eb529914c66c21..b069decaf2114e5477366336174b864684d8c584 100644 --- a/.gitlab/ci/configure_fedora33_tidy.cmake +++ b/.gitlab/ci/configure_fedora33_tidy.cmake @@ -1,4 +1,4 @@ -set(CMAKE_C_CLANG_TIDY "/usr/bin/clang-tidy" CACHE STRING "") -set(CMAKE_CXX_CLANG_TIDY "/usr/bin/clang-tidy" CACHE STRING "") +set(CMAKE_C_CLANG_TIDY "/usr/bin/clang-tidy" "--header-filter=$ENV{CI_PROJECT_DIR}" CACHE STRING "") +set(CMAKE_CXX_CLANG_TIDY "/usr/bin/clang-tidy" "--header-filter=$ENV{CI_PROJECT_DIR}" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora33.cmake") diff --git a/.gitlab/ci/configure_macos_plain.cmake b/.gitlab/ci/configure_macos_arm64.cmake similarity index 100% rename from .gitlab/ci/configure_macos_plain.cmake rename to .gitlab/ci/configure_macos_arm64.cmake diff --git a/.gitlab/ci/configure_macos_x86_64.cmake b/.gitlab/ci/configure_macos_x86_64.cmake new file mode 100644 index 0000000000000000000000000000000000000000..0a31ef868943295a5f5003c8d2dc3e07583f43eb --- /dev/null +++ b/.gitlab/ci/configure_macos_x86_64.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/configure_macos.cmake") diff --git a/.gitlab/ci/ctest_exclusions.cmake b/.gitlab/ci/ctest_exclusions.cmake index 46ba589bae9a9c5f1399891a9c0571432272dadb..1bb08da9b755feba668aec2f6a2f7693ffef037b 100644 --- a/.gitlab/ci/ctest_exclusions.cmake +++ b/.gitlab/ci/ctest_exclusions.cmake @@ -2,6 +2,15 @@ set(test_exclusions pv.MeshSelection ) +if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "windows") + list(APPEND test_exclusions + # PATH setup is needed for these to work. See: + # https://gitlab.kitware.com/paraview/paraview/-/merge_requests/5036 and + # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6299 + "^pv\\." + ) +endif () + if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "fedora") list(APPEND test_exclusions # VTK lighting seems to be wrong. diff --git a/.gitlab/ci/ctest_memcheck.cmake b/.gitlab/ci/ctest_memcheck.cmake index 65b585bd4a88950a370b480fcbc30661918f45fd..40c09ff64e6ca7b67a538766614a85c414646868 100644 --- a/.gitlab/ci/ctest_memcheck.cmake +++ b/.gitlab/ci/ctest_memcheck.cmake @@ -20,6 +20,7 @@ ctest_memcheck( PARALLEL_LEVEL "${nproc}" RETURN_VALUE test_result EXCLUDE "${test_exclusions}" + OUTPUT_JUNIT "${CTEST_BINARY_DIRECTORY}/junit.xml" DEFECT_COUNT defects) ctest_submit_multi(PARTS Test) ctest_submit_multi(PARTS Memcheck) diff --git a/.gitlab/ci/ctest_test.cmake b/.gitlab/ci/ctest_test.cmake index 721766cb47c997a5a513243be875900a0b495bcb..25f5d2b4a7dc9efe9a439c460db6b5692f188725 100644 --- a/.gitlab/ci/ctest_test.cmake +++ b/.gitlab/ci/ctest_test.cmake @@ -16,7 +16,8 @@ include("${CMAKE_CURRENT_LIST_DIR}/ctest_exclusions.cmake") ctest_test( PARALLEL_LEVEL "${nproc}" RETURN_VALUE test_result - EXCLUDE "${test_exclusions}") + EXCLUDE "${test_exclusions}" + OUTPUT_JUNIT "${CTEST_BINARY_DIRECTORY}/junit.xml") file(GLOB packages "${CTEST_BINARY_DIRECTORY}/PluginTests/*/build/plugin/build/*.tar.gz") diff --git a/.gitlab/ci/docker/fedora33-paraview/install_deps.sh b/.gitlab/ci/docker/fedora33-paraview/install_deps.sh index a62c1b7b51e9b8e3a11293ade7d8af6aeddf9761..a7f1c8b5b874383f80b054fb85fb98ce4a9133a6 100755 --- a/.gitlab/ci/docker/fedora33-paraview/install_deps.sh +++ b/.gitlab/ci/docker/fedora33-paraview/install_deps.sh @@ -1,14 +1,16 @@ #!/bin/sh +set -e + # Install build requirements. -dnf install -y \ +dnf install -y --setopt=install_weak_deps=False \ zlib-devel libcurl-devel python-devel python-unversioned-command \ freeglut-devel glew-devel graphviz-devel libpng-devel mesa-dri-drivers \ libxcb libxcb-devel libXt-devel xcb-util xcb-util-devel mesa-libGL-devel \ libxkbcommon-devel diffutils hostname file # Install development tools -dnf install -y \ +dnf install -y --setopt=install_weak_deps=False \ gcc-c++ \ qt5-qtbase-devel \ qt5-qtsvg-devel \ @@ -22,6 +24,10 @@ dnf install -y \ make \ chrpath +# Install static analysis tools +dnf install -y --setopt=install_weak_deps=False \ + clang-tools-extra + # Install memcheck tools dnf install -y \ libasan \ diff --git a/.gitlab/ci/docker/fedora33-vtk-python2/Dockerfile b/.gitlab/ci/docker/fedora33-vtk-python2/Dockerfile deleted file mode 100644 index 72102eab4c6682505bfb8d7f380de5b5495b93d4..0000000000000000000000000000000000000000 --- a/.gitlab/ci/docker/fedora33-vtk-python2/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM fedora:33 -MAINTAINER Ben Boeckel - -COPY install_deps.sh /root/install_deps.sh -RUN sh /root/install_deps.sh - -VOLUME /root/helpers -ARG SCCACHE_REDIS - -ARG superbuild_ref=origin/master -ENV SUPERBUILD_PREFIX /root/misc/root/smtk-deps -COPY install_superbuild.sh /root/install_superbuild.sh -RUN sh /root/install_superbuild.sh "$superbuild_ref" diff --git a/.gitlab/ci/docker/fedora33-vtk-python2/install_deps.sh b/.gitlab/ci/docker/fedora33-vtk-python2/install_deps.sh deleted file mode 100755 index be06541b2c00708d0e6bfb5636fadd66c043c595..0000000000000000000000000000000000000000 --- a/.gitlab/ci/docker/fedora33-vtk-python2/install_deps.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -# Install build requirements. -dnf install -y \ - zlib-devel libcurl-devel python-devel \ - freeglut-devel glew-devel graphviz-devel libpng-devel mesa-dri-drivers \ - libxcb libxcb-devel libXt-devel xcb-util xcb-util-devel mesa-libGL-devel \ - libxkbcommon-devel diffutils hostname file - -# Install development tools -dnf install -y \ - gcc-c++ \ - qt5-qtbase-devel \ - qt5-qtsvg-devel \ - qt5-qttools-devel \ - qt5-qtx11extras-devel \ - qt5-qtxmlpatterns-devel \ - cmake \ - git-core \ - git-lfs \ - ninja-build \ - make \ - chrpath - -dnf clean all diff --git a/.gitlab/ci/docker/fedora33-vtk-python2/install_superbuild.sh b/.gitlab/ci/docker/fedora33-vtk-python2/install_superbuild.sh deleted file mode 100755 index 1973a41cfa7dfaf3aaa368c8294f2c491f753c5e..0000000000000000000000000000000000000000 --- a/.gitlab/ci/docker/fedora33-vtk-python2/install_superbuild.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -set -e -set -x - -readonly superbuild_ref="$1" -shift - -readonly workdir="/builds/gitlab-kitware-sciviz-ci" -git clone --recursive https://gitlab.kitware.com/cmb/cmb-superbuild.git "$workdir" -git -C "$workdir" checkout "$superbuild_ref" -git -C "$workdir" submodule update --recursive --init -export GIT_CEILING_DIRECTORIES="$workdir" -mkdir -p "$workdir/build" -cd "$workdir/build" - -readonly sccache_mountpoint="/root/helpers/sccache" -sccache_settings="" -if [ -x "$sccache_mountpoint" ]; then - sccache_settings="-DCMAKE_C_COMPILER_LAUNCHER=$sccache_mountpoint -DCMAKE_CXX_COMPILER_LAUNCHER=$sccache_mountpoint" - "$sccache_mountpoint" --start-server - "$sccache_mountpoint" --show-stats -fi -readonly sccache_settings - -cmake -GNinja \ - -DDEVELOPER_MODE_smtk:BOOL=ON \ - -DENABLE_cmb:BOOL=OFF \ - -DENABLE_cmbusersguide:BOOL=OFF \ - -DENABLE_smtkprojectmanager:BOOL=OFF \ - -DENABLE_smtkresourcemanagerstate:BOOL=OFF \ - -DENABLE_vtkonly:BOOL=ON \ - -DENABLE_python2:BOOL=ON \ - -DSUPPRESS_szip_OUTPUT:BOOL=OFF \ - -DUSE_SYSTEM_qt5:BOOL=ON \ - $sccache_settings \ - "-D__BUILDBOT_INSTALL_LOCATION:PATH=$SUPERBUILD_PREFIX" \ - "$workdir" -ninja -cp smtk-developer-config.cmake "$SUPERBUILD_PREFIX" - -if [ -x "$sccache_mountpoint" ]; then - "$sccache_mountpoint" --show-stats -fi - -rm -rf "$workdir" diff --git a/.gitlab/ci/docker/fedora33-vtk/install_deps.sh b/.gitlab/ci/docker/fedora33-vtk/install_deps.sh index be06541b2c00708d0e6bfb5636fadd66c043c595..06e85806781db231d3560a9b42279280d5d2adcf 100755 --- a/.gitlab/ci/docker/fedora33-vtk/install_deps.sh +++ b/.gitlab/ci/docker/fedora33-vtk/install_deps.sh @@ -1,14 +1,16 @@ #!/bin/sh +set -e + # Install build requirements. -dnf install -y \ +dnf install -y --setopt=install_weak_deps=False \ zlib-devel libcurl-devel python-devel \ freeglut-devel glew-devel graphviz-devel libpng-devel mesa-dri-drivers \ libxcb libxcb-devel libXt-devel xcb-util xcb-util-devel mesa-libGL-devel \ libxkbcommon-devel diffutils hostname file # Install development tools -dnf install -y \ +dnf install -y --setopt=install_weak_deps=False \ gcc-c++ \ qt5-qtbase-devel \ qt5-qtsvg-devel \ diff --git a/.gitlab/ci/docker/fedora33/install_deps.sh b/.gitlab/ci/docker/fedora33/install_deps.sh index be06541b2c00708d0e6bfb5636fadd66c043c595..06e85806781db231d3560a9b42279280d5d2adcf 100755 --- a/.gitlab/ci/docker/fedora33/install_deps.sh +++ b/.gitlab/ci/docker/fedora33/install_deps.sh @@ -1,14 +1,16 @@ #!/bin/sh +set -e + # Install build requirements. -dnf install -y \ +dnf install -y --setopt=install_weak_deps=False \ zlib-devel libcurl-devel python-devel \ freeglut-devel glew-devel graphviz-devel libpng-devel mesa-dri-drivers \ libxcb libxcb-devel libXt-devel xcb-util xcb-util-devel mesa-libGL-devel \ libxkbcommon-devel diffutils hostname file # Install development tools -dnf install -y \ +dnf install -y --setopt=install_weak_deps=False \ gcc-c++ \ qt5-qtbase-devel \ qt5-qtsvg-devel \ diff --git a/.gitlab/ci/download_qt.cmake b/.gitlab/ci/download_qt.cmake index 33cbea696716e1f8880d13170843673bc1426cea..0ceafce955be3e37df2b2a1db6b22b0ad3c9869b 100644 --- a/.gitlab/ci/download_qt.cmake +++ b/.gitlab/ci/download_qt.cmake @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.12) # Input variables. set(qt_version_major "5") set(qt_version_minor "15") -set(qt_version_patch "1") +set(qt_version_patch "2") # This URL is only visible inside of Kitware's network. Please use your own Qt # Account to obtain these files. set(qt_url_root "https://paraview.org/files/dependencies/internal/qt") @@ -18,7 +18,9 @@ elseif ("$ENV{CMAKE_CONFIGURATION}" MATCHES "vs2017" OR set(qt_platform "windows_x86") set(msvc_year "2019") set(qt_abi "win64_msvc${msvc_year}_64") -elseif ("$ENV{CMAKE_CONFIGURATION}" MATCHES "macos") +elseif ("$ENV{CMAKE_CONFIGURATION}" MATCHES "macos_arm64") + set(qt_platform "mac_arm64") +elseif ("$ENV{CMAKE_CONFIGURATION}" MATCHES "macos_x86_64") set(qt_platform "mac_x64") set(qt_abi "clang_64") else () @@ -33,8 +35,7 @@ set(qt_version_nodot "${qt_version_major}${qt_version_minor}${qt_version_patch}" # Files needed to download. set(qt_files) if (qt_platform STREQUAL "windows_x86") - set(qt_build_stamp "202009071110") - + set(qt_build_stamp "202011130602") set(qt_file_name_prefix "${qt_version}-0-${qt_build_stamp}") list(APPEND qt_files "${qt_file_name_prefix}d3dcompiler_47-x64.7z" @@ -47,7 +48,7 @@ if (qt_platform STREQUAL "windows_x86") set(qt_subdir "${qt_version}/msvc${msvc_year}_64") elseif (qt_platform STREQUAL "mac_x64") - set(qt_build_stamp "202009071110") + set(qt_build_stamp "202011130601") set(qt_file_name_prefix "${qt_version}-0-${qt_build_stamp}") foreach (qt_component IN ITEMS qtbase qtsvg qttools qtxmlpatterns) @@ -56,6 +57,11 @@ elseif (qt_platform STREQUAL "mac_x64") endforeach () set(qt_subdir "${qt_version}/clang_64") +elseif (qt_platform STREQUAL "mac_arm64") + set(qt_subdir "qt-${qt_version}-macosx11.0-arm64") + set(qt_files "${qt_subdir}.tar.xz") + set("${qt_files}_hash" "e80d2647de461370bb65db60bc657148d196348b7393a2975d4a54bfba1b217f") + set(qt_url_prefix "https://gitlab.kitware.com/api/v4/projects/6955/packages/generic/qt/v${qt_version}-20210519.0") # XXX: see below else () message(FATAL_ERROR "Unknown files for ${qt_platform}") @@ -68,8 +74,10 @@ if (NOT qt_subdir) endif () # Build up the path to the file to download. -set(qt_url_path "${qt_platform}/desktop/qt5_${qt_version_nodot}/qt.qt5.${qt_version_nodot}.${qt_abi}") -set(qt_url_prefix "${qt_url_root}/${qt_url_path}") +if (NOT qt_url_prefix) # XXX: Replace this when Qt ships official arm64 binaries. + set(qt_url_path "${qt_platform}/desktop/qt5_${qt_version_nodot}/qt.qt5.${qt_version_nodot}.${qt_abi}") + set(qt_url_prefix "${qt_url_root}/${qt_url_path}") +endif () # Include the file containing the hashes of the files that matter. include("${CMAKE_CURRENT_LIST_DIR}/download_qt_hashes.cmake") diff --git a/.gitlab/ci/download_qt_hashes.cmake b/.gitlab/ci/download_qt_hashes.cmake index b9e4177c183bfca847fba1ddab4b19c9549cbf7e..59738cccf5835daae487e515434390c050cc8065 100644 --- a/.gitlab/ci/download_qt_hashes.cmake +++ b/.gitlab/ci/download_qt_hashes.cmake @@ -2,25 +2,25 @@ # # sha256sum $files | awk '{ print "set(\"" $2 "_hash\" " $1 ")" }' >> $thisfile -if (msvc_year STREQUAL "2015") - set("5.15.1-0-202009071110d3dcompiler_47-x64.7z_hash" a55cb8e4ef0a8271fd9937ca5d6305aa3994b178c675f4f39ecf0ee85b027d9d) - set("5.15.1-0-202009071110opengl32sw-64-mesa_12_0_rc2.7z_hash" 3408f3bc754a51835171ace18be3b0b71a5384c29f03917daef59b939e11a728) -else () - set("5.15.1-0-202009071110d3dcompiler_47-x64.7z_hash" 76defcbef78e29832a5fca39607deac58419d49963fda3d1d61fd5a76c5de78b) - set("5.15.1-0-202009071110opengl32sw-64-mesa_12_0_rc2.7z_hash" f4697dbe90fd5302a48558e22f4c9ce657d93c00247c24a1edb6d425303a0d80) -endif () - -set("5.15.1-0-202009071110qtbase-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86_64.7z_hash" 5d0d2e71e3b00cf88ac4c616b4b314a7e73871f325512821f53c464cdfee961f) -set("5.15.1-0-202009071110qtsvg-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86_64.7z_hash" 427e891531f775541b38f7fca3cdcb281af9ad4ef82b1b483a802b5ed211ea38) -set("5.15.1-0-202009071110qttools-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86_64.7z_hash" 393630ea20cc5fa29e7987df21526586bcac23c3499fb9889d980758942f942e) -set("5.15.1-0-202009071110qtxmlpatterns-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86_64.7z_hash" fc8c0b5776dee01fee943d13154400806acaef84d5b90ad682e3dcae967106ea) +set("5.15.2-0-202011130602qtbase-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86_64.7z_hash" 7d06f93329b79de466aba37109c2aa850ddd74ac03a054b545aeff272a716851) +set("5.15.2-0-202011130602qtsvg-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86_64.7z_hash" af204df1e149a862a9f9b2ebe9542a913275a2b3c54435857dd0c42b18ce5e0d) +set("5.15.2-0-202011130602qttools-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86_64.7z_hash" 210ad3e88ffbc2bda58371a227f0dcbb06719bd5acbd19d44e7da4f5b2d2af4b) +set("5.15.2-0-202011130602qtxmlpatterns-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86_64.7z_hash" f6ae775677ce96a28ab6df8e6cee138e9fcb69e45e4d6485b6d8a26e1de857dc) -set("5.15.1-0-202009071110qtbase-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z_hash" a5635124a135f383d9fb92bf628b018cff9f781addfd388926a367cda5b7cd38) -set("5.15.1-0-202009071110qtsvg-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z_hash" 9f344dafb9d00fadef4801a89e2e9d6f1599c8b25d3afd290a6c42f73ea16ed1) -set("5.15.1-0-202009071110qttools-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z_hash" 45b3debfc317f875d327e4506c0d211dc82ec92c1e9aa60e17b1a747ada22811) -set("5.15.1-0-202009071110qtxmlpatterns-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z_hash" dffcaf8a2028adb6621eb86ade6aa0bc8daa8961653a4a82841091b5165040ca) +# There's a filename conflict here. +if (msvc_year STREQUAL "2019") + set("5.15.2-0-202011130602d3dcompiler_47-x64.7z_hash" 0dc63ca9bb91cb204d479356edb89b30e3599f1c0bce469b1dd5a339134f25e2) + set("5.15.2-0-202011130602opengl32sw-64-mesa_12_0_rc2.7z_hash" 4e43bc46665f31e12e528f01105310b07d3b8c0ff914668e3b77969d672fcc14) +elseif (msvc_year STREQUAL "2015") + set("5.15.2-0-202011130602d3dcompiler_47-x64.7z_hash" 9ba5998b18974f43c8bad4e9ba1fbef0642dcb40ede2f3c7d01d4634f6296f1a) + set("5.15.2-0-202011130602opengl32sw-64-mesa_12_0_rc2.7z_hash" d4f11612346a0e2c23e2752f27f440c33adc42405faae7b7eb49bef74e33f2f7) +endif () +set("5.15.2-0-202011130602qtbase-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z_hash" e563de40230295841c2eece26e347de709edc4bf035515cc239cae3c994c9af6) +set("5.15.2-0-202011130602qtsvg-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z_hash" 22daa63531f2eed8aeec02e047b73641739fa9d0288a5d2db4da25baf3a005a7) +set("5.15.2-0-202011130602qttools-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z_hash" babb583bbbac0e946ad25a2a687b4a3349779d750b1f3de1c4dadbf1c343c3ea) +set("5.15.2-0-202011130602qtxmlpatterns-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z_hash" cc295d93f74c38277cb5fa2c56cbc1dfd8594a5228a82000c901fe42332e1c69) -set("5.15.1-0-202009071110qtbase-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z_hash" df2813ce7c6cb4287abd7956cd1cb9d08312e4ac1208b6cb57af4df11b8ebba1) -set("5.15.1-0-202009071110qtsvg-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z_hash" 5e624dd519dc67ef80ea60f83162dd49e9a0e912122ad049a0a83af914a97ea2) -set("5.15.1-0-202009071110qttools-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z_hash" 94c5e98afa548bf56c7ccc29bccf727b75e2e90df98e83d22575d07f64359cda) -set("5.15.1-0-202009071110qtxmlpatterns-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z_hash" fe01c55dfb073064fe24e1e77564951ccfa21042b91ff8bd3d629854d0b8a7b7) +set("5.15.2-0-202011130601qtbase-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z_hash" a6b225c8ae4eed1b5de1109b27c9c85ea779f56cdeea44ec48d136f32370c6e3) +set("5.15.2-0-202011130601qtsvg-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z_hash" 94f1c25eba441c97870597140c9b5db7e8b6d75865875be6ceca929ebd44c2f8) +set("5.15.2-0-202011130601qttools-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z_hash" 96f46f690845184ea5a99010c7b59e14443ca0fa4b91f0ea37a2d25af1a3de55) +set("5.15.2-0-202011130601qtxmlpatterns-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z_hash" 1a98346e84937f9e87d0b5375a90e18f70568b880bc70b141dc7f3cafac8c154) diff --git a/.gitlab/ci/download_superbuild.cmake b/.gitlab/ci/download_superbuild.cmake index 3b22be935b7ca8cffd768698a3e7d4ae1dab5a98..ac06e0356ac8bc0a315f04a85b6406d59a755242 100644 --- a/.gitlab/ci/download_superbuild.cmake +++ b/.gitlab/ci/download_superbuild.cmake @@ -10,11 +10,14 @@ set(data_host "https://data.kitware.com") # Determine the tarball to download. ci-smtk-ci-developer-{date}-{git-sha}.tar.gz # 20210420 if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "vs2019") - set(file_item "607f0ddb2fa25629b9f66898") - set(file_hash "c324884ec8f7832b450c948f57e6767735c88fc9a5930675891437b22b6abeb2b40fbb9cb1b498559f648693daaa71b3501e413caceccf88e714d784e9f8e75f") -elseif ("$ENV{CMAKE_CONFIGURATION}" MATCHES "macos") - set(file_item "607f0db12fa25629b9f6684f") - set(file_hash "96f7c03cb4da0091b7ded0d680ace228b72b617471d99272d28c4e0bcd42c584a34b700ac81d1ae4a9cc4e0942bf299234a00b4f6193ff8a590b6d8f7713e39a") + set(file_item "60eeffb52fa25629b96abfa2") + set(file_hash "c5e74138f82bf540dda882e73a067fd2aa94d494f1ba8e13881484f412abccb8e8baa7948b806ed016b5754dd29bcc26b439a39ad53b03ce5cc8a1d292e3fefe") +elseif ("$ENV{CMAKE_CONFIGURATION}" MATCHES "macos_x86_64") + set(file_item "60eefdaf2fa25629b96abef4") + set(file_hash "5c0d64ed1b26a39e890f7c8fab68cdfc52b1b9c3ad360dfd06de7dc9772e0a44643e093071adea5d04f45d18cf2bc21ae660c6a597d6d61c35208d0b897ca27a") +elseif ("$ENV{CMAKE_CONFIGURATION}" MATCHES "macos_arm64") + set(file_item "60eeff952fa25629b96abf71") + set(file_hash "58d95aef71a4b89061202c8ea8a4bef5e55df71527747d8b71692d1f1494b263df6edcee77c768f3f98a0e680ca461e50ddb34363ac30451c16dbf1d113bd724") else () message(FATAL_ERROR "Unknown build to use for the superbuild") diff --git a/.gitlab/ci/ninja.ps1 b/.gitlab/ci/ninja.ps1 index 697d3afda1338103288332e18551fed620aa8ef3..9f42d1daa63555e019ab1b9f6767a08920af2532 100755 --- a/.gitlab/ci/ninja.ps1 +++ b/.gitlab/ci/ninja.ps1 @@ -1,7 +1,7 @@ $erroractionpreference = "stop" -$version = "1.10.0" -$sha256sum = "919FD158C16BF135E8A850BB4046EC1CE28A7439EE08B977CD0B7F6B3463D178" +$version = "1.10.2" +$sha256sum = "BBDE850D247D2737C5764C927D1071CBB1F1957DCABDA4A130FA8547C12C695F" $filename = "ninja-win" $tarball = "$filename.zip" diff --git a/.gitlab/ci/ninja.sh b/.gitlab/ci/ninja.sh index 93c1ee95732969037da72ab616e97b4f6a733bd8..9011bbcf5e85a36ba41afed05a48d382cbdccb34 100755 --- a/.gitlab/ci/ninja.sh +++ b/.gitlab/ci/ninja.sh @@ -2,17 +2,17 @@ set -e -readonly version="1.10.0" +readonly version="1.10.2" case "$( uname -s )" in Linux) shatool="sha256sum" - sha256sum="6566836ddf3d72ca06685b34814e0c6fa0f0943542d651d0dab3150f10307c82" + sha256sum="763464859c7ef2ea3a0a10f4df40d2025d3bb9438fcb1228404640410c0ec22d" platform="linux" ;; Darwin) shatool="shasum -a 256" - sha256sum="2ee405c0e205d55666c60cc9c0d8d04c8ede06d3ef2e2c2aabe08fd81c17d22e" + sha256sum="6fa359f491fac7e5185273c6421a000eea6a2f0febf0ac03ac900bd4d80ed2a5" platform="mac" ;; *) diff --git a/.gitlab/ci/sccache.sh b/.gitlab/ci/sccache.sh index af24710406465b6871abc077afe7a6367e5893b1..c941ecdf8fd3586261af41f17d656aa083694ae5 100755 --- a/.gitlab/ci/sccache.sh +++ b/.gitlab/ci/sccache.sh @@ -2,43 +2,37 @@ set -e +readonly version="0.2.15-background-init" +readonly build_date="20210602.0" + case "$( uname -s )" in Linux) - version="0.2.13" shatool="sha256sum" - sha256sum="28a5499e340865b08b632306b435913beb590fbd7b49a3f887a623b459fabdeb" + sha256sum="34d62d30eae1a4145f00d62b01ad21c3456e28f11f8246c936b00cccf4855016" platform="x86_64-unknown-linux-musl" ;; Darwin) - version="gfe63078" shatool="shasum -a 256" - sha256sum="60a0302b1d7227f7ef56abd82266353f570d27c6e850c56c6448bf62def38888" - platform="x86_64-apple-darwin" + sha256sum="2fa396e98cc8d07e39429b187a77386db63d35409902251d462080bdd0087c22" + platform="universal-apple-darwin" ;; *) echo "Unrecognized platform $( uname -s )" exit 1 ;; esac -readonly version readonly shatool readonly sha256sum readonly platform -readonly filename="sccache-$version-$platform" -readonly tarball="$filename.tar.gz" +readonly filename="sccache-v$version-$platform" -if [ "$( uname -s )" = "Darwin" ]; then - url="https://paraview.org/files/dependencies" -else - url="https://github.com/mozilla/sccache/releases/download/$version" -fi -readonly url +readonly url="https://gitlab.kitware.com/api/v4/projects/6955/packages/generic/sccache/v$version-$build_date/" cd .gitlab -echo "$sha256sum $tarball" > sccache.sha256sum -curl -OL "$url/$tarball" +echo "$sha256sum $filename" > sccache.sha256sum +curl -OL "$url/$filename" $shatool --check sccache.sha256sum -tar xf "$tarball" -mv "$filename/sccache" . +mv "$filename" sccache +chmod +x sccache diff --git a/.gitlab/issue_templates/new-release.md b/.gitlab/issue_templates/new-release.md index 23022be0fa480514b30c96bc414921f2bcbd5142..dec45344e4e562dc29120f77040269b3a24c8531 100644 --- a/.gitlab/issue_templates/new-release.md +++ b/.gitlab/issue_templates/new-release.md @@ -14,50 +14,62 @@ Please remove this comment. # Preparatory steps - Update smtk guides - - Assemble release notes into `doc/release/notes/smtk-MAJOR.MINOR.md`. - - [ ] If `PATCH` is greater than 0, add items to the end of this file. - - [ ] Get positive review and merge. # Update smtk -Keep the relevant items for the kind of release this is. - -If making a first release candidate from master, i.e., `PATCH` is 0. - - - [ ] Update `master` branch for **smtk** -``` -git fetch origin -git checkout master -git merge --ff-only origin/master -``` - - [ ] Update `version.txt` and tag the commit -``` -git checkout -b update-to-vVERSION BRANCHPOINT -echo VERSION > version.txt -git commit -m 'Update version number to VERSION' version.txt -git tag -a -m 'SMTK VERSION' vVERSION HEAD -``` - + - Update the local copy of the base branch. + - If `PATCH` is 0, update `master` + - Otherwise, update `release` + - [ ] `git fetch origin` + - [ ] `git checkout $branch` + - [ ] `git merge --ff-only origin/$branch` + - If this fails, there are local commits that need to be removed + - Ensure that changes intended for the release are in it. + - The [`backport-mrs.py`][backport-mrs] script can be used to find and + ensure that merge requests assigned to the associated milestone are + available on the `release` branch. See its documentation for usage. - Integrate changes. - - Make a commit for each of these `release`-only changes - - [ ] Update `.gitlab/ci/cdash-groups.json` to track the `release` CDash groups + - Make a commit for each of these `release`-only changes on a single topic + (suggested branch name: `update-to-vVERSION`): + - Assemble release notes into `doc/release/notes/smtk-MAJOR.MINOR.md`. + - [ ] If `PATCH` is greater than 0, add items to the end of this file. + - [ ] Update `version.txt` and tag the commit (tag this commit below) + - [ ] `git checkout -b update-to-vVERSION BRANCHPOINT` + - [ ] `echo VERSION > version.txt` + - [ ] `git commit -m 'Update version number to VERSION' version.txt` + - [ ] Update `.gitlab/ci/cdash-groups.json` to track the `release` CDash + groups + - Create a merge request targeting `release` - - [ ] Obtain a GitLab API token for the `kwrobot.release.cmb` user (ask @ben.boeckel if you do not have one) - - [ ] Add the `kwrobot.release.cmb` user to your fork with at least `Developer` privileges (so it can open MRs) - - [ ] Use [the `release-mr`][release-mr] script to open the create the Merge Request (see script for usage) - - Pull the script for each release; it may have been updated since it was last used + - [ ] Obtain a GitLab API token for the `kwrobot.release.cmb` user (ask + @ben.boeckel if you do not have one) + - [ ] Add the `kwrobot.release.cmb` user to your fork with at least + `Developer` privileges (so it can open MRs) + - [ ] Use [the `release-mr`][release-mr] script to open the create the + Merge Request (see script for usage) + - Pull the script for each release; it may have been updated since it + was last used + - The script outputs the information it will be using to create the + merge request. Please verify that it is all correct before creating + the merge request. See usage at the top of the script to provide + information that is either missing or incorrect (e.g., if its data + extraction heuristics fail). - [ ] Get positive review - [ ] `Do: merge` - [ ] Push the tag to the main repository + - [ ] `git tag -a -m 'SMTK VERSION' vVERSION commit-that-updated-version.txt` - [ ] `git push origin vVERSION` - Software process updates (these can all be done independently) - [ ] Update kwrobot with the new `release` branch rules (@ben.boeckel) - [ ] Run [this script][cdash-update-groups] to update the CDash groups - - This must be done after a nightly run to ensure all builds are in the `release` group + - This must be done after a nightly run to ensure all builds are in the + `release` group - See the script itself for usage documentation - - [ ] Add (or update if `PATCH` is greater than 0) version selection entry in cmb-superbuild + - [ ] Add (or update if `PATCH` is greater than 0) version selection entry + in cmb-superbuild +[backport-mrs]: https://gitlab.kitware.com/utils/release-utils/-/blob/master/backport-mrs.py [release-mr]: https://gitlab.kitware.com/utils/release-utils/-/blob/master/release-mr.py [cdash-update-groups]: https://gitlab.kitware.com/utils/cdash-utils/-/blob/master/cdash-update-groups.py diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index df9000f454b0195dcceae0dc579359dc856c5658..ad137a44e71c457acb8bab33b6a4d06f8b193d28 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -5,7 +5,7 @@ ### Fedora .fedora33: - image: "kitware/cmb:ci-smtk-fedora33-20210420" + image: "kitware/cmb:ci-smtk-fedora33-20210714" variables: GIT_SUBMODULE_STRATEGY: recursive @@ -65,25 +65,18 @@ .fedora33_vtk_python3: extends: .fedora33 - image: "kitware/cmb:ci-smtk-fedora33-vtk-20210420" + image: "kitware/cmb:ci-smtk-fedora33-vtk-20210714" variables: CMAKE_CONFIGURATION: fedora33_vtk_python3 .fedora33_paraview: extends: .fedora33_vtk_python3 - image: "kitware/cmb:ci-smtk-fedora33-paraview-20210420" + image: "kitware/cmb:ci-smtk-fedora33-paraview-20210714" variables: CMAKE_CONFIGURATION: fedora33_paraview -.fedora33_vtk_python2: - extends: .fedora33 - image: "kitware/cmb:ci-smtk-fedora33-vtk-python2-20210420" - - variables: - CMAKE_CONFIGURATION: fedora33_vtk_python2 - ## Tags .linux_builder_tags: @@ -126,21 +119,7 @@ - sccache --start-server - sccache --show-stats - "$LAUNCHER ctest -V -S .gitlab/ci/ctest_configure.cmake" - - "$LAUNCHER ctest -V -S .gitlab/ci/ctest_build.cmake" - - sccache --show-stats - interruptible: true - -.cmake_build_linux_tidy: - stage: build - - script: - - *before_script_linux - - dnf install -y --setopt=install_weak_deps=False clang-tools-extra - - .gitlab/ci/sccache.sh - - sccache --start-server - - sccache --show-stats - - "$LAUNCHER ctest -V -S .gitlab/ci/ctest_configure.cmake" - - "$LAUNCHER ctest -V -S .gitlab/ci/ctest_build.cmake" + - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_build.cmake" - sccache --show-stats interruptible: true diff --git a/.gitlab/os-macos.yml b/.gitlab/os-macos.yml index 6b33c6dd22de52ab5db9646d3ce47a1713de8489..7cb8f5030c6d3fef5e2cf94e216f51adad2a42bc 100644 --- a/.gitlab/os-macos.yml +++ b/.gitlab/os-macos.yml @@ -8,7 +8,7 @@ GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmb-ci-ext/$CI_CONCURRENT_ID" # TODO: Factor this out so that each job selects the Xcode version to # use so that different versions can be tested in a single pipeline. - DEVELOPER_DIR: "/Applications/Xcode-11.5.app/Contents/Developer" + DEVELOPER_DIR: "/Applications/Xcode-12.4.app/Contents/Developer" # Avoid conflicting with other projects running on the same machine. SCCACHE_SERVER_PORT: 4231 @@ -25,11 +25,18 @@ # could run at the same time, so we drop it. GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmb-ci" -.macos_plain: +.macos_arm64: extends: .macos_build variables: - CMAKE_CONFIGURATION: macos_plain + CMAKE_CONFIGURATION: macos_arm64 + CTEST_NO_WARNINGS_ALLOWED: 1 + +.macos_x86_64: + extends: .macos_build + + variables: + CMAKE_CONFIGURATION: macos_x86_64 CTEST_NO_WARNINGS_ALLOWED: 1 ## Tags @@ -39,7 +46,15 @@ - cmb - macos - shell - - xcode-11.5 + - xcode-12.4 + - nonconcurrent + +.macos_arm64_builder_tags: + tags: + - cmb + - macos-arm64 + - shell + - xcode-12.4 - nonconcurrent ## macOS-specific scripts diff --git a/.readthedocs.yml b/.readthedocs.yml index 561e9075c1c34d0d19d617b8d4378d65761fc65c..39595f77e02f7639b5e2e7641779ed4e46489452 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,6 +1,7 @@ version: 2 -formats: all +formats: + - htmlzip python: version: 3.7 diff --git a/CMake/CTestCustom.cmake.in b/CMake/CTestCustom.cmake.in index c229655d1c5580a10ded5c6f506dfb2a271a8c2c..a2ad18fc406e47269b39bdb7720ea8d213835199 100644 --- a/CMake/CTestCustom.cmake.in +++ b/CMake/CTestCustom.cmake.in @@ -16,6 +16,29 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION # Ignore warnings from CMake autogen code "autogen" + + # ParaView generated code (paraview/paraview!4957) + "AutoStartImplementation.*modernize-use-nullptr" + "pqSMTKAutoStart.*Implementation.*modernize-use-nullptr" + # Fixes from paraview/paraview!5058 + "_server_manager\\.h.*misc-definitions-in-headers" + "_server_manager\\.h.*modernize-use-emplace" + "_server_manager_modules\\.h.*misc-definitions-in-headers" + "_server_manager_modules\\.h.*modernize-use-emplace" + "_client_server\\.h.*misc-definitions-in-headers" + "_qch\\.h.*modernize-deprecated-headers" + "_qch\\.h.*misc-definitions-in-headers" + "_server_manager_modules_data\\.h.*misc-definitions-in-headers" + "_server_manager_modules_data\\.h.*modernize-deprecated-headers" + "_server_manager_data\\.h.*misc-definitions-in-headers" + "_server_manager_data\\.h.*modernize-deprecated-headers" + "note: make as 'inline'" + + # CMake-generated sources. (cmake/cmake!6352) + "UnitTests_smtk_" + + # Warnings from the delaunay submodule. + "thirdparty/delaunay" ) ##------------------------------------------------------------------------------ @@ -35,5 +58,8 @@ if(@SMTK_COVERAGE_ENABLED@) "qt" "autogen" "CMakeFiles" + + # ParaView-generated sources. + "plugin/.*Plugin\.h" ) endif() diff --git a/CMake/InitializePlugins.cxx.in b/CMake/InitializePlugins.cxx.in deleted file mode 100644 index c86e9c30e66f16e19b1565504c37089d6a99b346..0000000000000000000000000000000000000000 --- a/CMake/InitializePlugins.cxx.in +++ /dev/null @@ -1,83 +0,0 @@ -//========================================================================= -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//========================================================================= - -#include "Initialize@PLUGIN_LIBRARY_TARGET@.h" - -#include "vtkPVPlugin.h" -#include "vtkPVPluginLoader.h" - -#include "vtkPVPluginTracker.h" - -#include - -@SMTK_PLUGIN_IMPORT_INIT@ - -namespace -{ -bool queryPlugins(const char* name, bool load); - -bool loadPlugins(const char* name) -{ - return queryPlugins(name, true); -} - -bool searchPlugins(const char* name) -{ - return queryPlugins(name, false); -} -} - -namespace smtk -{ -namespace extension -{ -namespace paraview -{ -void initialize@PLUGIN_LIBRARY_TARGET@() -{ - vtkPVPluginLoader::RegisterLoadPluginCallback(loadPlugins); - vtkPVPluginTracker::SetStaticPluginSearchFunction(searchPlugins); -} - -void load@PLUGIN_LIBRARY_TARGET@() -{ -@SMTK_PLUGIN_IMPORT@ -} -} -} -} - -namespace -{ -bool queryPlugins(const char* name, bool load) -{ - std::string sname = name; - -#define queryPlugin(plugin_name) \ - if (sname == #plugin_name) \ - { \ - if (load) \ - { \ - static bool loaded = false; \ - if (!loaded) \ - { \ - loaded = PV_PLUGIN_IMPORT(plugin_name); \ - } \ - } \ - return true; \ - } - -@SMTK_PLUGIN_QUERY@ - -#undef queryPlugin - - return false; -} -} diff --git a/CMake/SMTKInstallCMakePackage.cmake b/CMake/SMTKInstallCMakePackage.cmake index 4b0d7b2a16aa7dbacfc6b191e637e198f58d9abf..e460c1150a505d3ad271dea3494c484516507bf1 100644 --- a/CMake/SMTKInstallCMakePackage.cmake +++ b/CMake/SMTKInstallCMakePackage.cmake @@ -41,7 +41,8 @@ set(smtk_cmake_module_files SMTKMacros.cmake SMTKOperationXML.cmake SMTKPluginMacros.cmake - serverSource.cxx.in) + pqSMTKAutoStart.h.in + pqSMTKAutoStart.cxx.in) set(smtk_cmake_files_to_install "${prefix_file}") diff --git a/CMake/SMTKPVTestingMacros.cmake b/CMake/SMTKPVTestingMacros.cmake index d3c33d2b61c6632dac5ae9543668a24de75dfeea..957106e0584cfc39d8b379a5ca3a5d5a1a5d25a4 100644 --- a/CMake/SMTKPVTestingMacros.cmake +++ b/CMake/SMTKPVTestingMacros.cmake @@ -1,7 +1,7 @@ function (_smtk_paraview_add_tests test_function) _paraview_add_tests("${test_function}" LOAD_PLUGINS smtkPQComponentsPlugin - PLUGIN_PATHS $ ${ARGN}) endfunction () diff --git a/CMake/SMTKPluginMacros.cmake b/CMake/SMTKPluginMacros.cmake index 75362aa2c27f3a93dde53700928aec62b2467e58..697bd37a6509fefe0b695636312758481aa131a0 100644 --- a/CMake/SMTKPluginMacros.cmake +++ b/CMake/SMTKPluginMacros.cmake @@ -41,8 +41,9 @@ function (smtk_add_plugin name) string(TOLOWER "${_smtk_plugin__SKIP_DEPENDENCIES}" _smtk_plugin__SKIP_DEPENDENCIES) + set(_smtk_plugin_interfaces "") set(_smtk_plugin_sources "") - string(REPLACE ";" ", " _smtk_plugin_managers "${_smtk_plugin_MANAGERS}") + string(REPLACE ";" "\n , " _smtk_plugin_managers "${_smtk_plugin_MANAGERS}") if (DEFINED _smtk_plugin_REGISTRAR) if (NOT DEFINED _smtk_plugin_REGISTRAR_HEADER) @@ -50,26 +51,53 @@ function (smtk_add_plugin name) set(_smtk_plugin_REGISTRAR_HEADER "${_smtk_plugin_header_path}.h") endif () + set(_smtk_plugin_autostart_name "${_smtk_plugin_name}") configure_file( - "${_smtk_cmake_dir}/serverSource.cxx.in" - "${CMAKE_CURRENT_BINARY_DIR}/serverSource.cxx" + "${_smtk_cmake_dir}/pqSMTKAutoStart.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/pqSMTKAutoStart${_smtk_plugin_autostart_name}.h" @ONLY) - list(APPEND _smtk_plugin_sources "${CMAKE_CURRENT_BINARY_DIR}/serverSource.cxx") + configure_file( + "${_smtk_cmake_dir}/pqSMTKAutoStart.cxx.in" + "${CMAKE_CURRENT_BINARY_DIR}/pqSMTKAutoStart${_smtk_plugin_autostart_name}.cxx" + @ONLY) + paraview_plugin_add_auto_start( + CLASS_NAME "pqSMTKAutoStart${_smtk_plugin_autostart_name}" + INTERFACES _smtk_plugin_autostart_interface + SOURCES _smtk_plugin_autostart_sources) + list(APPEND _smtk_plugin_interfaces + ${_smtk_plugin_autostart_interface}) + list(APPEND _smtk_plugin_sources + "${CMAKE_CURRENT_BINARY_DIR}/pqSMTKAutoStart${_smtk_plugin_autostart_name}.h" + "${CMAKE_CURRENT_BINARY_DIR}/pqSMTKAutoStart${_smtk_plugin_autostart_name}.cxx" + ${_smtk_plugin_autostart_sources}) endif () if (DEFINED _smtk_plugin_REGISTRARS) # Additional registrars, must have a unique generated filename. - foreach(_smtk_plugin_REGISTRAR ${_smtk_plugin_REGISTRARS}) + foreach (_smtk_plugin_REGISTRAR IN LISTS _smtk_plugin_REGISTRARS) string(REPLACE "::" "/" _smtk_plugin_header_path "${_smtk_plugin_REGISTRAR}") string(REPLACE "::" "_" _smtk_plugin_header_name "${_smtk_plugin_REGISTRAR}") set(_smtk_plugin_REGISTRAR_HEADER "${_smtk_plugin_header_path}.h") - set(_smtk_plugin_filename "${CMAKE_CURRENT_BINARY_DIR}/serverSource_${_smtk_plugin_header_name}.cxx") + set(_smtk_plugin_autostart_name "${_smtk_plugin_header_name}") + configure_file( + "${_smtk_cmake_dir}/pqSMTKAutoStart.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/pqSMTKAutoStart${_smtk_plugin_autostart_name}.h" + @ONLY) configure_file( - "${_smtk_cmake_dir}/serverSource.cxx.in" - "${_smtk_plugin_filename}" + "${_smtk_cmake_dir}/pqSMTKAutoStart.cxx.in" + "${CMAKE_CURRENT_BINARY_DIR}/pqSMTKAutoStart${_smtk_plugin_autostart_name}.cxx" @ONLY) - list(APPEND _smtk_plugin_sources "${_smtk_plugin_filename}") - endforeach(_smtk_plugin_REGISTRAR) + paraview_plugin_add_auto_start( + CLASS_NAME "pqSMTKAutoStart${_smtk_plugin_autostart_name}" + INTERFACES _smtk_plugin_autostart_interface + SOURCES _smtk_plugin_autostart_sources) + list(APPEND _smtk_plugin_interfaces + ${_smtk_plugin_autostart_interface}) + list(APPEND _smtk_plugin_sources + "${CMAKE_CURRENT_BINARY_DIR}/pqSMTKAutoStart${_smtk_plugin_autostart_name}.h" + "${CMAKE_CURRENT_BINARY_DIR}/pqSMTKAutoStart${_smtk_plugin_autostart_name}.cxx" + ${_smtk_plugin_autostart_sources}) + endforeach () endif () # FIXME: This shouldn't really be necessary. Instead, SMTK should have its @@ -78,6 +106,7 @@ function (smtk_add_plugin name) # as well. paraview_add_plugin("${_smtk_plugin_name}" SOURCES ${_smtk_plugin_sources} + UI_INTERFACES ${_smtk_plugin_interfaces} ${_smtk_plugin_PARAVIEW_PLUGIN_ARGS}) target_link_libraries("${_smtk_plugin_name}" PRIVATE diff --git a/CMake/SMTKSanitize.cmake b/CMake/SMTKSanitize.cmake index f5b9be45da29c5d6da34e4e4949984e16f603e74..32a0681f20a276f92e5d19e564a0267cfc0931e6 100644 --- a/CMake/SMTKSanitize.cmake +++ b/CMake/SMTKSanitize.cmake @@ -32,3 +32,29 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=${SMTK_SANITIZER}") endif() endif() + +function (smtk_test_apply_sanitizer) + # Do nothing if we're not building under a sanitizer. + if (NOT SMTK_ENABLE_SANITIZER OR NOT SMTK_SANITIZER STREQUAL "address") + return () + endif () + + # Bail on non-Unix or macOS. + if (NOT UNIX OR APPLE) + return () + endif () + + find_library(LIBASAN_LIBRARY NAMES asan libasan.so.6 libasan.so.5) + mark_as_advanced(LIBASAN_LIBRARY) + + # Bail if we can't find `libasan`. + if (NOT LIBASAN_LIBRARY) + return () + endif () + + set_property(TEST ${ARGN} APPEND + PROPERTY + # XXX(cmake-3.22): use `ENVIRONMENT_MODIFICATION`. + # ENVIRONMENT_MODIFICATION "LD_PRELOAD=path_list_prepend:${LIBASAN_LIBRARY}") + ENVIRONMENT "LD_PRELOAD=${LIBASAN_LIBRARY}") +endfunction () diff --git a/CMake/SMTKTestingMacros.cmake b/CMake/SMTKTestingMacros.cmake index f05157a21959a2ea629ef53d61caf67418c03d5c..d239783d6c9e56fb474c8ed292c4e2a63a979059 100644 --- a/CMake/SMTKTestingMacros.cmake +++ b/CMake/SMTKTestingMacros.cmake @@ -58,7 +58,7 @@ function(smtk_unit_tests) ) set_tests_properties(${tname} PROPERTIES TIMEOUT 120) if(SMTK_ut_LABEL) - set_tests_properties(${tname} PROPERTIES LABELS ${SMTK_ut_LABEL}) + set_tests_properties(${tname} PROPERTIES LABELS "${SMTK_ut_LABEL}") endif() endforeach(test) @@ -130,7 +130,7 @@ function(smtk_build_failure_tests) ) set_tests_properties(${tname} PROPERTIES TIMEOUT 120 WILL_FAIL TRUE) if(SMTK_ut_LABEL) - set_tests_properties(${tname} PROPERTIES LABELS ${SMTK_ut_LABEL}) + set_tests_properties(${tname} PROPERTIES LABELS "${SMTK_ut_LABEL}") endif() endforeach() # attempt endforeach() # source_idx diff --git a/CMake/plugins.xml.in b/CMake/plugins.xml.in deleted file mode 100644 index 00f51f3ae60188838889a78f6b8d7bffa3c09930..0000000000000000000000000000000000000000 --- a/CMake/plugins.xml.in +++ /dev/null @@ -1,4 +0,0 @@ - - - @SMTK_PLUGINS_FILE_CONTENTS@ - diff --git a/CMake/pqSMTKAutoStart.cxx.in b/CMake/pqSMTKAutoStart.cxx.in new file mode 100644 index 0000000000000000000000000000000000000000..7879437ca1e900d8ce2a882e2ba801e44b13bfa8 --- /dev/null +++ b/CMake/pqSMTKAutoStart.cxx.in @@ -0,0 +1,40 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#include "pqSMTKAutoStart@_smtk_plugin_autostart_name@.h" + +#include "@_smtk_plugin_REGISTRAR_HEADER@" + +#include "smtk/plugin/Client.txx" + +#include + +pqSMTKAutoStart@_smtk_plugin_autostart_name@::pqSMTKAutoStart@_smtk_plugin_autostart_name@(QObject* parent) + : QObject(parent) +{ +} + +pqSMTKAutoStart@_smtk_plugin_autostart_name@::~pqSMTKAutoStart@_smtk_plugin_autostart_name@() = default; + +typedef smtk::plugin::Client<@_smtk_plugin_REGISTRAR@ + , @_smtk_plugin_managers@ + > Client; + +static std::shared_ptr myClient; + +void pqSMTKAutoStart@_smtk_plugin_autostart_name@::startup() +{ + myClient = std::dynamic_pointer_cast(Client::create()); +} + +void pqSMTKAutoStart@_smtk_plugin_autostart_name@::shutdown() +{ + myClient = nullptr; +} diff --git a/CMake/pqSMTKAutoStart.h.in b/CMake/pqSMTKAutoStart.h.in new file mode 100644 index 0000000000000000000000000000000000000000..4a5f13b4d02087134dcfd51e2f9557ab05fd8f14 --- /dev/null +++ b/CMake/pqSMTKAutoStart.h.in @@ -0,0 +1,30 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#ifndef pqSMTKAutoStart@_smtk_plugin_autostart_name@_h +#define pqSMTKAutoStart@_smtk_plugin_autostart_name@_h + +#include + +class pqSMTKAutoStart@_smtk_plugin_autostart_name@ : public QObject +{ + Q_OBJECT + typedef QObject Superclass; + Q_DISABLE_COPY(pqSMTKAutoStart@_smtk_plugin_autostart_name@) + +public: + pqSMTKAutoStart@_smtk_plugin_autostart_name@(QObject* parent = nullptr); + ~pqSMTKAutoStart@_smtk_plugin_autostart_name@() override; + + void startup(); + void shutdown(); +}; + +#endif diff --git a/CMake/serverSource.cxx.in b/CMake/serverSource.cxx.in deleted file mode 100644 index 107617e644c6a727fafc814f160441ca6567cb4e..0000000000000000000000000000000000000000 --- a/CMake/serverSource.cxx.in +++ /dev/null @@ -1,26 +0,0 @@ -/// Generated file. Do not edit. - -//========================================================================= -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//========================================================================= - -#include "@_smtk_plugin_REGISTRAR_HEADER@" - -#include "smtk/plugin/Client.txx" - -#include "vtkNew.h" -#include "vtkPVPluginLoader.h" - -#include - -typedef smtk::plugin::Client<@_smtk_plugin_REGISTRAR@, @_smtk_plugin_managers@> - @_smtk_plugin_name@Client; - -static std::shared_ptr<@_smtk_plugin_name@Client> my@_smtk_plugin_name@Client = - std::dynamic_pointer_cast<@_smtk_plugin_name@Client>(@_smtk_plugin_name@Client::create()); diff --git a/CMakeLists.txt b/CMakeLists.txt index 969999b894de22170377cb0245382cf11ec8a93f..587c1f83a7e1db0eca86f0150edee5a106c46231 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -403,6 +403,11 @@ if(SMTK_ENABLE_PYTHON_WRAPPING) set_property(CACHE SMTK_PYTHON_VERSION PROPERTY STRINGS "2;3") + if (SMTK_PYTHON_VERSION STREQUAL "2") + message(DEPRECATION + "Python2 support is deprecated and will be removed in a future release. " + "Please migrate to a supported version of Python.") + endif () if (SMTK_ENABLE_VTK_SUPPORT OR SMTK_ENABLE_PARAVIEW_SUPPORT) if (NOT SMTK_PYTHON_VERSION STREQUAL VTK_PYTHON_VERSION) message(FATAL_ERROR @@ -504,24 +509,6 @@ if(SMTK_ENABLE_PYTHON_WRAPPING) set(smtk_python_test_environment "PYTHONPATH=${smtk_pythonpath_env}") - if (SMTK_ENABLE_SANITIZER) - set(preload_libraries) - if (SMTK_SANITIZER MATCHES "address") - find_library(SMTK_ASAN_LIBRARY NAMES libasan.so.5 DOC "ASan library") - mark_as_advanced(SMTK_ASAN_LIBRARY) - - list(APPEND preload_libraries - "${SMTK_ASAN_LIBRARY}") - endif () - - if (preload_libraries) - if (UNIX AND NOT APPLE) - list(APPEND smtk_python_test_environment - "LD_PRELOAD=${preload_libraries}") - endif () - endif () - endif () - if (libpath_envvar AND smtk_libpath_env) list(APPEND smtk_python_test_environment "${libpath_envvar}=${smtk_libpath_env}") @@ -538,6 +525,7 @@ if(SMTK_ENABLE_PYTHON_WRAPPING) set_tests_properties("${name}" PROPERTIES ENVIRONMENT "${smtk_python_test_environment}") + smtk_test_apply_sanitizer("${name}") endfunction () endif() endif() @@ -594,32 +582,6 @@ install (FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}/Options.h DESTINATION include/${PROJECT_NAME}/${SMTK_VERSION}/smtk) -################################################################################ -# Install Related Settings -################################################################################ - -# Copy file needed by SMTKPluginMacros.cmake into the build directory so -# consuming projects can build against SMTK's build tree -configure_file( - ${PROJECT_SOURCE_DIR}/CMake/serverSource.cxx.in - ${PROJECT_BINARY_DIR}/serverSource.cxx.in - COPYONLY) - -# Install rules for SMTK macros usable by external packages: -install( - FILES - ${PROJECT_SOURCE_DIR}/CMake/SMTKMacros.cmake - ${PROJECT_SOURCE_DIR}/CMake/EncodeStringFunctions.cmake - ${PROJECT_SOURCE_DIR}/CMake/InitializePlugins.cxx.in - ${PROJECT_SOURCE_DIR}/CMake/InitializePlugins.h.in - ${PROJECT_SOURCE_DIR}/CMake/plugins.xml.in - ${PROJECT_SOURCE_DIR}/CMake/SMTKOperationXML.cmake - ${PROJECT_SOURCE_DIR}/CMake/SMTKPluginMacros.cmake - ${PROJECT_SOURCE_DIR}/CMake/serverSource.cxx.in - DESTINATION - ${SMTK_INSTALL_CONFIG_DIR} -) - ################################################################################ # Include Dirs Settings ################################################################################ diff --git a/CTestConfig.cmake b/CTestConfig.cmake index f44a82eda3a0366e756bff228a799a7011e5abd9..1dcdb9b5fdb82ce8f5fdbe44f0cb17f138139d6a 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -7,7 +7,8 @@ set(CTEST_PROJECT_NAME "SuperBuild-ConceptualModelBuilder") set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set(drop_sites kitware) +#set(drop_sites kitware) +set(drop_sites) set(CTEST_DROP_METHOD_kitware "https") set(CTEST_DROP_SITE_kitware "www.kitware.com/CDash") diff --git a/ReadMe.md b/ReadMe.md index 0928744fcf9cff4498bfc93f59e99e5bd1f71520..5383954b5ce076e0558d8b46bd089748f2abb8e1 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -62,7 +62,7 @@ See [CONTRIBUTING.md][] for instructions to contribute. Latest Release Notes ==================== -Can be found [here](doc/release/smtk-3.3.md). +Can be found [here](doc/release/smtk-21.05.rst). License ======= diff --git a/applications/ModelViewer/CMakeLists.txt b/applications/ModelViewer/CMakeLists.txt index 026a662b9eafa7e050902132233ead566ebb95fb..faeac2dc81b72ef37765f35c210f76d3c9fa4e77 100644 --- a/applications/ModelViewer/CMakeLists.txt +++ b/applications/ModelViewer/CMakeLists.txt @@ -264,14 +264,13 @@ install(CODE if (match) set(add_to_list ON) if (ignore_items) - if (\${conflicting_dep} NOT IN_LIST ignore_items) - set(add_to_list OFF) - endif() - endif() - if (add_to_list) + if (\${conflicting_dep} NOT IN_LIST ignore_items) + set(add_to_list OFF) + endif() + endif() + if (add_to_list) list(GET conflicting_deps_\${conflicting_dep} 0 dep) list(APPEND conflicting_deps \${dep}) - endif() endif() endif() endforeach() diff --git a/applications/ModelViewer/main.cxx b/applications/ModelViewer/main.cxx index 340ff7261151ae312575393ec22354c8953c5747..3caa6a49b22513d51e008de789b23fc55dad586a 100644 --- a/applications/ModelViewer/main.cxx +++ b/applications/ModelViewer/main.cxx @@ -36,6 +36,8 @@ #include "smtk/operation/Manager.h" +#include "smtk/plugin/Registry.h" + #include #include #include @@ -67,26 +69,15 @@ int main(int argc, char* argv[]) // Create a resource manager smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); - // Register mesh resources to the resource manager - { - smtk::session::mesh::Registrar::registerTo(resourceManager); - } - // Create an operation manager smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); - // Register mesh operators to the operation manager - { - smtk::session::mesh::Registrar::registerTo(operationManager); - } - // Create a geometry manager smtk::geometry::Manager::Ptr geometryManager = smtk::geometry::Manager::create(); - // Register mesh geometry to the geometry manager - { - smtk::session::mesh::Registrar::registerTo(geometryManager); - } + // Register mesh resources to the resource, operation, and geomety managers. + auto registry = smtk::plugin::addToManagers( + resourceManager, operationManager, geometryManager); // Register the resource manager to the operation manager (newly created // resources will be automatically registered to the resource manager). diff --git a/data/attribute/attribute_collection/attributeViewExample.sbt b/data/attribute/attribute_collection/attributeViewExample.sbt new file mode 100644 index 0000000000000000000000000000000000000000..83db9c87afde9ddf3a49d62ac91013b283bd4743 --- /dev/null +++ b/data/attribute/attribute_collection/attributeViewExample.sbt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38dedbf7c79e8a2e35b74db719437cbd5e2d5a087ca60617948416908863ccc1 +size 838 diff --git a/data/attribute/attribute_collection/emptyGroupItemExample.sbt b/data/attribute/attribute_collection/emptyGroupItemExample.sbt new file mode 100644 index 0000000000000000000000000000000000000000..55c36e757c8b027cd7747bc361dbf6c141b0c042 --- /dev/null +++ b/data/attribute/attribute_collection/emptyGroupItemExample.sbt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:176f76ba094b878ac0e027a2fcfe71cff66899285cd3754009e811517ae15c66 +size 1224 diff --git a/data/baseline/smtk/discrete/createedges-SimpleBox.png b/data/baseline/smtk/discrete/createedges-SimpleBox.png deleted file mode 100644 index b94e763284234764a998aacd8d91d4a65abceab4..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/createedges-SimpleBox.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7b82e97f8bb02470f809f3e9fc7402722a4811701e49ae7bb9131aea3a762ca1 -size 11170 diff --git a/data/baseline/smtk/discrete/createedges-hybridModelOneCube.png b/data/baseline/smtk/discrete/createedges-hybridModelOneCube.png deleted file mode 100644 index 6d55e036c765649fe6ce697e68bf666cb61547b4..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/createedges-hybridModelOneCube.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:05a84647b48e465588479e8bbc06c904bc6f1e773377ba1c6cf3001489c4945c -size 2188 diff --git a/data/baseline/smtk/discrete/edge-split-test2D.png b/data/baseline/smtk/discrete/edge-split-test2D.png deleted file mode 100644 index 2f602232bed5216a2b47cb0c5aa4646d7f1b8edb..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/edge-split-test2D.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7d91aabff49c48a07cd99206e5535b792e70eece4615158c8ea2fa0174a004a5 -size 1958 diff --git a/data/baseline/smtk/discrete/edgeOp2dm.png b/data/baseline/smtk/discrete/edgeOp2dm.png deleted file mode 100644 index ea99edea8febcd52df08e75d06ff0086fef21060..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/edgeOp2dm.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a50f5eea8368afefeaa2b2057f66639009a358e05c6ece99550202eacdf47d31 -size 10112 diff --git a/data/baseline/smtk/discrete/edgeOp2dm_1.png b/data/baseline/smtk/discrete/edgeOp2dm_1.png deleted file mode 100644 index 3043bc0fb4169eba7c6d1b92e6d9bb2a73e29084..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/edgeOp2dm_1.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:75bd5d0a683c98331f79c4819165367884b3c70b454abcc0dc62bac9a2d0182a -size 9209 diff --git a/data/baseline/smtk/discrete/edgeOp2dm_2.png b/data/baseline/smtk/discrete/edgeOp2dm_2.png deleted file mode 100644 index 623b73cf9b3938ac872eedaf324dc6355a939aee..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/edgeOp2dm_2.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b8aba55ac754354b1c4c0a635fba8786724817c7eb5346ff428c1c7b5e1c5cd7 -size 38215 diff --git a/data/baseline/smtk/discrete/edgeOp2dm_3.png b/data/baseline/smtk/discrete/edgeOp2dm_3.png deleted file mode 100644 index ce6a82052c5423a62b9e4e918850269f581ceae9..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/edgeOp2dm_3.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:140e33692731c609649ffd86178ede7715ea6d00a329f3d89a0c82ca35211500 -size 38193 diff --git a/data/baseline/smtk/discrete/hybridModelOneCube.png b/data/baseline/smtk/discrete/hybridModelOneCube.png deleted file mode 100644 index b93ef891add87b3b6ecbf1de87752a5d9fee3922..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/hybridModelOneCube.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0d02d13a20d5bbfe70ea7dd93efd8b5f77a90f216c56aad8a364c05eb1077814 -size 1865 diff --git a/data/baseline/smtk/discrete/import2dm.png b/data/baseline/smtk/discrete/import2dm.png deleted file mode 100644 index 434115cfc03b77d76c3b7de246f7410c0db5027d..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/import2dm.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:44eeaeb3814db9a0cabd06a95db5cd3a3cf4c44faf2d98703bdeda4a9dc1eee7 -size 9964 diff --git a/data/baseline/smtk/discrete/import2dm_1.png b/data/baseline/smtk/discrete/import2dm_1.png deleted file mode 100644 index cddae1c6a3417bc90124dad79d28a66cef74e160..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/import2dm_1.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e92ed67ffa57514d97011c8d231a8bb7d678d95b01a5f323a20faccd4adde0bd -size 39085 diff --git a/data/baseline/smtk/discrete/import2dm_2.png b/data/baseline/smtk/discrete/import2dm_2.png deleted file mode 100644 index 00b79ea21ef23f01e165a834590460ed7ce1a511..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/import2dm_2.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:877270a81106a9bf402925fa3c672a9e479465d89d60e61013b8e3fb213223a2 -size 37271 diff --git a/data/baseline/smtk/discrete/pmdc.png b/data/baseline/smtk/discrete/pmdc.png deleted file mode 100644 index e208d5725ab4b91e2c596e889d232e046200d145..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/pmdc.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:12bc6bf453481cd42f54404f408e8340d649f79e2a6477763ff94b7664fdda07 -size 8199 diff --git a/data/baseline/smtk/discrete/smtkModelfrom2dm.png b/data/baseline/smtk/discrete/smtkModelfrom2dm.png deleted file mode 100644 index 2d6dc9dab8a1873ca6cd05082a1896b5de314ceb..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/smtkModelfrom2dm.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cdbae873b6b9e7c01766964642183c273767fcca9c153d6bb261a017c06b2e03 -size 9332 diff --git a/data/baseline/smtk/discrete/smtkModelfrom2dm_1.png b/data/baseline/smtk/discrete/smtkModelfrom2dm_1.png deleted file mode 100644 index e243ce24f36611a7dd8036a9213089e6eb317aa5..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/smtkModelfrom2dm_1.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:88891c0a9b3ed9b3e3c6f7dd5fb4def8f27a20822c6d735e1d4aa1bdf5aa29bb -size 37141 diff --git a/data/baseline/smtk/discrete/smtkModelfrom2dm_2.png b/data/baseline/smtk/discrete/smtkModelfrom2dm_2.png deleted file mode 100644 index 81c798ad641801173eb165f5446507dd744a3e96..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/smtkModelfrom2dm_2.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3feef7de810964b0bd76b5618a3e4a092d3b6ebdea8c5d78336002be30978c00 -size 38873 diff --git a/data/baseline/smtk/discrete/smtkModelfrom2dm_3.png b/data/baseline/smtk/discrete/smtkModelfrom2dm_3.png deleted file mode 100644 index 8fb223acd9d393826f626e7297ab365c773273d0..0000000000000000000000000000000000000000 --- a/data/baseline/smtk/discrete/smtkModelfrom2dm_3.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:454771220c3d193d875251db1092e0e829c31b89b9fbb9493c8a1c95c3729731 -size 9274 diff --git a/data/baseline/smtk/vtk/test2D-with-colors_1.png b/data/baseline/smtk/vtk/test2D-with-colors_1.png new file mode 100644 index 0000000000000000000000000000000000000000..ae035f43a69972e04b15c34d7fba1279768ba64b --- /dev/null +++ b/data/baseline/smtk/vtk/test2D-with-colors_1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f5c4b39b5c0175b394142f73cb1f4ffd875ba4b630c2ce1a834560897ed584e3 +size 1178 diff --git a/data/model/3d/cmb/simplebox.cmb b/data/model/3d/cmb/simplebox.cmb deleted file mode 100644 index 73ecebbf31bf7d1715d725ec2b622bc816a35931..0000000000000000000000000000000000000000 --- a/data/model/3d/cmb/simplebox.cmb +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5b72a7123794bd9627db766a298002058dfa804b6a4a157fdb7486c86c0d4ab0 -size 42683 diff --git a/data/model/3d/cmb/smooth_surface.cmb b/data/model/3d/cmb/smooth_surface.cmb deleted file mode 100644 index 21b014ae2379063bd28a56596c5997b4a52f6616..0000000000000000000000000000000000000000 --- a/data/model/3d/cmb/smooth_surface.cmb +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f9dc6391c6f347cf7868528d3a59a14533ebbad3fc18d0946a8256cca85db7c4 -size 1652193 diff --git a/doc/conf.py b/doc/conf.py index 754eb561f8b3d71fd7b090894c7c071257be23a7..4042d9b2711e764fee69366a11deaed4cd79dd88 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -11,7 +11,7 @@ # # All configuration values have a default; values that are commented out # serve to show the default. -from __future__ import print_function + import sys import os @@ -161,9 +161,9 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'SMTK' +project = 'SMTK' year = datetime.datetime.now().year -copyright = u'%d, Kitware, Inc.' % year +copyright = '%d, Kitware, Inc.' % year def readVersionInfo(srcdir): @@ -314,7 +314,7 @@ else: # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". # html_title = None -html_title = u'SMTK: Simulation Modeling Tool Kit, v1.0' +html_title = 'SMTK: Simulation Modeling Tool Kit, v1.0' # A shorter title for the navigation bar. Default is the same as html_title. # html_short_title = None @@ -400,8 +400,8 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'SMTK.tex', u'SMTK Documentation', - u'Kitware, Inc.', 'manual'), + ('index', 'SMTK.tex', 'SMTK Documentation', + 'Kitware, Inc.', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -430,8 +430,8 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'smtk', u'SMTK Documentation', - [u'Kitware, Inc.'], 1) + ('index', 'smtk', 'SMTK Documentation', + ['Kitware, Inc.'], 1) ] # If true, show URL addresses after external links. @@ -444,8 +444,8 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'SMTK', u'SMTK Documentation', - u'Kitware, Inc.', 'SMTK', 'One line description of project.', + ('index', 'SMTK', 'SMTK Documentation', + 'Kitware, Inc.', 'SMTK', 'One line description of project.', 'Miscellaneous'), ] @@ -464,9 +464,9 @@ texinfo_documents = [ # -- Options for Epub output ---------------------------------------------- # Bibliographic Dublin Core info. -epub_title = u'SMTK: Simulation Modeling Tool Kit' -epub_author = u'Kitware, Inc.' -epub_publisher = u'Kitware, Inc.' +epub_title = 'SMTK: Simulation Modeling Tool Kit' +epub_author = 'Kitware, Inc.' +epub_publisher = 'Kitware, Inc.' epub_copyright = copyright # The basename for the epub file. It defaults to the project name. diff --git a/doc/release/notes/00-example.rst b/doc/release/notes/00-example.rst index f5a0602c61109fe87fc1fc0fe2873434e50ac045..2266da755f0e2724a07c40b36da321e43745b6c9 100644 --- a/doc/release/notes/00-example.rst +++ b/doc/release/notes/00-example.rst @@ -1,12 +1,12 @@ Example merge request note -========================== +-------------------------- Summarize the changes your merge request makes that are of interest to other developers. If your change will also affect users of SMTK-based applications, please consider splitting the note into two sections like so: Developer changes ------------------ +~~~~~~~~~~~~~~~~~~ Describe how your changes impact future developers. Remember this is for the release notes; @@ -18,7 +18,7 @@ it is not meant to describe internal changes but rather * changes to the build, test, installation, or packaging system. User-facing changes -------------------- +~~~~~~~~~~~~~~~~~~~ Describe changes to new and existing users of SMTK applications here. Do not assume users know obscure terminology or are already familiar with SMTK. diff --git a/doc/release/smtk-21.05.rst b/doc/release/smtk-21.05.rst index 88163dc452eac44cb1171eab453d773b91e1418c..e93039cf4a7f888e7abfa32b8858f29bf2e75e0c 100644 --- a/doc/release/smtk-21.05.rst +++ b/doc/release/smtk-21.05.rst @@ -1,9 +1,15 @@ +======================== SMTK 21.05 Release Notes -========= +======================== + +See also `SMTK 21.04 Release Notes`_ for previous changes. + +.. _`SMTK 21.04 Release Notes`: smtk-21.04.md + Changes to Project Subsystem ------- +============================= A major revision was undertaken to the ``smtk::project`` namespace that is not backward compatible. The previous Project class was hard-coded to a use single @@ -18,8 +24,10 @@ easier to implement custom project types for different solvers. More information is available in the SMTK user guide and there is also a new `create_a_project tutorial `_. +ParaView Related Changes +======================== ParaView-extension pipeline-creation changes ------ +-------------------------------------------- We have moved responsibility for creating pqSMTKResource proxies (which are ParaView pqPipelineSource subclasses) from consumers @@ -43,22 +51,24 @@ Finally, because resource proxies may be re-assigned a (different) SMTK resource, we monitor each proxy and update the lookup map as needed. External-facing changes -~~~~ +~~~~~~~~~~~~~~~~~~~~~~~ If you have code external to SMTK that invokes :cxx:`pqSMTKRenderResourceBehavior::instance()->createPipelineSource()`, you should eliminate it, but be aware that you cannot rely on the pipeline source being present or initialized at the time many observers are invoked. +Graph Resource Changes +====================== Graph-resource ArcMap ------- +--------------------- The graph resource now provides a custom subclass of TypeMap named smtk::graph::ArcMap. This subclass deletes the copy and assignment constructors to prevent modifications to accidental copies of arcs rather than to the resource's arc container. External changes -~~~~~~~~~ +~~~~~~~~~~~~~~~~ smtk::graph::ResourceBase::ArcSet type-alias was removed and the ArcMap class can now be used directly. @@ -67,8 +77,10 @@ If you maintain external code that depends on smtk::graph::Resource, you will need to replace the ResourceBase::ArcSet type-alias with ArcMap (which lives in smtk::graph not smtk::graph::ResourceBase). +Software Process Changes +======================== CMake package directory ------ +----------------------- The CMake package directory for SMTK is now in a location that CMake searches by default. This removes the need to do ``-Dsmtk_DIR`` and instead the install diff --git a/doc/release/smtk-21.07.rst b/doc/release/smtk-21.07.rst new file mode 100644 index 0000000000000000000000000000000000000000..a1bde93c3628e6b3325a0b897c2dc2c5d180ea42 --- /dev/null +++ b/doc/release/smtk-21.07.rst @@ -0,0 +1,256 @@ +========================= +SMTK 21.07 Release Notes +========================= + +See also `SMTK 21.05 Release Notes`_ for previous changes. + +.. _`SMTK 21.05 Release Notes`: smtk-21.05.md + +Registration Changes +==================== +Manager/registry tracking +------------------------- + +Tracking of registrations between registrars and managers should now only be +done through a held ``Registry`` instance as returned by the +``Registrar::addToManagers`` method. In the future, direct access to +``Registrar::registerTo`` and ``Registrar::unregisterFrom`` will be disabled +and the ``Registry`` RAII object will be the only way to manage registrations. +This ensures that registrations are accurately tracked. + +SMTK Resource and Component Changes +=================================== + +Expanding Default Property Types on SMTK Resources/Components +------------------------------------------------------------- +The default set of Properties now include int, bool, std::vector and std::vector. + +Attribute Resource Changes +========================== +Preserve State Information +-------------------------- + +SMTK will now preserve state information that pertains to +Attribute Resource views. The information persists even +after the resource has been closed, assuming the resource +was saved before it was closed. + +Information Preserved: + +- The active advance level. +- The active attributes in attribute views. +- The active tab in a group views. + +Fix isValid Check w/r to an Attribute's Associations +---------------------------------------------------- + +If an attribute had the following conditions: + +- Its association item set to have its NumberOfRequiredValues > 0 +- Its Resource had active categories +- All of its items where validity set with the exception of its association item + +Then its isValid() would mistakenly return true, due to the fact that its association item (which does not have categories set), would be excluded from the check. + +Now the association item is forced to be by turning off category checking for that item. By doing this, we are saying that if the attribute itself passes its category checks, then so does its association item. + +.. highlight::cpp + +.. highlight::cpp + +Added the ability to ignore an item +=================================== +There are times when a workflow may consider an item no longer relevant based on choices the user has made. In order model this behavior two methods have been added to Item: + +.. code-block:: c++ + + void setIsIgnored(bool val); + bool isIgnored() const; + + +If setIsIgnored is passed true, then the item's isRelevant() method will return false, regardless of any other facts. +This value is persistent and is supported in both JSON and XML formats. + +Changes to Attribute and Item isRelevant Methods +------------------------------------------------ + +Both Attribute::isRelevant and Item::isRelevant have been modified to optional do advance level checking. + +.. code-block:: c++ + + bool isRelevant(bool includeCategoryChecks = true, bool includeReadAccess = false, + int readAccessLevel = 0) const; + +If includeCategoryChecks is set to true, then the Attribute or Item must pass their category checks based on the +resource's Active Category Settings. + +If includeReadAccess is set to true then an Attribute is relevant iff at least one of it's children has a read access level <= readAccessLevel. + +In the case of an Item, if includeReadAccess is true then it must have it's read access level <= readAccessLevel + +Note that this modification does not require any code change in order to preserve previous functionality. + +Added hasRelevantChildren method to GroupItem +--------------------------------------------- +GroupItem now has a method to test if at least on of its children items passes their category checks and read access checks passed on the caller's requirements. + +.. code-block:: c++ + + bool hasRelevantChildren(bool includeCategoryChecks = true, bool includeReadAccess = false, + int readAccessLevel = 0) const; + +Changing ReferenceItem::AppendValue to Support Append Non-Unique +---------------------------------------------------------------- +* Added a nonUnique parameter that defaults to false +* This avoids unnecessarily having to scan the entire item when duplicates are allowed +* Item now also tracks the location of the first unset value in order to speed up the append process + +Model Resource Changes +====================== +Model resource transcription +---------------------------- + +SMTK now provides a way to avoid an O(n^2) performance +issue when embedding many cells into a model; +previously, each insertion would perform a linear search +of pre-existing relationships. However, many operations +(especially those in the importer group) will not attempt +to re-insert existing relationships. The ``Model::addCell()`` +and ``EntityRefArrangementOps::addSimpleRelationship()`` +methods now accept a boolean indicating whether to bypass +the linear-time check. + +The VTK session provides a static method, +``Session::setEnableTranscriptionChecks()``, for operations +to enable/disable this behavior during transcription. + +SMTK Project Changes +==================== +Changes to smtk::project::ResourceContainer API +----------------------------------------------- + +Changes to the ``smtk::project::ResourceContainer`` API to allow for non-unique roles +to be assigned to Resources in a project. + +Deprecated version >= 21.6 +~~~~~~~~~~~~~~~~~~~~~~~~~~ +``smtk::project::ResourceContainer::getByRole -> smtk::resource::ResourcePtr`` + +New API +~~~~~~~ +``smtk::project::ResourceContainer::findByRole -> std::set`` + +Other SMTK Core Changes +======================= +Visitors +-------- + +SMTK now provides an enumeration, ``smtk::common::Visit``, that visitor lambdas +may return to indicate whether visitation should continue (``smtk::common::Visit::Continue``) +or stop (``smtk::common::Visit::Halt``). +This enum is much easier to use than simply returning a ``bool`` as developers +frequently have trouble remembering which value (true or false) corresponds to +which iteration behaviour. + +This is currently only used by ``smtk::task::Task::visit()``, but will be +used more widely in the future. + +Task subsystem +-------------- + +SMTK now provides a task subsystem for representing user-actionable tasks in a workflow. +See the `task-system documentation`_ for more information about how to use this subsystem. + +.. _task-system documentation: https://smtk.readthedocs.io/en/latest/userguide/task/index.html +Qt UI Changes +============= +Removing Empty Frames in qtGroupItem +------------------------------------ +Using GroupItem's hasRelevantChildren method, qtGroupItem will now hide it's frame if there are no children to be displayed. + +Filter Advance Attribute Definitions +------------------------------------ + +Attribute views will now hide any attribute definitions +that have an advance level that is higher than the user's +active advance level. This enables the Attribute View to hide +itself if all its definitions should be hidden from the user. + +Hide disabled attribute resources +--------------------------------- + +The Attribute Editor panel will now first check to see if an +Attribute Resource is enabled before attempting to display it. +Telling the Attribute Editor panel to display a disabled Attribute +Resource will be the equivalent to telling the panel to display a +nullptr. The panel will be reset if it was currently display +any widgets. + +Improving UI handling of Signal Operations +------------------------------------------ +Originally the qtAttributeView class would ignore the Signal Operation since typically it would be the only Qt UI element that would be creating, removing, and changing the Attributes it is displaying. However, this prevented the UI designer from having AttributeViews that displayed the same information from being used in Selector Views or have different AttributeViews overlap their contents (for example one View could be displaying Fluid Boundary Conditions, while another was displaying all Boundary Conditions) + +This change now encodes the address of the View that initiated the change so that we can avoid a View from being updated via a Signal Operation that it itself initiated. + +qtAttributeView has now been updated to only ignore Signal Operations that it triggered. + +Supporting smtk.extensions.attribute_view.name_read_only in qtAttributeViews +---------------------------------------------------------------------------- +You can now indicate that an Attribute's name should not be modified by creating a bool Property on the Attribute called: **smtk.extensions.attribute_view.name_read_only** and setting its value to true. + +Observing Operations +-------------------- +qtAttributeView will now properly examine modified attributes to see if they have smtk.extensions.attribute_view.name_read_only property or if their names had been changed. + +Changes to Polygon Session +========================== +ImportPPG Operation +------------------- + +An ``ImportPPG`` operation has been added to the polygon session +for creating model resources from a simple text file input. +The "ppg" (Planar PolyGon) file format is a simple data format +that specifies 2-D geometry as a list of vertex coordinates and +polygon face definitions, with vertices connected implicitly by +straight-line model edges. Documentation is in the "Session: Polygon" +section of the SMTK user guide. + +The ``ImportPPG`` operation is provided as a convenience for exploring +CMB's many capabilities as well as for testing, debug, and demonstration. +To use this feature from modelbuilder, the "File -> New Resource" menu +item now includes an option "Polygon -> Planar Polygon Model from PPG +File". + +Removed Previously Deprecated API +================================= +The following deprecated methods have been removed: + +* Categories::Set::mode has been replaced with Categories::Set::inclusionMode +* Categories::Set::setMode has been replaced with Categories::Set::setInclusionMode +* Categories::Set::categoryNames has been replaced with Categories::Set::includedCategoryNames +* Categories::Set::set has been replaced with Categories::Set::setInclusions +* Categories::Set::insert has been replaced with Categories::Set::insertInclusion +* Categories::Set::erase has been replaced with Categories::Set::eraseInclusion +* Categories::Set::size has been replaced with Categories::Set::inclusionSize +* ReferenceItem::objectValue has been replaced with ReferenceItem::value +* ReferenceItem::setObjectValue has been replaced with ReferenceItem::setValue +* ReferenceItem::appendObjectValue has been replaced with ReferenceItem::appendValue +* ReferenceItem::setObjectValues has been replaced with ReferenceItem::setValues +* ReferenceItem::appendObjectValues has been replaced with ReferenceItem::appendValues +* PhraseModel::addSource now accepts const smtk::common::TypeContainer& +* PhraseModel::removeSource now accepts const smtk::common::TypeContainer& + +Software Process Changes +======================== +CMake Policies +-------------- + +Because of CMake policy CMP0115 (source file extensions must be explicit), +when passing test names to the ``smtk_add_test`` macro, be sure to include +the filename extension (such as ``.cxx``). + +Deprecate Python 2.x support +---------------------------- + +Python 2.x reached its end of life in January 2020. SMTK has deprecated its +Python 2 support and will remove it in a future release. diff --git a/doc/smtk.doxyfile.in b/doc/smtk.doxyfile.in index c9bd082c4cb6ed83e171ba4650260e90aa359d15..8f8467ace6e90e0a5069b342b1b0da92d72d9827 100644 --- a/doc/smtk.doxyfile.in +++ b/doc/smtk.doxyfile.in @@ -734,6 +734,7 @@ INPUT = \ "@smtk_SOURCE_DIR@/smtk/simulation" \ "@smtk_SOURCE_DIR@/smtk/project" \ "@smtk_SOURCE_DIR@/smtk/common" \ + "@smtk_SOURCE_DIR@/smtk/task" \ "@smtk_SOURCE_DIR@/smtk/workflow" \ "@smtk_SOURCE_DIR@/smtk/model" \ "@smtk_SOURCE_DIR@/smtk/model/operators" \ @@ -829,6 +830,7 @@ INPUT = \ "@smtk_BINARY_DIR@/smtk/simulation" \ "@smtk_BINARY_DIR@/smtk/project" \ "@smtk_BINARY_DIR@/smtk/common" \ + "@smtk_BINARY_DIR@/smtk/task" \ "@smtk_BINARY_DIR@/smtk/workflow" \ "@smtk_BINARY_DIR@/smtk/model" \ "@smtk_BINARY_DIR@/smtk/model/operators" \ diff --git a/doc/tutorials/implement_an_operator/implement_an_operator.cxx b/doc/tutorials/implement_an_operator/implement_an_operator.cxx index cb176516a6ca8582e694f7c0a2d41a493c2cc714..97d53c10950f404790e8cedb05eb032129eb8ae1 100644 --- a/doc/tutorials/implement_an_operator/implement_an_operator.cxx +++ b/doc/tutorials/implement_an_operator/implement_an_operator.cxx @@ -79,7 +79,7 @@ void testOperation(Model model) auto op = ex::CounterOperation::create(); smtk::attribute::ComponentItemPtr input = op->parameters()->findComponent("model"); - input->setObjectValue(model.component()); + input->setValue(model.component()); test(!!op, "Could not create operator."); test( diff --git a/doc/tutorials/python_first_steps/first_steps.py b/doc/tutorials/python_first_steps/first_steps.py index e2efa0853054836921fc6561ab1f1838c8d92add..85228be2a1a927e190a6929254550f2df10456f9 100755 --- a/doc/tutorials/python_first_steps/first_steps.py +++ b/doc/tutorials/python_first_steps/first_steps.py @@ -101,10 +101,10 @@ models = mmgr.findEntitiesByProperty('name', 'Test Model') model = smtk.model.Model(models[0]) groups = model.groups() if groups and len(groups): - wallGroup = (g for g in groups if g.name() == 'wall').next() - inletGroup = (g for g in groups if g.name() == 'inlet').next() - outletGroup = (g for g in groups if g.name() == 'outlet').next() - fluidGroup = (g for g in groups if g.name() == 'fluid').next() + wallGroup = next((g for g in groups if g.name() == 'wall')) + inletGroup = next((g for g in groups if g.name() == 'inlet')) + outletGroup = next((g for g in groups if g.name() == 'outlet')) + fluidGroup = next((g for g in groups if g.name() == 'fluid')) fluidIC.associateEntity(fluidGroup) outletBC.associateEntity(outletGroup) diff --git a/doc/userguide/common/factory.rst b/doc/userguide/common/factory.rst index 020ddbc965e9f0d19e5155abb6a22c70f8fea843..686d1d2ad28b170418d84b4157fce829b5660542 100644 --- a/doc/userguide/common/factory.rst +++ b/doc/userguide/common/factory.rst @@ -3,7 +3,7 @@ Factory SMTK's factory pattern (:smtk:`Factory `) allows consuming code to register types that share a common base class -with the factory insetance at runtime and subsequently construct +with a factory instance at runtime and subsequently construct instances of these types using the type (`Type`), type name (`smtk::common::typeName()`), or type index (`typeid(Type).hash_code()`). Upon declaration, a factory takes as @@ -12,5 +12,32 @@ passed to the generated classes upon construction. As a convenience, each of the above construction modes has an associated Interface to provide a uniform API when constructing objects. +Factories return unique pointers to objects they construct. +Because shared pointers can be constructed from unique pointers, +the factory pattern can be used in both cases where single and +shared ownership are needed. + An example that demonstrates the prinicples and API of this pattern -can be found at `smtk/comon/testing/cxx/UnitTestFactory.cxx`. +can be found at `smtk/common/testing/cxx/UnitTestFactory.cxx`. + +Instances +========= + +As an extension to the Factory pattern, SMTK also provides +a templated :smtk:`Instances ` class. +The Instances class not only tracks types that can be constructed +but also manages instances that have been constructed by holding +a shared pointer to each object it creates. + +The Instances class can be instructed to release any shared pointer +it owns which — assuming no other shared pointers reference the same +object — will delete the object. + +Upon construction and release of objects its manages, the Instances +object invokes Observers (covered later in this section). +Observing the construction and imminent deletion of objects allows +user interfaces an opportunity to present summaries of the system +state. + +Instances takes the same set of template parameters as the Factory: +the common base type and signatures used to construct instances. diff --git a/doc/userguide/figures/ppg-example1.png b/doc/userguide/figures/ppg-example1.png new file mode 100644 index 0000000000000000000000000000000000000000..890b0b979e1f8083bcc2162b98d7b3bf50def154 --- /dev/null +++ b/doc/userguide/figures/ppg-example1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38ec552771d48b74080b2083b3f4ab9472defeaebf15ff8974a3ea227255522e +size 6220 diff --git a/doc/userguide/figures/ppg-example2.png b/doc/userguide/figures/ppg-example2.png new file mode 100644 index 0000000000000000000000000000000000000000..1ee3ab6be75bfcc0776e9da186f141d44c3f2fd0 --- /dev/null +++ b/doc/userguide/figures/ppg-example2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf00b9a0f255f4bb7da61923e212c0a4f104cba31f68decad6db07fb9dab7e80 +size 3935 diff --git a/doc/userguide/index.rst b/doc/userguide/index.rst index 552f76f88a64ca812613522a2bd248301702e8a3..bcd785c26157a0243bc9e76b047c2771dd1ebcce 100644 --- a/doc/userguide/index.rst +++ b/doc/userguide/index.rst @@ -47,6 +47,7 @@ simulation domain. simulation/index.rst view/index.rst extension/index.rst + task/index.rst workflow/index.rst bindings/index.rst plugin/index.rst diff --git a/doc/userguide/model/example1.ppg b/doc/userguide/model/example1.ppg new file mode 100644 index 0000000000000000000000000000000000000000..66aafba8a6c4bc912fc478130161f6358f515132 --- /dev/null +++ b/doc/userguide/model/example1.ppg @@ -0,0 +1,26 @@ +# example1.ppg +# Polygon domain with embedded face and hole +# Note that vertex indices start with 1 +# Vertices 1-8 for the outer polygon +v 0.0 2.0 +v 1.0 0.0 +v 9.0 0.0 +v 9.0 2.0 +v 8.0 4.0 +v 6.0 5.0 +v 3.0 5.0 +v 1.0 4.0 +# Vertices 9-12 for the embedded parallelogram +v 2.0 1.5 +v 4.0 1.5 +v 4.5 3.0 +v 2.5 3.0 +# Vertices 12-16 for the square hole +v 7.0 1.0 +v 8.0 1.0 +v 8.0 2.0 +v 7.0 2.0 +# Faces +f 1 2 3 4 5 6 7 8 # face 1 +e 9 10 11 12 # face 2 (embedded) +h 13 14 15 16 # hole diff --git a/doc/userguide/model/example2.ppg b/doc/userguide/model/example2.ppg new file mode 100644 index 0000000000000000000000000000000000000000..913cfb219926a591d5594f2c4a5b70c75c28d620 --- /dev/null +++ b/doc/userguide/model/example2.ppg @@ -0,0 +1,11 @@ +# example2.ppg +# Two adjacent faces with common edge +v 0 0 +v 3 0 +v 3 1 +v 1 1 +v 0 1 +v 3 2 +v 1 2 +f 1 2 3 4 5 # face 1 +f 3 6 7 4 # face 2 diff --git a/doc/userguide/model/ppg-file-format.rst b/doc/userguide/model/ppg-file-format.rst new file mode 100644 index 0000000000000000000000000000000000000000..dad4a1f05eb758ed49b123baae636cbb74e75049 --- /dev/null +++ b/doc/userguide/model/ppg-file-format.rst @@ -0,0 +1,76 @@ +PPG File Format +--------------- + +The SMTK polygon session includes an ``ImportPPG`` operation for creating 2-D +models from text file input. The ``ImportPPG`` operation is provided as a +convenience for exploring CMB's many capabilities as well as for testing, +debug, and demonstration. +The "ppg" (Planar PolyGon) file format is a simple data format +that specifies 2-D geometry as a list of vertex coordinates and +polygon face definitions, with vertices connected implicitly by +straight-line model edges. + +.. include:: example1.ppg + :literal: + +This example produces a model with two faces, a parallelogram-shaped +face embedded in a polygon face that also contains a square hole. + +.. findfigure:: ppg-example1.png + +PPG Features +============ + +As a tool intended mainly for educational use, the supported feature set +is purposely limited. + +* Each polygon face must have simple geomety, specifically, polygons + cannot be self-intersecting, and polygons with more than four edges must + be convex. +* Polygons may share edges but cannot otherwise intersect or overlap. +* Polygons may include inner edge loops as either holes or embedded faces. + Inner edge loops may not share edges or vertices with other loops, and + embedded faces may not contain inner edge loops themselves. +* The ImportPPG operation has only syntactic checking, so users are + encouraged to check their input files carefully for geometric validity. + +File Format +=========== +A PPG file may contain comments, vertex data, and face elements. +Empty lines are ignored. + +**Comments** + +Anything following a hash character (#) is a comment. + +**Vertices** + +A model vertex is specified via a line starting with the letter +``v`` followed by the x and y coordinates. + +**Face Elements** + +Model faces are specified using a list of vertex indices. Vertex +indices start with 1. Each face is defined by three or more vertices. + +* An model face is specified with the letter ``f`` + followed by an ordered list of vertex indices. ImportPPG will + create a model edge between each pair of adjacent vertices in the + list, and between the last and first vertices, to form a polygon. +* Inner edge loops can be specified in the lines immediately following the + model face. +* Embedded faces are specified with the letter ``e`` followed by an + ordered list of vertices. +* Holes in the model face are specified with the letter ``h`` followed + by an ordered list of vertices. + +**Shared Edges** + +As noted above, model faces can be adjacent with a common internal edge +between them. Note that the vertices at either end of the common edge must +be included in the vertex list of each face. + +.. include:: example2.ppg + :literal: + +.. findfigure:: ppg-example2.png diff --git a/doc/userguide/model/session-polygon.rst b/doc/userguide/model/session-polygon.rst index 2aa112ad056f5b96e3467aa27f63fe2ab79e0801..4fd45188dc732def805fe185dbfa0105eef36ac6 100644 --- a/doc/userguide/model/session-polygon.rst +++ b/doc/userguide/model/session-polygon.rst @@ -61,3 +61,5 @@ Boost polygonal models are conforming piecewise-linear cell complexes (PLCs), an may thus be meshed by any SMTK mesh worker that accepts models in this form. .. _Boost.polygon: http://www.boost.org/doc/libs/1_59_0/libs/polygon/doc/index.htm + +.. include:: ppg-file-format.rst diff --git a/doc/userguide/task/classes.rst b/doc/userguide/task/classes.rst new file mode 100644 index 0000000000000000000000000000000000000000..b574b380dc83cbb31976cee1fb37125d430e6676 --- /dev/null +++ b/doc/userguide/task/classes.rst @@ -0,0 +1,73 @@ +.. _smtk-task-classes: + +Guide to task classes +===================== + +The following sections describe the different task subclasses that +exist for use in your workflows, the use cases that motivate them, +and how to configure them. + +Task +---- + +The :smtk:`base Task class` does not monitor +anything on its own but can be used to collect dependencies. +It is Completable by default. +The following JSON can be used to configure it: + +* ``title``: an optional string value holding instructions to users. +* ``completed``: an optional boolean value indicating whether the + user has marked the task complete or not. + +Example: + +.. code:: json + + { + "type": "smtk::task::Task", + "title": "Instructions to users.", + "completed": false + } + +TaskNeedsResources +------------------ + +The :smtk:`TaskNeedsResources ` class monitors +a resource manager and is incomplete until its configured list of required +resources is acceptable, at which time it transitions to completable. +It is Incomplete by default unless unconfigured (in which case it is Completable). +It accepts all the JSON configuration that the base Task class does, plus: + +* ``resources``: a JSON array of required resources, organized by role. + Each array entry must be a JSON object holding: + + * ``role``: an optional string holding a resource role name. If omitted, any role is allowed. + * ``type``: an optional string holding a resource typename. If omitted, any resource type is allowed. + * ``min``: an optional integer specifying the number of resources with the given role and type that must be present. + Only non-negative values are accepted. + It defaults to 1, which makes the requirement mandatory. + If set to 0, the requirement is optional. + * ``max``: an optional integer specifying the maximum number of resources with the given role and type allowed. + Negative values indicate that there is no maximum. + It defaults to -1. + It is possible to set this to 0 to indicate that resources of a given role/type are disallowed. + +Example: + +.. code:: json + + { + "type": "smtk::task::TaskNeedsResources", + "title": "Load a geometric model (or models) and a simulation template.", + "resources": [ + { + "role": "model geometry", + "type": "smtk::model::Resource" + }, + { + "role": "simulation attribute", + "type": "smtk::attribute::Resource", + "max": 1 + } + ] + } diff --git a/doc/userguide/task/concepts.rst b/doc/userguide/task/concepts.rst new file mode 100644 index 0000000000000000000000000000000000000000..bb933e14b29a00a26524c66a96bfa3e087f1b6b3 --- /dev/null +++ b/doc/userguide/task/concepts.rst @@ -0,0 +1,48 @@ +Key Concepts +============ + +The graph of tasks (with dependencies as arcs) indicates what tasks a user may +work on, what tasks are incomplete, and what tasks cannot be performed because of +unmet dependencies. + +A task becomes active when its dependencies are met and the user +chooses to focus on the task. +An application can compute the set of tasks which users +are allowed to focus on (make active) by cutting the graph along arcs +that connect completed tasks to incomplete tasks. + +:smtk:`State ` + is an enumeration of the states a task may take on. + Tasks are unavailable until dependencies are met; then they are + incomplete until the task's condition is met; then they are + completable (but not completed) until the user marks the task + as complete. + +:smtk:`Task ` + instances have dependent tasks and a flag to store whether the user has + marked a given task as complete. + You may observe task state transitions. + You should subclass this to implement logic that determines whether + your task is unavailable, incomplete, or completable; the base class + is unavailable until its dependencies are met, at which time it + will transition straight to completable. + +:smtk:`Instances ` + is used to create instances of registered task classes. + Any plugins that provide new task subclasses should + register those classes with the factory in their registrar + (see :ref:`smtk-plugin-sys`). + +:smtk:`Active ` + is used to get the currently active task or switch to a different task. + There can only be one active task at a time, although there may be + no active task. + Active tasks must be managed instances so that there is some + indication before deletion that the task will be destroyed and + thus should not be active. + This object can be observed for changes to the active task. + +:smtk:`Manager ` + is an object applications can create to hold a task factory and + the set of task instances the factory has created. + It also holds the active task tracker. diff --git a/doc/userguide/task/index.rst b/doc/userguide/task/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..c4b9aaa2ae3dee629a9c73ca19ab19616e69b9b8 --- /dev/null +++ b/doc/userguide/task/index.rst @@ -0,0 +1,15 @@ +.. _smtk-task-sys: + +-------------- +Workflow tasks +-------------- + +SMTK provides tools to guide users through the process of preparing a simulation description. +A workflow consists of a series of tasks that may have dependencies. +These tasks form a graph with dependencies as arcs. + +.. toctree:: + :maxdepth: 3 + + concepts.rst + classes.rst diff --git a/smtk/CMakeLists.txt b/smtk/CMakeLists.txt index 8508992b8fc7ca76373216621176ddc4480b176a..81e31d98773f9b3a311d2a784aaade7e11726674 100644 --- a/smtk/CMakeLists.txt +++ b/smtk/CMakeLists.txt @@ -33,6 +33,9 @@ smtk_source_group(model) add_subdirectory(simulation) smtk_source_group(simulation) +add_subdirectory(task) +smtk_source_group(task) + add_subdirectory(io) smtk_source_group(io) @@ -59,6 +62,7 @@ set(smtk_headers ${workflowHeaders} ${pluginHeaders} ${simulationHeaders} + ${taskHeaders} ${ioHeaders} ) set(smtk_srcs @@ -75,6 +79,7 @@ set(smtk_srcs ${workflowSrcs} ${pluginSrcs} ${simulationSrcs} + ${taskSrcs} ${ioSrcs} ) diff --git a/smtk/attribute/Analyses.h b/smtk/attribute/Analyses.h index 58ef3fa3dc5ad1ed5e75144d7f71e76311de0faa..eb47579b1ccab3eedbb9bc2d186064fb82bbde70 100644 --- a/smtk/attribute/Analyses.h +++ b/smtk/attribute/Analyses.h @@ -114,10 +114,7 @@ public: }; /// \brief Basic constructor - Note that by default top level Analyses are not Exclusive - Analyses() - : m_topLevelExclusive(false) - { - } + Analyses() = default; /// \brief Create a new Analysis and return it. /// Note that the name must be unique with respects to the other Analysis Instances defined within /// this Instance. If the name is not unique no Analysis is created and nullptr is returned. @@ -174,7 +171,9 @@ protected: void getAnalysisItemCategories(ConstItemPtr item, std::set& cats, bool itemNotAnalysis); - bool m_topLevelExclusive; ///< Indicates if the top level Analysis Instances are exclusive + bool m_topLevelExclusive{ + false + }; ///< Indicates if the top level Analysis Instances are exclusive std::vector m_analyses; ///< Analysis Instances managed by the Analyses Instance }; } // namespace attribute diff --git a/smtk/attribute/Attribute.cxx b/smtk/attribute/Attribute.cxx index c85504cbdd7915f82b7144796eaf3b2fb2882de1..7cfeb8d7106b6ab92787f8869db759929586b6f4 100644 --- a/smtk/attribute/Attribute.cxx +++ b/smtk/attribute/Attribute.cxx @@ -312,18 +312,38 @@ bool Attribute::isValid(const std::set& cats) const return false; } - // also check associations - return !(m_associatedObjects && !m_associatedObjects->isValid()); + // also check associations - make sure to turn active categories off + // since associations don't have them set + return !(m_associatedObjects && !m_associatedObjects->isValid(false)); } -bool Attribute::isRelevant() const +bool Attribute::isRelevant(bool includeCategoryCheck, bool includeReadAccess, int readAccessLevel) + const { - auto aResource = this->attributeResource(); - if (aResource && aResource->activeCategoriesEnabled()) + if (includeCategoryCheck) + { + auto aResource = this->attributeResource(); + if (aResource && aResource->activeCategoriesEnabled()) + { + if (!this->categories().passes(aResource->activeCategories())) + { + return false; + } + } + } + if (!includeReadAccess) { - return this->categories().passes(aResource->activeCategories()); + return true; } - return true; + + // Lets see if at least one of the attribute's items is relevant. + if (std::any_of(m_items.begin(), m_items.end(), [=](const ItemPtr& item) { + return item->isRelevant(includeCategoryCheck, includeReadAccess, readAccessLevel); + })) + { + return true; + } + return false; } ResourcePtr Attribute::attributeResource() const @@ -442,6 +462,7 @@ bool Attribute::removeAllAssociations(bool partialRemovalOk) } } m_associatedObjects->detachOwningResource(); + m_associatedObjects->reset(); return true; } diff --git a/smtk/attribute/Attribute.h b/smtk/attribute/Attribute.h index 019e7d2ca1a955a93fe37406f37b621a63c7322d..0542053b2a6161468aaf5aa15c76912743b88ba6 100644 --- a/smtk/attribute/Attribute.h +++ b/smtk/attribute/Attribute.h @@ -321,11 +321,17 @@ public: bool isValid(bool useActiveCategories = true) const; bool isValid(const std::set& categories) const; - ///\brief Returns true if the attribute is relevant based on the resource's - /// active categories. If the Resource does not have active categories enabled or - /// if the attribute passes its category check, this method will return true; else - /// it will return false - bool isRelevant() const; + ///\brief Returns true if the attribute is relevant. + /// + /// If includeCatagories is true and the attribute does not pass it's category checks with respects + /// to the resource's active category settings then return false, + /// If includeReadAccess is true, and if all of the items in the attribute have their + /// advanceLevel > readAccessLevel then return false. + /// Else return true. + bool isRelevant( + bool includeCategories = true, + bool includeReadAccess = false, + int readAccessLevel = 0) const; smtk::attribute::ResourcePtr attributeResource() const; const smtk::resource::ResourcePtr resource() const override; diff --git a/smtk/attribute/Categories.h b/smtk/attribute/Categories.h index 7cdcf53eefa4a2a1150c97532450570a3a34cc85..726984172194be1eb19b691dd4c7a3e7ed7e913e 100644 --- a/smtk/attribute/Categories.h +++ b/smtk/attribute/Categories.h @@ -56,12 +56,7 @@ public: Any = 0, //!< Check passes if any of the set's categories are found All = 1 //!< Check passes if all of the set's categories are found }; - Set() - : m_includeMode(CombinationMode::Any) - , m_excludeMode(CombinationMode::Any) - , m_combinationMode(CombinationMode::All) - { - } + Set() = default; ///@{ ///\brief Set/Get the how the sets of included and excluded categories are combined Set::CombinationMode combinationMode() const { return m_combinationMode; } @@ -132,53 +127,9 @@ public: static std::string combinationModeAsString(Set::CombinationMode mode); static bool combinationModeFromString(const std::string& val, Set::CombinationMode& mode); - // Deprecated Methods - [[deprecated( - "Categories::Set::mode has been replaced with Categories::Set::inclusionMode")]] Set:: - CombinationMode - mode() const - { - return this->inclusionMode(); - } - [[deprecated( - "Categories::Set::setMode has been replaced with Categories::Set::setInclusionMode")]] void - setMode(const Set::CombinationMode& newMode) - { - this->setInclusionMode(newMode); - } - [[deprecated("Categories::Set::categoryNames has been replaced with " - "Categories::Set::includedCategoryNames")]] const std::set& - categoryNames() const - { - return this->includedCategoryNames(); - } - [[deprecated( - "Categories::Set::set has been replaced with Categories::Set::setInclusions")]] void - set(const std::set& values, Set::CombinationMode mode) - { - this->setInclusions(values, mode); - } - [[deprecated( - "Categories::Set::insert has been replaced with Categories::Set::insertInclusion")]] void - insert(const std::string& val) - { - this->insertInclusion(val); - } - [[deprecated( - "Categories::Set::erase has been replaced with Categories::Set::eraseInclusion")]] void - erase(const std::string& val) - { - this->eraseInclusion(val); - } - [[deprecated( - "Categories::Set::size has been replaced with Categories::Set::inclusionSize")]] std::size_t - size() const - { - return this->inclusionSize(); - } - private: - Set::CombinationMode m_includeMode, m_excludeMode, m_combinationMode; + Set::CombinationMode m_includeMode{ CombinationMode::Any }, + m_excludeMode{ CombinationMode::Any }, m_combinationMode{ CombinationMode::All }; std::set m_includedCategories, m_excludedCategories; }; Categories() = default; diff --git a/smtk/attribute/DateTimeItem.cxx b/smtk/attribute/DateTimeItem.cxx index 7e46cb1d0aa839f66b2b133ea285ca980eabdd02..bc2cffc56b4f630d4a031fedcb8851360a3bd212 100644 --- a/smtk/attribute/DateTimeItem.cxx +++ b/smtk/attribute/DateTimeItem.cxx @@ -45,12 +45,8 @@ bool DateTimeItem::isValidInternal(bool useCategories, const std::setisEnabled()) - { - return true; - } + + // Check to see if all of its values are set for (auto it = m_isSet.begin(); it != m_isSet.end(); ++it) { if (!(*it)) diff --git a/smtk/attribute/FileItemDefinition.cxx b/smtk/attribute/FileItemDefinition.cxx index be269c8793f519f23eb0e9c96d58d88e98b47564..30bbdf8eae5bd4b1321399edf9bbe2805fd8f5d3 100644 --- a/smtk/attribute/FileItemDefinition.cxx +++ b/smtk/attribute/FileItemDefinition.cxx @@ -153,7 +153,7 @@ bool FileItemDefinition::isValueValid(const std::string& val) const return false; } - // If file filters are provided, we check if the value has an acceptible + // If file filters are provided, we check if the value has an acceptable // suffix. if (getFileFilters().empty()) { diff --git a/smtk/attribute/FileSystemItem.cxx b/smtk/attribute/FileSystemItem.cxx index 7a7b7987788c78fff0b73c08df8e51135d1df071..9d249bd0281e94a6d3a7b71e832bb2503ae4cb69 100644 --- a/smtk/attribute/FileSystemItem.cxx +++ b/smtk/attribute/FileSystemItem.cxx @@ -72,12 +72,7 @@ bool FileSystemItem::isValidInternal(bool useCategories, const std::setisEnabled()) - { - return true; - } + // Check to see if all of its values are set for (auto it = m_isSet.begin(); it != m_isSet.end(); ++it) { if (!(*it)) diff --git a/smtk/attribute/GroupItem.cxx b/smtk/attribute/GroupItem.cxx index 89f13f97ad5bc7564bfee368992bdba010910108..3eb7640bcfb8677bde14befdd9cb2b220cb6c837 100644 --- a/smtk/attribute/GroupItem.cxx +++ b/smtk/attribute/GroupItem.cxx @@ -62,7 +62,7 @@ bool GroupItem::isConditional() const return def->isConditional(); } -bool GroupItem::conditionalsSatisfied() const +bool GroupItem::conditionalsSatisfied(bool useActiveCategories) const { if (!this->isConditional()) { @@ -74,7 +74,7 @@ bool GroupItem::conditionalsSatisfied() const unsigned int numChoices = 0; for (auto it1 = (*it).begin(); it1 != (*it).end(); ++it1) { - if (*it1 && (*it1)->isRelevant() && (*it1)->isEnabled()) + if (*it1 && (*it1)->isRelevant(useActiveCategories) && (*it1)->isEnabled()) { numChoices++; } @@ -91,17 +91,14 @@ bool GroupItem::conditionalsSatisfied() const bool GroupItem::isValidInternal(bool useCategories, const std::set& categories) const { - // First lets see if the group itself would be filtered out based on the categories + // Lets see if the group itself would be filtered out based on the categories if (useCategories && !this->categories().passes(categories)) { return true; } - // If the item is not enabled or if all of its values are set then it is valid - // else it is enabled and contains unset values making it invalid - if (!this->isEnabled()) - { - return true; - } + + // Finally, if all of its values are set then it is valid + // else it is invalid unsigned int numChoices = 0; for (auto it = m_items.begin(); it != m_items.end(); ++it) { @@ -130,8 +127,20 @@ bool GroupItem::isValidInternal(bool useCategories, const std::set& } } } + + // Ideally we could just call GroupItem::conditionalsSatisfied but that method + // assumes we are testing against active categories, while this method is passed + // in the set of categories to be checked. So we do our own check. + if ( + this->isConditional() && + ((numChoices < m_minNumberOfChoices) || + ((m_maxNumberOfChoices != 0) && (numChoices > m_maxNumberOfChoices)))) + { + return false; + } } - return this->conditionalsSatisfied(); + + return true; } bool GroupItem::setDefinition(smtk::attribute::ConstItemDefinitionPtr gdef) @@ -499,3 +508,22 @@ bool GroupItem::assign(ConstItemPtr& sourceItem, unsigned int options) } return Item::assign(sourceItem, options); } + +bool GroupItem::hasRelevantChildren( + bool includeCategories, + bool includeReadAccess, + int readAccessLevel) const +{ + for (size_t elementIndex = 0; elementIndex < this->numberOfGroups(); elementIndex++) + { + for (size_t valueIndex = 0; valueIndex < this->numberOfItemsPerGroup(); valueIndex++) + { + if (this->item(elementIndex, valueIndex) + ->isRelevant(includeCategories, includeReadAccess, readAccessLevel)) + { + return true; + } + } + } + return false; +} diff --git a/smtk/attribute/GroupItem.h b/smtk/attribute/GroupItem.h index db7aeeeca041f36cdcffd8b595ac685832e8c1f7..d2be10b88847d14b0f3192b37bf2017af20b4543 100644 --- a/smtk/attribute/GroupItem.h +++ b/smtk/attribute/GroupItem.h @@ -135,9 +135,10 @@ public: /// \brief Returns true if the GroupItem satisfies its conditional requirements. /// /// Requirements are met if the item is not conditional, or if it have the appropriate - /// number of enabled items that are relevant w/r to the resource's active set of - /// categories - bool conditionalsSatisfied() const; + /// number of enabled items that are relevant. If useActiveCategories is true, then + /// category checking using the resource's active + /// categories is performed, else no category checking is done. + bool conditionalsSatisfied(bool useActiveCategories = true) const; ///@{ /// \brief Returns or sets the minimum number of choices that must be set for the @@ -168,6 +169,12 @@ public: /// See Items.h for a description of these options. bool assign(smtk::attribute::ConstItemPtr& sourceItem, unsigned int options = 0) override; + ///\brief Returns true if the group item has relevant children. + bool hasRelevantChildren( + bool includeCategories = true, + bool includeReadAccess = false, + int readAccessLevel = 0) const; + protected: GroupItem(Attribute* owningAttribute, int itemPosition); GroupItem(Item* owningItem, int myPosition, int mySubGroupPosition); diff --git a/smtk/attribute/InfixExpressionEvaluator.cxx b/smtk/attribute/InfixExpressionEvaluator.cxx index 68044b4aa05e3acc91989078610494da3a8ca545..1191f54fbdbd1b5f616062f31ee93dc6538b182c 100644 --- a/smtk/attribute/InfixExpressionEvaluator.cxx +++ b/smtk/attribute/InfixExpressionEvaluator.cxx @@ -203,7 +203,7 @@ bool smtk::attribute::InfixExpressionEvaluator::doesEvaluate(std::size_t element bool smtk::attribute::InfixExpressionEvaluator::doesEvaluate() { - for (int i = 0; i < numberOfEvaluatableElements(); ++i) + for (std::size_t i = 0; i < numberOfEvaluatableElements(); ++i) { if (!doesEvaluate(i)) return false; diff --git a/smtk/attribute/Item.cxx b/smtk/attribute/Item.cxx index fab9307ca5b4af7e1a18f7129ff96cf0188f6624..f690a35cd176a767042c29230a90e22e7e6fed39 100644 --- a/smtk/attribute/Item.cxx +++ b/smtk/attribute/Item.cxx @@ -24,6 +24,7 @@ Item::Item(Attribute* owningAttribute, int itemPosition) , m_position(itemPosition) , m_isEnabled(true) , m_forceRequired(false) + , m_isIgnored(false) { m_hasLocalAdvanceLevelInfo[0] = false; m_hasLocalAdvanceLevelInfo[1] = false; @@ -37,6 +38,7 @@ Item::Item(Item* inOwningItem, int itemPosition, int inSubGroupPosition) , m_subGroupPosition(inSubGroupPosition) , m_isEnabled(true) , m_forceRequired(false) + , m_isIgnored(false) { m_hasLocalAdvanceLevelInfo[0] = false; m_hasLocalAdvanceLevelInfo[1] = false; @@ -60,6 +62,13 @@ AttributePtr Item::attribute() const bool Item::isValid(bool useActiveCategories) const { + // If the item is not enabled, or marked to be ignored, then return true since the item + // is not going to have an effect + if ((!this->isEnabled()) || this->isIgnored()) + { + return true; + } + // If the resource has active categories enabled, use them if (useActiveCategories) { @@ -78,18 +87,31 @@ bool Item::isValid(bool useActiveCategories) const return this->isValidInternal(false, cats); } -bool Item::isRelevant() const +bool Item::isRelevant(bool includeCategories, bool includeReadAccess, unsigned int readAccessLevel) + const { - auto myAttribute = this->attribute(); - if (myAttribute) + if (m_isIgnored) { - auto aResource = myAttribute->attributeResource(); - if (aResource && aResource->activeCategoriesEnabled()) + return false; // Item has been marked to be ignored + } + + if (includeCategories) + { + auto myAttribute = this->attribute(); + if (myAttribute) { - return this->categories().passes(aResource->activeCategories()); + auto aResource = myAttribute->attributeResource(); + if (aResource && aResource->activeCategoriesEnabled()) + { + if (!this->categories().passes(aResource->activeCategories())) + { + return false; + } + } } } - return true; + + return (includeReadAccess ? (this->advanceLevel() <= readAccessLevel) : true); } std::string Item::name() const diff --git a/smtk/attribute/Item.h b/smtk/attribute/Item.h index d4cf2d222fb92ce4f190c2fa92ac35c152c5f17c..007886fce3812d6e2d5c6ac8fdc8b327bce17a58 100644 --- a/smtk/attribute/Item.h +++ b/smtk/attribute/Item.h @@ -92,15 +92,20 @@ public: bool isValid(bool useActiveCategories = true) const; bool isValid(const std::set& categories) const { - return this->isValidInternal(true, categories); + return (!this->isEnabled()) || this->isIgnored() || this->isValidInternal(true, categories); } /// @} - ///\brief Returns true if the item is relevant based on the resource's - /// active categories. If the Resource does not have active categories enabled or - /// if the item passes its category check, this method will return true; else - /// it will return false - bool isRelevant() const; + ///\brief Returns true if the item is relevant. + /// + /// If the item is marked ignored then return false. + /// If includeCatagories is true and the item does not pass it's category checks, then return false, + /// If includeReadAccess is true, and the item's advanceLevel is > readAccessLevel then return false. + /// Else return true. + virtual bool isRelevant( + bool includeCatagories = true, + bool includeReadAccess = false, + unsigned int readAccessLevel = 0) const; /// @{ /// \brief return a child item that matches name and satisfies the SearchStyle @@ -186,7 +191,7 @@ public: /// /// if mode is 1 then the write access level is returned; /// else the read access level is returned - /// The information can either be specificied directly to the item + /// The information can either be specified directly to the item /// using setLocalAdvanceLevel() or from the item's definition. /// If this item is not owned by another item or attribute the value /// is simply returned. Else the max of the value and that of its @@ -219,7 +224,7 @@ public: virtual void reset(); - /// Rotate internal data. Implementation to be added in subclasses. + /// Rotate internal data. Implementation to be added in sub-classes. /// Default behavior here is no-op (returns false). virtual bool rotate(std::size_t fromPosition, std::size_t toPosition); @@ -233,9 +238,21 @@ public: void detachOwningItem() { m_owningItem = nullptr; } /// Assigns this item to be equivalent to another. Options are processed by derived item classes - /// Returns true if success and false if a problem occured + /// Returns true if success and false if a problem occurred virtual bool assign(smtk::attribute::ConstItemPtr& sourceItem, unsigned int options = 0); + ///@{ + /// \brief Controls if an item should be ignored. + /// + /// There are cases within a work-flow when an item may not be currently relevant and should be ignored. + /// When setIgnored is passed true, the item::isRelevant will return false regardless of category or + /// advance property checks + /// By default isIgnored() will return false. + void setIsIgnored(bool val) { m_isIgnored = val; } + + bool isIgnored() const { return m_isIgnored; } + ///@} + static std::string type2String(Item::Type t); static Item::Type string2Type(const std::string& s); @@ -259,6 +276,7 @@ protected: int m_position; int m_subGroupPosition; bool m_isEnabled; + bool m_isIgnored; smtk::attribute::ConstItemDefinitionPtr m_definition; std::map m_userData; diff --git a/smtk/attribute/ReferenceItem.cxx b/smtk/attribute/ReferenceItem.cxx index 5e3761820c9218f9070f26eac7a1bc1224280516..e57d80320274dfe98b96e753a857d303c615e27d 100644 --- a/smtk/attribute/ReferenceItem.cxx +++ b/smtk/attribute/ReferenceItem.cxx @@ -212,6 +212,7 @@ ReferenceItem::ReferenceItem(Attribute* owningAttribute, int itemPosition) , m_referencedAttribute(owningAttribute->shared_from_this()) , m_cache(new Cache()) , m_currentConditional(ReferenceItemDefinition::s_invalidIndex) + , m_nextUnsetPos(-1) { } @@ -221,6 +222,7 @@ ReferenceItem::ReferenceItem(Item* inOwningItem, int itemPosition, int mySubGrou , m_referencedAttribute(inOwningItem->attribute()) , m_cache(new Cache()) , m_currentConditional(ReferenceItemDefinition::s_invalidIndex) + , m_nextUnsetPos(-1) { } @@ -229,6 +231,7 @@ ReferenceItem::ReferenceItem(const ReferenceItem& referenceItem) , m_referencedAttribute(referenceItem.m_referencedAttribute) , m_cache(new Cache(*referenceItem.m_cache)) , m_currentConditional(ReferenceItemDefinition::s_invalidIndex) + , m_nextUnsetPos(-1) { } @@ -237,6 +240,7 @@ ReferenceItem& ReferenceItem::operator=(const ReferenceItem& referenceItem) Item::operator=(referenceItem); m_referencedAttribute = referenceItem.m_referencedAttribute; m_cache.reset(new ReferenceItem::Cache(*(referenceItem.m_cache))); + m_nextUnsetPos = referenceItem.m_nextUnsetPos; return *this; } @@ -269,10 +273,6 @@ bool ReferenceItem::isValidInternal(bool useCategories, const std::setisEnabled()) - { - return true; - } // Do we have at least the number of required values present? if (this->numberOfValues() < this->numberOfRequiredValues()) { @@ -315,7 +315,8 @@ std::size_t ReferenceItem::numberOfValues() const bool ReferenceItem::setNumberOfValues(std::size_t newSize) { // If the current size is the same just return - if (this->numberOfValues() == newSize) + std::size_t currentSize = this->numberOfValues(); + if (currentSize == newSize) { return true; } @@ -334,6 +335,11 @@ bool ReferenceItem::setNumberOfValues(std::size_t newSize) if (n > 0 && newSize > n) return false; // The number of values requested is too large. + // Are we introducing any unset values? + if ((currentSize < newSize) && (m_nextUnsetPos > (currentSize + 1))) + { + m_nextUnsetPos = currentSize + 1; + } m_keys.resize(newSize); m_cache->resize(newSize); return true; @@ -449,11 +455,6 @@ bool ReferenceItem::setObjectKey( return false; } -smtk::resource::PersistentObjectPtr ReferenceItem::objectValue(std::size_t i) const -{ - return this->value(i); -} - smtk::resource::PersistentObjectPtr ReferenceItem::value(std::size_t i) const { if (i >= static_cast(m_cache->size())) @@ -575,6 +576,25 @@ bool ReferenceItem::setValue(std::size_t i, const PersistentObjectPtr& val) } assignToCache(i, val); + // Did we set a Null Value? + if ((val == nullptr) && (m_nextUnsetPos > i)) + { + m_nextUnsetPos = i; + } + else if ((val != nullptr) && (i == m_nextUnsetPos)) + { + // We need to scan for the next unset value + m_nextUnsetPos = -1; + std::size_t numVals = this->numberOfValues(); + for (size_t j = i + 1; j < numVals; j++) + { + if (!this->isSet(j)) + { + m_nextUnsetPos = j; + break; + } + } + } // Update the active children if this is a single value item if ((!def->isExtensible()) && (def->numberOfRequiredValues() == 1)) { @@ -583,7 +603,7 @@ bool ReferenceItem::setValue(std::size_t i, const PersistentObjectPtr& val) return true; } -bool ReferenceItem::appendValue(const PersistentObjectPtr& val) +bool ReferenceItem::appendValue(const PersistentObjectPtr& val, bool allowDuplicates) { // First - is this value valid? const auto* def = static_cast(this->definition().get()); @@ -592,26 +612,25 @@ bool ReferenceItem::appendValue(const PersistentObjectPtr& val) return false; } - // Second - is the value already in the item? - std::size_t emptyIndex, n = this->numberOfValues(); - bool foundEmpty = false; - for (std::size_t i = 0; i < n; ++i) + // Next - are we doing an append unique? + if (!allowDuplicates) { - if (this->isSet(i) && (this->value(i) == val)) - { - return true; - } - if (!this->isSet(i)) + std::size_t n = this->numberOfValues(); + for (std::size_t i = 0; i < n; ++i) { - foundEmpty = true; - emptyIndex = i; + if (this->isSet(i) && (this->value(i) == val)) + { + return true; + } } } - // If not, was there a space available? - if (foundEmpty) + + // Do we have an unset value location? + if (m_nextUnsetPos < std::size_t(-1)) { - return this->setValue(emptyIndex, val); + return this->setValue(m_nextUnsetPos, val); } + // Finally - are we allowed to change the number of values? if ( (def->isExtensible() && def->maxNumberOfValues() && @@ -646,6 +665,13 @@ bool ReferenceItem::removeValue(std::size_t i) { return false; // i can't be greater than the number of values } + + // Will removing this value shift the next unset value position? + if ((m_nextUnsetPos < std::size_t(-1)) && (m_nextUnsetPos > i)) + { + --m_nextUnsetPos; + } + myAtt->guardedLinks()->removeLink(m_keys[i]); m_keys.erase(m_keys.begin() + i); (*m_cache).erase((*m_cache).begin() + i); @@ -696,6 +722,11 @@ void ReferenceItem::reset() { m_keys.resize(this->numberOfRequiredValues()); (*m_cache).resize(this->numberOfRequiredValues()); + m_nextUnsetPos = 0; + } + else + { + m_nextUnsetPos = -1; } } @@ -865,6 +896,7 @@ bool ReferenceItem::setDefinition(smtk::attribute::ConstItemDefinitionPtr adef) { m_keys.resize(n); m_cache->resize(n); + m_nextUnsetPos = 0; } // Build the item's children def->buildChildrenItems(this); diff --git a/smtk/attribute/ReferenceItem.h b/smtk/attribute/ReferenceItem.h index c34c286027b15eab0434ec2e6902d1d00787a995..3e4068bea30a2cec7fbc1a7effc27c7dff0c9d67 100644 --- a/smtk/attribute/ReferenceItem.h +++ b/smtk/attribute/ReferenceItem.h @@ -222,13 +222,6 @@ public: { return std::dynamic_pointer_cast(this->value(i)); } - /** Return the \a i-th object stored in this item. - * \deprecated This method will go away in future versions of SMTK - * See instead value(std::size_t) - */ - [[deprecated( - "ReferenceItem::objectValue has been replaced with ReferenceItem::value")]] PersistentObjectPtr - objectValue(std::size_t i = 0) const; virtual bool isValueValid(std::size_t ii, const PersistentObjectPtr& entity) const; bool isValueValid(const PersistentObjectPtr& entity) const @@ -247,59 +240,12 @@ public: * Return the \a i-th object stored in this item. */ bool setValue(std::size_t i, const PersistentObjectPtr& val); - /**\brief Set the component stored with this item. - * - * This always sets the 0-th item and is a convenience method - * for cases where only 1 value is needed. - * \deprecated This method will go away in future versions of SMTK - * See instead setValue() - */ - [[deprecated( - "ReferenceItem::setObjectValue has been replaced with ReferenceItem::setValue")]] bool - setObjectValue(const PersistentObjectPtr& val) - { - return this - setValue(val); - } - /** Set the \a i-th value to the given item. This method does no checking to see if \a i is valid. - * bool setObjectValue(std::size_t i, const PersistentObjectPtr& val); - * Return the \a i-th object stored in this item. - * \deprecated This method will go away in future versions of SMTK - * See instead setValue(std::size_t, const PersistentObjectPtr&) - */ - [[deprecated( - "ReferenceItem::setObjectValue has been replaced with ReferenceItem::setValue")]] bool - setObjectValue(std::size_t i, const PersistentObjectPtr& val) - { - return this->setValue(i, val); - } - [[deprecated( - "ReferenceItem::appendObjectValue has been replaced with ReferenceItem::appendValue")]] bool - appendObjectValue(const PersistentObjectPtr& val) - { - return this->appendValue(val); - } template bool setValues(I vbegin, I vend, typename std::iterator_traits::difference_type offset = 0); template bool appendValues(I vbegin, I vend); - template - [[deprecated( - "ReferenceItem::setObjectValues has been replaced with ReferenceItem::setValues")]] bool - setObjectValues(I vbegin, I vend, typename std::iterator_traits::difference_type offset = 0) - { - return this->setValues(vbegin, vend, offset); - } - - template - [[deprecated( - "ReferenceItem::appendObjectValues has been replaced with ReferenceItem::appendValues")]] bool - appendObjectValues(I vbegin, I vend) - { - return this->appendValues(vbegin, vend); - } - template bool setValuesVia( I vbegin, @@ -309,7 +255,8 @@ public: template bool appendValuesVia(I vbegin, I vend, const T& converter); - /**\brief Add \a val if it is allowed and \a val is not already present in the item. + /**\brief Add \a val if it is allowed and \a val is not already present in the item + * unless allowDuplicates is true. * * This will **not** enable the item if it is disabled. * @@ -317,7 +264,7 @@ public: * if there is an unset value anywhere in the allocated array, that will * be preferred to reallocation. */ - bool appendValue(const PersistentObjectPtr& val); + bool appendValue(const PersistentObjectPtr& val, bool allowDuplicates = false); /**\brief Remove the value at the \a i-th location. * * If the number of values may not be changed, then the \a i-th @@ -487,6 +434,9 @@ private: std::vector m_activeChildrenItems; /// Index of the current active conditional std::size_t m_currentConditional; + /// Indicates where the next Null location is. If set to -1 then + /// there are no null locations in the item. + std::size_t m_nextUnsetPos; }; template<> @@ -504,20 +454,34 @@ bool ReferenceItem::setValues( if (this->setNumberOfValues(num)) { ok = true; + std::size_t firstUnsetPos = -1; std::size_t i = 0; for (I it = vbegin; it != vend; ++it, ++i) { if (!iteratorIsSet(it)) { + if (firstUnsetPos > (offset + i)) + { + firstUnsetPos = offset + i; + } continue; } if (!this->setValue(offset + i, *it)) { + // This value is also now unset + if (firstUnsetPos > (offset + i)) + { + firstUnsetPos = offset + i; + } ok = false; break; } } + if (m_nextUnsetPos > firstUnsetPos) + { + m_nextUnsetPos = firstUnsetPos; + } } // Enable or disable the item if it is optional. if (ok) @@ -546,19 +510,32 @@ bool ReferenceItem::setValuesVia( { ok = true; std::size_t i = 0; + std::size_t firstUnsetPos = -1; for (I it = vbegin; it != vend; ++it, ++i) { if (!iteratorIsSet(it)) { + if (firstUnsetPos > (offset + i)) + { + firstUnsetPos = offset + i; + } continue; } if (!this->setValue(offset + i, converter(*it))) { + if (firstUnsetPos > (offset + i)) + { + firstUnsetPos = offset + i; + } ok = false; break; } } + if (m_nextUnsetPos > firstUnsetPos) + { + m_nextUnsetPos = firstUnsetPos; + } } // Enable or disable the item if it is optional. if (ok) diff --git a/smtk/attribute/Resource.h b/smtk/attribute/Resource.h index 928c7bcf41288c7b0977db61b169a56639d1f0cd..24313866911c5befe39c7ae1785a814535f0af64 100644 --- a/smtk/attribute/Resource.h +++ b/smtk/attribute/Resource.h @@ -104,6 +104,12 @@ public: // removed (external nodes). bool removeDefinition(smtk::attribute::DefinitionPtr def); + // Description: + // Provide a way to mark a resource enabled/disabled + // so that we can hide it in certain contexts + void setIsPrivate(bool isPrivateValue) { m_isPrivate = isPrivateValue; } + bool isPrivate() const { return m_isPrivate; }; + smtk::attribute::AttributePtr createAttribute(const std::string& name, const std::string& type); smtk::attribute::AttributePtr createAttribute(attribute::DefinitionPtr def); smtk::attribute::AttributePtr createAttribute(const std::string& type); @@ -404,6 +410,8 @@ protected: AssociationRules m_associationRules; + bool m_isPrivate = true; + EvaluatorFactory m_evaluatorFactory; private: diff --git a/smtk/attribute/ValueItem.cxx b/smtk/attribute/ValueItem.cxx index 7c1644ad3d53ea31524535a7852b35e751ef59c3..c7d44d16c8adee66c6c4c4480d16fe6dfbde8516 100644 --- a/smtk/attribute/ValueItem.cxx +++ b/smtk/attribute/ValueItem.cxx @@ -123,13 +123,6 @@ bool ValueItem::isValidInternal(bool useCategories, const std::set& return true; } - // If the item is not enabled or if all of its values are set then it is valid - // else it is enabled and contains unset values making it invalid - if (!this->isEnabled()) - { - return true; - } - // Are we using an expression? Note that if we have an expression we // are not discrete and don't have children if (this->allowsExpressions() && (m_expression->value() != nullptr)) @@ -157,6 +150,7 @@ bool ValueItem::isValidInternal(bool useCategories, const std::set& return true; } + // Let check to make sure all of the values are set for (std::size_t i = 0; i < m_isSet.size(); ++i) { if (!m_isSet[i]) diff --git a/smtk/attribute/json/jsonItem.cxx b/smtk/attribute/json/jsonItem.cxx index 571ecb70c8051ea5454aee3273b8450299eeb053..45fd99f920d0aa0b97cc6e87efee0a36345bdacf 100644 --- a/smtk/attribute/json/jsonItem.cxx +++ b/smtk/attribute/json/jsonItem.cxx @@ -42,6 +42,10 @@ SMTKCORE_EXPORT void to_json(json& j, const smtk::attribute::ItemPtr& itemPtr) { j["AdvanceWriteLevel"] = itemPtr->localAdvanceLevel(1); } + if (itemPtr->isIgnored()) + { + j["IsIgnored"] = true; + } } SMTKCORE_EXPORT void from_json(const json& j, smtk::attribute::ItemPtr& itemPtr) @@ -75,6 +79,11 @@ SMTKCORE_EXPORT void from_json(const json& j, smtk::attribute::ItemPtr& itemPtr) { itemPtr->setLocalAdvanceLevel(1, *result); } + result = j.find("IsIgnored"); + if (result != j.end()) + { + itemPtr->setIsIgnored(*result); + } } } // namespace attribute } // namespace smtk diff --git a/smtk/attribute/json/jsonResource.cxx b/smtk/attribute/json/jsonResource.cxx index 4d9bec80b68b79c6fce07cc891a01b0165bee114..d879c9b7dc7530fbdd7f2e3778103388096f4a5c 100644 --- a/smtk/attribute/json/jsonResource.cxx +++ b/smtk/attribute/json/jsonResource.cxx @@ -37,6 +37,7 @@ SMTKCORE_EXPORT void to_json(json& j, const smtk::attribute::ResourcePtr& res) smtk::resource::to_json(j, smtk::static_pointer_cast(res)); // Set the version to 4.0 j["version"] = "4.0"; + j["IsPrivate"] = res->isPrivate(); // Write out the active category information if (!res->activeCategories().empty()) { @@ -326,6 +327,12 @@ SMTKCORE_EXPORT void from_json(const json& j, smtk::attribute::ResourcePtr& res) auto resource = std::static_pointer_cast(res); smtk::resource::from_json(j, resource); + // Set Private State + auto isPrivateResult = j.find("IsPrivate"); + // if we're reading in an older attribute resource, default value to true + bool isPrivateValue = isPrivateResult != j.end() ? isPrivateResult->get() : true; + res->setIsPrivate(isPrivateValue); + // Process Analysis Info auto result = j.find("Analyses"); if (result != j.end()) diff --git a/smtk/attribute/operators/Signal.sbt b/smtk/attribute/operators/Signal.sbt index eed2e7c8b803637ed54ae496d9d8365e7ca7c51f..cb96254f2a24625fbd8e35c892306f0c1f4e8a9a 100644 --- a/smtk/attribute/operators/Signal.sbt +++ b/smtk/attribute/operators/Signal.sbt @@ -17,12 +17,15 @@ - + + + + - + @@ -31,7 +34,7 @@ - + diff --git a/smtk/attribute/pybind11/PybindAnalyses.h b/smtk/attribute/pybind11/PybindAnalyses.h index 7b5bbf512dcba0d0cfd8d8ad5da1f91e3488dc02..0c6dc5017092b6573c6d7ce9d61a5797fb007971 100644 --- a/smtk/attribute/pybind11/PybindAnalyses.h +++ b/smtk/attribute/pybind11/PybindAnalyses.h @@ -23,7 +23,7 @@ namespace py = pybind11; -py::class_< smtk::attribute::Analyses > pybind11_init_smtk_attribute_Analyses(py::module &m) +inline py::class_< smtk::attribute::Analyses > pybind11_init_smtk_attribute_Analyses(py::module &m) { py::class_< smtk::attribute::Analyses, std::unique_ptr> instance(m, "Analyses"); instance diff --git a/smtk/attribute/pybind11/PybindAssociate.h b/smtk/attribute/pybind11/PybindAssociate.h index 001ceb5b9aa87075151533c249282e749201920a..d87c54fc7fa0aecd387e5029a3effd7c6d30e2bf 100644 --- a/smtk/attribute/pybind11/PybindAssociate.h +++ b/smtk/attribute/pybind11/PybindAssociate.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::Associate, smtk::operation::XMLOperation > pybind11_init_smtk_attribute_Associate(py::module &m) +inline PySharedPtrClass< smtk::attribute::Associate, smtk::operation::XMLOperation > pybind11_init_smtk_attribute_Associate(py::module &m) { PySharedPtrClass< smtk::attribute::Associate, smtk::operation::XMLOperation > instance(m, "Associate"); instance diff --git a/smtk/attribute/pybind11/PybindAttribute.h b/smtk/attribute/pybind11/PybindAttribute.h index e5dbcde9fb4ed10a49d1023b001a4ea598098c4f..08bafa23e8cdc3f0a4ed8f78d15746f2fc9a139e 100644 --- a/smtk/attribute/pybind11/PybindAttribute.h +++ b/smtk/attribute/pybind11/PybindAttribute.h @@ -37,7 +37,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::Attribute > pybind11_init_smtk_attribute_Attribute(py::module &m) +inline PySharedPtrClass< smtk::attribute::Attribute > pybind11_init_smtk_attribute_Attribute(py::module &m) { PySharedPtrClass< smtk::attribute::Attribute, smtk::resource::Component > instance(m, "Attribute", py::dynamic_attr()); instance @@ -97,7 +97,7 @@ PySharedPtrClass< smtk::attribute::Attribute > pybind11_init_smtk_attribute_Attr .def("isObjectAssociated", (bool (smtk::attribute::Attribute::*)(::smtk::resource::PersistentObjectPtr const &) const) &smtk::attribute::Attribute::isObjectAssociated, py::arg("componentPtr")) .def("isEntityAssociated", (bool (smtk::attribute::Attribute::*)(::smtk::common::UUID const &) const) &smtk::attribute::Attribute::isEntityAssociated, py::arg("entity")) .def("isEntityAssociated", (bool (smtk::attribute::Attribute::*)(::smtk::model::EntityRef const &) const) &smtk::attribute::Attribute::isEntityAssociated, py::arg("entityref")) - .def("isRelevant", &smtk::attribute::Attribute::isRelevant) + .def("isRelevant", &smtk::attribute::Attribute::isRelevant, py::arg("includeCategoryCheck") = true, py::arg("includeReadAccess") = false, py::arg("readAccessLevel") = 0) .def("isValid", (bool (smtk::attribute::Attribute::*)(bool) const) &smtk::attribute::Attribute::isValid, py::arg("useActiveCategories") = true) .def("isValid", (bool (smtk::attribute::Attribute::*)(std::set const &) const) &smtk::attribute::Attribute::isValid, py::arg("categories")) .def("items", &smtk::attribute::Attribute::items) diff --git a/smtk/attribute/pybind11/PybindCategories.h b/smtk/attribute/pybind11/PybindCategories.h index 9c581ca3196a193dbd18fe88751561ab5607cabc..d7662a7370efcc757291315059c6974ea90a1a44 100644 --- a/smtk/attribute/pybind11/PybindCategories.h +++ b/smtk/attribute/pybind11/PybindCategories.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::attribute::Categories > pybind11_init_smtk_attribute_Categories(py::module &m) +inline py::class_< smtk::attribute::Categories > pybind11_init_smtk_attribute_Categories(py::module &m) { py::class_< smtk::attribute::Categories > instance(m, "Categories"); instance @@ -61,14 +61,6 @@ py::class_< smtk::attribute::Categories > pybind11_init_smtk_attribute_Categorie .def("reset", &smtk::attribute::Categories::Set::reset) .def("passes", (bool (smtk::attribute::Categories::Set::*)(const ::std::set<::std::string>&) const) &smtk::attribute::Categories::Set::passes, py::arg("categories")) .def("passes", (bool (smtk::attribute::Categories::Set::*)(const ::std::string&) const) &smtk::attribute::Categories::Set::passes, py::arg("category")) - - .def("mode", &smtk::attribute::Categories::Set::inclusionMode) - .def("setMode", &smtk::attribute::Categories::Set::setInclusionMode) - .def("categoryNames", &smtk::attribute::Categories::Set::includedCategoryNames) - .def("set", &smtk::attribute::Categories::Set::setInclusions) - .def("insert", &smtk::attribute::Categories::Set::insertInclusion) - .def("erase", &smtk::attribute::Categories::Set::eraseInclusion) - .def("size", &smtk::attribute::Categories::Set::inclusionSize) ; py::enum_(instance, "CombinationMode") .value("Any", smtk::attribute::Categories::Set::CombinationMode::Any) diff --git a/smtk/attribute/pybind11/PybindComponentItem.h b/smtk/attribute/pybind11/PybindComponentItem.h index e16d68de735425b304d2afa547af43368e5de35f..e68e89d4f226bda05ab64e02bc008ea193dd477d 100644 --- a/smtk/attribute/pybind11/PybindComponentItem.h +++ b/smtk/attribute/pybind11/PybindComponentItem.h @@ -22,7 +22,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::ComponentItem, smtk::attribute::ReferenceItem > pybind11_init_smtk_attribute_ComponentItem(py::module &m) +inline PySharedPtrClass< smtk::attribute::ComponentItem, smtk::attribute::ReferenceItem > pybind11_init_smtk_attribute_ComponentItem(py::module &m) { PySharedPtrClass< smtk::attribute::ComponentItem, smtk::attribute::ReferenceItem > instance(m, "ComponentItem"); instance diff --git a/smtk/attribute/pybind11/PybindComponentItemDefinition.h b/smtk/attribute/pybind11/PybindComponentItemDefinition.h index c50daaf771b6ed0211c1c9de7385d7c35881dc2e..7bad40de166b1bc5bd7de1a834baee1292beef3e 100644 --- a/smtk/attribute/pybind11/PybindComponentItemDefinition.h +++ b/smtk/attribute/pybind11/PybindComponentItemDefinition.h @@ -22,7 +22,7 @@ namespace py = pybind11; -py::class_< smtk::attribute::ComponentItemDefinition, smtk::attribute::ReferenceItemDefinition > pybind11_init_smtk_attribute_ComponentItemDefinition(py::module &m) +inline py::class_< smtk::attribute::ComponentItemDefinition, smtk::attribute::ReferenceItemDefinition > pybind11_init_smtk_attribute_ComponentItemDefinition(py::module &m) { PySharedPtrClass< smtk::attribute::ComponentItemDefinition, smtk::attribute::ReferenceItemDefinition > instance(m, "ComponentItemDefinition"); instance diff --git a/smtk/attribute/pybind11/PybindDateTimeItem.h b/smtk/attribute/pybind11/PybindDateTimeItem.h index 3c3fd28ce94c1231c7bec5f8fa949ba9a215d4c6..4fc91e01dcebe2a6ad0163e239d21e63b598a82c 100644 --- a/smtk/attribute/pybind11/PybindDateTimeItem.h +++ b/smtk/attribute/pybind11/PybindDateTimeItem.h @@ -20,7 +20,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::DateTimeItem, smtk::attribute::Item > pybind11_init_smtk_attribute_DateTimeItem(py::module &m) +inline PySharedPtrClass< smtk::attribute::DateTimeItem, smtk::attribute::Item > pybind11_init_smtk_attribute_DateTimeItem(py::module &m) { PySharedPtrClass< smtk::attribute::DateTimeItem, smtk::attribute::Item > instance(m, "DateTimeItem"); instance diff --git a/smtk/attribute/pybind11/PybindDateTimeItemDefinition.h b/smtk/attribute/pybind11/PybindDateTimeItemDefinition.h index 61c87b35c4f8e3936f9ad2bd90c3b10abc05ce2a..d37ab90f516c6cca9a588a8cdf4bd41f3ff3f9be 100644 --- a/smtk/attribute/pybind11/PybindDateTimeItemDefinition.h +++ b/smtk/attribute/pybind11/PybindDateTimeItemDefinition.h @@ -22,7 +22,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::DateTimeItemDefinition, smtk::attribute::ItemDefinition > pybind11_init_smtk_attribute_DateTimeItemDefinition(py::module &m) +inline PySharedPtrClass< smtk::attribute::DateTimeItemDefinition, smtk::attribute::ItemDefinition > pybind11_init_smtk_attribute_DateTimeItemDefinition(py::module &m) { PySharedPtrClass< smtk::attribute::DateTimeItemDefinition, smtk::attribute::ItemDefinition > instance(m, "DateTimeItemDefinition"); instance diff --git a/smtk/attribute/pybind11/PybindDefinition.h b/smtk/attribute/pybind11/PybindDefinition.h index 4c82b04247a2b07428d3f4ee569ef97156e7617b..dda4386c13bb96d8071f541209a3bf26d9300b56 100644 --- a/smtk/attribute/pybind11/PybindDefinition.h +++ b/smtk/attribute/pybind11/PybindDefinition.h @@ -24,7 +24,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::Definition > pybind11_init_smtk_attribute_Definition(py::module &m) +inline PySharedPtrClass< smtk::attribute::Definition > pybind11_init_smtk_attribute_Definition(py::module &m) { PySharedPtrClass< smtk::attribute::Definition > instance(m, "Definition"); instance diff --git a/smtk/attribute/pybind11/PybindDirectoryItem.h b/smtk/attribute/pybind11/PybindDirectoryItem.h index c3cba9743586d33dd99ac81ab947f9757e5d2955..0675a8b6f943b6bc64aefeb7a608c68a43e29175 100644 --- a/smtk/attribute/pybind11/PybindDirectoryItem.h +++ b/smtk/attribute/pybind11/PybindDirectoryItem.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::DirectoryItem, smtk::attribute::FileSystemItem > pybind11_init_smtk_attribute_DirectoryItem(py::module &m) +inline PySharedPtrClass< smtk::attribute::DirectoryItem, smtk::attribute::FileSystemItem > pybind11_init_smtk_attribute_DirectoryItem(py::module &m) { PySharedPtrClass< smtk::attribute::DirectoryItem, smtk::attribute::FileSystemItem > instance(m, "DirectoryItem"); instance diff --git a/smtk/attribute/pybind11/PybindDirectoryItemDefinition.h b/smtk/attribute/pybind11/PybindDirectoryItemDefinition.h index fcaaab176f7e1b8a553f9b05898bedef35671352..f494a72336b729caeb6fb778d1bfcc9f6de6131b 100644 --- a/smtk/attribute/pybind11/PybindDirectoryItemDefinition.h +++ b/smtk/attribute/pybind11/PybindDirectoryItemDefinition.h @@ -22,7 +22,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::DirectoryItemDefinition, smtk::attribute::FileSystemItemDefinition > pybind11_init_smtk_attribute_DirectoryItemDefinition(py::module &m) +inline PySharedPtrClass< smtk::attribute::DirectoryItemDefinition, smtk::attribute::FileSystemItemDefinition > pybind11_init_smtk_attribute_DirectoryItemDefinition(py::module &m) { PySharedPtrClass< smtk::attribute::DirectoryItemDefinition, smtk::attribute::FileSystemItemDefinition > instance(m, "DirectoryItemDefinition"); instance diff --git a/smtk/attribute/pybind11/PybindDissociate.h b/smtk/attribute/pybind11/PybindDissociate.h index a9b80f68a293014318a859e97a444872e9402cc8..a9d928807c96091bb6eb18d93a8d78caf50e4fd8 100644 --- a/smtk/attribute/pybind11/PybindDissociate.h +++ b/smtk/attribute/pybind11/PybindDissociate.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::Dissociate, smtk::operation::XMLOperation > pybind11_init_smtk_attribute_Dissociate(py::module &m) +inline PySharedPtrClass< smtk::attribute::Dissociate, smtk::operation::XMLOperation > pybind11_init_smtk_attribute_Dissociate(py::module &m) { PySharedPtrClass< smtk::attribute::Dissociate, smtk::operation::XMLOperation > instance(m, "Dissociate"); instance diff --git a/smtk/attribute/pybind11/PybindDoubleItem.h b/smtk/attribute/pybind11/PybindDoubleItem.h index 68da230dd32b8988233833c89f96cdae68e03246..cb636cac8bc393ababe806f9215d6f58ab9a04eb 100644 --- a/smtk/attribute/pybind11/PybindDoubleItem.h +++ b/smtk/attribute/pybind11/PybindDoubleItem.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::DoubleItem, smtk::attribute::ValueItemTemplate > pybind11_init_smtk_attribute_DoubleItem(py::module &m) +inline PySharedPtrClass< smtk::attribute::DoubleItem, smtk::attribute::ValueItemTemplate > pybind11_init_smtk_attribute_DoubleItem(py::module &m) { PySharedPtrClass< smtk::attribute::DoubleItem, smtk::attribute::ValueItemTemplate > instance(m, "DoubleItem"); instance diff --git a/smtk/attribute/pybind11/PybindDoubleItemDefinition.h b/smtk/attribute/pybind11/PybindDoubleItemDefinition.h index 2da22dda64cf58329751ed5f9d85bdb8ff735622..96167bffd56f7300e3a59b98a95c4d0574eaa784 100644 --- a/smtk/attribute/pybind11/PybindDoubleItemDefinition.h +++ b/smtk/attribute/pybind11/PybindDoubleItemDefinition.h @@ -21,7 +21,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::DoubleItemDefinition, smtk::attribute::ValueItemDefinitionTemplate > pybind11_init_smtk_attribute_DoubleItemDefinition(py::module &m) +inline PySharedPtrClass< smtk::attribute::DoubleItemDefinition, smtk::attribute::ValueItemDefinitionTemplate > pybind11_init_smtk_attribute_DoubleItemDefinition(py::module &m) { PySharedPtrClass< smtk::attribute::DoubleItemDefinition, smtk::attribute::ValueItemDefinitionTemplate > instance(m, "DoubleItemDefinition"); instance diff --git a/smtk/attribute/pybind11/PybindExport.h b/smtk/attribute/pybind11/PybindExport.h index b8ea3b385fea895632a623a108376f4b174d7cc8..a20bb348f9c9f434aef9320abd5a5e3651123286 100644 --- a/smtk/attribute/pybind11/PybindExport.h +++ b/smtk/attribute/pybind11/PybindExport.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::Export, smtk::operation::XMLOperation > pybind11_init_smtk_attribute_Export(py::module &m) +inline PySharedPtrClass< smtk::attribute::Export, smtk::operation::XMLOperation > pybind11_init_smtk_attribute_Export(py::module &m) { PySharedPtrClass< smtk::attribute::Export, smtk::operation::XMLOperation > instance(m, "Export"); instance diff --git a/smtk/attribute/pybind11/PybindFileItem.h b/smtk/attribute/pybind11/PybindFileItem.h index 93bdc56db47501b61a54a8eb81f72c1a414f0b66..ac714c3ed1747a120f9f692e33c659a4af8e56af 100644 --- a/smtk/attribute/pybind11/PybindFileItem.h +++ b/smtk/attribute/pybind11/PybindFileItem.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::FileItem, smtk::attribute::FileSystemItem > pybind11_init_smtk_attribute_FileItem(py::module &m) +inline PySharedPtrClass< smtk::attribute::FileItem, smtk::attribute::FileSystemItem > pybind11_init_smtk_attribute_FileItem(py::module &m) { PySharedPtrClass< smtk::attribute::FileItem, smtk::attribute::FileSystemItem > instance(m, "FileItem"); instance diff --git a/smtk/attribute/pybind11/PybindFileItemDefinition.h b/smtk/attribute/pybind11/PybindFileItemDefinition.h index 9d7174a5c0b0e7cdb0d7713ff49419c9eb28b9a2..741824348960607817b81df942c64d6169dbb5b0 100644 --- a/smtk/attribute/pybind11/PybindFileItemDefinition.h +++ b/smtk/attribute/pybind11/PybindFileItemDefinition.h @@ -22,7 +22,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::FileItemDefinition, smtk::attribute::FileSystemItemDefinition > pybind11_init_smtk_attribute_FileItemDefinition(py::module &m) +inline PySharedPtrClass< smtk::attribute::FileItemDefinition, smtk::attribute::FileSystemItemDefinition > pybind11_init_smtk_attribute_FileItemDefinition(py::module &m) { PySharedPtrClass< smtk::attribute::FileItemDefinition, smtk::attribute::FileSystemItemDefinition > instance(m, "FileItemDefinition"); instance diff --git a/smtk/attribute/pybind11/PybindFileSystemItem.h b/smtk/attribute/pybind11/PybindFileSystemItem.h index 4c7f0b189e9947b93b49e66d56708ba54f66d53c..5def35fc17860d9b00d1c284c743d4d71a4e6d4b 100644 --- a/smtk/attribute/pybind11/PybindFileSystemItem.h +++ b/smtk/attribute/pybind11/PybindFileSystemItem.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::FileSystemItem, smtk::attribute::Item > pybind11_init_smtk_attribute_FileSystemItem(py::module &m) +inline PySharedPtrClass< smtk::attribute::FileSystemItem, smtk::attribute::Item > pybind11_init_smtk_attribute_FileSystemItem(py::module &m) { PySharedPtrClass< smtk::attribute::FileSystemItem, smtk::attribute::Item > instance(m, "FileSystemItem"); instance diff --git a/smtk/attribute/pybind11/PybindFileSystemItemDefinition.h b/smtk/attribute/pybind11/PybindFileSystemItemDefinition.h index e5db391be268ad8b7e6ea4c20f12a47773deafd4..5de6e3ded5c6b3ba13bdbc9c58c5f548f5377573 100644 --- a/smtk/attribute/pybind11/PybindFileSystemItemDefinition.h +++ b/smtk/attribute/pybind11/PybindFileSystemItemDefinition.h @@ -21,7 +21,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::FileSystemItemDefinition, smtk::attribute::ItemDefinition > pybind11_init_smtk_attribute_FileSystemItemDefinition(py::module &m) +inline PySharedPtrClass< smtk::attribute::FileSystemItemDefinition, smtk::attribute::ItemDefinition > pybind11_init_smtk_attribute_FileSystemItemDefinition(py::module &m) { PySharedPtrClass< smtk::attribute::FileSystemItemDefinition, smtk::attribute::ItemDefinition > instance(m, "FileSystemItemDefinition"); instance diff --git a/smtk/attribute/pybind11/PybindGroupItem.h b/smtk/attribute/pybind11/PybindGroupItem.h index a2ac7f93483e9bd1a9d75db2a2dfce1b0d283b36..19ba0124505d99cd3b863b8546b86245fd35d3c9 100644 --- a/smtk/attribute/pybind11/PybindGroupItem.h +++ b/smtk/attribute/pybind11/PybindGroupItem.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::GroupItem, smtk::attribute::Item > pybind11_init_smtk_attribute_GroupItem(py::module &m) +inline PySharedPtrClass< smtk::attribute::GroupItem, smtk::attribute::Item > pybind11_init_smtk_attribute_GroupItem(py::module &m) { PySharedPtrClass< smtk::attribute::GroupItem, smtk::attribute::Item > instance(m, "GroupItem"); instance @@ -28,7 +28,7 @@ PySharedPtrClass< smtk::attribute::GroupItem, smtk::attribute::Item > pybind11_i .def("appendGroup", &smtk::attribute::GroupItem::appendGroup) .def("assign", &smtk::attribute::GroupItem::assign, py::arg("sourceItem"), py::arg("options") = 0) .def("begin", &smtk::attribute::GroupItem::begin) - .def("conditionalsSatisfied", &smtk::attribute::GroupItem::conditionalsSatisfied) + .def("conditionalsSatisfied", &smtk::attribute::GroupItem::conditionalsSatisfied, py::arg("useActiveCategories") = true) .def("end", &smtk::attribute::GroupItem::end) .def("_find", (smtk::attribute::ItemPtr (smtk::attribute::GroupItem::*)(::std::string const &, ::smtk::attribute::SearchStyle)) &smtk::attribute::GroupItem::find, py::arg("name"), py::arg("style") = ::smtk::attribute::SearchStyle::IMMEDIATE) .def("_find", (smtk::attribute::ItemPtr (smtk::attribute::GroupItem::*)(::size_t, ::std::string const &, ::smtk::attribute::SearchStyle)) &smtk::attribute::GroupItem::find, py::arg("element"), py::arg("name"), py::arg("style") = ::smtk::attribute::SearchStyle::IMMEDIATE) @@ -38,6 +38,7 @@ PySharedPtrClass< smtk::attribute::GroupItem, smtk::attribute::Item > pybind11_i .def("isExtensible", &smtk::attribute::GroupItem::isExtensible) .def("item", (smtk::attribute::ItemPtr (smtk::attribute::GroupItem::*)(::size_t) const) &smtk::attribute::GroupItem::item, py::arg("ith")) .def("item", (smtk::attribute::ItemPtr (smtk::attribute::GroupItem::*)(::size_t, ::size_t) const) &smtk::attribute::GroupItem::item, py::arg("element"), py::arg("ith")) + .def("hasRelevantChildren", &smtk::attribute::GroupItem::insertGroups, py::arg("includeReadAccess"), py::arg("readAccessLevel")) .def("maxNumberOfChoices", &smtk::attribute::GroupItem::maxNumberOfChoices) .def("maxNumberOfGroups", &smtk::attribute::GroupItem::maxNumberOfGroups) .def("minNumberOfChoices", &smtk::attribute::GroupItem::minNumberOfChoices) diff --git a/smtk/attribute/pybind11/PybindGroupItemDefinition.h b/smtk/attribute/pybind11/PybindGroupItemDefinition.h index ed7073a8f24e9879b07daf01e140d999ae7272b5..3e6551270be65e46302678e1037ce759451e4eca 100644 --- a/smtk/attribute/pybind11/PybindGroupItemDefinition.h +++ b/smtk/attribute/pybind11/PybindGroupItemDefinition.h @@ -22,7 +22,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::GroupItemDefinition, smtk::attribute::ItemDefinition > pybind11_init_smtk_attribute_GroupItemDefinition(py::module &m) +inline PySharedPtrClass< smtk::attribute::GroupItemDefinition, smtk::attribute::ItemDefinition > pybind11_init_smtk_attribute_GroupItemDefinition(py::module &m) { PySharedPtrClass< smtk::attribute::GroupItemDefinition, smtk::attribute::ItemDefinition > instance(m, "GroupItemDefinition"); instance diff --git a/smtk/attribute/pybind11/PybindImport.h b/smtk/attribute/pybind11/PybindImport.h index c728415f62fb49447b82cb7601b331793f332d97..2c6d16ad18d71b202e08791226ea80fa1e96d82c 100644 --- a/smtk/attribute/pybind11/PybindImport.h +++ b/smtk/attribute/pybind11/PybindImport.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::Import, smtk::operation::XMLOperation > pybind11_init_smtk_attribute_Import(py::module &m) +inline PySharedPtrClass< smtk::attribute::Import, smtk::operation::XMLOperation > pybind11_init_smtk_attribute_Import(py::module &m) { PySharedPtrClass< smtk::attribute::Import, smtk::operation::XMLOperation > instance(m, "Import"); instance diff --git a/smtk/attribute/pybind11/PybindIntItem.h b/smtk/attribute/pybind11/PybindIntItem.h index d87a753cbdcbe5a421bf44cdb9319c37cf905a70..6ec42bbfc5a22505abd83c073b09224161443278 100644 --- a/smtk/attribute/pybind11/PybindIntItem.h +++ b/smtk/attribute/pybind11/PybindIntItem.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::IntItem, smtk::attribute::ValueItemTemplate > pybind11_init_smtk_attribute_IntItem(py::module &m) +inline PySharedPtrClass< smtk::attribute::IntItem, smtk::attribute::ValueItemTemplate > pybind11_init_smtk_attribute_IntItem(py::module &m) { PySharedPtrClass< smtk::attribute::IntItem, smtk::attribute::ValueItemTemplate > instance(m, "IntItem"); instance diff --git a/smtk/attribute/pybind11/PybindIntItemDefinition.h b/smtk/attribute/pybind11/PybindIntItemDefinition.h index c213c9b5813f4cbc66dbad9d944797d08b82a028..91e73a6fbe623e718aff0210fd8419d406ce0caa 100644 --- a/smtk/attribute/pybind11/PybindIntItemDefinition.h +++ b/smtk/attribute/pybind11/PybindIntItemDefinition.h @@ -21,7 +21,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::IntItemDefinition, smtk::attribute::ValueItemDefinitionTemplate > pybind11_init_smtk_attribute_IntItemDefinition(py::module &m) +inline PySharedPtrClass< smtk::attribute::IntItemDefinition, smtk::attribute::ValueItemDefinitionTemplate > pybind11_init_smtk_attribute_IntItemDefinition(py::module &m) { PySharedPtrClass< smtk::attribute::IntItemDefinition, smtk::attribute::ValueItemDefinitionTemplate > instance(m, "IntItemDefinition"); instance diff --git a/smtk/attribute/pybind11/PybindItem.h b/smtk/attribute/pybind11/PybindItem.h index 3203896fb9187858339545e95ff497b54ef2977b..0913273a417de8851a3d23bd678dbf739395fcfc 100644 --- a/smtk/attribute/pybind11/PybindItem.h +++ b/smtk/attribute/pybind11/PybindItem.h @@ -20,7 +20,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::Item > pybind11_init_smtk_attribute_Item(py::module &m) +inline PySharedPtrClass< smtk::attribute::Item > pybind11_init_smtk_attribute_Item(py::module &m) { PySharedPtrClass< smtk::attribute::Item > instance(m, "Item"); instance @@ -30,7 +30,7 @@ PySharedPtrClass< smtk::attribute::Item > pybind11_init_smtk_attribute_Item(py:: .def("name", &smtk::attribute::Item::name) .def("label", &smtk::attribute::Item::label) .def("type", &smtk::attribute::Item::type) - .def("isRelevant", &smtk::attribute::Item::isRelevant) + .def("isRelevant", &smtk::attribute::Item::isRelevant, py::arg("includeCategoryChecking") = true, py::arg("includeReadAccess") = true, py::arg("readAccessLevel") = 0) .def("isValid", (bool (smtk::attribute::Item::*)(bool) const) &smtk::attribute::Item::isValid, py::arg("useActiveCategories") = true) .def("isValid", (bool (smtk::attribute::Item::*)(std::set const &) const) &smtk::attribute::Item::isValid, py::arg("categories")) .def("definition", &smtk::attribute::Item::definition) @@ -44,6 +44,8 @@ PySharedPtrClass< smtk::attribute::Item > pybind11_init_smtk_attribute_Item(py:: .def("localEnabledState", &smtk::attribute::Item::localEnabledState) .def("setForceRequired", &smtk::attribute::Item::setForceRequired, py::arg("forceRequiredMode")) .def("forceRequired", &smtk::attribute::Item::forceRequired) + .def("setIsIgnored", &smtk::attribute::Item::setIsIgnored, py::arg("isIgnoredValue")) + .def("isIgnored", &smtk::attribute::Item::isIgnored) // NOTE that the Python form of this method is returning a copy since Python // doesn't support const references .def("categories", &smtk::attribute::Item::categories) diff --git a/smtk/attribute/pybind11/PybindItemDefinition.h b/smtk/attribute/pybind11/PybindItemDefinition.h index b49e7d5fe66050c57e0ebc362790b772be413b19..51d3378fbad724815fc90af932d077f4700fe338 100644 --- a/smtk/attribute/pybind11/PybindItemDefinition.h +++ b/smtk/attribute/pybind11/PybindItemDefinition.h @@ -22,7 +22,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::ItemDefinition > pybind11_init_smtk_attribute_ItemDefinition(py::module &m) +inline PySharedPtrClass< smtk::attribute::ItemDefinition > pybind11_init_smtk_attribute_ItemDefinition(py::module &m) { PySharedPtrClass< smtk::attribute::ItemDefinition > instance(m, "ItemDefinition"); instance diff --git a/smtk/attribute/pybind11/PybindModelEntityItem.h b/smtk/attribute/pybind11/PybindModelEntityItem.h index 435f32bbcc2032f85ca63250eb2d490f87152801..c47b31ada8876692cc4eb4814cbcafbffc4b2386 100644 --- a/smtk/attribute/pybind11/PybindModelEntityItem.h +++ b/smtk/attribute/pybind11/PybindModelEntityItem.h @@ -22,7 +22,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::ModelEntityItem, smtk::attribute::ComponentItem > pybind11_init_smtk_attribute_ModelEntityItem(py::module &m) +inline PySharedPtrClass< smtk::attribute::ModelEntityItem, smtk::attribute::ComponentItem > pybind11_init_smtk_attribute_ModelEntityItem(py::module &m) { PySharedPtrClass< smtk::attribute::ModelEntityItem, smtk::attribute::ComponentItem > instance(m, "ModelEntityItem"); instance diff --git a/smtk/attribute/pybind11/PybindModelEntityItemDefinition.h b/smtk/attribute/pybind11/PybindModelEntityItemDefinition.h index 50796c1455e0cfffa2a0dfdac512ad845d5570d5..afdeca20ee00de1d6adb168250c64bfd49871a1e 100644 --- a/smtk/attribute/pybind11/PybindModelEntityItemDefinition.h +++ b/smtk/attribute/pybind11/PybindModelEntityItemDefinition.h @@ -22,7 +22,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::ModelEntityItemDefinition, smtk::attribute::ComponentItemDefinition > pybind11_init_smtk_attribute_ModelEntityItemDefinition(py::module &m) +inline PySharedPtrClass< smtk::attribute::ModelEntityItemDefinition, smtk::attribute::ComponentItemDefinition > pybind11_init_smtk_attribute_ModelEntityItemDefinition(py::module &m) { PySharedPtrClass< smtk::attribute::ModelEntityItemDefinition, smtk::attribute::ComponentItemDefinition > instance(m, "ModelEntityItemDefinition"); instance diff --git a/smtk/attribute/pybind11/PybindQueries.h b/smtk/attribute/pybind11/PybindQueries.h index d3e477a2e56911694cd8f75c206b49cdd130aaf9..877f96ad3091c9ec801d79723507d8de291d9325 100644 --- a/smtk/attribute/pybind11/PybindQueries.h +++ b/smtk/attribute/pybind11/PybindQueries.h @@ -19,7 +19,7 @@ namespace py = pybind11; -void pybind11_init_smtk_attribute_queries(py::module &m) +inline void pybind11_init_smtk_attribute_queries(py::module &m) { m.def("checkUniquenessCondition", &smtk::attribute::utility::checkUniquenessCondition); m.def("associatableObjects", (std::set (*)(const smtk::attribute::ConstReferenceItemDefinitionPtr&, diff --git a/smtk/attribute/pybind11/PybindRead.h b/smtk/attribute/pybind11/PybindRead.h index 4251b1864405bab9bcc9c460b142db448cc2548c..9991d9116cf442f0c336ef318508d4477ce65f9e 100644 --- a/smtk/attribute/pybind11/PybindRead.h +++ b/smtk/attribute/pybind11/PybindRead.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::Read, smtk::operation::XMLOperation > pybind11_init_smtk_attribute_Read(py::module &m) +inline PySharedPtrClass< smtk::attribute::Read, smtk::operation::XMLOperation > pybind11_init_smtk_attribute_Read(py::module &m) { PySharedPtrClass< smtk::attribute::Read, smtk::operation::XMLOperation > instance(m, "Read"); instance diff --git a/smtk/attribute/pybind11/PybindReferenceItem.h b/smtk/attribute/pybind11/PybindReferenceItem.h index 3a0799046837016495f558b29038a5791b3866aa..7db3db0b20cfe848f7047cdb229a65de54af33a5 100644 --- a/smtk/attribute/pybind11/PybindReferenceItem.h +++ b/smtk/attribute/pybind11/PybindReferenceItem.h @@ -17,15 +17,14 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::ReferenceItem, smtk::attribute::Item > pybind11_init_smtk_attribute_ReferenceItem(py::module &m) +inline PySharedPtrClass< smtk::attribute::ReferenceItem, smtk::attribute::Item > pybind11_init_smtk_attribute_ReferenceItem(py::module &m) { PySharedPtrClass< smtk::attribute::ReferenceItem, smtk::attribute::Item > instance(m, "ReferenceItem"); instance .def(py::init<::smtk::attribute::ReferenceItem const &>()) .def("deepcopy", (smtk::attribute::ReferenceItem & (smtk::attribute::ReferenceItem::*)(::smtk::attribute::ReferenceItem const &)) &smtk::attribute::ReferenceItem::operator=) .def("_activeChildItem", &smtk::attribute::ReferenceItem::activeChildItem, py::arg("i")) - .def("appendValue", &smtk::attribute::ReferenceItem::appendValue, py::arg("val")) - .def("appendObjectValue", &smtk::attribute::ReferenceItem::appendValue, py::arg("val")) + .def("appendValue", &smtk::attribute::ReferenceItem::appendValue, py::arg("val"), py::arg("allowDuplicates") = true) .def("assign", &smtk::attribute::ReferenceItem::assign, py::arg("sourceItem"), py::arg("options") = 0) .def("begin", &smtk::attribute::ReferenceItem::begin) .def("childrenItems", &smtk::attribute::ReferenceItem::childrenItems) @@ -48,13 +47,10 @@ PySharedPtrClass< smtk::attribute::ReferenceItem, smtk::attribute::Item > pybind .def("numberOfChildrenItems", &smtk::attribute::ReferenceItem::numberOfChildrenItems) .def("numberOfRequiredValues", &smtk::attribute::ReferenceItem::numberOfRequiredValues) .def("numberOfValues", &smtk::attribute::ReferenceItem::numberOfValues) - .def("objectValue", (smtk::resource::PersistentObjectPtr (smtk::attribute::ReferenceItem::*)(std::size_t) const) &smtk::attribute::ReferenceItem::value, py::arg("i") = 0) .def("value", (smtk::resource::PersistentObjectPtr (smtk::attribute::ReferenceItem::*)(std::size_t) const) &smtk::attribute::ReferenceItem::value, py::arg("i") = 0) .def("removeValue", &smtk::attribute::ReferenceItem::removeValue, py::arg("i")) .def("reset", &smtk::attribute::ReferenceItem::reset) .def("setNumberOfValues", &smtk::attribute::ReferenceItem::setNumberOfValues, py::arg("newSize")) - .def("setObjectValue", (bool (smtk::attribute::ReferenceItem::*)(const ::smtk::resource::PersistentObjectPtr&)) &smtk::attribute::ReferenceItem::setValue, py::arg("val")) - .def("setObjectValue", (bool (smtk::attribute::ReferenceItem::*)(::size_t, const ::smtk::resource::PersistentObjectPtr&)) &smtk::attribute::ReferenceItem::setValue, py::arg("i"), py::arg("val")) .def("setValue", (bool (smtk::attribute::ReferenceItem::*)(const ::smtk::resource::PersistentObjectPtr&)) &smtk::attribute::ReferenceItem::setValue, py::arg("val")) .def("setValue", (bool (smtk::attribute::ReferenceItem::*)(::size_t, const ::smtk::resource::PersistentObjectPtr&)) &smtk::attribute::ReferenceItem::setValue, py::arg("i"), py::arg("val")) .def("type", &smtk::attribute::ReferenceItem::type) diff --git a/smtk/attribute/pybind11/PybindReferenceItemDefinition.h b/smtk/attribute/pybind11/PybindReferenceItemDefinition.h index dc538c20776570819eaa1d059fec8abb97b34ed0..da0c7832759b986a27023af7d5c98793a037e961 100644 --- a/smtk/attribute/pybind11/PybindReferenceItemDefinition.h +++ b/smtk/attribute/pybind11/PybindReferenceItemDefinition.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass +inline PySharedPtrClass pybind11_init_smtk_attribute_ReferenceItemDefinition(py::module& m) { PySharedPtrClass diff --git a/smtk/attribute/pybind11/PybindRegistrar.h b/smtk/attribute/pybind11/PybindRegistrar.h index 5ea2c028882145c6fd1a0ca85ee3f356730995ce..a8596cdd464b1841ede7f1f9d957b1ed2e96ff83 100644 --- a/smtk/attribute/pybind11/PybindRegistrar.h +++ b/smtk/attribute/pybind11/PybindRegistrar.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::attribute::Registrar > pybind11_init_smtk_attribute_Registrar(py::module &m) +inline py::class_< smtk::attribute::Registrar > pybind11_init_smtk_attribute_Registrar(py::module &m) { py::class_< smtk::attribute::Registrar > instance(m, "Registrar"); instance diff --git a/smtk/attribute/pybind11/PybindResource.h b/smtk/attribute/pybind11/PybindResource.h index daf0947d80504d76ab4743bf8fee28cddfd10bfa..35deee0e0f2430e2f38827f984a738fdcf528db4 100644 --- a/smtk/attribute/pybind11/PybindResource.h +++ b/smtk/attribute/pybind11/PybindResource.h @@ -25,7 +25,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::Resource> pybind11_init_smtk_attribute_Resource(py::module &m) +inline PySharedPtrClass< smtk::attribute::Resource> pybind11_init_smtk_attribute_Resource(py::module &m) { PySharedPtrClass< smtk::attribute::Resource, smtk::resource::Resource> instance(m, "Resource"); instance diff --git a/smtk/attribute/pybind11/PybindResourceItem.h b/smtk/attribute/pybind11/PybindResourceItem.h index 577801c455efa519d8c0906fec1f4ea46f624cf9..34feedbe793401ba933202b83c9b35fb4d259a2f 100644 --- a/smtk/attribute/pybind11/PybindResourceItem.h +++ b/smtk/attribute/pybind11/PybindResourceItem.h @@ -22,7 +22,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::ResourceItem, smtk::attribute::ReferenceItem > pybind11_init_smtk_attribute_ResourceItem(py::module &m) +inline PySharedPtrClass< smtk::attribute::ResourceItem, smtk::attribute::ReferenceItem > pybind11_init_smtk_attribute_ResourceItem(py::module &m) { PySharedPtrClass< smtk::attribute::ResourceItem, smtk::attribute::ReferenceItem > instance(m, "ResourceItem"); instance diff --git a/smtk/attribute/pybind11/PybindResourceItemDefinition.h b/smtk/attribute/pybind11/PybindResourceItemDefinition.h index 3de72435898ef7c7d075597832aa51543d143bf1..e13866c1e63a1fc2498079db679439522de69db0 100644 --- a/smtk/attribute/pybind11/PybindResourceItemDefinition.h +++ b/smtk/attribute/pybind11/PybindResourceItemDefinition.h @@ -22,7 +22,7 @@ namespace py = pybind11; -py::class_< smtk::attribute::ResourceItemDefinition, smtk::attribute::ReferenceItemDefinition > pybind11_init_smtk_attribute_ResourceItemDefinition(py::module &m) +inline py::class_< smtk::attribute::ResourceItemDefinition, smtk::attribute::ReferenceItemDefinition > pybind11_init_smtk_attribute_ResourceItemDefinition(py::module &m) { PySharedPtrClass< smtk::attribute::ResourceItemDefinition, smtk::attribute::ReferenceItemDefinition > instance(m, "ResourceItemDefinition"); instance diff --git a/smtk/attribute/pybind11/PybindSearchStyle.h b/smtk/attribute/pybind11/PybindSearchStyle.h index cdf32b727c51dea03a053f9f02656257b1dc81d5..fbade45444799dda28f5c0d11b6c5e1eb28d1ac5 100644 --- a/smtk/attribute/pybind11/PybindSearchStyle.h +++ b/smtk/attribute/pybind11/PybindSearchStyle.h @@ -17,7 +17,7 @@ namespace py = pybind11; -void pybind11_init_smtk_attribute_SearchStyle(py::module &m) +inline void pybind11_init_smtk_attribute_SearchStyle(py::module &m) { py::enum_(m, "SearchStyle") .value("IMMEDIATE", smtk::attribute::SearchStyle::IMMEDIATE) diff --git a/smtk/attribute/pybind11/PybindStringItem.h b/smtk/attribute/pybind11/PybindStringItem.h index 6cd6bc4188fab2250c92f51afa36992a72a1e066..431f01c819995671447174aa43b4595a69bf6e7d 100644 --- a/smtk/attribute/pybind11/PybindStringItem.h +++ b/smtk/attribute/pybind11/PybindStringItem.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::StringItem, smtk::attribute::ValueItemTemplate > > pybind11_init_smtk_attribute_StringItem(py::module &m) +inline PySharedPtrClass< smtk::attribute::StringItem, smtk::attribute::ValueItemTemplate > > pybind11_init_smtk_attribute_StringItem(py::module &m) { PySharedPtrClass< smtk::attribute::StringItem, smtk::attribute::ValueItemTemplate > > instance(m, "StringItem"); instance diff --git a/smtk/attribute/pybind11/PybindStringItemDefinition.h b/smtk/attribute/pybind11/PybindStringItemDefinition.h index 2c956cc851191a0e78bccc1b3512eb5beb3c870f..44e6b9e5fa185a413bb3b503ebc4830d0fea85b8 100644 --- a/smtk/attribute/pybind11/PybindStringItemDefinition.h +++ b/smtk/attribute/pybind11/PybindStringItemDefinition.h @@ -21,7 +21,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::StringItemDefinition, smtk::attribute::ValueItemDefinitionTemplate > > pybind11_init_smtk_attribute_StringItemDefinition(py::module &m) +inline PySharedPtrClass< smtk::attribute::StringItemDefinition, smtk::attribute::ValueItemDefinitionTemplate > > pybind11_init_smtk_attribute_StringItemDefinition(py::module &m) { PySharedPtrClass< smtk::attribute::StringItemDefinition, smtk::attribute::ValueItemDefinitionTemplate > > instance(m, "StringItemDefinition"); instance diff --git a/smtk/attribute/pybind11/PybindTag.h b/smtk/attribute/pybind11/PybindTag.h index b4487539653d0e3c7bf317a4b2c9122e3fa1f251..f6524d9c98c1c45adf596f2afc780625e88bf009 100644 --- a/smtk/attribute/pybind11/PybindTag.h +++ b/smtk/attribute/pybind11/PybindTag.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::attribute::Tag > pybind11_init_smtk_attribute_Tag(py::module &m) +inline py::class_< smtk::attribute::Tag > pybind11_init_smtk_attribute_Tag(py::module &m) { py::class_< smtk::attribute::Tag > instance(m, "Tag"); instance diff --git a/smtk/attribute/pybind11/PybindValueItem.h b/smtk/attribute/pybind11/PybindValueItem.h index 604520cc594179e92a61450b2de8cda6830268e0..80125c2b9a1be49706f1c1b4385caa4a948211e5 100644 --- a/smtk/attribute/pybind11/PybindValueItem.h +++ b/smtk/attribute/pybind11/PybindValueItem.h @@ -21,7 +21,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::ValueItem, smtk::attribute::Item > pybind11_init_smtk_attribute_ValueItem(py::module &m) +inline PySharedPtrClass< smtk::attribute::ValueItem, smtk::attribute::Item > pybind11_init_smtk_attribute_ValueItem(py::module &m) { PySharedPtrClass< smtk::attribute::ValueItem, smtk::attribute::Item > instance(m, "ValueItem"); instance diff --git a/smtk/attribute/pybind11/PybindValueItemDefinition.h b/smtk/attribute/pybind11/PybindValueItemDefinition.h index 5243bc03b25e38a2ebfe6e61e669e061c1f5879f..f43558edd01be6ceccc77efea68fdd268c1bbec1 100644 --- a/smtk/attribute/pybind11/PybindValueItemDefinition.h +++ b/smtk/attribute/pybind11/PybindValueItemDefinition.h @@ -22,7 +22,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::ValueItemDefinition, smtk::attribute::ItemDefinition > pybind11_init_smtk_attribute_ValueItemDefinition(py::module &m) +inline PySharedPtrClass< smtk::attribute::ValueItemDefinition, smtk::attribute::ItemDefinition > pybind11_init_smtk_attribute_ValueItemDefinition(py::module &m) { PySharedPtrClass< smtk::attribute::ValueItemDefinition, smtk::attribute::ItemDefinition > instance(m, "ValueItemDefinition"); instance diff --git a/smtk/attribute/pybind11/PybindValueItemDefinitionTemplate.h b/smtk/attribute/pybind11/PybindValueItemDefinitionTemplate.h index e7ecd8d8683a8caa63ab03470d4bf724d87e6dbf..24438657596643eee82f3de402af1b15c9de5f74 100644 --- a/smtk/attribute/pybind11/PybindValueItemDefinitionTemplate.h +++ b/smtk/attribute/pybind11/PybindValueItemDefinitionTemplate.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass, smtk::attribute::ValueItemDefinition> pybind11_init_smtk_attribute_ValueItemDefinitionTemplate_int_(py::module &m) +inline PySharedPtrClass, smtk::attribute::ValueItemDefinition> pybind11_init_smtk_attribute_ValueItemDefinitionTemplate_int_(py::module &m) { PySharedPtrClass, smtk::attribute::ValueItemDefinition> instance(m, "ValueItemDefinitionTemplate_int_"); instance @@ -48,7 +48,7 @@ PySharedPtrClass, smtk::attrib return instance; } -PySharedPtrClass, smtk::attribute::ValueItemDefinition> pybind11_init_smtk_attribute_ValueItemDefinitionTemplate_double_(py::module &m) +inline PySharedPtrClass, smtk::attribute::ValueItemDefinition> pybind11_init_smtk_attribute_ValueItemDefinitionTemplate_double_(py::module &m) { PySharedPtrClass, smtk::attribute::ValueItemDefinition> instance(m, "ValueItemDefinitionTemplate_double_"); instance @@ -77,7 +77,7 @@ PySharedPtrClass, smtk::att return instance; } -PySharedPtrClass, smtk::attribute::ValueItemDefinition> pybind11_init_smtk_attribute_ValueItemDefinitionTemplate_string_(py::module &m) +inline PySharedPtrClass, smtk::attribute::ValueItemDefinition> pybind11_init_smtk_attribute_ValueItemDefinitionTemplate_string_(py::module &m) { PySharedPtrClass, smtk::attribute::ValueItemDefinition> instance(m, "ValueItemDefinitionTemplate_string_"); instance @@ -106,7 +106,7 @@ PySharedPtrClass, smtk return instance; } -PySharedPtrClass, smtk::attribute::ValueItemDefinition> pybind11_init_smtk_attribute_ValueItemDefinitionTemplate_datetime_(py::module &m) +inline PySharedPtrClass, smtk::attribute::ValueItemDefinition> pybind11_init_smtk_attribute_ValueItemDefinitionTemplate_datetime_(py::module &m) { PySharedPtrClass, smtk::attribute::ValueItemDefinition> instance(m, "ValueItemDefinitionTemplate_datetime_"); instance diff --git a/smtk/attribute/pybind11/PybindValueItemTemplate.h b/smtk/attribute/pybind11/PybindValueItemTemplate.h index 33a514f3c3456d68c017d50f7a00e2852a087095..e2e5b8e921dff1c6c70a6b2ccc47307c3b817c20 100644 --- a/smtk/attribute/pybind11/PybindValueItemTemplate.h +++ b/smtk/attribute/pybind11/PybindValueItemTemplate.h @@ -18,7 +18,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::ValueItemTemplate, smtk::attribute::ValueItem > pybind11_init_smtk_attribute_ValueItemTemplate_int_(py::module &m) +inline PySharedPtrClass< smtk::attribute::ValueItemTemplate, smtk::attribute::ValueItem > pybind11_init_smtk_attribute_ValueItemTemplate_int_(py::module &m) { PySharedPtrClass< smtk::attribute::ValueItemTemplate, smtk::attribute::ValueItem > instance(m, "ValueItemTemplate_int_"); instance @@ -47,7 +47,7 @@ PySharedPtrClass< smtk::attribute::ValueItemTemplate, smtk::attribute::Valu return instance; } -PySharedPtrClass, smtk::attribute::ValueItem > pybind11_init_smtk_attribute_ValueItemTemplate_double_(py::module &m) +inline PySharedPtrClass, smtk::attribute::ValueItem > pybind11_init_smtk_attribute_ValueItemTemplate_double_(py::module &m) { PySharedPtrClass, smtk::attribute::ValueItem > instance(m, "ValueItemTemplate_double_"); instance @@ -76,7 +76,7 @@ PySharedPtrClass, smtk::attribute::Va return instance; } -PySharedPtrClass, smtk::attribute::ValueItem > pybind11_init_smtk_attribute_ValueItemTemplate_string_(py::module &m) +inline PySharedPtrClass, smtk::attribute::ValueItem > pybind11_init_smtk_attribute_ValueItemTemplate_string_(py::module &m) { PySharedPtrClass, smtk::attribute::ValueItem > instance(m, "ValueItemTemplate_string_"); instance diff --git a/smtk/attribute/pybind11/PybindVoidItem.h b/smtk/attribute/pybind11/PybindVoidItem.h index 75d4a205c3c655b2b309bb9d50dcb8b642336b98..c3ddcb0dedf7d8d8d1738e40a1fe12ee761515ae 100644 --- a/smtk/attribute/pybind11/PybindVoidItem.h +++ b/smtk/attribute/pybind11/PybindVoidItem.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::VoidItem, smtk::attribute::Item > pybind11_init_smtk_attribute_VoidItem(py::module &m) +inline PySharedPtrClass< smtk::attribute::VoidItem, smtk::attribute::Item > pybind11_init_smtk_attribute_VoidItem(py::module &m) { PySharedPtrClass< smtk::attribute::VoidItem, smtk::attribute::Item > instance(m, "VoidItem"); instance diff --git a/smtk/attribute/pybind11/PybindVoidItemDefinition.h b/smtk/attribute/pybind11/PybindVoidItemDefinition.h index 441de74cad40fa122775e53a1ed065a1329f1c00..ba10252f2b8209cd972d0f22f83e3c11be723ba0 100644 --- a/smtk/attribute/pybind11/PybindVoidItemDefinition.h +++ b/smtk/attribute/pybind11/PybindVoidItemDefinition.h @@ -21,7 +21,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::VoidItemDefinition, smtk::attribute::ItemDefinition > pybind11_init_smtk_attribute_VoidItemDefinition(py::module &m) +inline PySharedPtrClass< smtk::attribute::VoidItemDefinition, smtk::attribute::ItemDefinition > pybind11_init_smtk_attribute_VoidItemDefinition(py::module &m) { PySharedPtrClass< smtk::attribute::VoidItemDefinition, smtk::attribute::ItemDefinition > instance(m, "VoidItemDefinition"); instance diff --git a/smtk/attribute/pybind11/PybindWrite.h b/smtk/attribute/pybind11/PybindWrite.h index 497ef96766c6c518b06e83e76b49a985dc9145a5..732168964a87e02a05724d8e3dcdc2c18f471220 100644 --- a/smtk/attribute/pybind11/PybindWrite.h +++ b/smtk/attribute/pybind11/PybindWrite.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::attribute::Write, smtk::operation::XMLOperation > pybind11_init_smtk_attribute_Write(py::module &m) +inline PySharedPtrClass< smtk::attribute::Write, smtk::operation::XMLOperation > pybind11_init_smtk_attribute_Write(py::module &m) { PySharedPtrClass< smtk::attribute::Write, smtk::operation::XMLOperation > instance(m, "Write"); instance diff --git a/smtk/attribute/testing/cxx/CMakeLists.txt b/smtk/attribute/testing/cxx/CMakeLists.txt index 0f7162e7a5499d50c2a966e073aafe246e37b2c8..800643329abee427e715bb4f496aeb7c3ea0d079 100644 --- a/smtk/attribute/testing/cxx/CMakeLists.txt +++ b/smtk/attribute/testing/cxx/CMakeLists.txt @@ -74,38 +74,40 @@ endif() ################################################################################ set(unit_tests - unitAdvanceLevelTest - unitAssociationRulesTest - unitAssociationTest - unitAttributeAnalysis - unitAttributeAssociation - unitAttributeAssociationConstraints - unitAttributeBasics - unitAttributeExclusiveAnalysis - unitReferenceItemChildrenTest - unitCategories + unitAdvanceLevelTest.cxx + unitAssociationRulesTest.cxx + unitAssociationTest.cxx + unitAttributeAnalysis.cxx + unitAttributeAssociation.cxx + unitAttributeAssociationConstraints.cxx + unitAttributeBasics.cxx + unitAttributeExclusiveAnalysis.cxx + unitReferenceItemChildrenTest.cxx + unitCategories.cxx unitComponentItem.cxx - unitComponentItemConstraints - unitCustomItem + unitComponentItemConstraints.cxx + unitCustomItem.cxx unitDateTimeItem.cxx - unitDefinitionTags + unitDefinitionTags.cxx unitDoubleItem.cxx unitEvaluatorFactory.cxx unitEvaluatorManager.cxx - unitExclusionCategories + unitExclusionCategories.cxx unitInfixExpressionEvaluator.cxx + unitIsRelevant.cxx + unitIsValid.cxx unitJsonItemDefinitions.cxx - unitOptionalItems - unitPassCategories + unitOptionalItems.cxx + unitPassCategories.cxx unitPathGrammar.cxx unitRegistrar.cxx unitSymbolDependencyStorage.cxx ) set(unit_tests_which_require_data - unitAnalysisConfigurations - unitConditionalGroup - unitItemBlocks + unitAnalysisConfigurations.cxx + unitConditionalGroup.cxx + unitItemBlocks.cxx ) set(extra_libs ${Boost_LIBRARIES}) diff --git a/smtk/attribute/testing/cxx/unitAssociationTest.cxx b/smtk/attribute/testing/cxx/unitAssociationTest.cxx index 820602d85170b120f51af35b7c58489d03ceb86d..8fc83c2ac510d59d1d4188accb4f7e4c29ccae74 100644 --- a/smtk/attribute/testing/cxx/unitAssociationTest.cxx +++ b/smtk/attribute/testing/cxx/unitAssociationTest.cxx @@ -31,8 +31,16 @@ int unitAssociationTest(int /*unused*/, char* /*unused*/[]) "smtk::attribute::Resource", "attribute[type='testDef']", true); associationRule->setNumberOfRequiredValues(0); associationRule->setIsExtensible(true); + DefinitionPtr B = attRes->createDefinition("B"); + auto associationRule1 = B->createLocalAssociationRule(); + associationRule1->setAcceptsEntries( + "smtk::attribute::Resource", "attribute[type='testDef']", true); + associationRule1->setNumberOfRequiredValues(1); + associationRule->setIsExtensible(true); + B->localCategories().insertInclusion("foo"); attRes->finalizeDefinitions(); auto a = attRes->createAttribute("a", A); + auto b = attRes->createAttribute("b", B); auto t = attRes->createAttribute("test", TestDef); // Let associate a to t @@ -53,5 +61,27 @@ int unitAssociationTest(int /*unused*/, char* /*unused*/[]) smtkTest( a->associatedObjects()->numberOfValues() == 0, "Incorrect number of associated objects returned - should be 0"); + + // Lets test validity based on categories + std::set cats1 = { "foo" }; + std::set cats2 = { "bar" }; + smtkTest( + !b->isValid(), + "b with no categories specified was considered valid but it should have been invalid"); + + // with foo set, the attribute will pass its category filtering process but the fact + // that the attribute's association fails its validity check should make it invalid + attRes->setActiveCategories(cats1); + attRes->setActiveCategoriesEnabled(true); + smtkTest( + !b->isValid(), "b with foo specified was considered valid but it should have been invalid"); + + // with bar set, the attribute will fail its category filtering process so it will be + // considered valid though its association is not + attRes->setActiveCategories(cats2); + attRes->setActiveCategoriesEnabled(true); + smtkTest( + b->isValid(), "b with bar specified was considered invalid but it should have been valid"); + return 0; } diff --git a/smtk/attribute/testing/cxx/unitAttributeAssociation.cxx b/smtk/attribute/testing/cxx/unitAttributeAssociation.cxx index 3c4bb020a1a6ae2a976ffc55e1a7cb1dd665383e..7649a4b28e38f1595985b00aeb2fbc98824143f5 100644 --- a/smtk/attribute/testing/cxx/unitAttributeAssociation.cxx +++ b/smtk/attribute/testing/cxx/unitAttributeAssociation.cxx @@ -94,6 +94,13 @@ int unitAttributeAssociation(int /*unused*/, char* /*unused*/[]) e0.associateAttribute(att->attributeResource(), att->id()) == false, "Should not have been able to associate entity of wrong type."); + att->removeAllAssociations(); + att->associateEntity(v2); + auto assocObj = att->associations()->value(0); + smtkTest( + assocObj->id() == v2.entity(), + "Associated to wrong entity. Should be " << v2.entity() << " not " << assocObj->id()); + { auto associateOperation = smtk::attribute::Associate::create(); diff --git a/smtk/attribute/testing/cxx/unitCustomItem.cxx b/smtk/attribute/testing/cxx/unitCustomItem.cxx index 54c1505c93f750085f66f76b18cf74ccca95c399..40d06ee6b62a2fd6942d0ad75a673d65e843c588 100644 --- a/smtk/attribute/testing/cxx/unitCustomItem.cxx +++ b/smtk/attribute/testing/cxx/unitCustomItem.cxx @@ -36,6 +36,8 @@ #include "smtk/operation/Manager.h" #include "smtk/operation/Registrar.h" +#include "smtk/plugin/Registry.h" + #include "smtk/io/AttributeReader.h" #include "smtk/io/AttributeWriter.h" #include "smtk/io/Logger.h" @@ -242,11 +244,9 @@ int unitCustomItem(int /*unused*/, char* /*unused*/[]) auto managers = smtk::common::Managers::create(); // Construct smtk managers - { - smtk::resource::Registrar::registerTo(managers); - smtk::operation::Registrar::registerTo(managers); - smtk::attribute::Registrar::registerTo(managers); - } + auto resourceRegistry = smtk::plugin::addToManagers(managers); + auto operationRegistry = smtk::plugin::addToManagers(managers); + auto attributeRegistry = smtk::plugin::addToManagers(managers); // access smtk managers auto resourceManager = managers->get(); @@ -254,8 +254,9 @@ int unitCustomItem(int /*unused*/, char* /*unused*/[]) auto itemDefinitionManager = managers->get(); // Initialize smtk managers + auto attributeOpRegistry = + smtk::plugin::addToManagers(operationManager); { - smtk::attribute::Registrar::registerTo(operationManager); operationManager->registerResourceManager(resourceManager); itemDefinitionManager->registerDefinitions(); } diff --git a/smtk/attribute/testing/cxx/unitEvaluatorManager.cxx b/smtk/attribute/testing/cxx/unitEvaluatorManager.cxx index b2c9fdd77e933037a6131faa602d163c87ad8f12..ab26434c1d77a59bcd549d06ba08f33f0164bbfc 100644 --- a/smtk/attribute/testing/cxx/unitEvaluatorManager.cxx +++ b/smtk/attribute/testing/cxx/unitEvaluatorManager.cxx @@ -17,6 +17,8 @@ #include "smtk/common/testing/cxx/helpers.h" +#include "smtk/plugin/Registry.h" + #include "smtk/resource/Manager.h" class FooEvaluator : public smtk::attribute::Evaluator @@ -52,7 +54,7 @@ int unitEvaluatorManager(int /*argc*/, char** const /*argv*/) auto resourceManager = smtk::resource::Manager::create(); evaluatorManager->registerResourceManager(resourceManager); - smtk::attribute::Registrar::registerTo(resourceManager); + auto attributeRegistry = smtk::plugin::addToManagers(resourceManager); smtkTest( evaluatorManager->registerEvaluator("FooEvaluator"), diff --git a/smtk/attribute/testing/cxx/unitIsRelevant.cxx b/smtk/attribute/testing/cxx/unitIsRelevant.cxx new file mode 100644 index 0000000000000000000000000000000000000000..bc59abb9430a1ba69fea4a38081b985e88a73124 --- /dev/null +++ b/smtk/attribute/testing/cxx/unitIsRelevant.cxx @@ -0,0 +1,251 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +#include "smtk/attribute/Definition.h" +#include "smtk/attribute/FileItem.h" +#include "smtk/attribute/GroupItem.h" +#include "smtk/attribute/GroupItemDefinition.h" +#include "smtk/attribute/IntItem.h" +#include "smtk/attribute/ReferenceItem.h" +#include "smtk/attribute/Resource.h" +#include "smtk/attribute/ResourceItem.h" +#include "smtk/attribute/StringItemDefinition.h" +#include "smtk/attribute/VoidItemDefinition.h" +#include "smtk/attribute/operators/Read.h" +#include "smtk/attribute/operators/Write.h" +#include "smtk/io/AttributeReader.h" +#include "smtk/io/AttributeWriter.h" +#include "smtk/io/Logger.h" + +#include "smtk/common/testing/cxx/helpers.h" + +using namespace smtk::attribute; +using namespace smtk::common; +using namespace smtk; + +namespace +{ +bool testAttriubuteResource( + const attribute::ResourcePtr& attRes, + bool checkCategories, + bool checkAdvanceLevel, + unsigned int readAccessLevel, + bool attRelevance, + std::vector itemRelevances, + bool hasRelevantChildrenAnswer) +{ + bool result = true; + const attribute::AttributePtr& att = attRes->findAttribute("a"); + if (att == nullptr) + { + std::cerr << "Could not find attribute a\n"; + return false; + } + if (att->isRelevant(checkCategories, checkAdvanceLevel, readAccessLevel) != attRelevance) + { + std::cerr << "\t Attribute: " << att->name() << " had incorrect relevance! Should have been " + << attRelevance << std::endl; + result = false; + } + int n = (int)itemRelevances.size(); + for (int i = 0; i < n; i++) + { + if ( + att->item(i)->isRelevant(checkCategories, checkAdvanceLevel, readAccessLevel) != + itemRelevances[i]) + { + std::cerr << "\t Attribute: " << att->name() << "'s Item: " << att->item(i)->name() + << " had incorrect relevance! Should have been " << itemRelevances[i] << std::endl; + result = false; + } + auto groupItem = std::dynamic_pointer_cast(att->item(i)); + if ( + groupItem && + (groupItem->hasRelevantChildren(checkCategories, checkAdvanceLevel, readAccessLevel) != + hasRelevantChildrenAnswer)) + { + std::cerr << "\t Attribute: " << att->name() << "'s Item: " << att->item(i)->name() + << " had incorrect hasRelevantChildren response! Should have been " + << hasRelevantChildrenAnswer << std::endl; + result = false; + } + } + return result; +} + +bool runTests(const attribute::ResourcePtr& attRes, const std::string& prefix) +{ + bool result = true; + // First lets test not using advance levels but active categories set to A + // Lets define what the categories should be for this resource + std::set cats; + cats.insert("A"); + attRes->setActiveCategories(cats); + attRes->setActiveCategoriesEnabled(true); + // in this case the attribute should be relevant and all but the first item + // which is set to be ignored and the groupItem which has no categories (hence it has no relevant children) + std::vector test1 = { false, true, true, false }; + if (testAttriubuteResource(attRes, true, false, 0, true, test1, false)) + { + std::cerr << prefix << " Test 1 - Passed\n"; + } + else + { + std::cerr << prefix << " Test 1 - Failed\n"; + result = false; + } + // Second - same thing but with advance level testing on and access = 0 + // In this case everyone should fail since the only access level 0 items are the + // item is set to be ignored and the groupItem which has no categories + std::vector test2 = { false, false, false, false }; + if (testAttriubuteResource(attRes, true, true, 0, false, test2, false)) + { + std::cerr << prefix << " Test 2 - Passed\n"; + } + else + { + std::cerr << prefix << " Test 2 - Failed\n"; + result = false; + } + // Third - same thing but with advance level testing on and access = 1 + // In this case the attribute and second item should pass + std::vector test3 = { false, true, false, false }; + if (testAttriubuteResource(attRes, true, true, 1, true, test3, false)) + { + std::cerr << prefix << " Test 3 - Passed\n"; + } + else + { + std::cerr << prefix << " Test 3 - Failed\n"; + result = false; + } + // Fourth - same thing but with advance level testing on and access = 2 + // In this case the attribute and second and third items should pass + std::vector test4 = { false, true, true, false }; + if (testAttriubuteResource(attRes, true, true, 2, true, test4, false)) + { + std::cerr << prefix << " Test 4 - Passed\n"; + } + else + { + std::cerr << prefix << " Test 4 - Failed\n"; + result = false; + } + // Finally lets change the active categories to B - in this case all should fail + cats.clear(); + cats.insert("B"); + attRes->setActiveCategories(cats); + std::vector test5 = { false, false, false, false }; + if (testAttriubuteResource(attRes, true, false, 0, false, test5, false)) + { + std::cerr << prefix << " Test 5 - Passed\n"; + } + else + { + std::cerr << prefix << " Test 5 - Failed\n"; + result = false; + } + + // Finally lets turn off category filtering and test with advance level = 0 + // In this case only the groupItem should pass and it should have relevant children + std::vector test6 = { false, false, false, true }; + if (testAttriubuteResource(attRes, false, true, 0, true, test6, true)) + { + std::cerr << prefix << " Test 6 - Passed\n"; + } + else + { + std::cerr << prefix << " Test 6 - Failed\n"; + result = false; + } + + return result; +} +void setupAttributeResource(attribute::ResourcePtr& attRes) +{ + DefinitionPtr A = attRes->createDefinition("A"); + A->localCategories().insertInclusion("A"); + // Lets create 3 items of read access levels 0, 1, 2 respectively + // and a group item that has no categories + auto vItemDef = A->addItemDefinition("i0"); + vItemDef = A->addItemDefinition("i1"); + vItemDef->setLocalAdvanceLevel(1); + vItemDef = A->addItemDefinition("i2"); + vItemDef->setLocalAdvanceLevel(2); + auto gItemDef = A->addItemDefinition("g3"); + // let make sure this group has no categories + gItemDef->setIsOkToInherit(false); + vItemDef = gItemDef->addItemDefinition("g0i0"); + attRes->finalizeDefinitions(); + + auto att = attRes->createAttribute("a", "A"); + // Lets set the first item to be ignored + att->item(0)->setIsIgnored(true); +} +} // namespace + +int unitIsRelevant(int /*unused*/, char* /*unused*/[]) +{ + std::cerr << std::boolalpha; // To print out booleans + // + // I. Let's create an attribute resource and some definitions + attribute::ResourcePtr attRes = attribute::Resource::create(); + setupAttributeResource(attRes); + + smtkTest(runTests(attRes, "First Pass - "), "Failed isRelevant Tests in First Pass"); + io::AttributeWriter writer; + io::AttributeReader reader; + io::Logger logger; + std::string writeRroot(SMTK_SCRATCH_DIR); + std::string fname = writeRroot + "/unitIsRelevantTest.sbi"; + std::string rname = writeRroot + "/unitIsRelevantTest.smtk"; + + //Test JSON File I/O + attRes->setLocation(rname); + smtk::attribute::Write::Ptr writeOp = smtk::attribute::Write::create(); + writeOp->parameters()->associate(attRes); + auto opresult = writeOp->operate(); + + smtkTest( + opresult->findInt("outcome")->value() == + static_cast(smtk::operation::Operation::Outcome::SUCCEEDED), + "JSON Write operation failed\n" + << writeOp->log().convertToString()); + attRes = nullptr; + smtk::attribute::Read::Ptr readOp = smtk::attribute::Read::create(); + readOp->parameters()->findFile("filename")->setValue(rname); + opresult = readOp->operate(); + smtkTest( + opresult->findInt("outcome")->value() == + static_cast(smtk::operation::Operation::Outcome::SUCCEEDED), + "JSON Read operation failed\n" + << writeOp->log().convertToString()); + attRes = std::dynamic_pointer_cast( + opresult->findResource("resource")->value()); + //Test the resource created using JSON + smtkTest(runTests(attRes, "JSON Pass - "), "Failed isRelevant Tests in JSON Pass"); + + //Test XML File I/O + writer.write(attRes, fname, logger); + smtkTest( + !logger.hasErrors(), + "Error Generated when XML writing file (" << fname << "):\n" + << logger.convertToString()); + + attRes = attribute::Resource::create(); + reader.read(attRes, fname, logger); + smtkTest( + !logger.hasErrors(), + "Error Generated when XML reading file (" << fname << "):\n" + << logger.convertToString()); + //Test the resource created using XML + smtkTest(runTests(attRes, "XML Pass - "), "Failed isRelevant Tests in XML Pass"); + + return 0; +} diff --git a/smtk/attribute/testing/cxx/unitIsValid.cxx b/smtk/attribute/testing/cxx/unitIsValid.cxx new file mode 100644 index 0000000000000000000000000000000000000000..96294ff19339a1563140f812bfd90564a13b35c9 --- /dev/null +++ b/smtk/attribute/testing/cxx/unitIsValid.cxx @@ -0,0 +1,101 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +#include "smtk/attribute/Definition.h" +#include "smtk/attribute/GroupItem.h" +#include "smtk/attribute/Resource.h" +#include "smtk/attribute/StringItem.h" +#include "smtk/io/AttributeReader.h" +#include "smtk/io/Logger.h" + +#include "smtk/common/testing/cxx/helpers.h" + +#include +#include + +const std::string attTemplate = + "\n" + " \n" + " Flow\n" + " \n" + " \n" + " \n" + " \n" + " Flow\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " " + " \n" + "\n"; + +/* This test verifies that Attribute::isValid() accounts for categories, + * enabled state, and ignored state of items. + */ + +int unitIsValid(int /*unused*/, char* /*unused*/[]) +{ + auto attResource = smtk::attribute::Resource::create(); + smtk::io::AttributeReader reader; + auto logger = smtk::io::Logger::instance(); + bool err = reader.readContents(attResource, attTemplate, logger); + smtkTest(!err, "Error reading template."); + + auto att = attResource->findAttribute("Test1"); + smtkTest(att != nullptr, "Test1 attribute not found"); + auto sitem = att->findString("String Item"); + smtkTest(sitem != nullptr, "String Item not found"); + + // Test with no categories + sitem->setIsEnabled(false); + smtkTest(att->isValid(), "No-categories Test1 should be valid when string item disabled."); + + sitem->setIsEnabled(true); + smtkTest(!att->isValid(), "No-categories Test1 should be invalid when string item enabled."); + + sitem->setIsIgnored(true); + smtkTest(att->isValid(), "No-categories Test1 should be valid when string item ignored."); + sitem->setIsIgnored(false); + + // Test with categories passed in + std::set categories = { "Flow" }; + + sitem->setIsEnabled(false); + smtkTest( + att->isValid(categories), "With-categories Test1 should be valid when string item disabled."); + + sitem->setIsEnabled(true); + smtkTest( + !att->isValid(categories), "With-categories Test1 should be invalid when string item enabled."); + + sitem->setIsIgnored(true); + smtkTest( + att->isValid(categories), "With-categories Test1 should be valid when string item ignored."); + sitem->setIsIgnored(false); + + // Test with categories set on resource + attResource->setActiveCategoriesEnabled(true); + attResource->setActiveCategories(categories); + + sitem->setIsEnabled(false); + smtkTest(att->isValid(), "Active-categories Test1 should be valid when string item disabled."); + + sitem->setIsEnabled(true); + smtkTest(!att->isValid(), "Active-categories Test1 should be invalid when string item enabled."); + + sitem->setIsIgnored(true); + smtkTest(att->isValid(), "Active-categories Test1 should be valid when string item ignored."); + sitem->setIsIgnored(false); + + return 0; +} diff --git a/smtk/attribute/testing/cxx/unitRegistrar.cxx b/smtk/attribute/testing/cxx/unitRegistrar.cxx index 8bafaf8555df5e7fd8508ca4152a8a24b15f9175..3bc2db3b5c3fe25e576d79dc3e6fd4b5b363610e 100644 --- a/smtk/attribute/testing/cxx/unitRegistrar.cxx +++ b/smtk/attribute/testing/cxx/unitRegistrar.cxx @@ -14,6 +14,8 @@ #include "smtk/common/Managers.h" #include "smtk/common/testing/cxx/helpers.h" +#include "smtk/plugin/Registry.h" + #include "smtk/resource/Manager.h" #include "smtk/resource/Registrar.h" @@ -22,25 +24,27 @@ void testDefaultEvaluatorRegistration() { auto managers = smtk::common::Managers::create(); - smtk::resource::Registrar::registerTo(managers); - smtk::attribute::Registrar::registerTo(managers); + auto resourceRegistry = smtk::plugin::addToManagers(managers); + auto attributeRegistry = smtk::plugin::addToManagers(managers); auto resourceManager = managers->get(); auto evaluatorManager = managers->get(); - smtk::attribute::Registrar::registerTo(evaluatorManager); + auto attributeResourceRegistry = + smtk::plugin::addToManagers(resourceManager); - smtk::attribute::Registrar::registerTo(resourceManager); auto attRes = resourceManager->create(); auto infixDefinition = attRes->createDefinition("infixExpression"); - smtkTest( - attRes->evaluatorFactory().addDefinitionForEvaluator( - "InfixExpressionEvaluator", infixDefinition->type()) == true, - "Expected to be able to add definition for InfixExpressionEvaluator because " - "Registrar already registered InfixExpressionEvaluator.") - - smtk::attribute::Registrar::unregisterFrom(evaluatorManager); + { + auto attributeEvalRegistry = + smtk::plugin::addToManagers(evaluatorManager); + smtkTest( + attRes->evaluatorFactory().addDefinitionForEvaluator( + "InfixExpressionEvaluator", infixDefinition->type()) == true, + "Expected to be able to add definition for InfixExpressionEvaluator because " + "Registrar already registered InfixExpressionEvaluator."); + } auto fooDefinition = attRes->createDefinition("fooExpression"); diff --git a/smtk/attribute/testing/python/basicAttributeXMLWriterTest.py b/smtk/attribute/testing/python/basicAttributeXMLWriterTest.py index d4f9825496db3a125e6d5a1dc40266a2d8320401..625a5c9805c573a8fa05a06e8e727488ec0ffff7 100644 --- a/smtk/attribute/testing/python/basicAttributeXMLWriterTest.py +++ b/smtk/attribute/testing/python/basicAttributeXMLWriterTest.py @@ -85,11 +85,11 @@ if __name__ == '__main__': iitemdef.addDiscreteValue(2, 'Hours') iitemdef.addDiscreteValue(3, 'Days') iitemdef.setDefaultDiscreteIndex(0) - iitemdef.localCategories().insert('Time') + iitemdef.localCategories().insertInclusion('Time') iitemdef = smtk.attribute.IntItemDefinition.New('IntItem2') base.addItemDefinition(iitemdef) iitemdef.setDefaultValue(10) - iitemdef.localCategories().insert('Heat') + iitemdef.localCategories().insertInclusion('Heat') def1 = resource.createDefinition('Derived1', 'BaseDef') def1.setLocalAssociationMask( @@ -98,7 +98,7 @@ if __name__ == '__main__': ditemdef = smtk.attribute.DoubleItemDefinition.New('DoubleItem1') def1.addItemDefinition(ditemdef) # Allow this one to hold an expression - ditemdef.localCategories().insert('Veg') + ditemdef.localCategories().insertInclusion('Veg') ditemdef.setExpressionDefinition(expDef) # Check to make sure we can use expressions if not ditemdef.allowsExpressions(): @@ -109,7 +109,7 @@ if __name__ == '__main__': ditemdef.setDefaultValue(-35.2) ditemdef.setMinRange(-100, True) ditemdef.setMaxRange(125.0, False) - ditemdef.localCategories().insert('Constituent') + ditemdef.localCategories().insertInclusion('Constituent') vdef = smtk.attribute.VoidItemDefinition.New('VoidItem') def1.addItemDefinition(vdef) vdef.setIsOptional(True) @@ -121,18 +121,18 @@ if __name__ == '__main__': sitemdef = smtk.attribute.StringItemDefinition.New('StringItem1') def2.addItemDefinition(sitemdef) sitemdef.setIsMultiline(True) - sitemdef.localCategories().insert('Flow') + sitemdef.localCategories().insertInclusion('Flow') sitemdef = smtk.attribute.StringItemDefinition.New('StringItem2') def2.addItemDefinition(sitemdef) sitemdef.setDefaultValue('Default') - sitemdef.localCategories().insert('General') + sitemdef.localCategories().insertInclusion('General') uitemdef = smtk.attribute.ModelEntityItemDefinition.New('ModelEntityItem1') def2.addItemDefinition(uitemdef) - uitemdef.localCategories().insert('Flow') + uitemdef.localCategories().insertInclusion('Flow') uitemdef.setMembershipMask(int(smtk.model.FACE)) uitemdef = smtk.attribute.ModelEntityItemDefinition.New('ModelEntityItem2') def2.addItemDefinition(uitemdef) - uitemdef.localCategories().insert('General') + uitemdef.localCategories().insertInclusion('General') uitemdef.setMembershipMask( int(smtk.model.GROUP_ENTITY | smtk.model.HOMOGENOUS_GROUP)) dirdef = smtk.attribute.DirectoryItemDefinition.New('DirectoryItem') @@ -151,8 +151,8 @@ if __name__ == '__main__': sitemdef = smtk.attribute.StringItemDefinition.New('GroupString') gdef1.addItemDefinition(sitemdef) sitemdef.setDefaultValue('Something Cool') - sitemdef.localCategories().insert('General') - sitemdef.localCategories().insert('Flow') + sitemdef.localCategories().insertInclusion('General') + sitemdef.localCategories().insertInclusion('Flow') # Add in a Attribute definition with a reference to another attribute attcompdef = resource.createDefinition('AttributeComponentDef') diff --git a/smtk/attribute/testing/python/categoryTest.py b/smtk/attribute/testing/python/categoryTest.py index cb80267c79d4f8854fab0a38984510744f82a3d1..c61c630452539ca769d21cc896d5a56088a98f2b 100644 --- a/smtk/attribute/testing/python/categoryTest.py +++ b/smtk/attribute/testing/python/categoryTest.py @@ -42,18 +42,18 @@ if __name__ == '__main__': # Lets add some item definitions iitemdef = smtk.attribute.IntItemDefinition.New("IntItem1") base.addItemDefinition(iitemdef) - iitemdef.localCategories().insert("Flow") + iitemdef.localCategories().insertInclusion("Flow") iitemdef = smtk.attribute.IntItemDefinition.New("IntItem2") base.addItemDefinition(iitemdef) iitemdef.setDefaultValue(10) - iitemdef.localCategories().insert("Heat") + iitemdef.localCategories().insertInclusion("Heat") def1 = resource.createDefinition("Derived1", "BaseDef") # Lets add some item definitions ditemdef = smtk.attribute.DoubleItemDefinition.New("DoubleItem1") def1.addItemDefinition(ditemdef) # Allow this one to hold an expression - ditemdef.localCategories().insert("Veg") + ditemdef.localCategories().insertInclusion("Veg") ditemdef.setExpressionDefinition(expDef) # Check to make sure we can use expressions if not ditemdef.allowsExpressions(): @@ -62,17 +62,17 @@ if __name__ == '__main__': ditemdef = smtk.attribute.DoubleItemDefinition.New("DoubleItem2") def1.addItemDefinition(ditemdef) ditemdef.setDefaultValue(-35.2) - ditemdef.localCategories().insert("Constituent") + ditemdef.localCategories().insertInclusion("Constituent") def2 = resource.createDefinition("Derived2", "Derived1") # Lets add some item definitions sitemdef = smtk.attribute.StringItemDefinition.New("StringItem1") def2.addItemDefinition(sitemdef) - sitemdef.localCategories().insert("Flow") + sitemdef.localCategories().insertInclusion("Flow") sitemdef = smtk.attribute.StringItemDefinition.New("StringItem2") def2.addItemDefinition(sitemdef) sitemdef.setDefaultValue("Default") - sitemdef.localCategories().insert("General") + sitemdef.localCategories().insertInclusion("General") # Process Definition Information resource.finalizeDefinitions() diff --git a/smtk/common/CMakeLists.txt b/smtk/common/CMakeLists.txt index ae61f4bb4a00968240875338641e4ee99b8fce36..0b3fa7a89ef979d590e08f57139cdc0805fb4435 100644 --- a/smtk/common/CMakeLists.txt +++ b/smtk/common/CMakeLists.txt @@ -26,6 +26,7 @@ set(commonHeaders CompilerInformation.h DateTime.h DateTimeZonePair.h + Deprecation.h Environment.h Extension.h Factory.h @@ -36,6 +37,7 @@ set(commonHeaders InfixExpressionEvaluation.h InfixExpressionGrammar.h InfixExpressionGrammarImpl.h + Instances.h json/jsonLinks.h json/jsonTypeMap.h json/jsonUUID.h @@ -55,6 +57,8 @@ set(commonHeaders TypeContainer.h UUID.h UUIDGenerator.h + VersionMacros.h + Visit.h testing/cxx/helpers.h ${CMAKE_CURRENT_BINARY_DIR}/Version.h diff --git a/smtk/common/Deprecation.h b/smtk/common/Deprecation.h new file mode 100644 index 0000000000000000000000000000000000000000..9911f882847b5fd3f795d2e5e024640069f34e79 --- /dev/null +++ b/smtk/common/Deprecation.h @@ -0,0 +1,65 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#ifndef smtk_common_Deprecation_h +#define smtk_common_Deprecation_h + +#include "smtk/common/VersionMacros.h" + +// The level at which warnings should be made. +#ifndef SMTK_DEPRECATION_LEVEL +// SMTK defaults to deprecation of its current version. +#define SMTK_DEPRECATION_LEVEL SMTK_VERSION_NUMBER +#endif + +// API deprecated before 21.4 have already been removed. +#define SMTK_MINIMUM_DEPRECATION_LEVEL SMTK_VERSION_CHECK(21, 4) + +// Force the deprecation level to be at least that of SMTK's build +// configuration. +#if SMTK_DEPRECATION_LEVEL < SMTK_MINIMUM_DEPRECATION_LEVEL +#undef SMTK_DEPRECATION_LEVEL +#define SMTK_DEPRECATION_LEVEL SMTK_MINIMUM_DEPRECATION_LEVEL +#endif + +#if 0 && __cplusplus >= 201402L +// This is currently hard-disabled because compilers do not mix C++ attributes +// and `__attribute__` extensions together well. +#define SMTK_DEPRECATION_II(reason) [[deprecated(reason)]] +#else +#if defined(_WIN32) || defined(_WIN64) +#define SMTK_DEPRECATION(reason) __declspec(deprecated(reason)) +#elif defined(__clang__) +#if __has_extension(attribute_deprecated_with_message) +#define SMTK_DEPRECATION(reason) __attribute__((__deprecated__(reason))) +#else +#define SMTK_DEPRECATION(reason) __attribute__((__deprecated__)) +#endif +#elif defined(__GNUC__) +#if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) +#define SMTK_DEPRECATION(reason) __attribute__((__deprecated__(reason))) +#else +#define SMTK_DEPRECATION(reason) __attribute__((__deprecated__)) +#endif +#else +#define SMTK_DEPRECATION(reason) +#endif +#endif + +#define SMTK_DEPRECATION_REASON(version_major, version_minor, reason) \ + "SMTK Deprecated in " #version_major "." #version_minor ": " #reason + +#if SMTK_DEPRECATION_LEVEL >= SMTK_VERSION_CHECK(21, 07) +#define SMTK_DEPRECATED_IN_21_07(reason) SMTK_DEPRECATION(SMTK_DEPRECATION_REASON(21, 07, reason)) +#else +#define SMTK_DEPRECATED_IN_21_07(reason) +#endif + +#endif // smtk_common_Deprecation_h diff --git a/smtk/common/Factory.h b/smtk/common/Factory.h index 1bdfa3ee4ba3fbcbe9139819fa382828c109a7d8..44746751bd4566c5053632020e58eb4af2f45825 100644 --- a/smtk/common/Factory.h +++ b/smtk/common/Factory.h @@ -139,7 +139,7 @@ class SMTK_ALWAYS_EXPORT Factory } }; - // A Metdata class that holds the create methods for a spcecific construction + // A Metdata class that holds the create methods for a specific construction // signature (InputType, defined at class-template scope) and derived type to // create (Type, defined explicitly using the class's constructor). This class // is the composing element for the factory's Metadata instance. diff --git a/smtk/common/Generator.h b/smtk/common/Generator.h index 772ad90084bd5c528dc38a6caeacc43ee3c707b2..2a3b7c1236e1ff484dc00433792a09c78e22967f 100644 --- a/smtk/common/Generator.h +++ b/smtk/common/Generator.h @@ -13,6 +13,7 @@ #include "smtk/common/CompilerInformation.h" +#include #include #include #include @@ -181,14 +182,10 @@ bool Generator::valid(const Input& input) const { return false; } - for (auto gen : *gens) - { - if (gen->valid(input)) - { - return true; - } - } - return false; + return std::any_of( + gens->begin(), gens->end(), [&input](const GeneratorBase* gen) { + return gen->valid(input); + }); } template diff --git a/smtk/common/Instances.h b/smtk/common/Instances.h new file mode 100644 index 0000000000000000000000000000000000000000..3932bf5696c9906918350f9767e22deff3d03e04 --- /dev/null +++ b/smtk/common/Instances.h @@ -0,0 +1,202 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +#ifndef smtk_common_Instances_h +#define smtk_common_Instances_h + +#include "smtk/common/Factory.h" +#include "smtk/common/Observers.h" +#include "smtk/common/Visit.h" + +namespace smtk +{ +namespace common +{ + +/// Events that an instance-manager can observe. +enum class InstanceEvent +{ + Managed, //!< An instance of a managed class was added to the instance manager. + Unmanaged //!< An instance of a managed class was removed from the instance manager. +}; + +/// The Instances class is used to manage instances of objects which +/// share an inherited base type (the BaseType template parameter). +/// It owns references to the instances, which keeps them alive. +/// It provides methods to observe when instances are managed (added +/// to Instances) and unmanaged (removed from Instances — at which +/// point their destructor is usually called, although destruction +/// only occurs if no other shared pointers to the object exist). +/// +/// Instances are created via smtk::common::Factory, which this class +/// inherits, and observers are invoked via smtk::common::Observers. +/// The Instances class mutates the signature of its parent Factory +/// class's creation methods so that they return shared pointers. +template +class SMTK_ALWAYS_EXPORT Instances : public Factory +{ +public: + /// An alias for the inherited parent class. + using Superclass = smtk::common::Factory; + /// The signature of observers watching managed instance lifecycle events. + using Observer = std::function&)>; + /// Access to the set of observers of instances. + using Observers = smtk::common::Observers; + /// The signature used to visit managed instances of objects. + using Visitor = std::function&)>; + + /// Construct a manager of object instances. + Instances() + : m_observers([this](Observer& observer) { + for (const auto& instance : m_instances) + { + observer(InstanceEvent::Managed, instance); + } + }) + { + } + + /// Delete copy constructor and assignment operator. + Instances(const Instances&) = delete; + void operator=(const Instances&) = delete; + + /// Unregister a Type using its type name. + using Superclass::unregisterType; // (const std::string&); + + /// Determine whether or not a Type is available using its type name. + using Superclass::contains; // (const std::string&) const; + + /// Create an instance of the given \a Type and manage it. + template + std::shared_ptr create(Args&&... args) + { + std::shared_ptr instance = this->Superclass::createFromIndex( + typeid(Type).hash_code(), std::forward(args)...); // .release(); + if (instance) + { + m_instances.insert(instance); + m_observers(InstanceEvent::Managed, instance); + } + return std::static_pointer_cast(instance); + } + + /// Create and manage an instance of \a Type using its type-name. + template + std::shared_ptr createFromName(const std::string& typeName, Args&&... args) + { + std::shared_ptr instance = + this->Superclass::createFromName(typeName, std::forward(args)...); + if (instance) + { + m_instances.insert(instance); + m_observers(InstanceEvent::Managed, instance); + } + return instance; + } + + /// Create and manage an instance of a Type using its type-index. + template + std::shared_ptr createFromIndex(const std::size_t& typeIndex, Args&&... args) + { + std::shared_ptr instance = + this->Superclass::createFromIndex(typeIndex, std::forward(args)...); + if (instance) + { + m_instances.insert(instance); + m_observers(InstanceEvent::Managed, instance); + } + return instance; + } + + /// Manage an already-created instance of a class. + /// + /// This returns true if the instance was added and + /// false otherwise (which can occur if passed a null + /// pointer or an already-managed instance). + bool manage(const std::shared_ptr& instance) + { + if (!instance) + { + return false; + } + bool didManage = m_instances.insert(instance).second; + if (didManage) + { + m_observers(InstanceEvent::Managed, instance); + } + return didManage; + } + + /// Unmanage (drop the reference to) an \a instance. + /// + /// This may result in the destruction of \a instance + /// but is not guaranteed to do so (i.e., when other + /// shared-pointers to \a instance exist). + bool unmanage(const std::shared_ptr& instance) + { + if (!instance) + { + return false; + } + auto it = m_instances.find(instance); + if (it == m_instances.end()) + { + return false; + } + m_instances.erase(it); + m_observers(InstanceEvent::Unmanaged, instance); + return true; + } + + /// Determine whether \a instance is managed or not. + bool contains(const std::shared_ptr& instance) + { + return m_instances.find(instance) != m_instances.end(); + } + + /// Unmanage all instances. + void clear() + { + for (const auto& instance : m_instances) + { + m_observers(InstanceEvent::Unmanaged, instance); + } + m_instances.clear(); + } + + /// Return the set of observers of instances (so that you can insert an observer). + Observers& observers() { return m_observers; } + + /// Iterate over the collection of instances, invoking a visitor on each. + /// + /// The return value indicates whether iteration was terminated early or not. + smtk::common::Visit visit(Visitor visitor) + { + for (const auto& instance : m_instances) + { + if (visitor(instance) == smtk::common::Visit::Halt) + { + return smtk::common::Visit::Halt; + } + } + return smtk::common::Visit::Continue; + } + +private: + /// The container that owns managed instances. + using Container = std::set>; + /// The container of instances. + Container m_instances; + /// Observers of changes to m_instances. + Observers m_observers; +}; +} // namespace common +} // namespace smtk + +#endif diff --git a/smtk/common/Observers.h b/smtk/common/Observers.h index 00f5b5bb56081daf684ef1673da4790b8d41b099..a853075c44f1ed86b83427faa58eefa6795e837c 100644 --- a/smtk/common/Observers.h +++ b/smtk/common/Observers.h @@ -193,12 +193,10 @@ public: Observers() : m_initializer() - , m_observing(false) { } Observers(Initializer&& initializer) : m_initializer(initializer) - , m_observing(false) { } @@ -428,7 +426,7 @@ private: return m_observers.erase(key); } - bool m_observing; + bool m_observing{ false }; std::set m_toErase; std::mutex m_mutex; diff --git a/smtk/common/PythonInterpreter.cxx b/smtk/common/PythonInterpreter.cxx index d4432a08f6e68ad13d91a59672d651a3007d8629..26eda343844470717ae03b869310b8f0773fb8c0 100644 --- a/smtk/common/PythonInterpreter.cxx +++ b/smtk/common/PythonInterpreter.cxx @@ -75,7 +75,6 @@ PythonInterpreter& PythonInterpreter::instance() } PythonInterpreter::PythonInterpreter() - : m_embedded(false) { this->initialize(); } diff --git a/smtk/common/PythonInterpreter.h b/smtk/common/PythonInterpreter.h index e64fec816e7f1102eb88903cc59919d90ad6da70..8badc1cc0bcc781d2858742a13837138834444a8 100644 --- a/smtk/common/PythonInterpreter.h +++ b/smtk/common/PythonInterpreter.h @@ -93,7 +93,7 @@ private: static PythonInterpreter m_instance; - bool m_embedded; + bool m_embedded{ false }; }; } // namespace common } // namespace smtk diff --git a/smtk/common/ThreadPool.h b/smtk/common/ThreadPool.h index 84764c46b67a393b630c03df13c70b472762c105..564aef115ab88e9ddc4c0a2c4bdb70f57f6fd923 100644 --- a/smtk/common/ThreadPool.h +++ b/smtk/common/ThreadPool.h @@ -71,15 +71,14 @@ protected: std::mutex m_queueMutex; std::vector m_threads; std::queue> m_queue; - bool m_initialized; + bool m_initialized{ false }; std::atomic m_active; unsigned int m_maxThreads; }; template ThreadPool::ThreadPool(unsigned int maxThreads) - : m_initialized(false) - , m_active(true) + : m_active(true) , m_maxThreads(maxThreads == 0 ? std::thread::hardware_concurrency() : maxThreads) { } diff --git a/smtk/common/TimeZone.cxx b/smtk/common/TimeZone.cxx index 0857a66f3d610d148ccde195a49ad1dfc6cdd9d8..848115f0a74d9ad7c5f91b68f296c7187569798d 100644 --- a/smtk/common/TimeZone.cxx +++ b/smtk/common/TimeZone.cxx @@ -26,7 +26,6 @@ bool TimeZone::s_databaseLoaded = false; TimeZone::TimeZone() : m_boostTimeZone(nullptr) - , m_isUTC(false) { } diff --git a/smtk/common/TimeZone.h b/smtk/common/TimeZone.h index f26e0fb4f10db4516702a4e5595a3c0da03de0ab..6327b0d9a3e8d7aa7296acc05b715cb12cad5817 100644 --- a/smtk/common/TimeZone.h +++ b/smtk/common/TimeZone.h @@ -61,7 +61,7 @@ public: private: boost::local_time::time_zone_ptr m_boostTimeZone; - bool m_isUTC; + bool m_isUTC{ false }; std::string m_region; // Static timezone database diff --git a/smtk/common/UUID.cxx b/smtk/common/UUID.cxx index 414771223e8b2a24426aa6bd9c458f7059325fcb..a971a17b1fcceb479ae75d355f9f8abeb8267df7 100644 --- a/smtk/common/UUID.cxx +++ b/smtk/common/UUID.cxx @@ -46,10 +46,15 @@ UUID::UUID(const_iterator inBegin, const_iterator inEnd) } /// Construct a UUID from a text string (36 characters long, including hyphens). +/// The UUID stays in its default state of nil if the input string is empty. UUID::UUID(const std::string& txt) + : m_data() { - boost::uuids::string_generator sgen; - m_data = sgen(txt); + if (!txt.empty()) + { + boost::uuids::string_generator sgen; + m_data = sgen(txt); + } } /// Construct a UUID from a boost UUID object. diff --git a/smtk/common/VersionMacros.h b/smtk/common/VersionMacros.h new file mode 100644 index 0000000000000000000000000000000000000000..d125be56c39b881409adc8bbc8d6c1fee01dbb2f --- /dev/null +++ b/smtk/common/VersionMacros.h @@ -0,0 +1,20 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#ifndef smtk_common_VersionMacros_h +#define smtk_common_VersionMacros_h + +#include "smtk/common/Version.h" + +#define SMTK_VERSION_CHECK(major, minor) (100ULL * (major) + (minor)) + +#define SMTK_VERSION_NUMBER SMTK_VERSION_CHECK(SMTK_VERSION_MAJOR, SMTK_VERSION_MINOR) + +#endif // smtk_common_VersionMacros_h diff --git a/smtk/common/Visit.h b/smtk/common/Visit.h new file mode 100644 index 0000000000000000000000000000000000000000..92b750a1307925f8d09e47fc9867ec717b0ed37a --- /dev/null +++ b/smtk/common/Visit.h @@ -0,0 +1,29 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +/*! \file */ +#ifndef smtk_common_Visit_h +#define smtk_common_Visit_h + +namespace smtk +{ +namespace common +{ + +/// Return values common to most visitor methods. +enum class Visit +{ + Continue, //!< Continue to visit items. + Halt //!< Stop visiting items immediately. +}; + +} // namespace common +} // namespace smtk + +#endif // smtk_common_Visit_h diff --git a/smtk/common/pybind11/PybindColor.h b/smtk/common/pybind11/PybindColor.h index 02c55476a65fe5bba78f4e2df1b10c0dd320670e..486a047d96edd808f8e381d2f0ce5d3ed221fbb2 100644 --- a/smtk/common/pybind11/PybindColor.h +++ b/smtk/common/pybind11/PybindColor.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::common::Color > pybind11_init_smtk_common_Color(py::module &m) +inline py::class_< smtk::common::Color > pybind11_init_smtk_common_Color(py::module &m) { py::class_< smtk::common::Color > instance(m, "Color"); instance diff --git a/smtk/common/pybind11/PybindDateTime.h b/smtk/common/pybind11/PybindDateTime.h index da998fe973f4e4ceb234c1f9e31434818065436d..91f5a5e2715e06a2748bb903a36f0689e9ae7b3e 100644 --- a/smtk/common/pybind11/PybindDateTime.h +++ b/smtk/common/pybind11/PybindDateTime.h @@ -18,7 +18,7 @@ namespace py = pybind11; -py::class_< smtk::common::DateTime > pybind11_init_smtk_common_DateTime(py::module &m) +inline py::class_< smtk::common::DateTime > pybind11_init_smtk_common_DateTime(py::module &m) { py::class_< smtk::common::DateTime > instance(m, "DateTime"); instance diff --git a/smtk/common/pybind11/PybindDateTimeZonePair.h b/smtk/common/pybind11/PybindDateTimeZonePair.h index 68bdd765b92040ade4bf4d2b36e34e45d7e111c6..b6e31c09b143d9550087f16e97e7615208c0b8ae 100644 --- a/smtk/common/pybind11/PybindDateTimeZonePair.h +++ b/smtk/common/pybind11/PybindDateTimeZonePair.h @@ -20,7 +20,7 @@ namespace py = pybind11; -py::class_< smtk::common::DateTimeZonePair > pybind11_init_smtk_common_DateTimeZonePair(py::module &m) +inline py::class_< smtk::common::DateTimeZonePair > pybind11_init_smtk_common_DateTimeZonePair(py::module &m) { py::class_< smtk::common::DateTimeZonePair > instance(m, "DateTimeZonePair"); instance diff --git a/smtk/common/pybind11/PybindEnvironment.h b/smtk/common/pybind11/PybindEnvironment.h index e68f39b7e3689850d91218d85487eb1884cf6561..c0a629523dcc2faf057086dd59cb12496c87ccbe 100644 --- a/smtk/common/pybind11/PybindEnvironment.h +++ b/smtk/common/pybind11/PybindEnvironment.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::common::Environment > pybind11_init_smtk_common_Environment(py::module &m) +inline py::class_< smtk::common::Environment > pybind11_init_smtk_common_Environment(py::module &m) { py::class_< smtk::common::Environment > instance(m, "Environment"); instance diff --git a/smtk/common/pybind11/PybindFileLocation.h b/smtk/common/pybind11/PybindFileLocation.h index 13f4d7729b9c382ca65c8dbff0838b99492c944d..3a14fae5ca0b71d2672f741027a9d8e7ed23b59a 100644 --- a/smtk/common/pybind11/PybindFileLocation.h +++ b/smtk/common/pybind11/PybindFileLocation.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::common::FileLocation > pybind11_init_smtk_common_FileLocation(py::module &m) +inline py::class_< smtk::common::FileLocation > pybind11_init_smtk_common_FileLocation(py::module &m) { py::class_< smtk::common::FileLocation > instance(m, "FileLocation"); instance diff --git a/smtk/common/pybind11/PybindPaths.h b/smtk/common/pybind11/PybindPaths.h index 731f6e3464e19a8975ce64061a035b103c8aba6b..8422104e00d88c8c6ca9dfab736771d273396fab 100644 --- a/smtk/common/pybind11/PybindPaths.h +++ b/smtk/common/pybind11/PybindPaths.h @@ -18,7 +18,7 @@ namespace py = pybind11; -py::class_< smtk::common::Paths > pybind11_init_smtk_common_Paths(py::module &m) +inline py::class_< smtk::common::Paths > pybind11_init_smtk_common_Paths(py::module &m) { py::class_< smtk::common::Paths > instance(m, "Paths"); instance diff --git a/smtk/common/pybind11/PybindPathsHelperUnix.h b/smtk/common/pybind11/PybindPathsHelperUnix.h index 5770eb2dd194716a358fad709091b2b66e9f5840..6e7babe1520ed275b6e05a100b3cc81b950ad1d3 100644 --- a/smtk/common/pybind11/PybindPathsHelperUnix.h +++ b/smtk/common/pybind11/PybindPathsHelperUnix.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::common::PathsHelperUnix > pybind11_init_smtk_common_PathsHelperUnix(py::module &m) +inline py::class_< smtk::common::PathsHelperUnix > pybind11_init_smtk_common_PathsHelperUnix(py::module &m) { py::class_< smtk::common::PathsHelperUnix > instance(m, "PathsHelperUnix"); instance diff --git a/smtk/common/pybind11/PybindStringUtil.h b/smtk/common/pybind11/PybindStringUtil.h index 95de06c409344dce523862de79346c5aabdaed08..c74d124477b0d318ac2d800fb451e136fce9ef93 100644 --- a/smtk/common/pybind11/PybindStringUtil.h +++ b/smtk/common/pybind11/PybindStringUtil.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::common::StringUtil > pybind11_init_smtk_common_StringUtil(py::module &m) +inline py::class_< smtk::common::StringUtil > pybind11_init_smtk_common_StringUtil(py::module &m) { py::class_< smtk::common::StringUtil > instance(m, "StringUtil"); instance diff --git a/smtk/common/pybind11/PybindTimeZone.h b/smtk/common/pybind11/PybindTimeZone.h index 1541eac8582aaab51692985d18ec93e5f4707e8f..85451d55f78c4dfe5df5d6fd86b76af724ee95fd 100644 --- a/smtk/common/pybind11/PybindTimeZone.h +++ b/smtk/common/pybind11/PybindTimeZone.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::common::TimeZone > pybind11_init_smtk_common_TimeZone(py::module &m) +inline py::class_< smtk::common::TimeZone > pybind11_init_smtk_common_TimeZone(py::module &m) { py::class_< smtk::common::TimeZone > instance(m, "TimeZone"); instance diff --git a/smtk/common/pybind11/PybindUUID.h b/smtk/common/pybind11/PybindUUID.h index fe21e764660a4aae3c415fa2cfd9ddb2e31fad6d..a3c0c968b71f2d7696e5aaf4ff01fc5483ec67e3 100644 --- a/smtk/common/pybind11/PybindUUID.h +++ b/smtk/common/pybind11/PybindUUID.h @@ -19,7 +19,7 @@ namespace py = pybind11; -py::class_< smtk::common::UUID > pybind11_init_smtk_common_UUID(py::module &m) +inline py::class_< smtk::common::UUID > pybind11_init_smtk_common_UUID(py::module &m) { py::class_< smtk::common::UUID > instance(m, "UUID"); instance diff --git a/smtk/common/pybind11/PybindUUIDGenerator.h b/smtk/common/pybind11/PybindUUIDGenerator.h index 6d2cdaaaa14327291f9e62d9529ffb3ede643bb4..57ea902122cf9badc64eec74dc87ea9de45fe783 100644 --- a/smtk/common/pybind11/PybindUUIDGenerator.h +++ b/smtk/common/pybind11/PybindUUIDGenerator.h @@ -21,7 +21,7 @@ namespace py = pybind11; -py::class_< smtk::common::UUIDGenerator > pybind11_init_smtk_common_UUIDGenerator(py::module &m) +inline py::class_< smtk::common::UUIDGenerator > pybind11_init_smtk_common_UUIDGenerator(py::module &m) { py::class_< smtk::common::UUIDGenerator > instance(m, "UUIDGenerator"); instance diff --git a/smtk/common/pybind11/PybindVersion.h b/smtk/common/pybind11/PybindVersion.h index cdbf2e52a7488dee9cb006456c131c7135de4f0c..2b1744662556f9fec586bcc89cfee753fc337091 100644 --- a/smtk/common/pybind11/PybindVersion.h +++ b/smtk/common/pybind11/PybindVersion.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::common::Version > pybind11_init_smtk_common_Version(py::module &m) +inline py::class_< smtk::common::Version > pybind11_init_smtk_common_Version(py::module &m) { py::class_< smtk::common::Version > instance(m, "Version"); instance diff --git a/smtk/common/testing/cxx/CMakeLists.txt b/smtk/common/testing/cxx/CMakeLists.txt index 131016cf4837c17f19e35fbdfe5ebd2ceeab4ee4..09848514682a18c92f8e57d089116b44210f411f 100644 --- a/smtk/common/testing/cxx/CMakeLists.txt +++ b/smtk/common/testing/cxx/CMakeLists.txt @@ -33,25 +33,25 @@ endif() set(unit_tests TestArchive.cxx - UnitTestDerivedThreadPool + UnitTestDerivedThreadPool.cxx UnitTestDateTime.cxx UnitTestDateTimeZonePair.cxx - UnitTestFactory + UnitTestFactory.cxx UnitTestInfixExpressionGrammar.cxx UnitTestInfixExpressionGrammarImpl.cxx - UnitTestLinks - UnitTestObservers - UnitTestThreadPool - UnitTestTypeContainer - UnitTestTypeMap - UnitTestTypeName + UnitTestLinks.cxx + UnitTestObservers.cxx + UnitTestThreadPool.cxx + UnitTestTypeContainer.cxx + UnitTestTypeMap.cxx + UnitTestTypeName.cxx ) set(unit_tests_which_require_data ) smtk_unit_tests( - Label "Common" + LABEL "Common" SOURCES ${unit_tests} SOURCES_REQUIRE_DATA ${unit_tests_which_require_data} LIBRARIES smtkCore ${Boost_LIBRARIES} Threads::Threads MOAB diff --git a/smtk/common/testing/cxx/unitUUID.cxx b/smtk/common/testing/cxx/unitUUID.cxx index 54a072a96694c910bd5e328c8e710375bfa64871..4295e88e5d58fdad0a10671b957c4fbf2ddfd7eb 100644 --- a/smtk/common/testing/cxx/unitUUID.cxx +++ b/smtk/common/testing/cxx/unitUUID.cxx @@ -31,7 +31,14 @@ int main(int argc, char* argv[]) UUID fromRaw(data, data + 16); // String constructor - UUID fromStr("a3d75703-fc9b-4d99-a104-ee67cf6d11b9"); + std::string str = "a3d75703-fc9b-4d99-a104-ee67cf6d11b9"; + UUID fromStr(str); + test(fromStr.toString() == str, "String constructor must match its string input"); + + str = ""; + UUID fromEmptyStr(str); + test( + fromEmptyStr.isNull(), "String constructor with empty string as input must create a null UUID"); // Try the << operator std::ostringstream os; diff --git a/smtk/extension/delaunay/pybind11/PybindRegistrar.h b/smtk/extension/delaunay/pybind11/PybindRegistrar.h index 980d58fee7a6fcc2301a7c3cbc57a7c40c055875..0af4a2075988f500c4753640ee119331cbaa4967 100644 --- a/smtk/extension/delaunay/pybind11/PybindRegistrar.h +++ b/smtk/extension/delaunay/pybind11/PybindRegistrar.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::extension::delaunay::Registrar > pybind11_init_smtk_extension_delaunay_Registrar(py::module &m) +inline py::class_< smtk::extension::delaunay::Registrar > pybind11_init_smtk_extension_delaunay_Registrar(py::module &m) { py::class_< smtk::extension::delaunay::Registrar > instance(m, "Registrar"); instance diff --git a/smtk/extension/delaunay/pybind11/PybindTessellateFaces.h b/smtk/extension/delaunay/pybind11/PybindTessellateFaces.h index 4056734e85d4df5a4d7c7c0b4a27d7e249b5b16b..e5450bed20f14f674e9979560d53423f68dad796 100644 --- a/smtk/extension/delaunay/pybind11/PybindTessellateFaces.h +++ b/smtk/extension/delaunay/pybind11/PybindTessellateFaces.h @@ -15,7 +15,7 @@ #include "smtk/extension/delaunay/operators/TessellateFaces.h" -PySharedPtrClass< smtk::extension::delaunay::TessellateFaces, smtk::operation::XMLOperation > pybind11_init_smtk_extension_delaunay_TessellateFaces(py::module &m) +inline PySharedPtrClass< smtk::extension::delaunay::TessellateFaces, smtk::operation::XMLOperation > pybind11_init_smtk_extension_delaunay_TessellateFaces(py::module &m) { PySharedPtrClass< smtk::extension::delaunay::TessellateFaces, smtk::operation::XMLOperation > instance(m, "TessellateFaces"); instance diff --git a/smtk/extension/delaunay/pybind11/PybindTriangulateFaces.h b/smtk/extension/delaunay/pybind11/PybindTriangulateFaces.h index e5afde37b0ce211c0f3db0cb50cb33205224fbe4..3d5630a1a99f55672d748d68a0dd7928247154dd 100644 --- a/smtk/extension/delaunay/pybind11/PybindTriangulateFaces.h +++ b/smtk/extension/delaunay/pybind11/PybindTriangulateFaces.h @@ -17,7 +17,7 @@ #include "smtk/operation/XMLOperation.h" -PySharedPtrClass< smtk::extension::delaunay::TriangulateFaces, smtk::operation::XMLOperation > pybind11_init_smtk_extension_delaunay_TriangulateFaces(py::module &m) +inline PySharedPtrClass< smtk::extension::delaunay::TriangulateFaces, smtk::operation::XMLOperation > pybind11_init_smtk_extension_delaunay_TriangulateFaces(py::module &m) { PySharedPtrClass< smtk::extension::delaunay::TriangulateFaces, smtk::operation::XMLOperation > instance(m, "TriangulateFaces"); instance diff --git a/smtk/extension/matplotlib/testing/cxx/CMakeLists.txt b/smtk/extension/matplotlib/testing/cxx/CMakeLists.txt index 0458bbbf54d17c329c7c596137c0f52489c0e1ed..0e5a31a88b4281806b0ca747d649c0cc00ac2e7b 100644 --- a/smtk/extension/matplotlib/testing/cxx/CMakeLists.txt +++ b/smtk/extension/matplotlib/testing/cxx/CMakeLists.txt @@ -24,7 +24,7 @@ if (SMTK_ENABLE_VTK_SUPPORT) endif() smtk_unit_tests( - LABEL "vtk" + LABEL "VTK" SOURCES ${unit_tests} SOURCES_REQUIRE_DATA ${unit_tests_which_require_data} EXTRA_SOURCES ${additional_sources} diff --git a/smtk/extension/matplotlib/testing/cxx/RenderMesh.cxx b/smtk/extension/matplotlib/testing/cxx/RenderMesh.cxx index e9a76f5c09346906e0df9c0a14b66a949433847d..72d8ea3fbec6b1e01446c33423d9f7e67aaaa3b5 100644 --- a/smtk/extension/matplotlib/testing/cxx/RenderMesh.cxx +++ b/smtk/extension/matplotlib/testing/cxx/RenderMesh.cxx @@ -24,6 +24,8 @@ #include "smtk/operation/Operation.h" +#include "smtk/plugin/Registry.h" + #include #include @@ -68,10 +70,8 @@ int RenderMesh(int argc, char* argv[]) smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); // Register matplotlib operators to the operation manager - { - smtk::extension::matplotlib::Registrar registrar; - registrar.registerTo(operationManager); - } + auto registry = + smtk::plugin::addToManagers(operationManager); // Access a 2-dimensional mesh with interesting z-features from the // data directory diff --git a/smtk/extension/paraview/appcomponents/VisibilityBadge.cxx b/smtk/extension/paraview/appcomponents/VisibilityBadge.cxx index a09e43f3356745263cccbae73c9822d56679d8ab..c98ee0c5d7c0f39c85274af981f0dc70c1c23cae 100644 --- a/smtk/extension/paraview/appcomponents/VisibilityBadge.cxx +++ b/smtk/extension/paraview/appcomponents/VisibilityBadge.cxx @@ -213,7 +213,6 @@ int UpdateVisibilityForFootprint( VisibilityBadge::VisibilityBadge() : m_icon(pqEyeball_svg) , m_iconClosed(pqEyeballClosed_svg) - , m_parent(nullptr) { } diff --git a/smtk/extension/paraview/appcomponents/VisibilityBadge.h b/smtk/extension/paraview/appcomponents/VisibilityBadge.h index 6aac752c4370a03acd9d0e612c9a6fce956d8392..e85a95d4360fc08a8f082106a4a101a64cef7c5a 100644 --- a/smtk/extension/paraview/appcomponents/VisibilityBadge.h +++ b/smtk/extension/paraview/appcomponents/VisibilityBadge.h @@ -87,7 +87,7 @@ private: std::string m_iconClosed; // Selection state of items shown in m_phraseModel: std::map m_visibleThings; - const smtk::view::BadgeSet* m_parent; + const smtk::view::BadgeSet* m_parent{ nullptr }; }; } // namespace appcomponents } // namespace paraview diff --git a/smtk/extension/paraview/appcomponents/plugin/pqSMTKCloseResourceBehavior.cxx b/smtk/extension/paraview/appcomponents/plugin/pqSMTKCloseResourceBehavior.cxx index e3fb5cdd1b1d43b451faa6c0a6a5402d0ccac6ba..ba4541df9484b82aa0715bcd0da45bc1cfae3140 100644 --- a/smtk/extension/paraview/appcomponents/plugin/pqSMTKCloseResourceBehavior.cxx +++ b/smtk/extension/paraview/appcomponents/plugin/pqSMTKCloseResourceBehavior.cxx @@ -204,16 +204,13 @@ static pqSMTKCloseResourceBehavior* g_instance = nullptr; pqSMTKCloseResourceBehavior::pqSMTKCloseResourceBehavior(QObject* parent) : Superclass(parent) - , m_newMenu(nullptr) { initCloseResourceBehaviorResources(); - // Wait until the event loop starts, ensuring that the main window will be - // accessible. - QTimer::singleShot(0, this, [this]() { - auto* pqCore = pqApplicationCore::instance(); - if (pqCore) - { + auto* pqCore = pqApplicationCore::instance(); + if (pqCore) + { + QObject::connect(pqCore, &pqApplicationCore::clientEnvironmentDone, [this]() { QAction* closeResourceAction = new QAction(QPixmap(":/CloseResourceBehavior/Close22.png"), tr("&Close Resource"), this); closeResourceAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); @@ -221,6 +218,13 @@ pqSMTKCloseResourceBehavior::pqSMTKCloseResourceBehavior(QObject* parent) QMainWindow* mainWindow = qobject_cast(pqCoreUtilities::mainWidget()); + // Stop here if main window does not exist + // This is typically the case for certain unit tests. + if (!mainWindow) + { + return; + } + QList menuBarActions = mainWindow->menuBar()->actions(); QMenu* menu = nullptr; @@ -271,8 +275,8 @@ pqSMTKCloseResourceBehavior::pqSMTKCloseResourceBehavior(QObject* parent) mainWindow->menuBar()->insertMenu(::findHelpMenuAction(mainWindow->menuBar()), menu); } new pqCloseResourceReaction(closeResourceAction); - } - }); + }); + } } pqSMTKCloseResourceBehavior* pqSMTKCloseResourceBehavior::instance(QObject* parent) diff --git a/smtk/extension/paraview/appcomponents/plugin/pqSMTKCloseResourceBehavior.h b/smtk/extension/paraview/appcomponents/plugin/pqSMTKCloseResourceBehavior.h index 795318bf254e47b2a264067d02d48649039b8b3f..03c2ca515fadd1367c2a1c163210350c409f6c7d 100644 --- a/smtk/extension/paraview/appcomponents/plugin/pqSMTKCloseResourceBehavior.h +++ b/smtk/extension/paraview/appcomponents/plugin/pqSMTKCloseResourceBehavior.h @@ -69,7 +69,7 @@ protected: private: Q_DISABLE_COPY(pqSMTKCloseResourceBehavior); - QMenu* m_newMenu; + QMenu* m_newMenu{ nullptr }; }; #endif // smtk_extension_paraview_appcomponents_pqSMTKCloseResourceBehavior_h diff --git a/smtk/extension/paraview/appcomponents/plugin/pqSMTKCloseWithActiveOperationBehavior.cxx b/smtk/extension/paraview/appcomponents/plugin/pqSMTKCloseWithActiveOperationBehavior.cxx index 17cb13cbd2c3def7e118d228ca04d2a550dd24aa..721a8b3facaa8857ed88168927c8c74501cd3ea8 100644 --- a/smtk/extension/paraview/appcomponents/plugin/pqSMTKCloseWithActiveOperationBehavior.cxx +++ b/smtk/extension/paraview/appcomponents/plugin/pqSMTKCloseWithActiveOperationBehavior.cxx @@ -60,13 +60,10 @@ pqSMTKCloseWithActiveOperationBehavior::pqSMTKCloseWithActiveOperationBehavior(Q // Wait until the event loop starts, ensuring that the main window will be // accessible. - QTimer::singleShot(0, this, []() { - // Blech: pqApplicationCore doesn't have the selection manager yet, - // so wait until we hear that the server is ready to make the connection. - // We can't have a selection before the first connection, anyway. - auto* pqCore = pqApplicationCore::instance(); - if (pqCore) - { + auto* pqCore = pqApplicationCore::instance(); + if (pqCore) + { + QObject::connect(pqCore, &pqApplicationCore::clientEnvironmentDone, [this]() { // This functor is connected to the main window's "close" signal, and // it allows the user to cancel the close if there is an active operation. QObject::connect( @@ -83,8 +80,8 @@ pqSMTKCloseWithActiveOperationBehavior::pqSMTKCloseWithActiveOperationBehavior(Q closeEvent->ignore(); } }); - } - }); + }); + } } void pqSMTKCloseWithActiveOperationBehavior::trackActiveOperations( diff --git a/smtk/extension/paraview/appcomponents/plugin/pqSMTKDisplayAttributeOnLoadBehavior.cxx b/smtk/extension/paraview/appcomponents/plugin/pqSMTKDisplayAttributeOnLoadBehavior.cxx index c78e26f0b9d95b988e10d84cc3d61eea61271013..b97ecc4f1da81227e461b9b7d63301d540e5e7e7 100644 --- a/smtk/extension/paraview/appcomponents/plugin/pqSMTKDisplayAttributeOnLoadBehavior.cxx +++ b/smtk/extension/paraview/appcomponents/plugin/pqSMTKDisplayAttributeOnLoadBehavior.cxx @@ -41,7 +41,6 @@ static pqSMTKDisplayAttributeOnLoadBehavior* g_displayOnLoad = nullptr; pqSMTKDisplayAttributeOnLoadBehavior::pqSMTKDisplayAttributeOnLoadBehavior(QObject* parent) : Superclass(parent) - , m_panel(nullptr) { if (!g_displayOnLoad) { diff --git a/smtk/extension/paraview/appcomponents/plugin/pqSMTKDisplayAttributeOnLoadBehavior.h b/smtk/extension/paraview/appcomponents/plugin/pqSMTKDisplayAttributeOnLoadBehavior.h index 43f4079249d3440fd377c23b986dee3250eb6586..2d646b800a1a701fcd66be35ad05bdb5dca60d80 100644 --- a/smtk/extension/paraview/appcomponents/plugin/pqSMTKDisplayAttributeOnLoadBehavior.h +++ b/smtk/extension/paraview/appcomponents/plugin/pqSMTKDisplayAttributeOnLoadBehavior.h @@ -52,7 +52,7 @@ protected slots: protected: std::map m_resourceManagerObservers; - pqSMTKAttributePanel* m_panel; + pqSMTKAttributePanel* m_panel{ nullptr }; std::weak_ptr m_attr; private: diff --git a/smtk/extension/paraview/appcomponents/plugin/pqSMTKExportSimulationBehavior.cxx b/smtk/extension/paraview/appcomponents/plugin/pqSMTKExportSimulationBehavior.cxx index 0fcf97c7e030c9b7a943f3e5d58e9dd04b9bdcd8..b20e4efc14f66cff373bc86442686f2df9799500 100644 --- a/smtk/extension/paraview/appcomponents/plugin/pqSMTKExportSimulationBehavior.cxx +++ b/smtk/extension/paraview/appcomponents/plugin/pqSMTKExportSimulationBehavior.cxx @@ -22,8 +22,7 @@ #include "smtk/attribute/StringItem.h" #include "smtk/extension/paraview/appcomponents/pqSMTKBehavior.h" #include "smtk/extension/paraview/appcomponents/pqSMTKWrapper.h" -#include "smtk/extension/qt/qtOperationView.h" -#include "smtk/extension/qt/qtUIManager.h" +#include "smtk/extension/qt/qtOperationDialog.h" #include "smtk/io/Logger.h" #include "smtk/operation/Manager.h" #include "smtk/operation/operators/ImportPythonOperation.h" @@ -31,12 +30,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include pqExportSimulationReaction::pqExportSimulationReaction(QAction* parentObject) @@ -114,34 +115,21 @@ void pqExportSimulationReaction::exportSimulation() auto exportOp = wrapper->smtkOperationManager()->create(result->findString("unique_name")->value()); - // Construct a modal dialog for the operation. - QSharedPointer exportDialog = QSharedPointer(new QDialog()); + // Construct a modal dialog for the operation spec + auto exportDialog = + QSharedPointer(new smtk::extension::qtOperationDialog( + exportOp, + wrapper->smtkResourceManager(), + wrapper->smtkViewManager(), + pqCoreUtilities::mainWidget())); exportDialog->setObjectName("SimulationExportDialog"); exportDialog->setWindowTitle("Simulation Export Dialog"); - exportDialog->setLayout(new QVBoxLayout(exportDialog.data())); - // TODO: the dialog size should not be set this way. It should auto-expand - // to accommodate the contained opView. Either Qt is being coy, or smtk's - // qtBaseView logic for resizing doesn't inform the containing parent of its - // decisions. - exportDialog->resize(600, 300); - - // Create a new UI for the dialog. - QSharedPointer uiManager = - QSharedPointer(new smtk::extension::qtUIManager( - exportOp, wrapper->smtkResourceManager(), wrapper->smtkViewManager())); - - // Create an operation view for the operation. - smtk::view::ConfigurationPtr view = uiManager->findOrCreateOperationView(); - smtk::extension::qtOperationView* opView = dynamic_cast( - uiManager->setSMTKView(view, exportDialog.data())); - - exportDialog->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // Alert the user if the operation fails. Close the dialog if the operation // succeeds. - connect( - opView, - &smtk::extension::qtOperationView::operationExecuted, + QObject::connect( + exportDialog.get(), + &smtk::extension::qtOperationDialog::operationExecuted, [=](const smtk::operation::Operation::Result& result) { if ( result->findInt("outcome")->value() != @@ -156,18 +144,8 @@ void pqExportSimulationReaction::exportSimulation() QGridLayout* layout = (QGridLayout*)msgBox.layout(); layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); msgBox.exec(); - - // Once the user has accepted that their export failed, they are - // free to try again without changing any options. - opView->onModifiedParameters(); - } - else - { - exportDialog->done(QDialog::Accepted); } }); - - // Launch the modal dialog and wait for the operation to succeed. exportDialog->exec(); // Remove the export operation from the operation manager. @@ -213,16 +191,21 @@ static pqSMTKExportSimulationBehavior* g_instance = nullptr; pqSMTKExportSimulationBehavior::pqSMTKExportSimulationBehavior(QObject* parent) : Superclass(parent) { - // Wait until the event loop starts, ensuring that the main window will be - // accessible. - QTimer::singleShot(0, this, [this]() { - auto* pqCore = pqApplicationCore::instance(); - if (pqCore) - { + auto* pqCore = pqApplicationCore::instance(); + if (pqCore) + { + QObject::connect(pqCore, &pqApplicationCore::clientEnvironmentDone, [this]() { QAction* exportSimulationAction = new QAction(tr("&Export Simulation..."), this); QMainWindow* mainWindow = qobject_cast(pqCoreUtilities::mainWidget()); + // Stop here if main window does not exist + // This is typically the case for certain unit tests. + if (!mainWindow) + { + return; + } + QList menuBarActions = mainWindow->menuBar()->actions(); QMenu* menu = nullptr; @@ -281,8 +264,8 @@ pqSMTKExportSimulationBehavior::pqSMTKExportSimulationBehavior(QObject* parent) mainWindow->menuBar()->insertMenu(::findHelpMenuAction(mainWindow->menuBar()), menu); } new pqExportSimulationReaction(exportSimulationAction); - } - }); + }); + } } pqSMTKExportSimulationBehavior* pqSMTKExportSimulationBehavior::instance(QObject* parent) diff --git a/smtk/extension/paraview/appcomponents/plugin/pqSMTKImportIntoResourceBehavior.cxx b/smtk/extension/paraview/appcomponents/plugin/pqSMTKImportIntoResourceBehavior.cxx index b725ff43bca08292aae5a33d0eff77d8ce2968fd..81b3747f9f7afcbadc0ed531dd69bc8f7f98f7cf 100644 --- a/smtk/extension/paraview/appcomponents/plugin/pqSMTKImportIntoResourceBehavior.cxx +++ b/smtk/extension/paraview/appcomponents/plugin/pqSMTKImportIntoResourceBehavior.cxx @@ -207,17 +207,22 @@ static pqSMTKImportIntoResourceBehavior* g_instance = nullptr; pqSMTKImportIntoResourceBehavior::pqSMTKImportIntoResourceBehavior(QObject* parent) : Superclass(parent) { - // Wait until the event loop starts, ensuring that the main window will be - // accessible. - QTimer::singleShot(0, this, [this]() { - auto* pqCore = pqApplicationCore::instance(); - if (pqCore) - { + auto* pqCore = pqApplicationCore::instance(); + if (pqCore) + { + QObject::connect(pqCore, &pqApplicationCore::clientEnvironmentDone, [this]() { QAction* importIntoResourceAction = new QAction(tr("&Import Into Resource..."), this); importIntoResourceAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_I)); QMainWindow* mainWindow = qobject_cast(pqCoreUtilities::mainWidget()); + // Stop here if main window does not exist + // This is typically the case for certain unit tests. + if (!mainWindow) + { + return; + } + QList menuBarActions = mainWindow->menuBar()->actions(); QMenu* menu = nullptr; @@ -268,8 +273,8 @@ pqSMTKImportIntoResourceBehavior::pqSMTKImportIntoResourceBehavior(QObject* pare mainWindow->menuBar()->insertMenu(::findHelpMenuAction(mainWindow->menuBar()), menu); } new pqImportIntoResourceReaction(importIntoResourceAction); - } - }); + }); + } } pqSMTKImportIntoResourceBehavior* pqSMTKImportIntoResourceBehavior::instance(QObject* parent) diff --git a/smtk/extension/paraview/appcomponents/plugin/pqSMTKImportOperationBehavior.cxx b/smtk/extension/paraview/appcomponents/plugin/pqSMTKImportOperationBehavior.cxx index 0ae581704921164a40b7a6123f12fbca2d7ef111..dbf658b24b6a3ee4ce4bca9b2793c38fe3cbf924 100644 --- a/smtk/extension/paraview/appcomponents/plugin/pqSMTKImportOperationBehavior.cxx +++ b/smtk/extension/paraview/appcomponents/plugin/pqSMTKImportOperationBehavior.cxx @@ -136,17 +136,22 @@ pqSMTKImportOperationBehavior::pqSMTKImportOperationBehavior(QObject* parent) { initImportOperationBehaviorResources(); - // Wait until the event loop starts, ensuring that the main window will be - // accessible. - QTimer::singleShot(0, this, [this]() { - auto* pqCore = pqApplicationCore::instance(); - if (pqCore) - { + auto* pqCore = pqApplicationCore::instance(); + if (pqCore) + { + QObject::connect(pqCore, &pqApplicationCore::clientEnvironmentDone, [this]() { QAction* importOperationAction = new QAction( QPixmap(":/ImportOperationBehavior/python-28x28.png"), tr("&Import Operation..."), this); QMainWindow* mainWindow = qobject_cast(pqCoreUtilities::mainWidget()); + // Stop here if main window does not exist + // This is typically the case for certain unit tests. + if (!mainWindow) + { + return; + } + QList menuBarActions = mainWindow->menuBar()->actions(); QMenu* menu = nullptr; @@ -205,8 +210,8 @@ pqSMTKImportOperationBehavior::pqSMTKImportOperationBehavior(QObject* parent) mainWindow->menuBar()->insertMenu(::findHelpMenuAction(mainWindow->menuBar()), menu); } new pqImportOperationReaction(importOperationAction); - } - }); + }); + } } pqSMTKImportOperationBehavior* pqSMTKImportOperationBehavior::instance(QObject* parent) diff --git a/smtk/extension/paraview/appcomponents/plugin/pqSMTKNewResourceBehavior.cxx b/smtk/extension/paraview/appcomponents/plugin/pqSMTKNewResourceBehavior.cxx index ae11b326eaf210fbf7b7bd167e93da4d863388b7..d1119d1afdd8615d9faaa2a2049525672a658155 100644 --- a/smtk/extension/paraview/appcomponents/plugin/pqSMTKNewResourceBehavior.cxx +++ b/smtk/extension/paraview/appcomponents/plugin/pqSMTKNewResourceBehavior.cxx @@ -155,16 +155,20 @@ static pqSMTKNewResourceBehavior* g_instance = nullptr; pqSMTKNewResourceBehavior::pqSMTKNewResourceBehavior(QObject* parent) : Superclass(parent) - , m_newMenu(nullptr) { - // Wait until the event loop starts, ensuring that the main window will be - // accessible. - QTimer::singleShot(0, this, [this]() { - auto* pqCore = pqApplicationCore::instance(); - if (pqCore) - { + auto* pqCore = pqApplicationCore::instance(); + if (pqCore) + { + QObject::connect(pqCore, &pqApplicationCore::clientEnvironmentDone, [this]() { QMenu* fileMenu = this->fileMenu(); + // If no main window exists, then there would be no + // file menu. Stop here if this is the case. + if (fileMenu == nullptr) + { + return; + } + // We want to defer the creation of the menu actions as much as possible // so the File menu will already be populated by the time we add our // custom actions. If our actions are inserted first, there is no way to @@ -206,14 +210,21 @@ pqSMTKNewResourceBehavior::pqSMTKNewResourceBehavior(QObject* parent) // Access the creator group. auto creatorGroup = smtk::operation::CreatorGroup(wrapper->smtkOperationManager()); } - } - }); + }); + } } QMenu* pqSMTKNewResourceBehavior::fileMenu() { QMainWindow* mainWindow = qobject_cast(pqCoreUtilities::mainWidget()); + // Stop here if main window does not exist + // This is typically the case for certain unit tests. + if (!mainWindow) + { + return nullptr; + } + QList menuBarActions = mainWindow->menuBar()->actions(); QMenu* menu = nullptr; diff --git a/smtk/extension/paraview/appcomponents/plugin/pqSMTKNewResourceBehavior.h b/smtk/extension/paraview/appcomponents/plugin/pqSMTKNewResourceBehavior.h index 4fbe962a2e672119d072a7b664054c2d5eff977b..801cbd7d02db04284ca998d62e9ba0c12df3f004 100644 --- a/smtk/extension/paraview/appcomponents/plugin/pqSMTKNewResourceBehavior.h +++ b/smtk/extension/paraview/appcomponents/plugin/pqSMTKNewResourceBehavior.h @@ -73,7 +73,7 @@ protected: private: Q_DISABLE_COPY(pqSMTKNewResourceBehavior); - QMenu* m_newMenu; + QMenu* m_newMenu{ nullptr }; smtk::operation::GroupObservers::Key m_key; }; diff --git a/smtk/extension/paraview/appcomponents/plugin/pqSMTKPipelineSelectionBehavior.cxx b/smtk/extension/paraview/appcomponents/plugin/pqSMTKPipelineSelectionBehavior.cxx index 8350fe7cdd88f4316fdb50e5cd5d147c7e2eaa16..5e4b567307ec8a84140f5120271b0566af41e4f2 100644 --- a/smtk/extension/paraview/appcomponents/plugin/pqSMTKPipelineSelectionBehavior.cxx +++ b/smtk/extension/paraview/appcomponents/plugin/pqSMTKPipelineSelectionBehavior.cxx @@ -38,7 +38,6 @@ static pqSMTKPipelineSelectionBehavior* g_pipelineSelection = nullptr; pqSMTKPipelineSelectionBehavior::pqSMTKPipelineSelectionBehavior(QObject* parent) : Superclass(parent) - , m_changingSource(false) , m_selectionValue("selected") { if (!g_pipelineSelection) diff --git a/smtk/extension/paraview/appcomponents/plugin/pqSMTKPipelineSelectionBehavior.h b/smtk/extension/paraview/appcomponents/plugin/pqSMTKPipelineSelectionBehavior.h index 1e3776d296f671cdf0677d2587d2aab044efd2ae..2be029e9120d337a4dc8e64eb0eb7cbe001dd4ad 100644 --- a/smtk/extension/paraview/appcomponents/plugin/pqSMTKPipelineSelectionBehavior.h +++ b/smtk/extension/paraview/appcomponents/plugin/pqSMTKPipelineSelectionBehavior.h @@ -52,7 +52,7 @@ protected slots: virtual void unobserveSelectionOnServer(vtkSMSMTKWrapperProxy* mgr, pqServer* server); protected: - bool m_changingSource; + bool m_changingSource{ false }; std::string m_selectionValue; std::map m_selectionObservers; diff --git a/smtk/extension/paraview/appcomponents/plugin/pqSMTKSaveOnCloseResourceBehavior.cxx b/smtk/extension/paraview/appcomponents/plugin/pqSMTKSaveOnCloseResourceBehavior.cxx index 94e4a1c6639ad7a4ab53c00806aedc0f12a7abcd..9f7322475cb3107c17aa248137cef7df6dbc0e06 100644 --- a/smtk/extension/paraview/appcomponents/plugin/pqSMTKSaveOnCloseResourceBehavior.cxx +++ b/smtk/extension/paraview/appcomponents/plugin/pqSMTKSaveOnCloseResourceBehavior.cxx @@ -48,15 +48,10 @@ static pqSMTKSaveOnCloseResourceBehavior* g_instance = nullptr; pqSMTKSaveOnCloseResourceBehavior::pqSMTKSaveOnCloseResourceBehavior(QObject* parent) : Superclass(parent) { - // Wait until the event loop starts, ensuring that the main window will be - // accessible. - QTimer::singleShot(0, this, []() { - // Blech: pqApplicationCore doesn't have the selection manager yet, - // so wait until we hear that the server is ready to make the connection. - // We can't have a selection before the first connection, anyway. - auto* pqCore = pqApplicationCore::instance(); - if (pqCore) - { + auto* pqCore = pqApplicationCore::instance(); + if (pqCore) + { + QObject::connect(pqCore, &pqApplicationCore::clientEnvironmentDone, [this, pqCore]() { // The first functor listens to the object builder's "destroying" signal // to identify pqPipelineSources that are being removed in order to give // the user a chance to save resources before they are destroyed. ParaView @@ -204,8 +199,8 @@ pqSMTKSaveOnCloseResourceBehavior::pqSMTKSaveOnCloseResourceBehavior(QObject* pa } closeEvent->setAccepted(ret != QMessageBox::Cancel); }); - } - }); + }); + } } int pqSMTKSaveOnCloseResourceBehavior::showDialog( diff --git a/smtk/extension/paraview/appcomponents/plugin/pqSMTKSaveResourceBehavior.cxx b/smtk/extension/paraview/appcomponents/plugin/pqSMTKSaveResourceBehavior.cxx index 6c3d8b17504a6568efc165ae0e97779aebafc7b0..84e8ba3f5c3192cb98bab7bdfe276b037c5448b9 100644 --- a/smtk/extension/paraview/appcomponents/plugin/pqSMTKSaveResourceBehavior.cxx +++ b/smtk/extension/paraview/appcomponents/plugin/pqSMTKSaveResourceBehavior.cxx @@ -278,15 +278,10 @@ pqSMTKSaveResourceBehavior::pqSMTKSaveResourceBehavior(QObject* parent) { initSaveResourceBehaviorResources(); - // Wait until the event loop starts, ensuring that the main window will be - // accessible. - QTimer::singleShot(0, this, [this]() { - // Blech: pqApplicationCore doesn't have the selection manager yet, - // so wait until we hear that the server is ready to make the connection. - // We can't have a selection before the first connection, anyway. - auto* pqCore = pqApplicationCore::instance(); - if (pqCore) - { + auto* pqCore = pqApplicationCore::instance(); + if (pqCore) + { + QObject::connect(pqCore, &pqApplicationCore::clientEnvironmentDone, [this]() { QAction* saveResourceAction = new QAction(QPixmap(":/SaveResourceBehavior/Save24.png"), tr("&Save Resource"), this); saveResourceAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S)); @@ -296,6 +291,13 @@ pqSMTKSaveResourceBehavior::pqSMTKSaveResourceBehavior(QObject* parent) QMainWindow* mainWindow = qobject_cast(pqCoreUtilities::mainWidget()); + // Stop here if main window does not exist + // This is typically the case for certain unit tests. + if (!mainWindow) + { + return; + } + QList menuBarActions = mainWindow->menuBar()->actions(); QMenu* menu = nullptr; @@ -347,8 +349,8 @@ pqSMTKSaveResourceBehavior::pqSMTKSaveResourceBehavior(QObject* parent) } new pqSaveResourceReaction(saveResourceAction); new pqSaveResourceAsReaction(saveResourceAsAction); - } - }); + }); + } } pqSMTKSaveResourceBehavior* pqSMTKSaveResourceBehavior::instance(QObject* parent) diff --git a/smtk/extension/paraview/appcomponents/pqSMTKAttributePanel.cxx b/smtk/extension/paraview/appcomponents/pqSMTKAttributePanel.cxx index c58d8ddc944e9b07446b7597a65d01b4bd60e7c9..cdc7cd4bddc20f8c7aace35774936269fa282e53 100644 --- a/smtk/extension/paraview/appcomponents/pqSMTKAttributePanel.cxx +++ b/smtk/extension/paraview/appcomponents/pqSMTKAttributePanel.cxx @@ -44,10 +44,9 @@ pqSMTKAttributePanel::pqSMTKAttributePanel(QWidget* parent) : Superclass(parent) - , m_attrUIMgr(nullptr) { this->setObjectName("attributeEditor"); - this->setWindowTitle("Attribute Editor"); + updateTitle(); QWidget* w = new QWidget(this); w->setObjectName("attributePanel"); this->setWidget(w); @@ -56,10 +55,14 @@ pqSMTKAttributePanel::pqSMTKAttributePanel(QWidget* parent) &pqActiveObjects::instance(), SIGNAL(sourceChanged(pqPipelineSource*)), this, - SLOT(displayPipelineSource(pqPipelineSource*))); + SLOT(displayPipelineSource(pqPipelineSource*)), + Qt::QueuedConnection); QObject::connect( - &pqActiveObjects::instance(), SIGNAL(dataUpdated()), this, SLOT(updatePipeline())); - + &pqActiveObjects::instance(), + SIGNAL(dataUpdated()), + this, + SLOT(updatePipeline()), + Qt::QueuedConnection); auto* pqCore = pqApplicationCore::instance(); if (pqCore) { @@ -115,34 +118,59 @@ bool pqSMTKAttributePanel::displayPipelineSource(pqPipelineSource* psrc) return false; } -bool pqSMTKAttributePanel::displayResource(const smtk::attribute::ResourcePtr& rsrc) +void pqSMTKAttributePanel::resetPanel(smtk::resource::ManagerPtr rsrcMgr) { - bool didDisplay = false; - auto previousResource = m_rsrc.lock(); - if (!rsrc || rsrc == previousResource) - { - return didDisplay; - } - - if (previousResource) - { - auto rsrcMgr = previousResource->manager(); - if (rsrcMgr && m_observer.assigned()) - { - rsrcMgr->observers().erase(m_observer); - } - } - m_rsrc = rsrc; if (m_attrUIMgr) { m_propertyLinks.clear(); delete m_attrUIMgr; + m_attrUIMgr = nullptr; while (QWidget* w = this->widget()->findChild()) { delete w; } } + if (rsrcMgr && m_observer.assigned()) + { + rsrcMgr->observers().erase(m_observer); + } + + m_rsrc = std::weak_ptr(); +} + +bool pqSMTKAttributePanel::displayResource(const smtk::attribute::ResourcePtr& rsrc) +{ + bool didDisplay = false; + + if (rsrc) + { + auto previousResource = m_rsrc.lock(); + + if (rsrc->isPrivate() && rsrc != previousResource) + { + resetPanel(rsrc->manager()); + didDisplay = displayResourceInternal(rsrc); + } + else if (!rsrc->isPrivate() && rsrc == previousResource) + { + // the panel is displaying a resource that is now private + // stop displaying it + resetPanel(rsrc->manager()); + } + } + + this->updateTitle(); + + return didDisplay; +} + +bool pqSMTKAttributePanel::displayResourceInternal(const smtk::attribute::ResourcePtr& rsrc) +{ + bool didDisplay = false; + + m_rsrc = rsrc; + m_attrUIMgr = new smtk::extension::qtUIManager(rsrc); m_attrUIMgr->setOperationManager(m_opManager); // Assign the operation manager m_attrUIMgr->setViewManager(m_viewManager); @@ -214,17 +242,9 @@ bool pqSMTKAttributePanel::displayResource(const smtk::attribute::ResourcePtr& r { // The application is removing the attribute resource we are viewing. // Clear out the panel and unobserve the manager. - delete m_attrUIMgr; - m_attrUIMgr = nullptr; + this->resetPanel(weakResourceManager.lock()); + this->updateTitle(); m_seln = nullptr; - while (QWidget* w = this->widget()->findChild()) - { - delete w; - } - if (auto rsrcMgr = weakResourceManager.lock()) - { - rsrcMgr->observers().erase(m_observer); - } } }, "pqSMTKAttributePanel: Clear panel if a removed resource is being displayed."); @@ -291,3 +311,11 @@ void pqSMTKAttributePanel::updateSettings() auto* smtkSettings = vtkSMTKSettings::GetInstance(); m_attrUIMgr->setHighlightOnHover(smtkSettings->GetHighlightOnHover()); } + +void pqSMTKAttributePanel::updateTitle() +{ + auto rsrc = m_rsrc.lock(); + QString panelName = "Attribute Editor"; + QString title = rsrc ? (panelName + '(' + rsrc->name().c_str() + ')') : panelName; + this->setWindowTitle(title); +} diff --git a/smtk/extension/paraview/appcomponents/pqSMTKAttributePanel.h b/smtk/extension/paraview/appcomponents/pqSMTKAttributePanel.h index f7403886fff9aadbb1878a7b14faf249900cce3a..d654e9e36b61f74365c5637bb4b7b96a904e44dc 100644 --- a/smtk/extension/paraview/appcomponents/pqSMTKAttributePanel.h +++ b/smtk/extension/paraview/appcomponents/pqSMTKAttributePanel.h @@ -83,6 +83,10 @@ public slots: * contents have changed). Re-render. */ virtual bool updatePipeline(); + /**\brief Clear panel widgets, unobserve displayed resource, + * and set the attribute resource pointer to null. + */ + virtual void resetPanel(smtk::resource::ManagerPtr rsrcMgr); protected slots: /**\brief Called when vtkSMTKSettings is modified, indicating user preferences have changed. @@ -96,7 +100,9 @@ protected slots: virtual void updateSettings(); protected: - smtk::extension::qtUIManager* m_attrUIMgr; + virtual bool displayResourceInternal(const smtk::attribute::ResourcePtr& rsrc); + virtual void updateTitle(); + smtk::extension::qtUIManager* m_attrUIMgr{ nullptr }; std::weak_ptr m_rsrc; smtk::view::SelectionPtr m_seln; smtk::view::ManagerPtr m_viewManager; diff --git a/smtk/extension/paraview/appcomponents/pqSMTKOperationPanel.cxx b/smtk/extension/paraview/appcomponents/pqSMTKOperationPanel.cxx index 99dfc9f6803b21441977c1249ef355dfb7db0633..08335536fe33a95644d127b99bf356dbe68ddc57 100644 --- a/smtk/extension/paraview/appcomponents/pqSMTKOperationPanel.cxx +++ b/smtk/extension/paraview/appcomponents/pqSMTKOperationPanel.cxx @@ -96,10 +96,7 @@ public: pqSMTKOperationPanel::pqSMTKOperationPanel(QWidget* parent) : Superclass(parent) - , m_p(nullptr) - , m_wrapper(nullptr) , m_editing(nullptr) - , m_attrUIMgr(nullptr) { // This must come before m_p is created, since the m_p->OperationList widget will reference it: auto opFilterSort = smtk::workflow::OperationFilterSort::create(); diff --git a/smtk/extension/paraview/appcomponents/pqSMTKOperationPanel.h b/smtk/extension/paraview/appcomponents/pqSMTKOperationPanel.h index 21eaa4d0800428480d26ca52cd3d40f85fa2de1b..af066710ecb9b080853c71d5f3a89eedc9bda95b 100644 --- a/smtk/extension/paraview/appcomponents/pqSMTKOperationPanel.h +++ b/smtk/extension/paraview/appcomponents/pqSMTKOperationPanel.h @@ -100,10 +100,12 @@ protected: virtual void displayDocumentation(const smtk::operation::Operation::Index& index); class Internal; - Internal* m_p; - pqSMTKWrapper* m_wrapper; // TODO: Remove the need for me. This ties us to a single pqServer. + Internal* m_p{ nullptr }; + pqSMTKWrapper* m_wrapper{ + nullptr + }; // TODO: Remove the need for me. This ties us to a single pqServer. smtk::operation::OperationPtr m_editing; - smtk::extension::qtUIManager* m_attrUIMgr; + smtk::extension::qtUIManager* m_attrUIMgr{ nullptr }; std::weak_ptr m_rsrc; smtk::view::AvailableOperationsPtr m_availableOperations; smtk::resource::Observers::Key m_observer; diff --git a/smtk/extension/paraview/appcomponents/pqSMTKResourcePanel.cxx b/smtk/extension/paraview/appcomponents/pqSMTKResourcePanel.cxx index 993b076f3729bfbff673bf4dd5a9d07f91928e68..777a87269f930569d64e3d746449abdb36ab7ad6 100644 --- a/smtk/extension/paraview/appcomponents/pqSMTKResourcePanel.cxx +++ b/smtk/extension/paraview/appcomponents/pqSMTKResourcePanel.cxx @@ -23,8 +23,6 @@ pqSMTKResourcePanel::pqSMTKResourcePanel(QWidget* parent) : Superclass(parent) - , m_browser(nullptr) - , m_viewUIMgr(nullptr) { // Parse a json representation of our default config, save it. nlohmann::json j = nlohmann::json::parse(pqSMTKResourceBrowser::getJSONConfiguration()); diff --git a/smtk/extension/paraview/appcomponents/pqSMTKResourcePanel.h b/smtk/extension/paraview/appcomponents/pqSMTKResourcePanel.h index 3bbabdf97c0fc25691b16302798fa5b05fb581b3..aff448754c8daa22019d22e95aaafdfafec064ee 100644 --- a/smtk/extension/paraview/appcomponents/pqSMTKResourcePanel.h +++ b/smtk/extension/paraview/appcomponents/pqSMTKResourcePanel.h @@ -42,9 +42,9 @@ protected slots: virtual void resourceManagerRemoved(pqSMTKWrapper* mgr, pqServer* server); protected: - pqSMTKResourceBrowser* m_browser; + pqSMTKResourceBrowser* m_browser{ nullptr }; smtk::view::ConfigurationPtr m_view; - smtk::extension::qtUIManager* m_viewUIMgr; + smtk::extension::qtUIManager* m_viewUIMgr{ nullptr }; }; #endif // smtk_extension_paraview_appcomponents_pqSMTKResourcePanel_h diff --git a/smtk/extension/paraview/mesh/testing/xml/CMakeLists.txt b/smtk/extension/paraview/mesh/testing/xml/CMakeLists.txt index c68e1d18fb4ab40fcea9b48445e8884753e401a5..d8d317938cf69b96daf7713bbcf169912b7810cc 100644 --- a/smtk/extension/paraview/mesh/testing/xml/CMakeLists.txt +++ b/smtk/extension/paraview/mesh/testing/xml/CMakeLists.txt @@ -9,9 +9,10 @@ set(MeshSelection_USES_DIRECT_DATA ON) if (SMTK_DATA_DIR) smtk_add_client_tests( -# LABEL "pv_meshsession" + #LABEL "MeshSession" TEST_SCRIPTS ${TESTS_WITH_BASELINES} LOAD_PLUGINS + smtkAttributePlugin smtkResourcePlugin smtkOperationPlugin smtkGeometryPlugin @@ -22,6 +23,7 @@ smtk_add_client_tests( smtkPQComponentsPlugin smtkPVMeshExtPlugin PLUGIN_PATHS + $/.. $/.. $/.. $/.. diff --git a/smtk/extension/paraview/server/RespondToVTKSelection.cxx b/smtk/extension/paraview/server/RespondToVTKSelection.cxx index 0572cc0b984235d35db6e6bf989ed8b0fda6a7f8..64e84e2b6ba8c175ba2c415867a91648464177c0 100644 --- a/smtk/extension/paraview/server/RespondToVTKSelection.cxx +++ b/smtk/extension/paraview/server/RespondToVTKSelection.cxx @@ -54,12 +54,7 @@ namespace view { RespondToVTKSelection::RespondToVTKSelection() - : m_vtkSelection(nullptr) - , m_vtkData(nullptr) - , m_smtkSelectionSource("paraview") - , m_smtkSelectionValue(1) - , m_modifier(/* replace current selection */ 0) - , m_selectingBlocks(false) + : m_smtkSelectionSource("paraview") { } diff --git a/smtk/extension/paraview/server/RespondToVTKSelection.h b/smtk/extension/paraview/server/RespondToVTKSelection.h index 5ac01f1268e334cd80648b3d5ed2f55391bb0d23..4134bc51f9194b8e0075ff882184c01604d1011d 100644 --- a/smtk/extension/paraview/server/RespondToVTKSelection.h +++ b/smtk/extension/paraview/server/RespondToVTKSelection.h @@ -149,13 +149,13 @@ protected: void generateSummary(Operation::Result&) override {} int m_interactionMode; - ::vtkSelection* m_vtkSelection; - vtkMultiBlockDataSet* m_vtkData; + ::vtkSelection* m_vtkSelection{ nullptr }; + vtkMultiBlockDataSet* m_vtkData{ nullptr }; smtk::view::WeakSelectionPtr m_smtkSelection; std::string m_smtkSelectionSource; - int m_smtkSelectionValue; - int m_modifier; - bool m_selectingBlocks; + int m_smtkSelectionValue{ 1 }; + int m_modifier{ /* replace current selection */ 0 }; + bool m_selectingBlocks{ false }; private: const char* xmlDescription() const override; diff --git a/smtk/extension/paraview/server/vtkSMTKResource.cxx b/smtk/extension/paraview/server/vtkSMTKResource.cxx index b3a4ebe4080f547d4d95df29e352325d78a40903..9490a1ad519d03c5581726249e22752694f17a6f 100644 --- a/smtk/extension/paraview/server/vtkSMTKResource.cxx +++ b/smtk/extension/paraview/server/vtkSMTKResource.cxx @@ -31,7 +31,6 @@ vtkCxxSetObjectMacro(vtkSMTKResource, Wrapper, vtkSMTKWrapper); vtkSMTKResource::vtkSMTKResource() : Converter(nullptr) - , Wrapper(nullptr) { this->SetNumberOfInputPorts(0); } diff --git a/smtk/extension/paraview/server/vtkSMTKResource.h b/smtk/extension/paraview/server/vtkSMTKResource.h index 6a3847e52662d2c68defa340798f96c26cf419b4..2adf79435a59cbc2d4c87dee0e3bc6f5e106aa5e 100644 --- a/smtk/extension/paraview/server/vtkSMTKResource.h +++ b/smtk/extension/paraview/server/vtkSMTKResource.h @@ -66,7 +66,7 @@ protected: std::weak_ptr Resource; smtk::common::UUID ResourceId; vtkSmartPointer Converter; - vtkSMTKWrapper* Wrapper; + vtkSMTKWrapper* Wrapper{ nullptr }; }; #endif diff --git a/smtk/extension/paraview/server/vtkSMTKResourceRepresentation.cxx b/smtk/extension/paraview/server/vtkSMTKResourceRepresentation.cxx index 8fa3629267accbfbcfd6a29de047d4115bf2923b..cf6ca703ec7e764b39351beaae313699add8b301 100644 --- a/smtk/extension/paraview/server/vtkSMTKResourceRepresentation.cxx +++ b/smtk/extension/paraview/server/vtkSMTKResourceRepresentation.cxx @@ -174,8 +174,7 @@ typename std::enable_if::value, void>::type MarkRedistrib vtkStandardNewMacro(vtkSMTKResourceRepresentation); vtkSMTKResourceRepresentation::vtkSMTKResourceRepresentation() - : Wrapper(nullptr) - , EntityMapper(vtkSmartPointer::New()) + : EntityMapper(vtkSmartPointer::New()) , SelectedEntityMapper(vtkSmartPointer::New()) , GlyphMapper(vtkSmartPointer::New()) , SelectedGlyphMapper(vtkSmartPointer::New()) @@ -183,10 +182,6 @@ vtkSMTKResourceRepresentation::vtkSMTKResourceRepresentation() , SelectedEntities(vtkSmartPointer::New()) , GlyphEntities(vtkSmartPointer::New()) , SelectedGlyphEntities(vtkSmartPointer::New()) - , EntitiesActorPickId(-1) - , SelectedEntitiesActorPickId(-1) - , GlyphEntitiesActorPickId(-1) - , SelectedGlyphEntitiesActorPickId(-1) { this->SetupDefaults(); this->SetNumberOfInputPorts(3); diff --git a/smtk/extension/paraview/server/vtkSMTKResourceRepresentation.h b/smtk/extension/paraview/server/vtkSMTKResourceRepresentation.h index 342e78d86b7c27a5ee7a9619b067db474ca71c83..28bb61f420f6885c25846f03d0ef4d56e62ca2ef 100644 --- a/smtk/extension/paraview/server/vtkSMTKResourceRepresentation.h +++ b/smtk/extension/paraview/server/vtkSMTKResourceRepresentation.h @@ -425,7 +425,7 @@ protected: * + to determine the color for some non-visual entity types such as groups or models; and * + in certain coloring modes, such as when coloring by volume. */ - vtkSMTKWrapper* Wrapper; + vtkSMTKWrapper* Wrapper{ nullptr }; /// If Wrapper is non-null, SelectionObserver is the handle of an observer of Wrapper->GetSelection(). smtk::view::SelectionObservers::Key SelectionObserver; /** @@ -456,10 +456,10 @@ protected: vtkSmartPointer SelectedGlyphEntities; // IDs assigned by vtkPVRenderView for hardware picking: - int EntitiesActorPickId; - int SelectedEntitiesActorPickId; - int GlyphEntitiesActorPickId; - int SelectedGlyphEntitiesActorPickId; + int EntitiesActorPickId{ -1 }; + int SelectedEntitiesActorPickId{ -1 }; + int GlyphEntitiesActorPickId{ -1 }; + int SelectedGlyphEntitiesActorPickId{ -1 }; /** * Rendering properties shared between Entities and GlyphEntities diff --git a/smtk/extension/paraview/server/vtkSMTKResourceSource.cxx b/smtk/extension/paraview/server/vtkSMTKResourceSource.cxx index b834d6c6a5b12e2bc0ce0cd559f543d9e7075cac..412bde14bc535ff15e978ab1d6dd1224226227ad 100644 --- a/smtk/extension/paraview/server/vtkSMTKResourceSource.cxx +++ b/smtk/extension/paraview/server/vtkSMTKResourceSource.cxx @@ -23,7 +23,6 @@ using namespace smtk; vtkStandardNewMacro(vtkSMTKResourceSource); vtkSMTKResourceSource::vtkSMTKResourceSource() - : VTKResource(nullptr) { this->SetNumberOfInputPorts(0); } diff --git a/smtk/extension/paraview/server/vtkSMTKResourceSource.h b/smtk/extension/paraview/server/vtkSMTKResourceSource.h index eca62ebd8e06939c5276df4558677345247bd286..b65b3dfea3994e85d5b011fd9f467760a96b41ad 100644 --- a/smtk/extension/paraview/server/vtkSMTKResourceSource.h +++ b/smtk/extension/paraview/server/vtkSMTKResourceSource.h @@ -60,7 +60,7 @@ protected: vtkSMTKResourceSource(); ~vtkSMTKResourceSource() override; - vtkSMTKResource* VTKResource; + vtkSMTKResource* VTKResource{ nullptr }; }; #endif diff --git a/smtk/extension/paraview/server/vtkSMTKSettings.cxx b/smtk/extension/paraview/server/vtkSMTKSettings.cxx index 98067149e7e8555b128223709003c280ab0a1a4b..bcf2e426212ff3da705b6cf2d6a22c49691bd7e6 100644 --- a/smtk/extension/paraview/server/vtkSMTKSettings.cxx +++ b/smtk/extension/paraview/server/vtkSMTKSettings.cxx @@ -22,12 +22,9 @@ vtkSMTKSettings* vtkSMTKSettings::New() } vtkSMTKSettings::vtkSMTKSettings() - : HighlightOnHover(true) - , ShowSaveResourceOnClose(AskUser) + : ShowSaveResourceOnClose(AskUser) , SelectionRenderStyle(SolidSelectionStyle) , ResourceTreeStyle(HierarchicalStyle) - , WorkflowsFolder(nullptr) - , ProjectsRootFolder(nullptr) { } diff --git a/smtk/extension/paraview/server/vtkSMTKSettings.h b/smtk/extension/paraview/server/vtkSMTKSettings.h index b3a33859df6c922da44274600017479cc0cadd2e..0138cc0d31d391a37209898d63cc3dbe6209ea0b 100644 --- a/smtk/extension/paraview/server/vtkSMTKSettings.h +++ b/smtk/extension/paraview/server/vtkSMTKSettings.h @@ -87,12 +87,12 @@ public: protected: vtkSMTKSettings(); - bool HighlightOnHover; + bool HighlightOnHover{ true }; int ShowSaveResourceOnClose; int SelectionRenderStyle; int ResourceTreeStyle; - char* WorkflowsFolder; - char* ProjectsRootFolder; + char* WorkflowsFolder{ nullptr }; + char* ProjectsRootFolder{ nullptr }; private: static vtkSmartPointer Instance; diff --git a/smtk/extension/paraview/server/vtkSMTKWrapper.cxx b/smtk/extension/paraview/server/vtkSMTKWrapper.cxx index b90b495636e47b95676df0e4606759ccd6ffd03d..299e8af073322746fa110234e6f499243d0740c7 100644 --- a/smtk/extension/paraview/server/vtkSMTKWrapper.cxx +++ b/smtk/extension/paraview/server/vtkSMTKWrapper.cxx @@ -75,12 +75,7 @@ vtkStandardNewMacro(vtkSMTKWrapper); vtkCxxSetObjectMacro(vtkSMTKWrapper, Representation, vtkPVDataRepresentation); vtkSMTKWrapper::vtkSMTKWrapper() - : ActiveResource(nullptr) - , Managers(smtk::common::Managers::create()) - , SelectedPort(nullptr) - , SelectionObj(nullptr) - , JSONRequest(nullptr) - , JSONResponse(nullptr) + : Managers(smtk::common::Managers::create()) , SelectionSource("paraview") { smtk::plugin::Manager::instance()->registerPluginsTo(this->Managers); diff --git a/smtk/extension/paraview/server/vtkSMTKWrapper.h b/smtk/extension/paraview/server/vtkSMTKWrapper.h index db4b452c1ab81efeb56cb16557739aa841d1b34d..8c52d89a374f4564f3b49ecaae3b49fef57bbf69 100644 --- a/smtk/extension/paraview/server/vtkSMTKWrapper.h +++ b/smtk/extension/paraview/server/vtkSMTKWrapper.h @@ -154,11 +154,11 @@ protected: vtkSMTKResource* GetVTKResource(vtkAlgorithm*); vtkPVDataRepresentation* Representation = nullptr; - vtkAlgorithmOutput* ActiveResource; - vtkAlgorithmOutput* SelectedPort; - vtkAlgorithmOutput* SelectionObj; - char* JSONRequest; - char* JSONResponse; + vtkAlgorithmOutput* ActiveResource{ nullptr }; + vtkAlgorithmOutput* SelectedPort{ nullptr }; + vtkAlgorithmOutput* SelectionObj{ nullptr }; + char* JSONRequest{ nullptr }; + char* JSONResponse{ nullptr }; smtk::common::Managers::Ptr Managers; std::string SelectionSource; diff --git a/smtk/extension/paraview/widgets/testing/xml/CMakeLists.txt b/smtk/extension/paraview/widgets/testing/xml/CMakeLists.txt index 863c1e8c659398c9230cd08e2ab77d36062f4317..4f3b04da2971e252f801b29cd0b68883f48f98f6 100644 --- a/smtk/extension/paraview/widgets/testing/xml/CMakeLists.txt +++ b/smtk/extension/paraview/widgets/testing/xml/CMakeLists.txt @@ -21,7 +21,7 @@ set(SplineWidget_USES_DIRECT_DATA ON) if (SMTK_DATA_DIR) smtk_add_client_tests( -# LABEL "pv_meshsession" + #LABEL "MeshSession" TEST_SCRIPTS ${TESTS_WITH_BASELINES} LOAD_PLUGINS smtkResourcePlugin @@ -42,4 +42,10 @@ smtk_add_client_tests( DATA_DIRECTORY ${PROJECT_SOURCE_DIR}/data BASELINE_DIR ${PROJECT_SOURCE_DIR}/data/baseline/smtk/widgets ) +set(pv_tests) +foreach (test_file IN LISTS TESTS_WITH_BASELINES) + get_filename_component(test_basename "${test_file}" NAME_WE) + list(APPEND pv_tests "pv.${test_basename}") +endforeach () +smtk_test_apply_sanitizer(${pv_tests}) endif() diff --git a/smtk/extension/qt/MembershipBadge.cxx b/smtk/extension/qt/MembershipBadge.cxx index cb260380bc0a79b6f18cd78094265706fb1a15d1..0bfc580bee5812b143ee78ab03d0480bdd40361a 100644 --- a/smtk/extension/qt/MembershipBadge.cxx +++ b/smtk/extension/qt/MembershipBadge.cxx @@ -42,18 +42,15 @@ namespace qt { MembershipBadge::MembershipBadge() - : m_singleSelect(false) - , m_iconOn(selected_svg) + : m_iconOn(selected_svg) , m_iconOff(unselected_svg) - , m_parent(nullptr) { } MembershipBadge::MembershipBadge( smtk::view::BadgeSet& parent, const smtk::view::Configuration::Component& config) - : m_singleSelect(false) - , m_iconOn(selected_svg) + : m_iconOn(selected_svg) , m_iconOff(unselected_svg) , m_parent(&parent) { diff --git a/smtk/extension/qt/MembershipBadge.h b/smtk/extension/qt/MembershipBadge.h index 3c915e8016700559dc339f3bbd993df102539b0e..2d5889cff13fe14473f95f902bff6fcd1cf87e1c 100644 --- a/smtk/extension/qt/MembershipBadge.h +++ b/smtk/extension/qt/MembershipBadge.h @@ -68,11 +68,13 @@ signals: void membershipChange(int val); protected: - MemberMap m_members; //!< From available items, has this object been turned on? - bool m_singleSelect; //!< If true, only 1 item may be a member; toggling an item resets others. + MemberMap m_members; //!< From available items, has this object been turned on? + bool m_singleSelect{ + false + }; //!< If true, only 1 item may be a member; toggling an item resets others. std::string m_iconOn; //!< SVG for icon showing membership. std::string m_iconOff; //!< SVG for icon showing non-membership. - const smtk::view::BadgeSet* m_parent; + const smtk::view::BadgeSet* m_parent{ nullptr }; }; } // namespace qt } // namespace extension diff --git a/smtk/extension/qt/examples/cxx/browseModel.cxx b/smtk/extension/qt/examples/cxx/browseModel.cxx index 2f036765c81957e03b799ef55e1b92ae1337225a..6cf1609838c1d589a20c38cdf6e9aeb38e297fc1 100644 --- a/smtk/extension/qt/examples/cxx/browseModel.cxx +++ b/smtk/extension/qt/examples/cxx/browseModel.cxx @@ -31,6 +31,8 @@ #include "smtk/common/testing/cxx/helpers.h" #include "smtk/model/testing/cxx/helpers.h" +#include "smtk/plugin/Registry.h" + #include #include #include @@ -67,9 +69,9 @@ int main(int argc, char* argv[]) auto operationManager = smtk::operation::Manager::create(); auto resourceManager = smtk::resource::Manager::create(); auto viewManager = smtk::view::Manager::create(); - smtk::view::Registrar::registerTo(viewManager); - smtk::model::Registrar::registerTo(resourceManager); - smtk::attribute::Registrar::registerTo(resourceManager); + auto viewRegistry = smtk::plugin::addToManagers(viewManager); + auto modelRegistry = smtk::plugin::addToManagers(resourceManager); + auto attributeRegistry = smtk::plugin::addToManagers(resourceManager); nlohmann::json jconfig; if (configname) diff --git a/smtk/extension/qt/examples/cxx/qtAttributePreview.cxx b/smtk/extension/qt/examples/cxx/qtAttributePreview.cxx index ce8e738f46f6e02972bf54a1cd9099eb45392efd..2d7bb7966af05b222293d95761fdc9e8338364f6 100644 --- a/smtk/extension/qt/examples/cxx/qtAttributePreview.cxx +++ b/smtk/extension/qt/examples/cxx/qtAttributePreview.cxx @@ -43,6 +43,8 @@ // SMTK build tree includes #include "smtk/operation/Operation_xml.h" +#include "smtk/plugin/Registry.h" + // Qt includes #include #include @@ -288,10 +290,11 @@ int main(int argc, char* argv[]) // Initialize operation manager and view manager auto operationManager = smtk::operation::Manager::create(); - smtk::attribute::Registrar::registerTo(operationManager); + auto attributeRegistry = + smtk::plugin::addToManagers(operationManager); auto viewManager = smtk::view::Manager::create(); - smtk::view::Registrar::registerTo(viewManager); - smtk::extension::qtViewRegistrar::registerTo(viewManager); + auto viewRegistry = smtk::plugin::addToManagers(viewManager); + auto qtViewRegistry = smtk::plugin::addToManagers(viewManager); // Instantiate smtk's qtUIManager smtk::extension::qtUIManager* uiManager = new smtk::extension::qtUIManager(attResource); diff --git a/smtk/extension/qt/examples/cxx/qtOperationPreview.cxx b/smtk/extension/qt/examples/cxx/qtOperationPreview.cxx index f22b85ab866e5fcfca5c37c31237299d8953073f..c693faa6a19733e7426c45b22e7f8878bb00c6e7 100644 --- a/smtk/extension/qt/examples/cxx/qtOperationPreview.cxx +++ b/smtk/extension/qt/examples/cxx/qtOperationPreview.cxx @@ -11,11 +11,11 @@ #include "smtk/attribute/Registrar.h" #include "smtk/extension/qt/qtOperationDialog.h" -#include "smtk/extension/qt/qtUIManager.h" #include "smtk/extension/qt/qtViewRegistrar.h" #include "smtk/model/Registrar.h" #include "smtk/operation/Manager.h" #include "smtk/operation/Registrar.h" +#include "smtk/plugin/Registry.h" #include "smtk/resource/Manager.h" #include "smtk/view/Manager.h" @@ -60,13 +60,12 @@ int main(int argc, char* argv[]) // Initialize smtk managers auto resManager = smtk::resource::Manager::create(); - smtk::attribute::Registrar::registerTo(resManager); - smtk::model::Registrar::registerTo(resManager); auto opManager = smtk::operation::Manager::create(); opManager->registerResourceManager(resManager); - smtk::attribute::Registrar::registerTo(opManager); - smtk::model::Registrar::registerTo(opManager); + auto attributeRegistry = + smtk::plugin::addToManagers(resManager, opManager); + auto modelRegistry = smtk::plugin::addToManagers(resManager, opManager); // Process command line QCommandLineParser parser; @@ -116,14 +115,11 @@ int main(int argc, char* argv[]) // Initialize and register managers auto viewManager = smtk::view::Manager::create(); - smtk::view::Registrar::registerTo(viewManager); - smtk::extension::qtViewRegistrar::registerTo(viewManager); - - auto uiManager = QSharedPointer( - new smtk::extension::qtUIManager(op, resManager, viewManager)); + auto viewRegistry = smtk::plugin::addToManagers(viewManager); + auto qtViewRegistry = smtk::plugin::addToManagers(viewManager); // Initialize dialog - smtk::extension::qtOperationDialog dialog(op, uiManager, nullptr); + smtk::extension::qtOperationDialog dialog(op, resManager, viewManager, false, nullptr); int retcode = dialog.exec(); return retcode; } diff --git a/smtk/extension/qt/qtAttributeView.cxx b/smtk/extension/qt/qtAttributeView.cxx index bcc3ee1577bb531971ddee82ec8ffc4fc9ad4a74..d6701a4467debaed5928af09b9572e5a1e7d1455 100644 --- a/smtk/extension/qt/qtAttributeView.cxx +++ b/smtk/extension/qt/qtAttributeView.cxx @@ -28,6 +28,7 @@ #include "smtk/attribute/GroupItemDefinition.h" #include "smtk/attribute/ItemDefinition.h" #include "smtk/attribute/Resource.h" +#include "smtk/attribute/StringItem.h" #include "smtk/attribute/ValueItem.h" #include "smtk/attribute/ValueItemDefinition.h" #include "smtk/attribute/VoidItem.h" @@ -83,6 +84,22 @@ class qtAttributeViewInternals public: ~qtAttributeViewInternals() { delete this->CurrentAtt; } + // Return a list of defs from the input that pass the advance read level check + QList removeAdvancedDefs( + smtk::extension::qtUIManager* uiManager, + const QList& defs) const + { + QList allVisibleDefs; + for (const auto& def : defs) + { + if (uiManager->passAdvancedCheck(def->advanceLevel())) + { + allVisibleDefs.append(def); + } + } + return allVisibleDefs; + } + // Return a list of definitions based on the current settings // of the UI Manager and whether the View is to ignore // categories @@ -92,14 +109,14 @@ public: { if (ignoreCategories) { - return this->AllDefs; + return removeAdvancedDefs(uiManager, this->AllDefs); } auto attResource = uiManager->attResource(); if (!(attResource && attResource->activeCategoriesEnabled())) { // There are no active categories - return everything - return this->AllDefs; + return removeAdvancedDefs(uiManager, this->AllDefs); } if (attResource->activeCategories().size() == 1) @@ -107,9 +124,9 @@ public: std::string theCategory = *(attResource->activeCategories().begin()); if (this->AttDefMap.keys().contains(theCategory.c_str())) { - return this->AttDefMap[theCategory.c_str()]; + return removeAdvancedDefs(uiManager, this->AttDefMap[theCategory.c_str()]); } - return this->AllDefs; + return removeAdvancedDefs(uiManager, this->AllDefs); } QList defs; @@ -120,7 +137,7 @@ public: defs.push_back(attDef); } } - return defs; + return removeAdvancedDefs(uiManager, defs); } QTableView* ListTable; @@ -154,6 +171,7 @@ public: //Last selected attribute WeakAttributePtr selectedAttribute; + const std::string m_activeAttributeViewAttName = "ActiveAttribute"; // Model for filtering the attribute by combobox. QPointer checkableAttComboModel; @@ -249,7 +267,7 @@ void qtAttributeView::createWidget() // m_internals->AttDefMap has to be initialized before getAllDefinitions() // since the getAllDefinitions() call needs the categories list in AttDefMap - // Create a map for all catagories so we can cluster the definitions + // Create a map for all categories so we can cluster the definitions m_internals->AttDefMap.clear(); const ResourcePtr attResource = this->uiManager()->attResource(); std::set::const_iterator it; @@ -530,6 +548,20 @@ smtk::attribute::Attribute* qtAttributeView::getRawAttributeFromItem(const QStan return (item ? static_cast(item->data(Qt::UserRole).value()) : nullptr); } +smtk::attribute::Attribute* qtAttributeView::getRawAttributeFromIndex(const QModelIndex& index) +{ + if (!index.isValid()) + { + return nullptr; + } + + QModelIndex attIndex = index.sibling(index.row(), name_column); + smtk::attribute::Attribute* raw = + static_cast(attIndex.data(Qt::UserRole).value()); + + return raw; +} + smtk::attribute::AttributePtr qtAttributeView::getAttributeFromItem(const QStandardItem* item) { smtk::attribute::Attribute* raw = this->getRawAttributeFromItem(item); @@ -543,20 +575,22 @@ smtk::attribute::AttributePtr qtAttributeView::getAttributeFromItem(const QStand smtk::attribute::AttributePtr qtAttributeView::getAttributeFromIndex(const QModelIndex& index) { - if (!index.isValid()) - { - return smtk::attribute::AttributePtr(); - } + smtk::attribute::Attribute* raw = this->getRawAttributeFromIndex(index); + return (raw ? raw->shared_from_this() : smtk::attribute::AttributePtr()); +} - QModelIndex attIndex = index.sibling(index.row(), name_column); - smtk::attribute::Attribute* raw = - static_cast(attIndex.data(Qt::UserRole).value()); - if (raw == nullptr) +QStandardItem* qtAttributeView::getItemFromAttribute(smtk::attribute::Attribute* attribute) +{ + int n = m_internals->ListTableModel->rowCount(); + for (int i = 0; i < n; i++) { - return smtk::attribute::AttributePtr(); + QStandardItem* item = m_internals->ListTableModel->item(i); + if (this->getRawAttributeFromItem(item) == attribute) + { + return item; + } } - - return raw->shared_from_this(); + return nullptr; } // The selected item will always refer to the item that has the attribute data assigned to @@ -637,6 +671,8 @@ void qtAttributeView::onListBoxSelectionChanged() if (dataItem) { + this->getObject()->details().setAttribute( + m_internals->m_activeAttributeViewAttName, dataItem->id().toString()); this->updateAssociationEnableState(dataItem); this->updateTableWithAttribute(dataItem); emit attributeSelected(dataItem); @@ -921,8 +957,13 @@ QStandardItem* qtAttributeView::addAttributeListItem(smtk::attribute::AttributeP { QStandardItem* item = new QStandardItem(QString::fromUtf8(childData->name().c_str())); Qt::ItemFlags nonEditableFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - Qt::ItemFlags itemFlags( - nonEditableFlags | (this->attributeNamesConstant() ? 0x0 : Qt::ItemIsEditable)); + + //Can the attribute name be changed? + bool nameIsConstant = this->attributeNamesConstant() || + (childData->properties().contains("smtk.extensions.attribute_view.name_read_only") && + childData->properties().at("smtk.extensions.attribute_view.name_read_only")); + + Qt::ItemFlags itemFlags(nonEditableFlags | (nameIsConstant ? 0x0 : Qt::ItemIsEditable)); QVariant vdata; vdata.setValue(static_cast(childData.get())); item->setData(vdata, Qt::UserRole); @@ -1027,7 +1068,28 @@ void qtAttributeView::onViewBy() if (m_internals->ListTableModel->rowCount() && !this->getSelectedItem()) { // so switch tabs would not reset selection - if (!m_internals->AssociationsWidget->hasSelectedItem()) + // get the active tab from the view config if it exists + std::string activeAttUuid; + this->getObject()->details().attribute( + m_internals->m_activeAttributeViewAttName, activeAttUuid); + smtk::attribute::ConstAttributePtr activeAtt = + this->uiManager()->attResource()->findAttribute(smtk::common::UUID(activeAttUuid)); + + if (activeAtt) + { + auto items = this->m_internals->ListTableModel->findItems( + activeAtt->name().c_str(), Qt::MatchExactly, name_column); + if (!items.empty()) + { + auto* activeItem = items.at(0); + // Select the newly created attribute + m_internals->ListTable->selectRow(activeItem->row()); + QModelIndex index = activeItem->index(); + QModelIndex mappedIndex = m_internals->ListTableProxyModel->mapFromSource(index); + m_internals->ListTable->setCurrentIndex(mappedIndex); + } + } + else if (!m_internals->AssociationsWidget->hasSelectedItem()) { // In this case there was no previous selection so lets select the // first attribute @@ -1040,6 +1102,7 @@ void qtAttributeView::onViewBy() } else { + m_internals->selectedAttribute.reset(); this->onListBoxSelectionChanged(); } frame->handle(1)->setEnabled(true); @@ -1419,9 +1482,12 @@ int qtAttributeView::handleOperationEvent( } // Since the Signal Operation originates from a Qt Signal - // being fired we can ignore this - if (op.typeName() == smtk::common::typeName()) + // being fired we need to see if this view is one that triggered it + if ( + (op.typeName() == smtk::common::typeName()) && + (op.parameters()->findString("source")->value() == m_addressString)) { + // We can ignore this operation since we initiated it return 0; } @@ -1429,13 +1495,34 @@ int qtAttributeView::handleOperationEvent( // current attribute being displayed smtk::attribute::ComponentItemPtr compItem; std::size_t i, n; - if (m_internals->CurrentAtt != nullptr) + smtk::attribute::DefinitionPtr currentDef = this->getCurrentDef(); + + if (currentDef == nullptr) { - compItem = result->findComponent("modified"); - n = compItem->numberOfValues(); - for (i = 0; i < n; i++) + // There is nothing being displayed so nothing needs to be updated + return 0; + } + + compItem = result->findComponent("modified"); + n = compItem->numberOfValues(); + for (i = 0; i < n; i++) + { + // We need to make sure the attribute's name and name edit-ability are properly set + if (!compItem->isSet(i)) { - if (compItem->isSet(i) && (compItem->value(i) == m_internals->CurrentAtt->attribute())) + continue; + } + + auto att = dynamic_pointer_cast(compItem->value(i)); + if (att == nullptr) + { + continue; + } + smtk::attribute::DefinitionPtr attDef = att->definition(); + if (attDef->isA(currentDef)) + { + // Is this the current attribute being displayed? + if (att == m_internals->CurrentAtt->attribute()) { // Update the attribute's items auto items = m_internals->CurrentAtt->items(); @@ -1443,7 +1530,28 @@ int qtAttributeView::handleOperationEvent( { item->updateItemData(); } - break; // we don't have to keep looking for this ComponentPtr + } + // Need to update the item's name and edit ability + auto* item = this->getItemFromAttribute(att.get()); + if (item) + { + item->setText(QString::fromUtf8(att->name().c_str())); + if (!this->attributeNamesConstant()) + { + // Need to see if the name is editable + if ( + att->properties().contains("smtk.extensions.attribute_view.name_read_only") && + att->properties().at("smtk.extensions.attribute_view.name_read_only")) + { + Qt::ItemFlags itemFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + item->setFlags(itemFlags); + } + else + { + Qt::ItemFlags itemFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable); + item->setFlags(itemFlags); + } + } } } } @@ -1456,14 +1564,26 @@ int qtAttributeView::handleOperationEvent( { for (i = 0; i < n; i++) { - if (compItem->isSet(i)) + if (!compItem->isSet(i)) + { + continue; + } + + auto att = dynamic_pointer_cast(compItem->value(i)); + if (att == nullptr) + { + continue; + } + smtk::attribute::DefinitionPtr attDef = att->definition(); + // Is this type of attribute being displayed? + if (attDef->isA(currentDef)) { int row, numRows = m_internals->ListTableModel->rowCount(); for (row = 0; row < numRows; ++row) { QStandardItem* item = m_internals->ListTableModel->item(row, name_column); - smtk::attribute::Attribute* att = this->getRawAttributeFromItem(item); - if (compItem->value(i).get() == att) + smtk::attribute::Attribute* itemAtt = this->getRawAttributeFromItem(item); + if (att.get() == itemAtt) { m_internals->ListTableModel->removeRow(row); break; @@ -1473,14 +1593,6 @@ int qtAttributeView::handleOperationEvent( } } - // In the case of created components we need to see if anything would - // cause us to reset the list view - smtk::attribute::DefinitionPtr currentDef = this->getCurrentDef(); - if (currentDef == nullptr) - { - return 0; // nothing to do - } - compItem = result->findComponent("created"); n = compItem->numberOfValues(); for (i = 0; i < n; i++) diff --git a/smtk/extension/qt/qtAttributeView.h b/smtk/extension/qt/qtAttributeView.h index c06581c6439b17504c042679ebb51bda4a883ffc..c957c2cb4696656478c69a44a8fd36a7c7b1e38f 100644 --- a/smtk/extension/qt/qtAttributeView.h +++ b/smtk/extension/qt/qtAttributeView.h @@ -123,6 +123,8 @@ protected: smtk::attribute::AttributePtr getAttributeFromItem(const QStandardItem* item); smtk::attribute::AttributePtr getAttributeFromIndex(const QModelIndex& index); smtk::attribute::Attribute* getRawAttributeFromItem(const QStandardItem* item); + smtk::attribute::Attribute* getRawAttributeFromIndex(const QModelIndex& index); + QStandardItem* getItemFromAttribute(smtk::attribute::Attribute* attribute); ///\brief Method used to delete an attribute from its resource virtual bool deleteAttribute(smtk::attribute::AttributePtr att); diff --git a/smtk/extension/qt/qtAvailableOperations.cxx b/smtk/extension/qt/qtAvailableOperations.cxx index 0bde35fce4abddba5e94318d8b62854a427a78c4..e9ecafd62335d112b4fa1bd07db45a1fe434ff48 100644 --- a/smtk/extension/qt/qtAvailableOperations.cxx +++ b/smtk/extension/qt/qtAvailableOperations.cxx @@ -20,10 +20,7 @@ namespace extension qtAvailableOperations::qtAvailableOperations(QWidget* parent) : QWidget(parent) - , m_operationList(nullptr) - , m_layout(nullptr) , m_operationSource(nullptr) - , m_useLabels(false) { m_operationList = new QListWidget(this); m_layout = new QVBoxLayout(this); diff --git a/smtk/extension/qt/qtAvailableOperations.h b/smtk/extension/qt/qtAvailableOperations.h index 27a9ef259858082aa444f6a852d972362a3da097..06975d5987f0dbcda276d1b033609f7149b5f5dd 100644 --- a/smtk/extension/qt/qtAvailableOperations.h +++ b/smtk/extension/qt/qtAvailableOperations.h @@ -50,11 +50,11 @@ signals: void hoverOperation(const smtk::operation::Operation::Index& op); protected: - QListWidget* m_operationList; - QVBoxLayout* m_layout; + QListWidget* m_operationList{ nullptr }; + QVBoxLayout* m_layout{ nullptr }; smtk::view::AvailableOperationsPtr m_operationSource; smtk::view::AvailableOperations::Observers::Key m_operationSourceObserverId; - bool m_useLabels; + bool m_useLabels{ false }; void updateList(); }; diff --git a/smtk/extension/qt/qtBaseAttributeView.cxx b/smtk/extension/qt/qtBaseAttributeView.cxx index 6fa5bca6a52027aa377663b936c1f1aa6fc953f5..f4d32e19e662750bf2d610f116f8d95d31771e3e 100644 --- a/smtk/extension/qt/qtBaseAttributeView.cxx +++ b/smtk/extension/qt/qtBaseAttributeView.cxx @@ -40,6 +40,8 @@ #include #include +#include + using namespace smtk::extension; class qtBaseAttributeViewInternals @@ -82,6 +84,12 @@ qtBaseAttributeView::qtBaseAttributeView(const smtk::view::Information& info) m_fixedLabelWidth = m_viewInfo.m_UIManager->maxValueLabelLength(); m_topLevelInitialized = false; m_ignoreCategories = m_viewInfo.m_view->details().attributeAsBool("IgnoreCategories"); + // We need to be able to determine within the a Signal Operation, which View caused + // the change in order to avoid infinite loops. To do this, each View will have an addressString + // set to its address. This string is then passed to the signalAttribute function when needed. + std::stringstream me; + me << std::hex << (void const*)this << std::dec; + m_addressString = me.str(); } qtBaseAttributeView::~qtBaseAttributeView() @@ -190,7 +198,8 @@ void signalAttribute( smtk::extension::qtUIManager* uiManager, const smtk::attribute::AttributePtr& attr, const char* itemName, - std::vector items = std::vector()) + std::vector items, + const std::string& source = "") { if (attr && uiManager && itemName && itemName[0]) { @@ -202,6 +211,7 @@ void signalAttribute( auto signalOp = opManager->create(); if (signalOp) { + signalOp->parameters()->findString("source")->setValue(source); signalOp->parameters()->findComponent(itemName)->appendValue(attr); signalOp->parameters()->findString("items")->setValues(items.begin(), items.end()); opManager->launchers()(signalOp); @@ -223,35 +233,25 @@ void qtBaseAttributeView::attributeCreated(const smtk::attribute::AttributePtr& return; } - // Let the toplevel view process attribute creation - if (!this->isTopLevel()) - { - auto* topView = dynamic_cast(this->uiManager()->topView()); - if (topView) - { - topView->attributeCreated(attr); - return; - } - } - + qtBaseAttributeView* topView = dynamic_cast(this->uiManager()->topView()); // If the toplevel view is using analysis configuration we need // to check to see if the attribute is an analysis configuration - if (this->Internals->m_configurationCombo != nullptr) + if (topView && topView->Internals->m_configurationCombo != nullptr) { - smtk::attribute::DefinitionPtr def = m_topLevelConfigurationDef.lock(); + smtk::attribute::DefinitionPtr def = topView->m_topLevelConfigurationDef.lock(); if (attr->definition()->isA(def)) { // if the combobox allows creation of configurations, the number // of existing configurations is 1 less. - int n = this->Internals->m_configurationCombo->count(); - if (m_topLevelCanCreateConfigurations) + int n = topView->Internals->m_configurationCombo->count(); + if (topView->m_topLevelCanCreateConfigurations) { --n; } // If there are no configurations in the combobox just prep it if (!n) { - this->prepConfigurationComboBox(attr->name()); + topView->prepConfigurationComboBox(attr->name()); } else { @@ -259,21 +259,21 @@ void qtBaseAttributeView::attributeCreated(const smtk::attribute::AttributePtr& bool needToInsert = true; for (int i = 0; (i < n) && needToInsert; i++) { - if (this->Internals->m_configurationCombo->itemText(i).toStdString() > attr->name()) + if (topView->Internals->m_configurationCombo->itemText(i).toStdString() > attr->name()) { - this->Internals->m_configurationCombo->insertItem(i, attr->name().c_str()); + topView->Internals->m_configurationCombo->insertItem(i, attr->name().c_str()); needToInsert = false; } } if (needToInsert) { - this->Internals->m_configurationCombo->insertItem(n, attr->name().c_str()); + topView->Internals->m_configurationCombo->insertItem(n, attr->name().c_str()); } } } } - //Let observers know the attribute was created - signalAttribute(this->uiManager(), attr, "created"); + //Let observers know the attribute was created and who created it + signalAttribute(this->uiManager(), attr, "created", std::vector(), m_addressString); } void qtBaseAttributeView::attributeChanged( @@ -285,30 +285,20 @@ void qtBaseAttributeView::attributeChanged( return; } - // Let the toplevel view process attribute modification - if (!this->isTopLevel()) - { - auto* topView = dynamic_cast(this->uiManager()->topView()); - if (topView) - { - topView->attributeChanged(attr, items); - return; - } - } - + qtBaseAttributeView* topView = dynamic_cast(this->uiManager()->topView()); // If the toplevel view is using analysis configuration we need // to check to see if the attribute is an analysis configuration - if (this->Internals->m_configurationCombo != nullptr) + if (topView && topView->Internals->m_configurationCombo != nullptr) { - smtk::attribute::DefinitionPtr def = m_topLevelConfigurationDef.lock(); + smtk::attribute::DefinitionPtr def = topView->m_topLevelConfigurationDef.lock(); if (attr->definition()->isA(def)) { // We only need to refresh the combobox - this->prepConfigurationComboBox(""); + topView->prepConfigurationComboBox(""); } } - //Let observers know the attribute was modified - signalAttribute(this->uiManager(), attr, "modified", items); + //Let observers know the attribute was modified and which view modified it + signalAttribute(this->uiManager(), attr, "modified", items, m_addressString); } void qtBaseAttributeView::attributeRemoved(const smtk::attribute::AttributePtr& attr) @@ -318,31 +308,21 @@ void qtBaseAttributeView::attributeRemoved(const smtk::attribute::AttributePtr& return; } - // Let the toplevel view process attribute removal - if (!this->isTopLevel()) - { - auto* topView = dynamic_cast(this->uiManager()->topView()); - if (topView) - { - topView->attributeRemoved(attr); - return; - } - } - + qtBaseAttributeView* topView = dynamic_cast(this->uiManager()->topView()); // If the toplevel view is using analysis configuration we need // to check to see if the attribute is an analysis configuration - if (this->Internals->m_configurationCombo != nullptr) + if (topView && topView->Internals->m_configurationCombo != nullptr) { - smtk::attribute::DefinitionPtr def = m_topLevelConfigurationDef.lock(); + smtk::attribute::DefinitionPtr def = topView->m_topLevelConfigurationDef.lock(); if (attr->definition()->isA(def)) { // See if we can find the attribute - int n = this->Internals->m_configurationCombo->findText(attr->name().c_str()); + int n = topView->Internals->m_configurationCombo->findText(attr->name().c_str()); if (n != -1) { - this->Internals->m_configurationCombo->blockSignals(true); - int currentIndex = this->Internals->m_configurationCombo->currentIndex(); + topView->Internals->m_configurationCombo->blockSignals(true); + int currentIndex = topView->Internals->m_configurationCombo->currentIndex(); // If the attribute being removed the selected one? If it is then select the // select another configuration first if (n == currentIndex) @@ -353,22 +333,22 @@ void qtBaseAttributeView::attributeRemoved(const smtk::attribute::AttributePtr& { // Else we will select the first one in the list if one // exists. - int count = this->Internals->m_configurationCombo->count(); - if (m_topLevelCanCreateConfigurations) + int count = topView->Internals->m_configurationCombo->count(); + if (topView->m_topLevelCanCreateConfigurations) { --count; } newSelection = (count > 1) ? 0 : -1; } - this->Internals->m_configurationCombo->removeItem(n); - this->Internals->m_configurationCombo->setCurrentIndex(newSelection); + topView->Internals->m_configurationCombo->removeItem(n); + topView->Internals->m_configurationCombo->setCurrentIndex(newSelection); } else { // This is the case where the attribute is not currently selected. - this->Internals->m_configurationCombo->removeItem(n); + topView->Internals->m_configurationCombo->removeItem(n); } - this->Internals->m_configurationCombo->blockSignals(false); + topView->Internals->m_configurationCombo->blockSignals(false); } } } @@ -377,9 +357,12 @@ void qtBaseAttributeView::attributeRemoved(const smtk::attribute::AttributePtr& // the case of an attribute being referenced by a Reference Item // - See SMTK Issue 415) // so we need to update the UI. - this->updateUI(); - //Let observers know the attribute was removed - signalAttribute(this->uiManager(), attr, "expunged"); + if (topView) + { + topView->updateUI(); + } + //Let observers know the attribute was removed and which view removed it + signalAttribute(this->uiManager(), attr, "expunged", std::vector(), m_addressString); } bool qtBaseAttributeView::setFixedLabelWidth(int w) @@ -845,7 +828,8 @@ void qtBaseAttributeView::prepConfigurationComboBox(const std::string& newConfig att->properties().get()["_selectedConfiguration"] = 1; attRes->analyses().getAnalysisAttributeCategories(att, cats); //Let observers know the attribute was modified - signalAttribute(this->uiManager(), att, "modified", std::vector()); + signalAttribute( + this->uiManager(), att, "modified", std::vector(), m_addressString); } } diff --git a/smtk/extension/qt/qtBaseAttributeView.h b/smtk/extension/qt/qtBaseAttributeView.h index ddef0df211985fa8d0d64bc833dc71aaaff65abd..e45ff38513d9210dae4ab89d6961d76fb0088fda 100644 --- a/smtk/extension/qt/qtBaseAttributeView.h +++ b/smtk/extension/qt/qtBaseAttributeView.h @@ -120,6 +120,7 @@ protected: bool m_topLevelCanCreateConfigurations; smtk::attribute::WeakDefinitionPtr m_topLevelConfigurationDef; bool m_ignoreCategories; + std::string m_addressString; private: int m_fixedLabelWidth; diff --git a/smtk/extension/qt/qtBaseView.h b/smtk/extension/qt/qtBaseView.h index c97b2890c405bf334a91edd30d5a53836554f67e..f0eb154e1103abac8694f1496abc458c3f3263d8 100644 --- a/smtk/extension/qt/qtBaseView.h +++ b/smtk/extension/qt/qtBaseView.h @@ -38,8 +38,7 @@ class SMTKQTEXT_EXPORT ViewInfo : public smtk::view::Information { public: ViewInfo(smtk::view::ConfigurationPtr view, QWidget* parent, qtUIManager* uiman) - : smtk::view::Information() - , m_view(view) + : m_view(view) , m_parent(parent) , m_UIManager(uiman) { diff --git a/smtk/extension/qt/qtDescriptivePhraseDelegate.cxx b/smtk/extension/qt/qtDescriptivePhraseDelegate.cxx index 625fe397a7ff051123e2c0351c3450f467a7c0b7..de6ba94394bfc85f97c46ac2098f632f2e4e97f1 100644 --- a/smtk/extension/qt/qtDescriptivePhraseDelegate.cxx +++ b/smtk/extension/qt/qtDescriptivePhraseDelegate.cxx @@ -27,14 +27,6 @@ const int padding = 7; qtDescriptivePhraseDelegate::qtDescriptivePhraseDelegate(QWidget* owner) : QStyledItemDelegate(owner) - , m_titleFontSize(14) - , m_subtitleFontSize(10) - , m_titleFontWeight(2) - , m_subtitleFontWeight(1) - , m_textVerticalPad(2) - , m_drawSubtitle(true) - , m_visibilityMode(false) - , m_highlightOnHover(false) { } diff --git a/smtk/extension/qt/qtDescriptivePhraseDelegate.h b/smtk/extension/qt/qtDescriptivePhraseDelegate.h index 11723d88f04171d31083872f4bfe4c8d77699c84..cbb438dc162699611d82881cb913bbeea637f43b 100644 --- a/smtk/extension/qt/qtDescriptivePhraseDelegate.h +++ b/smtk/extension/qt/qtDescriptivePhraseDelegate.h @@ -88,14 +88,14 @@ protected: const QStyleOptionViewItem& option, const QModelIndex& index) override; - int m_titleFontSize; - int m_subtitleFontSize; - int m_titleFontWeight; - int m_subtitleFontWeight; - int m_textVerticalPad; - bool m_drawSubtitle; - bool m_visibilityMode; - bool m_highlightOnHover; + int m_titleFontSize{ 14 }; + int m_subtitleFontSize{ 10 }; + int m_titleFontWeight{ 2 }; + int m_subtitleFontWeight{ 1 }; + int m_textVerticalPad{ 2 }; + bool m_drawSubtitle{ true }; + bool m_visibilityMode{ false }; + bool m_highlightOnHover{ false }; }; } // namespace extension diff --git a/smtk/extension/qt/qtGroupItem.cxx b/smtk/extension/qt/qtGroupItem.cxx index c6ba7ba352599aec51087e1233a217d5f90f1028..c0854c2f17ef1663aeffcae407cf4391aed46090 100644 --- a/smtk/extension/qt/qtGroupItem.cxx +++ b/smtk/extension/qt/qtGroupItem.cxx @@ -201,7 +201,11 @@ void qtGroupItem::createWidget() { m_internals->m_titleCheckbox->setVisible(true); m_internals->m_titleCheckbox->setChecked(item->localEnabledState()); - m_internals->m_contentsFrame->setVisible(item->localEnabledState()); + auto* iview = m_itemInfo.baseView(); + bool enforceCategories = (iview) ? (!iview->ignoreCategories()) : true; + m_internals->m_contentsFrame->setVisible( + item->localEnabledState() && + item->hasRelevantChildren(enforceCategories, true, this->uiManager()->advanceLevel())); } else { @@ -211,19 +215,22 @@ void qtGroupItem::createWidget() void qtGroupItem::setEnabledState(int state) { - bool enabled = (state == Qt::Checked); - m_internals->m_contentsFrame->setVisible(enabled); - auto item = m_itemInfo.item(); + auto item = m_itemInfo.itemAs(); if (item == nullptr) { return; } + auto* iview = m_itemInfo.baseView(); + bool enabled = (state == Qt::Checked); + bool enforceCategories = (iview) ? (!iview->ignoreCategories()) : true; + m_internals->m_contentsFrame->setVisible( + enabled && + item->hasRelevantChildren(enforceCategories, true, this->uiManager()->advanceLevel())); if (enabled != item->localEnabledState()) { item->setIsEnabled(enabled); emit this->modified(); - auto* iview = m_itemInfo.baseView(); if (iview) { iview->valueChanged(item); diff --git a/smtk/extension/qt/qtGroupView.cxx b/smtk/extension/qt/qtGroupView.cxx index b2d25898e314f6da21f9017a1ef7d871470e5ba1..3be1e46834ce1ab07d56136f536cf8fd55c97cc1 100644 --- a/smtk/extension/qt/qtGroupView.cxx +++ b/smtk/extension/qt/qtGroupView.cxx @@ -60,6 +60,7 @@ public: QTabWidget::TabPosition m_tabPosition{ QTabWidget::East }; std::string m_savedViewName; QIcon m_alertIcon; + const std::string m_activeTabViewAttNamee = "ActiveTab"; }; void qtGroupViewInternals::updateChildren(qtGroupView* gview, qtBaseViewMemFn mfunc) @@ -95,7 +96,8 @@ void qtGroupViewInternals::updateChildren(qtGroupView* gview, qtBaseViewMemFn mf } tabWidget->blockSignals(true); tabWidget->clear(); - std::string lastSavedViewName = gview->uiManager()->activeTabInfo(gview->getObject()->name()); + std::string lastSavedViewName; + gview->getObject()->details().attribute(m_activeTabViewAttNamee, lastSavedViewName); m_TabbedViews.clear(); m_currentTabSelected = -1; int i, size = m_ChildViews.size(); @@ -204,13 +206,14 @@ void qtGroupView::updateCurrentTab(int ithTab) if (ithTab == -1) { //Clear the active tab info since nothing is selected - this->uiManager()->setActiveTabInfo(this->getObject()->name(), ""); + this->getObject()->details().setAttribute(m_internals->m_activeTabViewAttNamee, ""); return; } qtBaseView* currView = this->getChildView(ithTab); if (currView) { - this->uiManager()->setActiveTabInfo(this->getObject()->name(), currView->getObject()->name()); + this->getObject()->details().setAttribute( + m_internals->m_activeTabViewAttNamee, currView->getObject()->name()); currView->updateUI(); } } @@ -254,7 +257,8 @@ void qtGroupView::createWidget() QTabWidget* tab = new QTabWidget(this->parentWidget()); // If we have previously created a widget for this view // lets get the name of the last selected tab View name - m_internals->m_savedViewName = this->uiManager()->activeTabInfo(this->getObject()->name()); + this->getObject()->details().attribute( + m_internals->m_activeTabViewAttNamee, m_internals->m_savedViewName); tab->setUsesScrollButtons(true); this->Widget = tab; } @@ -321,9 +325,9 @@ void qtGroupView::createWidget() qtBaseView* currView = this->getChildView(m_internals->m_currentTabSelected); if (currView) { - this->uiManager()->setActiveTabInfo( - this->getObject()->name(), currView->getObject()->name()); m_internals->m_savedViewName = currView->getObject()->name(); + this->getObject()->details().setAttribute( + m_internals->m_activeTabViewAttNamee, m_internals->m_savedViewName); } } QObject::connect(tabWidget, &QTabWidget::currentChanged, this, &qtGroupView::updateCurrentTab); diff --git a/smtk/extension/qt/qtInstancedView.cxx b/smtk/extension/qt/qtInstancedView.cxx index 596e6fa8706016e2826416b0e13d53a69002840e..908e8b1ec8bfe9902f33ed4d02cc101db0ca2bba 100644 --- a/smtk/extension/qt/qtInstancedView.cxx +++ b/smtk/extension/qt/qtInstancedView.cxx @@ -12,6 +12,7 @@ #include "smtk/attribute/Attribute.h" #include "smtk/attribute/ComponentItem.h" +#include "smtk/attribute/StringItem.h" #include "smtk/attribute/operators/Signal.h" #include "smtk/extension/qt/qtAttribute.h" #include "smtk/extension/qt/qtUIManager.h" @@ -292,9 +293,12 @@ int qtInstancedView::handleOperationEvent( } // Since the Signal Operation originates from a Qt Signal - // being fired we can ignore this - if (op.typeName() == smtk::common::typeName()) + // being fired we need to see if this view is one that triggered it + if ( + (op.typeName() == smtk::common::typeName()) && + (op.parameters()->findString("source")->value() == m_addressString)) { + // We can ignore this operation since we initiated it return 0; } diff --git a/smtk/extension/qt/qtLineEdit.cxx b/smtk/extension/qt/qtLineEdit.cxx index 54e50fe9411bd3ab02396b1236568beb4c4f6f33..21a5805fb32b83d8f67235689565f44a0f842747 100644 --- a/smtk/extension/qt/qtLineEdit.cxx +++ b/smtk/extension/qt/qtLineEdit.cxx @@ -45,8 +45,6 @@ using namespace smtk::extension; //----------------------------------------------------------------------------- qtLineEdit::qtLineEdit(QWidget* _parent) : Superclass(_parent) - , EditingFinishedPending(false) - , ResetCursorPositionOnEditingFinished(true) { qtLineEdit::connect(this, SIGNAL(editingFinished()), this, SLOT(onEditingFinished())); qtLineEdit::connect(this, SIGNAL(textEdited(const QString&)), this, SLOT(onTextEdited())); @@ -55,8 +53,6 @@ qtLineEdit::qtLineEdit(QWidget* _parent) //----------------------------------------------------------------------------- qtLineEdit::qtLineEdit(const QString& _contents, QWidget* _parent) : Superclass(_contents, _parent) - , EditingFinishedPending(false) - , ResetCursorPositionOnEditingFinished(true) { qtLineEdit::connect(this, SIGNAL(editingFinished()), this, SLOT(onEditingFinished())); qtLineEdit::connect(this, SIGNAL(textEdited(const QString&)), this, SLOT(onTextEdited())); diff --git a/smtk/extension/qt/qtLineEdit.h b/smtk/extension/qt/qtLineEdit.h index 86e3f11cda1526224cab97148e011e8537b87498..25ea1138e9467e8a81660754e7fac1e9f02691ac 100644 --- a/smtk/extension/qt/qtLineEdit.h +++ b/smtk/extension/qt/qtLineEdit.h @@ -135,8 +135,8 @@ protected: private: Q_DISABLE_COPY(qtLineEdit) - bool EditingFinishedPending; - bool ResetCursorPositionOnEditingFinished; + bool EditingFinishedPending{ false }; + bool ResetCursorPositionOnEditingFinished{ true }; }; } // namespace extension } // namespace smtk diff --git a/smtk/extension/qt/qtOperationDialog.cxx b/smtk/extension/qt/qtOperationDialog.cxx index c703b413a90a8fd5bf822c542e26a29dd3b3c4cd..ad498cac16965bcc346a4033e862a6c6a24b972e 100644 --- a/smtk/extension/qt/qtOperationDialog.cxx +++ b/smtk/extension/qt/qtOperationDialog.cxx @@ -17,16 +17,67 @@ #include "smtk/model/Registrar.h" #include "smtk/view/Manager.h" +#include #include +#include #include +#include +#include #include +#include +#include +#include +#include #include #include #include #include +#include +#include using namespace smtk::extension; +namespace +{ +// Internal class for constraining QScrollArea to vertical direction +class qtVerticalScrollArea : public QScrollArea +{ +public: + qtVerticalScrollArea(QWidget* parent = nullptr) + : QScrollArea(parent) + { + } + +protected: + // Override eventFilter on resize events to set width + bool eventFilter(QObject* obj, QEvent* event) override + { + if (obj && obj == this->widget() && event->type() == QEvent::Resize) + { + // Get width of contents + int contentsWidth = + this->widget()->minimumSizeHint().width() + this->verticalScrollBar()->width(); + + // Get width of screen +#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) + const QRect screenRect = QApplication::desktop()->screenGeometry(this->widget()); + int screenWidth = screenRect.width(); +#else + int screenWidth = this->widget()->screen()->size().width(); +#endif + // If contents width is less than 1/2 screen width, expand + // so that horizontal scrolling is not needed. + if (contentsWidth < screenWidth / 2) + { + this->setMinimumWidth(contentsWidth); + } + } + return QScrollArea::eventFilter(obj, event); + } +}; + +} // namespace + class qtOperationDialogInternals { public: @@ -63,10 +114,25 @@ qtOperationDialog::qtOperationDialog( this->buildUI(op, uiManager); } +qtOperationDialog::qtOperationDialog( + smtk::operation::OperationPtr op, + smtk::resource::ManagerPtr resManager, + smtk::view::ManagerPtr viewManager, + bool scrollable, + QWidget* parentWidget) + : QDialog(parentWidget) +{ + auto uiManager = QSharedPointer( + new smtk::extension::qtUIManager(op, resManager, viewManager)); + this->buildUI(op, uiManager, scrollable); +} + void qtOperationDialog::buildUI( smtk::operation::OperationPtr op, - QSharedPointer uiManager) + QSharedPointer uiManager, + bool scrollable) { + this->setObjectName("ExportDialog"); m_internals = new qtOperationDialogInternals(); m_internals->m_uiManager = uiManager; m_internals->m_operation = op; @@ -76,16 +142,31 @@ void qtOperationDialog::buildUI( m_internals->m_tabWidget->setStyleSheet("QTabBar::tab { min-width: 100px; }"); // 1. Create the editor tab - QWidget* editorWidget = new QWidget(this); - QVBoxLayout* editorLayout = new QVBoxLayout(editorWidget); - - // Create the SMTK view auto viewConfig = m_internals->m_uiManager->findOrCreateOperationView(); - auto* qtView = m_internals->m_uiManager->setSMTKView(viewConfig, editorWidget); - m_internals->m_smtkView = dynamic_cast(qtView); - - editorWidget->setLayout(editorLayout); - m_internals->m_tabWidget->addTab(editorWidget, "Parameters"); + if (scrollable) + { + qtVerticalScrollArea* scroll = new qtVerticalScrollArea(); + QWidget* viewport = new QWidget(); + scroll->setWidget(viewport); + scroll->setWidgetResizable(true); + + QVBoxLayout* viewportLayout = new QVBoxLayout(viewport); + viewport->setLayout(viewportLayout); + + // Create the SMTK view + auto* qtView = m_internals->m_uiManager->setSMTKView(viewConfig, viewport); + m_internals->m_smtkView = dynamic_cast(qtView); + m_internals->m_tabWidget->addTab(scroll, "Parameters"); + } + else + { + QWidget* editorWidget = new QWidget(this); + QVBoxLayout* editorLayout = new QVBoxLayout(editorWidget); + auto* qtView = m_internals->m_uiManager->setSMTKView(viewConfig, editorWidget); + editorWidget->setLayout(editorLayout); + m_internals->m_smtkView = dynamic_cast(qtView); + m_internals->m_tabWidget->addTab(editorWidget, "Parameters"); + } // 2. Create the info tab QTextEdit* infoWidget = new QTextEdit(this); @@ -125,6 +206,13 @@ void qtOperationDialog::buildUI( // 4. And the window title std::string title = viewConfig->label(); this->setWindowTitle(title.c_str()); + + if (scrollable) + { + // Set min height for reasonable display + // Application can always override this + this->setMinimumHeight(480); + } } qtOperationDialog::~qtOperationDialog() diff --git a/smtk/extension/qt/qtOperationDialog.h b/smtk/extension/qt/qtOperationDialog.h index e1129001308dd4af78c1a5ed8e1c8d112af0e7a8..acbdea3ac5c10d26c01872f7ba75548e442131be 100644 --- a/smtk/extension/qt/qtOperationDialog.h +++ b/smtk/extension/qt/qtOperationDialog.h @@ -55,6 +55,19 @@ public: smtk::resource::ManagerPtr resourceManager, smtk::view::ManagerPtr viewManager, QWidget* parentWidget = nullptr); + + // Use this constructor to display the operation view in a + // vertically-scrolling area. You would generally only need + // this option if the operation parameters are lengthy and + // take up a significant amount of vertical display space. + // When setting the scrollable option, you would generally + // also want to call this class' setMinimumHeight() method. + qtOperationDialog( + smtk::operation::OperationPtr operation, + smtk::resource::ManagerPtr resourceManager, + smtk::view::ManagerPtr viewManager, + bool scrollable, + QWidget* parentWidget = nullptr); ~qtOperationDialog() override; signals: @@ -68,7 +81,8 @@ protected slots: protected: void buildUI( smtk::operation::OperationPtr op, - QSharedPointer uiMManager); + QSharedPointer uiMManager, + bool scrollable = false); // Override showEvent() in order to fix Qt sizing issue void showEvent(QShowEvent* event) override; diff --git a/smtk/extension/qt/qtReferenceItem.cxx b/smtk/extension/qt/qtReferenceItem.cxx index f212a43854c0c01dbf10e666219bcb2187f35e5a..eff4c8474aaa6613a7fd63bcc69e0e573a0d2c0c 100644 --- a/smtk/extension/qt/qtReferenceItem.cxx +++ b/smtk/extension/qt/qtReferenceItem.cxx @@ -100,11 +100,7 @@ qtItem* qtReferenceItem::createItemWidget(const qtAttributeItemInfo& info) } qtReferenceItemData::qtReferenceItemData() - : m_optional(nullptr) - , m_alreadyClosingPopup(false) - , m_qtModel(nullptr) - , m_qtDelegate(nullptr) - , m_selectedIconURL(":/icons/display/selected.png") + : m_selectedIconURL(":/icons/display/selected.png") , m_unselectedIconURL(":/icons/display/unselected.png") { } diff --git a/smtk/extension/qt/qtReferenceItemData.h b/smtk/extension/qt/qtReferenceItemData.h index 163c293044fdedaa618f2202d9086750cc8517c5..c3cf2c2814f57eabc904d665f4d5c6fe11eb6542 100644 --- a/smtk/extension/qt/qtReferenceItemData.h +++ b/smtk/extension/qt/qtReferenceItemData.h @@ -59,7 +59,7 @@ public: // Main widget contents QGridLayout* m_grid; - QCheckBox* m_optional; // Added if the item is optional to reflect IsEnabled(). + QCheckBox* m_optional{ nullptr }; // Added if the item is optional to reflect IsEnabled(). QLabel* m_label; // The item's label (or name if no label). QLabel* m_synopsis; // A live summary of the item's entries and acceptability QPushButton* m_copyFromSelection; // A button to copy the selection into the item's entries @@ -72,7 +72,9 @@ public: QDialog* m_popup; QVBoxLayout* m_popupLayout; QListView* m_popupList; - bool m_alreadyClosingPopup; // Set when synchronizeAndHide() should **not** hide the QMenu. + bool m_alreadyClosingPopup{ + false + }; // Set when synchronizeAndHide() should **not** hide the QMenu. // Selection state of items shown in m_phraseModel, from the MembershipBadge // std::map, int, @@ -80,8 +82,8 @@ public: // m_members; // Link between Qt and SMTK - smtk::extension::qtDescriptivePhraseModel* m_qtModel; - smtk::extension::qtDescriptivePhraseDelegate* m_qtDelegate; + smtk::extension::qtDescriptivePhraseModel* m_qtModel{ nullptr }; + smtk::extension::qtDescriptivePhraseDelegate* m_qtDelegate{ nullptr }; smtk::view::PhraseModelObservers::Key m_modelObserverId; diff --git a/smtk/extension/qt/qtResourceBrowserP.cxx b/smtk/extension/qt/qtResourceBrowserP.cxx index 5ad80535e1182b90246ee2aca7bdbffcf8ce2e9f..07fbea4852084eefd5b25b978d31ebee1d18b0fc 100644 --- a/smtk/extension/qt/qtResourceBrowserP.cxx +++ b/smtk/extension/qt/qtResourceBrowserP.cxx @@ -28,13 +28,8 @@ using namespace smtk::extension; /// @relates smtk::extension::qtResourceBrowser::Internal qtResourceBrowser::Internal::Internal() - : m_container(nullptr) - , m_layout(nullptr) - , m_view(nullptr) - , m_selnLabel("selected") + : m_selnLabel("selected") , m_hoverLabel("hovered") - , m_resourceTreeStyle(-1) - , m_updatingPanelSelectionFromSMTK(false) { std::ostringstream name; name << "resource panel " << this; diff --git a/smtk/extension/qt/qtResourceBrowserP.h b/smtk/extension/qt/qtResourceBrowserP.h index 3e3d52be9732db05a7a7a47ee05fb8503967dc84..4246c144559c8063eb9e8639189da95842602d5c 100644 --- a/smtk/extension/qt/qtResourceBrowserP.h +++ b/smtk/extension/qt/qtResourceBrowserP.h @@ -46,9 +46,9 @@ public: smtk::extension::qtDescriptivePhraseModel* descriptivePhraseModel() const; void setDescriptivePhraseModel(QAbstractItemModel* qmodel); - QWidget* m_container; - QVBoxLayout* m_layout; - QTreeView* m_view; + QWidget* m_container{ nullptr }; + QVBoxLayout* m_layout{ nullptr }; + QTreeView* m_view{ nullptr }; QPointer m_self; QPointer m_model; QPointer m_delegate; @@ -63,12 +63,12 @@ public: std::string m_hoverLabel; std::string m_viewName; std::string m_resourceTreeType; // "default" or specific type. - int m_resourceTreeStyle; // Which default subphrase generator should be used? + int m_resourceTreeStyle{ -1 }; // Which default subphrase generator should be used? // Set to true when inside sendSMTKSelectionToPanel. // Used to avoid updating the SMTK selection from the panel while // the panel is being updated from SMTK: - bool m_updatingPanelSelectionFromSMTK; + bool m_updatingPanelSelectionFromSMTK{ false }; }; } // namespace extension } // namespace smtk diff --git a/smtk/extension/qt/qtUIManager.cxx b/smtk/extension/qt/qtUIManager.cxx index 5e774c0dde41a94ad82f4c6f78153706f1df6b95..f2ae607ac4476ddb888a2841890bed0fcfcaeddc 100644 --- a/smtk/extension/qt/qtUIManager.cxx +++ b/smtk/extension/qt/qtUIManager.cxx @@ -232,6 +232,11 @@ void qtUIManager::initializeUI(QWidget* pWidget, bool useInternalFileBrowser) } if (m_topView) { + if (m_topView->getObject()->details().attribute(m_activeAdvLevelXmlAttName)) + { + m_topView->getObject()->details().attributeAsInt( + m_activeAdvLevelXmlAttName, m_currentAdvLevel); + } if (m_currentAdvLevel) // only build advanced level when needed) { m_topView->showAdvanceLevel(m_currentAdvLevel); @@ -442,6 +447,7 @@ void qtUIManager::setAdvanceLevel(int b) if (m_topView) { m_topView->showAdvanceLevel(b); + m_topView->getObject()->details().setAttribute(m_activeAdvLevelXmlAttName, std::to_string(b)); } } @@ -1132,23 +1138,6 @@ qtItem* qtUIManager::defaultItemConstructor(const qtAttributeItemInfo& info) return aItem; } -void qtUIManager::setActiveTabInfo( - const std::string& groupViewName, - const std::string& activeTabName) -{ - m_activeTabInfo[groupViewName] = activeTabName; -} - -std::string qtUIManager::activeTabInfo(const std::string& groupViewName) const -{ - auto it = m_activeTabInfo.find(groupViewName); - if (it == m_activeTabInfo.end()) - { - return ""; - } - return it->second; -} - void qtUIManager::setHighlightOnHover(bool val) { if (val == m_highlightOnHover) diff --git a/smtk/extension/qt/qtUIManager.h b/smtk/extension/qt/qtUIManager.h index 114a117b96326d8a2be40a017cd3f01fa8b27290..137d7098b0c55d516c167547779a1f3ad2f84951 100644 --- a/smtk/extension/qt/qtUIManager.h +++ b/smtk/extension/qt/qtUIManager.h @@ -259,10 +259,6 @@ public: int hoverBit() const { return m_hoverBit; } void setHoverBit(int val) { m_hoverBit = val; } - ///methods for saving/retrieving the active tab in a group view - void setActiveTabInfo(const std::string& groupViewName, const std::string& activeTabName); - std::string activeTabInfo(const std::string& groupViewName) const; - bool highlightOnHover() const { return m_highlightOnHover; } void setHighlightOnHover(bool val); @@ -361,6 +357,8 @@ private: std::map m_activeTabInfo; QPixmap m_alertPixmap; + const std::string m_activeAdvLevelXmlAttName = "ActiveAdvanceLevel"; + }; // class //A sublcass of QTextEdit to give initial sizehint diff --git a/smtk/extension/qt/testing/cxx/CMakeLists.txt b/smtk/extension/qt/testing/cxx/CMakeLists.txt index 5157d2567f63382583d6afd0f62047a2be813263..43394864245cd9525366b4c70846b8b67053f11e 100644 --- a/smtk/extension/qt/testing/cxx/CMakeLists.txt +++ b/smtk/extension/qt/testing/cxx/CMakeLists.txt @@ -67,7 +67,8 @@ endif () set(CMAKE_AUTOMOC 1) -smtk_unit_tests(LABEL "qt" +smtk_unit_tests( + LABEL "Qt" SOURCES ${unit_tests} SOURCES_REQUIRE_DATA ${unit_tests_which_require_data} EXTRA_SOURCES ${unit_tests_headers} diff --git a/smtk/extension/qt/testing/cxx/UnitTestForceRequiredItem.cxx b/smtk/extension/qt/testing/cxx/UnitTestForceRequiredItem.cxx index 2c20eda35ab54d444e6efc40b51de4bdf6a47803..ec9b230b2e310a694f92966b3737e6d3fe3911f3 100644 --- a/smtk/extension/qt/testing/cxx/UnitTestForceRequiredItem.cxx +++ b/smtk/extension/qt/testing/cxx/UnitTestForceRequiredItem.cxx @@ -16,6 +16,7 @@ #include "smtk/extension/qt/qtViewRegistrar.h" #include "smtk/io/AttributeReader.h" #include "smtk/io/Logger.h" +#include "smtk/plugin/Registry.h" #include "smtk/view/Manager.h" #include "smtk/view/Registrar.h" @@ -69,8 +70,8 @@ int UnitTestForceRequiredItem(int argc, char** const argv) // Initialize view and UI managers auto viewManager = smtk::view::Manager::create(); - smtk::view::Registrar::registerTo(viewManager); - smtk::extension::qtViewRegistrar::registerTo(viewManager); + auto viewRegistry = smtk::plugin::addToManagers(viewManager); + auto qtViewRegistry = smtk::plugin::addToManagers(viewManager); smtk::extension::qtUIManager* uiManager = new smtk::extension::qtUIManager(attResource); uiManager->setViewManager(viewManager); diff --git a/smtk/extension/qt/testing/cxx/unitQtComponentItem.cxx b/smtk/extension/qt/testing/cxx/unitQtComponentItem.cxx index b90b887ccb4202d02af968d21ac2c2b4f9987545..b4e2c4ca9b681c5c881657a927decb4eeff486ce 100644 --- a/smtk/extension/qt/testing/cxx/unitQtComponentItem.cxx +++ b/smtk/extension/qt/testing/cxx/unitQtComponentItem.cxx @@ -177,10 +177,9 @@ int unitQtComponentItem(int argc, char* argv[]) // those resources registered with rsrcMgr: operMgr->registerResourceManager(rsrcMgr); - auto registry = smtk::plugin:: - Registry( - rsrcMgr, operMgr); - smtk::view::Registrar::registerTo(viewMgr); + auto polygonRegistry = + smtk::plugin::addToManagers(rsrcMgr, operMgr); + auto viewRegistry = smtk::plugin::addToManagers(viewMgr); // Constructing the PhraseModel with a View properly initializes the SubphraseGenerator // to point back to the model (thus ensuring subphrases are decorated). This is required diff --git a/smtk/extension/vtk/io/pybind11/PybindExportVTKData.h b/smtk/extension/vtk/io/pybind11/PybindExportVTKData.h index ae39634b2171b4d1adf4780879f988a7b2f71d27..d45aa509b901d45a3b321e7064d230b742f65322 100644 --- a/smtk/extension/vtk/io/pybind11/PybindExportVTKData.h +++ b/smtk/extension/vtk/io/pybind11/PybindExportVTKData.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::extension::vtk::io::mesh::ExportVTKData > pybind11_init_smtk_extension_vtk_io_mesh_ExportVTKData(py::module &m) +inline py::class_< smtk::extension::vtk::io::mesh::ExportVTKData > pybind11_init_smtk_extension_vtk_io_mesh_ExportVTKData(py::module &m) { py::class_< smtk::extension::vtk::io::mesh::ExportVTKData > instance(m, "ExportVTKData"); instance diff --git a/smtk/extension/vtk/io/pybind11/PybindImportAsVTKData.h b/smtk/extension/vtk/io/pybind11/PybindImportAsVTKData.h index 53d505c23d483aabe493bd3ea724099d718396bf..5995e1224a48209974523fa46f44f3a3a45fd2ab 100644 --- a/smtk/extension/vtk/io/pybind11/PybindImportAsVTKData.h +++ b/smtk/extension/vtk/io/pybind11/PybindImportAsVTKData.h @@ -21,7 +21,7 @@ namespace py = pybind11; -py::class_ pybind11_init_smtk_extension_vtk_io_ImportAsVTKData(py::module &m) +inline py::class_ pybind11_init_smtk_extension_vtk_io_ImportAsVTKData(py::module &m) { py::class_< smtk::extension::vtk::io::ImportAsVTKData> instance(m, "ImportAsVTKData"); instance diff --git a/smtk/extension/vtk/io/pybind11/PybindImportVTKData.h b/smtk/extension/vtk/io/pybind11/PybindImportVTKData.h index 3a77f4053ed242220144a92270b427aa2c136ecd..c1762340310a267df27c7d99beb504b89586af02 100644 --- a/smtk/extension/vtk/io/pybind11/PybindImportVTKData.h +++ b/smtk/extension/vtk/io/pybind11/PybindImportVTKData.h @@ -19,7 +19,7 @@ namespace py = pybind11; -py::class_< smtk::extension::vtk::io::mesh::ImportVTKData > pybind11_init_smtk_extension_vtk_io_mesh_ImportVTKData(py::module &m) +inline py::class_< smtk::extension::vtk::io::mesh::ImportVTKData > pybind11_init_smtk_extension_vtk_io_mesh_ImportVTKData(py::module &m) { py::class_< smtk::extension::vtk::io::mesh::ImportVTKData > instance(m, "ImportVTKData"); instance diff --git a/smtk/extension/vtk/io/pybind11/PybindMeshIOVTK.h b/smtk/extension/vtk/io/pybind11/PybindMeshIOVTK.h index 453aa4e132a97d012c5735e41e7be2935598e71b..acc788d56a8189efa206466f0db34556edf823d1 100644 --- a/smtk/extension/vtk/io/pybind11/PybindMeshIOVTK.h +++ b/smtk/extension/vtk/io/pybind11/PybindMeshIOVTK.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::extension::vtk::io::mesh::MeshIOVTK, smtk::io::mesh::MeshIO > pybind11_init_smtk_extension_vtk_io_mesh_MeshIOVTK(py::module &m) +inline PySharedPtrClass< smtk::extension::vtk::io::mesh::MeshIOVTK, smtk::io::mesh::MeshIO > pybind11_init_smtk_extension_vtk_io_mesh_MeshIOVTK(py::module &m) { PySharedPtrClass< smtk::extension::vtk::io::mesh::MeshIOVTK, smtk::io::mesh::MeshIO > instance(m, "MeshIOVTK"); instance diff --git a/smtk/extension/vtk/io/testing/cxx/CMakeLists.txt b/smtk/extension/vtk/io/testing/cxx/CMakeLists.txt index 0a5b0b004f46432256e6529e614deca158fc7211..bd8890b3528050513829ddbf91a93dde63cf52f9 100644 --- a/smtk/extension/vtk/io/testing/cxx/CMakeLists.txt +++ b/smtk/extension/vtk/io/testing/cxx/CMakeLists.txt @@ -23,7 +23,7 @@ set(unit_tests_which_require_data set(unit_test_libs) -smtk_unit_tests(LABEL "vtk/io" +smtk_unit_tests(LABELS "VTK" SOURCES ${unit_tests} SOURCES_REQUIRE_DATA ${unit_tests_which_require_data} LIBRARIES smtkIOVTK smtkCoreModelTesting diff --git a/smtk/extension/vtk/operators/testing/cxx/DeleteSmtkCell.cxx b/smtk/extension/vtk/operators/testing/cxx/DeleteSmtkCell.cxx index 5bc2295d94e6e5c6c16bc2a1555bc4314ae66b93..82cf1cc832962ee225379549180cd0777a107d64 100644 --- a/smtk/extension/vtk/operators/testing/cxx/DeleteSmtkCell.cxx +++ b/smtk/extension/vtk/operators/testing/cxx/DeleteSmtkCell.cxx @@ -34,6 +34,8 @@ #include "smtk/operation/Registrar.h" #include "smtk/operation/operators/ReadResource.h" +#include "smtk/plugin/Registry.h" + #include "smtk/session/polygon/Registrar.h" #include "smtk/session/polygon/Resource.h" #include "smtk/session/polygon/operators/Delete.h" @@ -69,18 +71,14 @@ int main(int argc, char* argv[]) // Create a resource manager smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); - { - smtk::session::polygon::Registrar::registerTo(resourceManager); - } - // Create an operation manager smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); - { - smtk::operation::Registrar::registerTo(operationManager); - smtk::model::Registrar::registerTo(operationManager); - smtk::session::polygon::Registrar::registerTo(operationManager); - } + auto operationRegistry = + smtk::plugin::addToManagers(operationManager); + auto modelRegistry = smtk::plugin::addToManagers(operationManager); + auto polygonRegistry = smtk::plugin::addToManagers( + resourceManager, operationManager); // Register the resource manager to the operation manager (newly created // resources will be automatically registered to the resource manager). diff --git a/smtk/extension/vtk/operators/testing/cxx/DeleteSmtkCell2.cxx b/smtk/extension/vtk/operators/testing/cxx/DeleteSmtkCell2.cxx index 99f7f79e55f7d334499dcd98f23670ab9d4336ae..d13c762bf2888737277953487e862c510a0e3903 100644 --- a/smtk/extension/vtk/operators/testing/cxx/DeleteSmtkCell2.cxx +++ b/smtk/extension/vtk/operators/testing/cxx/DeleteSmtkCell2.cxx @@ -32,6 +32,8 @@ #include "smtk/operation/Registrar.h" #include "smtk/operation/operators/ReadResource.h" +#include "smtk/plugin/Registry.h" + #include "smtk/session/polygon/Registrar.h" #include "smtk/session/polygon/Resource.h" #include "smtk/session/polygon/operators/Delete.h" @@ -68,18 +70,14 @@ int main(int argc, char* argv[]) // Create a resource manager smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); - { - smtk::session::polygon::Registrar::registerTo(resourceManager); - } - // Create an operation manager smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); - { - smtk::operation::Registrar::registerTo(operationManager); - smtk::model::Registrar::registerTo(operationManager); - smtk::session::polygon::Registrar::registerTo(operationManager); - } + auto operationRegistry = + smtk::plugin::addToManagers(operationManager); + auto modelRegistry = smtk::plugin::addToManagers(operationManager); + auto polygonRegistry = smtk::plugin::addToManagers( + resourceManager, operationManager); // Register the resource manager to the operation manager (newly created // resources will be automatically registered to the resource manager). diff --git a/smtk/extension/vtk/source/testing/cxx/displayAuxiliaryGeometry.cxx b/smtk/extension/vtk/source/testing/cxx/displayAuxiliaryGeometry.cxx index dc01b3cce52e43f6ddcae99c0320c42d8e344104..40dae6fd9778a9ea9f72f3e77d8e0dd0e5af11a7 100644 --- a/smtk/extension/vtk/source/testing/cxx/displayAuxiliaryGeometry.cxx +++ b/smtk/extension/vtk/source/testing/cxx/displayAuxiliaryGeometry.cxx @@ -34,6 +34,8 @@ #include "smtk/operation/Manager.h" +#include "smtk/plugin/Registry.h" + #include "smtk/extension/vtk/source/vtkModelMultiBlockSource.h" #include "vtkActor.h" @@ -125,19 +127,13 @@ int main(int argc, char* argv[]) // Create a resource manager smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); - // Register mesh resources to the resource manager - { - smtk::session::mesh::Registrar::registerTo(resourceManager); - } - // Create an operation manager smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); - // Register model and mesh operators to the operation manager - { - smtk::model::Registrar::registerTo(operationManager); - smtk::session::mesh::Registrar::registerTo(operationManager); - } + // Register model and mesh operators to the managers + auto modelRegistry = smtk::plugin::addToManagers(operationManager); + auto meshRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); // Register the resource manager to the operation manager (newly created // resources will be automatically registered to the resource manager). diff --git a/smtk/extension/vtk/source/testing/python/CMakeLists.txt b/smtk/extension/vtk/source/testing/python/CMakeLists.txt index 269ee9904c9ff6d5c1977e5d9dba2b108f6adf0d..0445f51470df5e310fc4215888303e4ba525815d 100644 --- a/smtk/extension/vtk/source/testing/python/CMakeLists.txt +++ b/smtk/extension/vtk/source/testing/python/CMakeLists.txt @@ -18,6 +18,6 @@ if (SMTK_DATA_DIR) foreach(test ${smtkExtensionVTKSourcePythonDataTests}) smtk_add_test_python(${test}Py ${test}.py --data-dir=${SMTK_DATA_DIR} ) - set_tests_properties( ${test}Py PROPERTIES LABELS "Source" ) + set_tests_properties( ${test}Py PROPERTIES LABELS "VTK" ) endforeach() endif() diff --git a/smtk/extension/vtk/source/vtkConeFrustum.cxx b/smtk/extension/vtk/source/vtkConeFrustum.cxx index b20be089799081155c7d3bebc307b9e78d4a3de9..51fe05fd5e59eb18d4e0f000bc137467396d81b5 100644 --- a/smtk/extension/vtk/source/vtkConeFrustum.cxx +++ b/smtk/extension/vtk/source/vtkConeFrustum.cxx @@ -31,11 +31,8 @@ vtkStandardNewMacro(vtkConeFrustum); vtkConeFrustum::vtkConeFrustum(int res) : BottomPoint{ 0, 0, 0 } - , BottomRadius(0.5) , TopPoint{ 0, 0, 1 } - , TopRadius(0.0) , Resolution(res <= 3 ? 3 : res) - , OutputPointsPrecision(SINGLE_PRECISION) { this->SetNumberOfInputPorts(0); this->SetNumberOfOutputPorts(NumberOfOutputs); diff --git a/smtk/extension/vtk/source/vtkConeFrustum.h b/smtk/extension/vtk/source/vtkConeFrustum.h index 5a825c511323e833f637d10deab90428e18983a2..587a20e0d156ed01a6e74a8a333464a19eac72b0 100644 --- a/smtk/extension/vtk/source/vtkConeFrustum.h +++ b/smtk/extension/vtk/source/vtkConeFrustum.h @@ -139,11 +139,11 @@ protected: int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; double BottomPoint[3]; - double BottomRadius; + double BottomRadius{ 0.5 }; double TopPoint[3]; - double TopRadius; + double TopRadius{ 0.0 }; int Resolution; - int OutputPointsPrecision; + int OutputPointsPrecision{ SINGLE_PRECISION }; }; #endif diff --git a/smtk/extension/vtk/source/vtkImplicitConeFrustum.cxx b/smtk/extension/vtk/source/vtkImplicitConeFrustum.cxx index c72a50a4b1172c8fe776683121a9ffe6e12eeea2..b6c5b26b15dcc13099cb4b928924e1d97fcc0772 100644 --- a/smtk/extension/vtk/source/vtkImplicitConeFrustum.cxx +++ b/smtk/extension/vtk/source/vtkImplicitConeFrustum.cxx @@ -22,9 +22,7 @@ vtkStandardNewMacro(vtkImplicitConeFrustum); vtkImplicitConeFrustum::vtkImplicitConeFrustum() : BottomPoint{ 0, 0, 0 } - , BottomRadius(0.5) , TopPoint{ 0, 0, 1 } - , TopRadius(0.0) { // Our output is defined by our subclass, which we configure based on // calls that set our member variables. diff --git a/smtk/extension/vtk/source/vtkImplicitConeFrustum.h b/smtk/extension/vtk/source/vtkImplicitConeFrustum.h index a6f44edf629813d3aed1bfcbf6ff0d79eb676036..fa83d1b8fc7f339fdbfecb5fe6893eeaeed54255 100644 --- a/smtk/extension/vtk/source/vtkImplicitConeFrustum.h +++ b/smtk/extension/vtk/source/vtkImplicitConeFrustum.h @@ -117,11 +117,11 @@ protected: vtkNew ConeTransform; vtkVector3d BottomPoint; - double BottomRadius; + double BottomRadius{ 0.5 }; vtkNew BottomPlane; vtkVector3d TopPoint; - double TopRadius; + double TopRadius{ 0.0 }; vtkNew TopPlane; }; diff --git a/smtk/extension/vtk/source/vtkResourceMultiBlockSource.cxx b/smtk/extension/vtk/source/vtkResourceMultiBlockSource.cxx index 9b57d2a9a56e9ba35917b64819db0dc8e5e6028f..0872a09373fc141a98467fabeb216ab217c973d8 100644 --- a/smtk/extension/vtk/source/vtkResourceMultiBlockSource.cxx +++ b/smtk/extension/vtk/source/vtkResourceMultiBlockSource.cxx @@ -31,7 +31,6 @@ vtkInformationKeyMacro(vtkResourceMultiBlockSource, COMPONENT_ID, String); //---------------------------------------------------------------------------- vtkResourceMultiBlockSource::vtkResourceMultiBlockSource() - : LastModified(0) { this->SetNumberOfInputPorts(0); } diff --git a/smtk/extension/vtk/source/vtkResourceMultiBlockSource.h b/smtk/extension/vtk/source/vtkResourceMultiBlockSource.h index 38c11f0d80579033dc7773f9d6e584db6b16befe..d03b669910feb1c9928e21104a46ecf613411af5 100644 --- a/smtk/extension/vtk/source/vtkResourceMultiBlockSource.h +++ b/smtk/extension/vtk/source/vtkResourceMultiBlockSource.h @@ -172,7 +172,7 @@ protected: std::weak_ptr Resource; std::map Cache; std::set Visited; // Populated with extant entities during RequestData. - smtk::geometry::Geometry::GenerationNumber LastModified; + smtk::geometry::Geometry::GenerationNumber LastModified{ 0 }; }; #endif diff --git a/smtk/extension/vtk/widgets/vtkConeRepresentation.cxx b/smtk/extension/vtk/widgets/vtkConeRepresentation.cxx index 8c1de2b93170b58a35401f8c8e50980a6aeb9d5b..7cc17f04a54b77c4f7a6ce3903ac61c758a8b98e 100644 --- a/smtk/extension/vtk/widgets/vtkConeRepresentation.cxx +++ b/smtk/extension/vtk/widgets/vtkConeRepresentation.cxx @@ -53,16 +53,6 @@ vtkStandardNewMacro(vtkConeRepresentation); vtkConeRepresentation::vtkConeRepresentation() - : BumpDistance(0.01) - , AlongXAxis(0) - , AlongYAxis(0) - , AlongZAxis(0) - , Resolution(128) - , Tolerance(1e-8) - , ScaleEnabled(1) - , DrawCone(1) - , Tubing(1) - , Cylindrical(0) { this->HandleSize = 7.5; this->Cone->SetResolution(128); diff --git a/smtk/extension/vtk/widgets/vtkConeRepresentation.h b/smtk/extension/vtk/widgets/vtkConeRepresentation.h index 9267cc9d3380c67dccc289102d55f055b80905f4..af460b30e36287622a0bc40d227ff38683a913d8 100644 --- a/smtk/extension/vtk/widgets/vtkConeRepresentation.h +++ b/smtk/extension/vtk/widgets/vtkConeRepresentation.h @@ -391,21 +391,21 @@ protected: // Keep track of event positions double LastEventPosition[3]; // Controlling the push operation - double BumpDistance; + double BumpDistance{ 0.01 }; // Controlling ivars - vtkTypeBool AlongXAxis; - vtkTypeBool AlongYAxis; - vtkTypeBool AlongZAxis; + vtkTypeBool AlongXAxis{ 0 }; + vtkTypeBool AlongYAxis{ 0 }; + vtkTypeBool AlongZAxis{ 0 }; // The actual cylinder which is being manipulated vtkNew Cone; // The facet resolution for rendering purposes. - int Resolution; - double Tolerance; // How close are endpoints allowed to be? - vtkTypeBool ScaleEnabled; //whether the widget can be scaled - vtkTypeBool DrawCone; + int Resolution{ 128 }; + double Tolerance{ 1e-8 }; // How close are endpoints allowed to be? + vtkTypeBool ScaleEnabled{ 1 }; //whether the widget can be scaled + vtkTypeBool DrawCone{ 1 }; vtkNew AxisTuber; // Used to style edges. - vtkTypeBool Tubing; //control whether tubing is on - int Cylindrical; // control whether the cone is a cylinder (apex at infinity) + vtkTypeBool Tubing{ 1 }; //control whether tubing is on + int Cylindrical{ 0 }; // control whether the cone is a cylinder (apex at infinity) // Source of endpoint handle geometry vtkNew Sphere; diff --git a/smtk/extension/vtk/widgets/vtkSBFunctionParser.cxx b/smtk/extension/vtk/widgets/vtkSBFunctionParser.cxx index cb2fb4725b6f6e579244b8baa48baa1e2ebb80ba..35d218acd897dab2cb1a3c229649dce7db08151f 100644 --- a/smtk/extension/vtk/widgets/vtkSBFunctionParser.cxx +++ b/smtk/extension/vtk/widgets/vtkSBFunctionParser.cxx @@ -44,12 +44,6 @@ void vtkSBFunctionParser::vtkInternal::DefineConstants() vtkSBFunctionParser::vtkSBFunctionParser() : IndependentVariableName("X") - , IsVectorResult(false) - , InitialValue(0.0) - , Delta(0.0) - , NumberOfValues(-1) - , Help(nullptr) - , Result(nullptr) { this->Implementation = new vtkInternal(); diff --git a/smtk/extension/vtk/widgets/vtkSBFunctionParser.h b/smtk/extension/vtk/widgets/vtkSBFunctionParser.h index 52202b8d846fbcb4da2fe36ca206f07c30cbf90c..b561cc1e137674cb6a1bbcaa2cec45a990af1278 100644 --- a/smtk/extension/vtk/widgets/vtkSBFunctionParser.h +++ b/smtk/extension/vtk/widgets/vtkSBFunctionParser.h @@ -94,13 +94,13 @@ private: std::string Function; - bool IsVectorResult; - double InitialValue; - double Delta; - int NumberOfValues; + bool IsVectorResult{ false }; + double InitialValue{ 0.0 }; + double Delta{ 0.0 }; + int NumberOfValues{ -1 }; - char* Help; - vtkDoubleArray* Result; + char* Help{ nullptr }; + vtkDoubleArray* Result{ nullptr }; class vtkInternal; vtkInternal* Implementation; diff --git a/smtk/geometry/pybind11/PybindBackend.h b/smtk/geometry/pybind11/PybindBackend.h index dacb4c5b66f150ac00f17630bdeca8f1ee7c5958..7817683e426e2a754f7c755e9aac4224bfacffc7 100644 --- a/smtk/geometry/pybind11/PybindBackend.h +++ b/smtk/geometry/pybind11/PybindBackend.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::geometry::Backend > pybind11_init_smtk_geometry_Backend(py::module &m) +inline py::class_< smtk::geometry::Backend > pybind11_init_smtk_geometry_Backend(py::module &m) { py::class_< smtk::geometry::Backend > instance(m, "Backend"); instance diff --git a/smtk/geometry/pybind11/PybindGeometry.h b/smtk/geometry/pybind11/PybindGeometry.h index 38f4ad69a5d214f51e4d03d0a7e90a5ba980ef05..da6e9c50c561723b003b32a24619c12b3c40e3e7 100644 --- a/smtk/geometry/pybind11/PybindGeometry.h +++ b/smtk/geometry/pybind11/PybindGeometry.h @@ -22,7 +22,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::geometry::Geometry > pybind11_init_smtk_geometry_Geometry(py::module &m) +inline PySharedPtrClass< smtk::geometry::Geometry > pybind11_init_smtk_geometry_Geometry(py::module &m) { PySharedPtrClass< smtk::geometry::Geometry > instance(m, "Geometry"); instance diff --git a/smtk/geometry/pybind11/PybindManager.h b/smtk/geometry/pybind11/PybindManager.h index 6736be8050bbd9a3c8974d7b31b00754a21ce653..ebb8932ac1722b6324e5940a179f1d6c5f57a7a8 100644 --- a/smtk/geometry/pybind11/PybindManager.h +++ b/smtk/geometry/pybind11/PybindManager.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::geometry::Manager > pybind11_init_smtk_geometry_Manager(py::module &m) +inline PySharedPtrClass< smtk::geometry::Manager > pybind11_init_smtk_geometry_Manager(py::module &m) { PySharedPtrClass< smtk::geometry::Manager > instance(m, "Manager"); instance diff --git a/smtk/geometry/pybind11/PybindResource.h b/smtk/geometry/pybind11/PybindResource.h index 07259d3ef9388203b69764d318804ba4fc466181..96b664ebc8fde1e28ae7a0918bfafa1027956f30 100644 --- a/smtk/geometry/pybind11/PybindResource.h +++ b/smtk/geometry/pybind11/PybindResource.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::geometry::Resource, smtk::resource::DerivedFrom > pybind11_init_smtk_geometry_Resource(py::module &m) +inline PySharedPtrClass< smtk::geometry::Resource, smtk::resource::DerivedFrom > pybind11_init_smtk_geometry_Resource(py::module &m) { PySharedPtrClass< smtk::geometry::Resource, smtk::resource::DerivedFrom > instance(m, "Resource"); instance diff --git a/smtk/geometry/testing/cxx/CMakeLists.txt b/smtk/geometry/testing/cxx/CMakeLists.txt index 624ef432436e7deb3e5efc68c8a3146070af1f2e..8af763a539e7f207b468aa235fb81681b3a4476e 100644 --- a/smtk/geometry/testing/cxx/CMakeLists.txt +++ b/smtk/geometry/testing/cxx/CMakeLists.txt @@ -7,7 +7,7 @@ set(unit_tests ) smtk_unit_tests( - Label "Geometry" + LABEL "Geometry" SOURCES ${unit_tests} LIBRARIES smtkCore ) diff --git a/smtk/geometry/testing/cxx/TestSelectionFootprint.cxx b/smtk/geometry/testing/cxx/TestSelectionFootprint.cxx index 120756470cb9701f69cddf70128db0a7efbfcf38..baeb72c29a270b43d4029a68ec36459067d3bfeb 100644 --- a/smtk/geometry/testing/cxx/TestSelectionFootprint.cxx +++ b/smtk/geometry/testing/cxx/TestSelectionFootprint.cxx @@ -34,6 +34,8 @@ #include "smtk/resource/DerivedFrom.h" #include "smtk/resource/Manager.h" +#include "smtk/plugin/Registry.h" + #include "smtk/common/testing/cxx/helpers.h" #include @@ -185,11 +187,11 @@ int TestSelectionFootprint(int /*unused*/, char** const /*unused*/) geometryManager->registerBackend(); RegisterBackend::registerClass(); - smtk::model::Registrar::registerTo(resourceManager); - smtk::model::Registrar::registerTo(operationManager); + auto modelRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); - smtk::attribute::Registrar::registerTo(resourceManager); - smtk::attribute::Registrar::registerTo(operationManager); + auto attributeRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); // Create a new model resource type auto modelRsrc = resourceManager->create(); diff --git a/smtk/graph/Resource.h b/smtk/graph/Resource.h index 12e26f5fb274f270e4a4267621603d21eb79901a..52d1b44217af2575c793c6cb7cfdb2a31aad71c6 100644 --- a/smtk/graph/Resource.h +++ b/smtk/graph/Resource.h @@ -134,6 +134,8 @@ public: return smtk::resource::filter::Filter(filterString); } + Resource(const Resource&) = delete; + protected: Resource(smtk::resource::ManagerPtr manager = nullptr) : Superclass(manager) diff --git a/smtk/graph/testing/cxx/CMakeLists.txt b/smtk/graph/testing/cxx/CMakeLists.txt index 371c09cd4386db1768c40e5d1c45b8b2a2a56592..18197ac5b95843e6294225bcc7d30fd5d995128f 100644 --- a/smtk/graph/testing/cxx/CMakeLists.txt +++ b/smtk/graph/testing/cxx/CMakeLists.txt @@ -9,7 +9,7 @@ set(unit_tests ) smtk_unit_tests( - Label "GraphResource" + LABEL "Graph" SOURCES ${unit_tests} LIBRARIES smtkCore ) diff --git a/smtk/io/AttributeReader.cxx b/smtk/io/AttributeReader.cxx index c1aa928ee759a5b0e6f1d52b5c3ff21e73bea160..f1788db8fd496d38d8e5c1263765d2acb4766636 100644 --- a/smtk/io/AttributeReader.cxx +++ b/smtk/io/AttributeReader.cxx @@ -381,7 +381,6 @@ void AttributeReaderInternals::readAttributes( } AttributeReader::AttributeReader() - : m_reportAsError(true) { m_internals = new AttributeReaderInternals(); } diff --git a/smtk/io/AttributeReader.h b/smtk/io/AttributeReader.h index 9b3efd2faa453deb5d6042e2d97e1994a566d1b9..55ac4df3829453b44e546479661741004f45e2c1 100644 --- a/smtk/io/AttributeReader.h +++ b/smtk/io/AttributeReader.h @@ -72,7 +72,7 @@ public: protected: private: - bool m_reportAsError; + bool m_reportAsError{ true }; std::vector m_searchPaths; AttributeReaderInternals* m_internals; }; diff --git a/smtk/io/AttributeWriter.cxx b/smtk/io/AttributeWriter.cxx index 841e4ab9b74c1d0188d8998142a8fc4ac6f6d912..79ca3b3f5c2d0a91adfc9811c9aad14baa97eea8 100644 --- a/smtk/io/AttributeWriter.cxx +++ b/smtk/io/AttributeWriter.cxx @@ -29,17 +29,6 @@ namespace io AttributeWriter::AttributeWriter() : m_fileVersion(DEFAULT_FILE_VERSION) - , m_includeAdvanceLevels(true) - , m_includeAnalyses(true) - , m_includeAttributeAssociations(true) - , m_includeDefinitions(true) - , m_includeEvaluators(true) - , m_includeInstances(true) - , m_includeResourceAssociations(true) - , m_includeResourceID(true) - , m_includeUniqueRoles(true) - , m_includeViews(true) - , m_useDirectoryInfo(false) { } diff --git a/smtk/io/AttributeWriter.h b/smtk/io/AttributeWriter.h index c3e5be044b8c01c76dc6072d7f93d491b29c5357..de8ae47659827a5880156ef10b0ce8e599e3c4b9 100644 --- a/smtk/io/AttributeWriter.h +++ b/smtk/io/AttributeWriter.h @@ -114,18 +114,19 @@ protected: smtk::io::Logger& logger) const; private: + // NOLINTNEXTLINE(modernize-use-default-member-init) unsigned int m_fileVersion; - bool m_includeAdvanceLevels; - bool m_includeAnalyses; - bool m_includeAttributeAssociations; - bool m_includeDefinitions; - bool m_includeEvaluators; - bool m_includeInstances; - bool m_includeResourceAssociations; - bool m_includeResourceID; - bool m_includeUniqueRoles; - bool m_includeViews; - bool m_useDirectoryInfo; + bool m_includeAdvanceLevels{ true }; + bool m_includeAnalyses{ true }; + bool m_includeAttributeAssociations{ true }; + bool m_includeDefinitions{ true }; + bool m_includeEvaluators{ true }; + bool m_includeInstances{ true }; + bool m_includeResourceAssociations{ true }; + bool m_includeResourceID{ true }; + bool m_includeUniqueRoles{ true }; + bool m_includeViews{ true }; + bool m_useDirectoryInfo{ false }; std::vector m_includedDefs; }; } // namespace io diff --git a/smtk/io/Logger.h b/smtk/io/Logger.h index 03c91512d0b0e1ef55b76fcbfddadaaaf16916ce..c01ecd0c032384ac901f2f25309dd86663e951dc 100644 --- a/smtk/io/Logger.h +++ b/smtk/io/Logger.h @@ -107,10 +107,10 @@ public: struct Record { - Severity severity; + Severity severity{ INFO }; std::string message; std::string fileName; - unsigned int lineNumber; + unsigned int lineNumber{ 0 }; Record(Severity s, const std::string& m, const std::string& f = "", unsigned int l = 0) : severity(s) , message(m) @@ -118,24 +118,14 @@ public: , lineNumber(l) { } - Record() - : severity(INFO) - , lineNumber(0) - { - } + Record() = default; }; - Logger() - : m_hasErrors(false) - , m_stream(nullptr) - , m_ownStream(false) - { - } + Logger() = default; Logger(const Logger& logger) : m_hasErrors(logger.m_hasErrors) , m_records(logger.m_records) - , m_ownStream(false) { } @@ -184,10 +174,10 @@ protected: void flushRecordsToStream(std::size_t beginRec, std::size_t endRec); std::string toStringInternal(std::size_t i, std::size_t j, bool includeSourceLoc = false) const; - bool m_hasErrors; + bool m_hasErrors{ false }; std::vector m_records; - std::ostream* m_stream; - bool m_ownStream; + std::ostream* m_stream{ nullptr }; + bool m_ownStream{ false }; std::function m_callback; private: diff --git a/smtk/io/ModelToMesh.cxx b/smtk/io/ModelToMesh.cxx index 94f5a0c0f973af814348c301c25753d931a58ee4..b685ad4741a3ef7469bacc3f3b7f2247534d4558 100644 --- a/smtk/io/ModelToMesh.cxx +++ b/smtk/io/ModelToMesh.cxx @@ -403,11 +403,7 @@ void find_entities_with_tessellation( } } //namespace detail -ModelToMesh::ModelToMesh() - : m_mergeDuplicates(true) - , m_tolerance(-1) -{ -} +ModelToMesh::ModelToMesh() = default; smtk::mesh::ResourcePtr ModelToMesh::operator()(const smtk::model::ResourcePtr& modelResource) const { diff --git a/smtk/io/ModelToMesh.h b/smtk/io/ModelToMesh.h index d88a067165ebd324211943a96cb0f530c4063774..5c76fefb72ab9687f6803f80bc971e548252a72d 100644 --- a/smtk/io/ModelToMesh.h +++ b/smtk/io/ModelToMesh.h @@ -43,8 +43,8 @@ public: smtk::mesh::ResourcePtr operator()(const smtk::model::Model& model) const; private: - bool m_mergeDuplicates; - double m_tolerance; + bool m_mergeDuplicates{ true }; + double m_tolerance{ -1 }; }; } // namespace io } // namespace smtk diff --git a/smtk/io/XmlDocV3Parser.cxx b/smtk/io/XmlDocV3Parser.cxx index 0d6a68e811d436afc1b39ac8dfcdbe836f502b6e..cb02c51141caaf2f39ae3ade5bd5bc2de7da2a74 100644 --- a/smtk/io/XmlDocV3Parser.cxx +++ b/smtk/io/XmlDocV3Parser.cxx @@ -1164,15 +1164,15 @@ void XmlDocV3Parser::processConfigurations(pugi::xml_node& configurationsNode) break; } } - else if (!setAnalysisConfigurationHelper(configAtt, analysisNode, m_logger)) - { - smtkErrorMacro( - m_logger, - "Encountered problem constructing configuration: " << configAtt->name() - << " - configuration not built"); - m_resource->removeAttribute(configAtt); - break; - } + } + else if (!setAnalysisConfigurationHelper(configAtt, analysisNode, m_logger)) + { + smtkErrorMacro( + m_logger, + "Encountered problem constructing configuration: " << configAtt->name() + << " - configuration not built"); + m_resource->removeAttribute(configAtt); + break; } } } diff --git a/smtk/io/XmlDocV4Parser.cxx b/smtk/io/XmlDocV4Parser.cxx index 720e60e578d3a41cf804591b3a7083cc08097508..2dd61b9f394ae092e29018d372092d11f94361d1 100644 --- a/smtk/io/XmlDocV4Parser.cxx +++ b/smtk/io/XmlDocV4Parser.cxx @@ -201,6 +201,11 @@ void XmlDocV4Parser::processItem(pugi::xml_node& node, smtk::attribute::ItemPtr { item->setForceRequired(xatt.as_bool()); } + xatt = node.attribute("IsIgnored"); + if (xatt) + { + item->setIsIgnored(xatt.as_bool()); + } } void XmlDocV4Parser::processViews(xml_node& root) diff --git a/smtk/io/XmlV2StringWriter.cxx b/smtk/io/XmlV2StringWriter.cxx index d6d9a1dd88286788ec8c5818be09b7840b5135c1..91b57192d2b2372b9bc8bd2a5f3cc3ba444e5906 100644 --- a/smtk/io/XmlV2StringWriter.cxx +++ b/smtk/io/XmlV2StringWriter.cxx @@ -1154,6 +1154,10 @@ void XmlV2StringWriter::processItemAttributes(xml_node& node, ItemPtr item) { node.append_attribute("AdvanceWriteLevel") = item->localAdvanceLevel(1); } + if (item->isIgnored()) + { + node.append_attribute("IsIgnored").set_value(item->isIgnored()); + } } void XmlV2StringWriter::processItemType(xml_node& node, ItemPtr item) diff --git a/smtk/io/pybind11/PybindAttributeReader.h b/smtk/io/pybind11/PybindAttributeReader.h index 8ad653abe3113102b19a1c47f42dd7b6c843b975..6e0cbd955999c5d12d7afef583f67908491e08bf 100644 --- a/smtk/io/pybind11/PybindAttributeReader.h +++ b/smtk/io/pybind11/PybindAttributeReader.h @@ -21,7 +21,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::io::AttributeReader > pybind11_init_smtk_io_AttributeReader(py::module &m) +inline PySharedPtrClass< smtk::io::AttributeReader > pybind11_init_smtk_io_AttributeReader(py::module &m) { PySharedPtrClass< smtk::io::AttributeReader > instance(m, "AttributeReader"); instance diff --git a/smtk/io/pybind11/PybindAttributeWriter.h b/smtk/io/pybind11/PybindAttributeWriter.h index 03c0a07aa803e55254ca75c57a4ff7f4cb4a2529..565b3e7d1f44f3f3b61070d55437c4ae95448706 100644 --- a/smtk/io/pybind11/PybindAttributeWriter.h +++ b/smtk/io/pybind11/PybindAttributeWriter.h @@ -20,7 +20,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::io::AttributeWriter > pybind11_init_smtk_io_AttributeWriter(py::module &m) +inline PySharedPtrClass< smtk::io::AttributeWriter > pybind11_init_smtk_io_AttributeWriter(py::module &m) { PySharedPtrClass< smtk::io::AttributeWriter > instance(m, "AttributeWriter"); instance diff --git a/smtk/io/pybind11/PybindExportMesh.h b/smtk/io/pybind11/PybindExportMesh.h index cc7285e0d363c9110d44b118a1394b220d8740c4..99734d0a1f4293f8abfcd6d548a3b5cb6f5e3f29 100644 --- a/smtk/io/pybind11/PybindExportMesh.h +++ b/smtk/io/pybind11/PybindExportMesh.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::io::ExportMesh > pybind11_init_smtk_io_ExportMesh(py::module &m) +inline PySharedPtrClass< smtk::io::ExportMesh > pybind11_init_smtk_io_ExportMesh(py::module &m) { PySharedPtrClass< smtk::io::ExportMesh > instance(m, "ExportMesh"); instance @@ -29,12 +29,12 @@ PySharedPtrClass< smtk::io::ExportMesh > pybind11_init_smtk_io_ExportMesh(py::mo return instance; } -void pybind11_init__ZN4smtk2io10exportMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io10exportMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) { m.def("exportMesh", (bool (*)(::std::string const &, ::smtk::mesh::ResourcePtr)) &smtk::io::exportMesh, "", py::arg("filePath"), py::arg("resource")); } -void pybind11_init__ZN4smtk2io10exportMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEENSA_INS_5model7ResourceEEES9_(py::module &m) +inline void pybind11_init__ZN4smtk2io10exportMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEENSA_INS_5model7ResourceEEES9_(py::module &m) { m.def("exportMesh", (bool (*)(::std::string const &, ::smtk::mesh::ResourcePtr, ::smtk::model::ResourcePtr, ::std::string const &)) &smtk::io::exportMesh, "", py::arg("filePath"), py::arg("resource"), py::arg("resource"), py::arg("modelPropertyName")); } diff --git a/smtk/io/pybind11/PybindFormat.h b/smtk/io/pybind11/PybindFormat.h index 382906209efb40f71fce2220b1e226b5f9b19b0e..2110e865e2871bdc26b0c4bb3d750c4ecd0c7ecb 100644 --- a/smtk/io/pybind11/PybindFormat.h +++ b/smtk/io/pybind11/PybindFormat.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::io::mesh::Format > pybind11_init_smtk_io_mesh_Format(py::module &m) +inline PySharedPtrClass< smtk::io::mesh::Format > pybind11_init_smtk_io_mesh_Format(py::module &m) { PySharedPtrClass< smtk::io::mesh::Format > instance(m, "Format"); instance diff --git a/smtk/io/pybind11/PybindImportMesh.h b/smtk/io/pybind11/PybindImportMesh.h index f09f29d34661009b6bfd90988bc330396483720b..39ab9f2ffd1016f408c73e28d612466f2c024c2b 100644 --- a/smtk/io/pybind11/PybindImportMesh.h +++ b/smtk/io/pybind11/PybindImportMesh.h @@ -18,7 +18,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::io::ImportMesh > pybind11_init_smtk_io_ImportMesh(py::module &m) +inline PySharedPtrClass< smtk::io::ImportMesh > pybind11_init_smtk_io_ImportMesh(py::module &m) { PySharedPtrClass< smtk::io::ImportMesh > instance(m, "ImportMesh"); instance @@ -30,22 +30,22 @@ PySharedPtrClass< smtk::io::ImportMesh > pybind11_init_smtk_io_ImportMesh(py::mo return instance; } -void pybind11_init__ZN4smtk2io10importMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh7InterfaceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io10importMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh7InterfaceEEE(py::module &m) { m.def("importMesh", (smtk::mesh::ResourcePtr (*)(::std::string const &, const ::smtk::mesh::InterfacePtr&)) &smtk::io::importMesh, "", py::arg("filePath"), py::arg("interface")); } -void pybind11_init__ZN4smtk2io10importMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh7InterfaceEEES9_(py::module &m) +inline void pybind11_init__ZN4smtk2io10importMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh7InterfaceEEES9_(py::module &m) { m.def("importMesh", (smtk::mesh::ResourcePtr (*)(::std::string const &, const ::smtk::mesh::InterfacePtr&, ::std::string const &)) &smtk::io::importMesh, "", py::arg("filePath"), py::arg("interface"), py::arg("domainPropertyName")); } -void pybind11_init__ZN4smtk2io10importMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io10importMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) { m.def("importMesh", (bool (*)(::std::string const &, ::smtk::mesh::ResourcePtr)) &smtk::io::importMesh, "", py::arg("filePath"), py::arg("resource")); } -void pybind11_init__ZN4smtk2io10importMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEES9_(py::module &m) +inline void pybind11_init__ZN4smtk2io10importMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEES9_(py::module &m) { m.def("importMesh", (bool (*)(::std::string const &, ::smtk::mesh::ResourcePtr, ::std::string const &)) &smtk::io::importMesh, "", py::arg("filePath"), py::arg("resource"), py::arg("domainPropertyName")); } diff --git a/smtk/io/pybind11/PybindLogger.h b/smtk/io/pybind11/PybindLogger.h index 6b5ec6d72eefabf74140e69502964274672855cd..3a334634e07f073f39854cc4420add48c14331a1 100644 --- a/smtk/io/pybind11/PybindLogger.h +++ b/smtk/io/pybind11/PybindLogger.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::io::Logger > pybind11_init_smtk_io_Logger(py::module &m) +inline PySharedPtrClass< smtk::io::Logger > pybind11_init_smtk_io_Logger(py::module &m) { PySharedPtrClass< smtk::io::Logger > instance(m, "Logger"); instance diff --git a/smtk/io/pybind11/PybindMeshIO.h b/smtk/io/pybind11/PybindMeshIO.h index aae70a419091d4a63598cd9f5edb2b2a6823a958..03cbd0f8e516f7667fac7a2e085af1c0616a2727 100644 --- a/smtk/io/pybind11/PybindMeshIO.h +++ b/smtk/io/pybind11/PybindMeshIO.h @@ -17,7 +17,7 @@ namespace py = pybind11; -void pybind11_init_smtk_io_mesh_Subset(py::module &m) +inline void pybind11_init_smtk_io_mesh_Subset(py::module &m) { py::enum_(m, "Subset") .value("EntireResource", smtk::io::mesh::Subset::EntireResource) @@ -27,7 +27,7 @@ void pybind11_init_smtk_io_mesh_Subset(py::module &m) .export_values(); } -PySharedPtrClass< smtk::io::mesh::MeshIO > pybind11_init_smtk_io_mesh_MeshIO(py::module &m) +inline PySharedPtrClass< smtk::io::mesh::MeshIO > pybind11_init_smtk_io_mesh_MeshIO(py::module &m) { PySharedPtrClass< smtk::io::mesh::MeshIO > instance(m, "MeshIO"); instance diff --git a/smtk/io/pybind11/PybindMeshIOMoab.h b/smtk/io/pybind11/PybindMeshIOMoab.h index 22d54b34f9adaedd2c88bdb3931c49f48a59fbe8..5a6397b755c63af45b4c51af7b27a506d62a8734 100644 --- a/smtk/io/pybind11/PybindMeshIOMoab.h +++ b/smtk/io/pybind11/PybindMeshIOMoab.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::io::mesh::MeshIOMoab > pybind11_init_smtk_io_mesh_MeshIOMoab(py::module &m, PySharedPtrClass< smtk::io::mesh::MeshIO >& parent) +inline PySharedPtrClass< smtk::io::mesh::MeshIOMoab > pybind11_init_smtk_io_mesh_MeshIOMoab(py::module &m, PySharedPtrClass< smtk::io::mesh::MeshIO >& parent) { PySharedPtrClass< smtk::io::mesh::MeshIOMoab > instance(m, "MeshIOMoab", parent); instance diff --git a/smtk/io/pybind11/PybindMeshIOXMS.h b/smtk/io/pybind11/PybindMeshIOXMS.h index c1e350940aa2d138ed23b1e876586f7d3adec4dd..8a6f89994798ff18c9982951606045f9c95a3efe 100644 --- a/smtk/io/pybind11/PybindMeshIOXMS.h +++ b/smtk/io/pybind11/PybindMeshIOXMS.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::io::mesh::MeshIOXMS > pybind11_init_smtk_io_mesh_MeshIOXMS(py::module &m, PySharedPtrClass< smtk::io::mesh::MeshIO >& parent) +inline PySharedPtrClass< smtk::io::mesh::MeshIOXMS > pybind11_init_smtk_io_mesh_MeshIOXMS(py::module &m, PySharedPtrClass< smtk::io::mesh::MeshIO >& parent) { PySharedPtrClass< smtk::io::mesh::MeshIOXMS > instance(m, "MeshIOXMS", parent); instance diff --git a/smtk/io/pybind11/PybindModelToMesh.h b/smtk/io/pybind11/PybindModelToMesh.h index 07e19fc69a1560077cb1c3f16c6c85e97d123edc..07426dd1e7970223339e060cf732a4f5382260aa 100644 --- a/smtk/io/pybind11/PybindModelToMesh.h +++ b/smtk/io/pybind11/PybindModelToMesh.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::io::ModelToMesh > pybind11_init_smtk_io_ModelToMesh(py::module &m) +inline PySharedPtrClass< smtk::io::ModelToMesh > pybind11_init_smtk_io_ModelToMesh(py::module &m) { PySharedPtrClass< smtk::io::ModelToMesh > instance(m, "ModelToMesh"); instance diff --git a/smtk/io/pybind11/PybindReadMesh.h b/smtk/io/pybind11/PybindReadMesh.h index 394d5f9b823fe23c6bc002a879064871cce28283..1b7d3c5fee5a725dedac99afc09ce23e3b9d8740 100644 --- a/smtk/io/pybind11/PybindReadMesh.h +++ b/smtk/io/pybind11/PybindReadMesh.h @@ -18,7 +18,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::io::ReadMesh > pybind11_init_smtk_io_ReadMesh(py::module &m) +inline PySharedPtrClass< smtk::io::ReadMesh > pybind11_init_smtk_io_ReadMesh(py::module &m) { PySharedPtrClass< smtk::io::ReadMesh > instance(m, "ReadMesh"); instance @@ -30,52 +30,52 @@ PySharedPtrClass< smtk::io::ReadMesh > pybind11_init_smtk_io_ReadMesh(py::module return instance; } -void pybind11_init__ZN4smtk2io13readDirichletERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh7InterfaceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io13readDirichletERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh7InterfaceEEE(py::module &m) { m.def("readDirichlet", (smtk::mesh::ResourcePtr (*)(::std::string const &, const ::smtk::mesh::InterfacePtr&)) &smtk::io::readDirichlet, "", py::arg("filePath"), py::arg("interface")); } -void pybind11_init__ZN4smtk2io13readDirichletERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io13readDirichletERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) { m.def("readDirichlet", (bool (*)(::std::string const &, ::smtk::mesh::ResourcePtr)) &smtk::io::readDirichlet, "", py::arg("filePath"), py::arg("resource")); } -void pybind11_init__ZN4smtk2io10readDomainERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh7InterfaceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io10readDomainERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh7InterfaceEEE(py::module &m) { m.def("readDomain", (smtk::mesh::ResourcePtr (*)(::std::string const &, const ::smtk::mesh::InterfacePtr&)) &smtk::io::readDomain, "", py::arg("filePath"), py::arg("interface")); } -void pybind11_init__ZN4smtk2io10readDomainERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io10readDomainERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) { m.def("readDomain", (bool (*)(::std::string const &, ::smtk::mesh::ResourcePtr)) &smtk::io::readDomain, "", py::arg("filePath"), py::arg("resource")); } -void pybind11_init__ZN4smtk2io20readEntireResourceERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh7InterfaceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io20readEntireResourceERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh7InterfaceEEE(py::module &m) { m.def("readEntireResource", (smtk::mesh::ResourcePtr (*)(::std::string const &, const ::smtk::mesh::InterfacePtr&)) &smtk::io::readEntireResource, "", py::arg("filePath"), py::arg("interface")); } -void pybind11_init__ZN4smtk2io20readEntireResourceERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io20readEntireResourceERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) { m.def("readEntireResource", (bool (*)(::std::string const &, ::smtk::mesh::ResourcePtr)) &smtk::io::readEntireResource, "", py::arg("filePath"), py::arg("resource")); } -void pybind11_init__ZN4smtk2io8readMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh7InterfaceEEENS0_4mesh6SubsetE(py::module &m) +inline void pybind11_init__ZN4smtk2io8readMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh7InterfaceEEENS0_4mesh6SubsetE(py::module &m) { m.def("readMesh", (smtk::mesh::ResourcePtr (*)(::std::string const &, const ::smtk::mesh::InterfacePtr&, ::smtk::io::mesh::Subset)) &smtk::io::readMesh, "", py::arg("filePath"), py::arg("interface"), py::arg("subset") = ::smtk::io::mesh::Subset::EntireResource); } -void pybind11_init__ZN4smtk2io8readMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEENS0_4mesh6SubsetE(py::module &m) +inline void pybind11_init__ZN4smtk2io8readMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEENS0_4mesh6SubsetE(py::module &m) { m.def("readMesh", (bool (*)(::std::string const &, ::smtk::mesh::ResourcePtr, ::smtk::io::mesh::Subset)) &smtk::io::readMesh, "", py::arg("filePath"), py::arg("resource"), py::arg("subset") = ::smtk::io::mesh::Subset::EntireResource); } -void pybind11_init__ZN4smtk2io11readNeumannERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh7InterfaceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io11readNeumannERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh7InterfaceEEE(py::module &m) { m.def("readNeumann", (smtk::mesh::ResourcePtr (*)(::std::string const &, const ::smtk::mesh::InterfacePtr&)) &smtk::io::readNeumann, "", py::arg("filePath"), py::arg("interface")); } -void pybind11_init__ZN4smtk2io11readNeumannERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io11readNeumannERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) { m.def("readNeumann", (bool (*)(::std::string const &, ::smtk::mesh::ResourcePtr)) &smtk::io::readNeumann, "", py::arg("filePath"), py::arg("resource")); } diff --git a/smtk/io/pybind11/PybindWriteMesh.h b/smtk/io/pybind11/PybindWriteMesh.h index 51f4728ef3e93f5c9c09d756af45a06aa3f27b3b..7cc97da8a6650d43aaceb9a49dca0b9ec0754447 100644 --- a/smtk/io/pybind11/PybindWriteMesh.h +++ b/smtk/io/pybind11/PybindWriteMesh.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::io::WriteMesh > pybind11_init_smtk_io_WriteMesh(py::module &m) +inline PySharedPtrClass< smtk::io::WriteMesh > pybind11_init_smtk_io_WriteMesh(py::module &m) { PySharedPtrClass< smtk::io::WriteMesh > instance(m, "WriteMesh"); instance @@ -28,52 +28,52 @@ PySharedPtrClass< smtk::io::WriteMesh > pybind11_init_smtk_io_WriteMesh(py::modu return instance; } -void pybind11_init__ZN4smtk2io14writeDirichletERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io14writeDirichletERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) { m.def("writeDirichlet", (bool (*)(::std::string const &, ::smtk::mesh::ResourcePtr)) &smtk::io::writeDirichlet, "", py::arg("filePath"), py::arg("resource")); } -void pybind11_init__ZN4smtk2io14writeDirichletENSt3__110shared_ptrINS_4mesh10ResourceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io14writeDirichletENSt3__110shared_ptrINS_4mesh10ResourceEEE(py::module &m) { m.def("writeDirichlet", (bool (*)(::smtk::mesh::ResourcePtr)) &smtk::io::writeDirichlet, "", py::arg("resource")); } -void pybind11_init__ZN4smtk2io11writeDomainERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io11writeDomainERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) { m.def("writeDomain", (bool (*)(::std::string const &, ::smtk::mesh::ResourcePtr)) &smtk::io::writeDomain, "", py::arg("filePath"), py::arg("resource")); } -void pybind11_init__ZN4smtk2io11writeDomainENSt3__110shared_ptrINS_4mesh10ResourceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io11writeDomainENSt3__110shared_ptrINS_4mesh10ResourceEEE(py::module &m) { m.def("writeDomain", (bool (*)(::smtk::mesh::ResourcePtr)) &smtk::io::writeDomain, "", py::arg("resource")); } -void pybind11_init__ZN4smtk2io21writeEntireResourceERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io21writeEntireResourceERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) { m.def("writeEntireResource", (bool (*)(::std::string const &, ::smtk::mesh::ResourcePtr)) &smtk::io::writeEntireResource, "", py::arg("filePath"), py::arg("resource")); } -void pybind11_init__ZN4smtk2io21writeEntireResourceENSt3__110shared_ptrINS_4mesh10ResourceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io21writeEntireResourceENSt3__110shared_ptrINS_4mesh10ResourceEEE(py::module &m) { m.def("writeEntireResource", (bool (*)(::smtk::mesh::ResourcePtr)) &smtk::io::writeEntireResource, "", py::arg("resource")); } -void pybind11_init__ZN4smtk2io9writeMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEENS0_4mesh6SubsetE(py::module &m) +inline void pybind11_init__ZN4smtk2io9writeMeshERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEENS0_4mesh6SubsetE(py::module &m) { m.def("writeMesh", (bool (*)(::std::string const &, ::smtk::mesh::ResourcePtr, ::smtk::io::mesh::Subset)) &smtk::io::writeMesh, "", py::arg("filePath"), py::arg("resource"), py::arg("subset") = ::smtk::io::mesh::Subset::EntireResource); } -void pybind11_init__ZN4smtk2io9writeMeshENSt3__110shared_ptrINS_4mesh10ResourceEEENS0_4mesh6SubsetE(py::module &m) +inline void pybind11_init__ZN4smtk2io9writeMeshENSt3__110shared_ptrINS_4mesh10ResourceEEENS0_4mesh6SubsetE(py::module &m) { m.def("writeMesh", (bool (*)(::smtk::mesh::ResourcePtr, ::smtk::io::mesh::Subset)) &smtk::io::writeMesh, "", py::arg("resource"), py::arg("subset") = ::smtk::io::mesh::Subset::EntireResource); } -void pybind11_init__ZN4smtk2io12writeNeumannERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io12writeNeumannERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_10shared_ptrINS_4mesh10ResourceEEE(py::module &m) { m.def("writeNeumann", (bool (*)(::std::string const &, ::smtk::mesh::ResourcePtr)) &smtk::io::writeNeumann, "", py::arg("filePath"), py::arg("resource")); } -void pybind11_init__ZN4smtk2io12writeNeumannENSt3__110shared_ptrINS_4mesh10ResourceEEE(py::module &m) +inline void pybind11_init__ZN4smtk2io12writeNeumannENSt3__110shared_ptrINS_4mesh10ResourceEEE(py::module &m) { m.def("writeNeumann", (bool (*)(::smtk::mesh::ResourcePtr)) &smtk::io::writeNeumann, "", py::arg("resource")); } diff --git a/smtk/io/testing/cxx/groupItemCSVTest.cxx b/smtk/io/testing/cxx/groupItemCSVTest.cxx index fab1821df47e257cc16c21ffea9f2c371a01bc27..9873bf94a47aedd1ebece1b0896e346be8946b23 100644 --- a/smtk/io/testing/cxx/groupItemCSVTest.cxx +++ b/smtk/io/testing/cxx/groupItemCSVTest.cxx @@ -32,7 +32,7 @@ namespace { bool checkGroupItem(GroupItemPtr gitem, int numGroups) { - if (gitem->numberOfGroups() != numGroups) + if (gitem->numberOfGroups() != static_cast(numGroups)) { std::cerr << "Group has " << gitem->numberOfGroups() << " instead of " << numGroups << std::endl; diff --git a/smtk/io/testing/cxx/groupItemDoubleFileTest.cxx b/smtk/io/testing/cxx/groupItemDoubleFileTest.cxx index 68e82d637f0a4019a9dae77f60fe40e439080e44..38d01ba45da59a38ac2926518e7ef6f634b9096d 100644 --- a/smtk/io/testing/cxx/groupItemDoubleFileTest.cxx +++ b/smtk/io/testing/cxx/groupItemDoubleFileTest.cxx @@ -32,7 +32,7 @@ namespace { bool checkGroupItem(GroupItemPtr gitem, int numGroups) { - if (gitem->numberOfGroups() != numGroups) + if (gitem->numberOfGroups() != static_cast(numGroups)) { std::cerr << "Group has " << gitem->numberOfGroups() << " instead of " << numGroups << std::endl; diff --git a/smtk/mesh/core/ForEachTypes.cxx b/smtk/mesh/core/ForEachTypes.cxx index b52bd33dd26a5fb4f6edb826aedd7e191802c105..34a7af93862df574cebf954bf9b5715142381081 100644 --- a/smtk/mesh/core/ForEachTypes.cxx +++ b/smtk/mesh/core/ForEachTypes.cxx @@ -17,9 +17,7 @@ namespace mesh MeshForEach::~MeshForEach() = default; CellForEach::CellForEach(bool wantCoordinates) - : m_pointIds(nullptr) - , m_coords(nullptr) - , m_wantsCoordinates(wantCoordinates) + : m_wantsCoordinates(wantCoordinates) { } diff --git a/smtk/mesh/core/ForEachTypes.h b/smtk/mesh/core/ForEachTypes.h index 8892fd76f43bf842b1528d9dc7c9a0f7ff0d8b19..cd398ead1450ee69c7993b40b6dabdb70c24df8c 100644 --- a/smtk/mesh/core/ForEachTypes.h +++ b/smtk/mesh/core/ForEachTypes.h @@ -72,8 +72,8 @@ public: private: smtk::mesh::ResourcePtr m_resource; - const smtk::mesh::Handle* m_pointIds; - std::vector* m_coords; + const smtk::mesh::Handle* m_pointIds{ nullptr }; + std::vector* m_coords{ nullptr }; bool m_wantsCoordinates; }; diff --git a/smtk/mesh/core/Interface.h b/smtk/mesh/core/Interface.h index 6d29cfb16177f7bc26c31929d16e22e58cb8d175..71b08982c1c43630d63f938111f17853fc5a05c1 100644 --- a/smtk/mesh/core/Interface.h +++ b/smtk/mesh/core/Interface.h @@ -77,10 +77,7 @@ public: class SMTKCORE_EXPORT BufferedCellAllocator { public: - BufferedCellAllocator() - : m_validState(false) - { - } + BufferedCellAllocator() = default; virtual ~BufferedCellAllocator() = default; @@ -115,7 +112,7 @@ public: bool isValid() const { return m_validState; } protected: - bool m_validState; + bool m_validState{ false }; }; // IncrementalAllocator allows for the allocation of meshes by incrementally @@ -181,13 +178,9 @@ public: //current cell when we are iterating. struct IterationState { - IterationState() - : whichConnectivityVector(0) - , ptrOffsetInVector(0) - { - } - std::size_t whichConnectivityVector; - std::size_t ptrOffsetInVector; + IterationState() = default; + std::size_t whichConnectivityVector{ 0 }; + std::size_t ptrOffsetInVector{ 0 }; }; virtual void initTraversal(IterationState& state) = 0; @@ -211,22 +204,13 @@ public: //copy of vector on return, ugggh. struct Results { - Results() - : pointIds() - , sqDistances() - , x_s() - , y_s() - , z_s() - , want_sqDistances(false) - , want_Coordinates(false) - { - } + Results() = default; std::vector pointIds; std::vector sqDistances; std::vector x_s, y_s, z_s; - bool want_sqDistances; - bool want_Coordinates; + bool want_sqDistances{ false }; + bool want_Coordinates{ false }; }; virtual ~PointLocatorImpl() = default; diff --git a/smtk/mesh/core/MeshSet.cxx b/smtk/mesh/core/MeshSet.cxx index a322b4c2828ffe2645d900f962d2e903816b0108..647a1ef83198e7076596ae9672f7ff7ec8d863df 100644 --- a/smtk/mesh/core/MeshSet.cxx +++ b/smtk/mesh/core/MeshSet.cxx @@ -22,10 +22,7 @@ namespace smtk namespace mesh { -MeshSet::MeshSet() - : m_handle() -{ -} +MeshSet::MeshSet() = default; MeshSet::MeshSet(const smtk::mesh::ResourcePtr& parent, smtk::mesh::Handle handle) { diff --git a/smtk/mesh/core/MeshSet.h b/smtk/mesh/core/MeshSet.h index c4c37e8b3b0f22173fa4cf3451287b926f123080..909563cf36dfe49417c3ce60f652a74434eb06aa 100644 --- a/smtk/mesh/core/MeshSet.h +++ b/smtk/mesh/core/MeshSet.h @@ -222,7 +222,7 @@ private: friend std::shared_ptr Component::create(const MeshSet&); smtk::mesh::ResourcePtr m_parent; - smtk::mesh::Handle m_handle; + smtk::mesh::Handle m_handle{}; smtk::mesh::HandleRange m_range; //range of entity sets mutable smtk::common::UUID m_id; }; diff --git a/smtk/mesh/core/PointLocator.h b/smtk/mesh/core/PointLocator.h index 9e9273f09d2f59f629744cd1facddd11b4838084..a6180b737924e31f0e07a95e4747deb217e80806 100644 --- a/smtk/mesh/core/PointLocator.h +++ b/smtk/mesh/core/PointLocator.h @@ -43,7 +43,7 @@ public: //Based on the backend these points maybe be added to the resource for //duration of the PointLocator PointLocator( - const smtk::mesh::ResourcePtr resource, + smtk::mesh::ResourcePtr resource, std::size_t numPoints, const std::function(std::size_t)>& coordinates); PointLocator( diff --git a/smtk/mesh/core/Resource.cxx b/smtk/mesh/core/Resource.cxx index 9d91753126c0322475f0c53d994a8b4223ba6846..51103eb38b458641384bf2a6e05e9cff9ba9bce4 100644 --- a/smtk/mesh/core/Resource.cxx +++ b/smtk/mesh/core/Resource.cxx @@ -54,7 +54,6 @@ typedef std::tuple QueryList; Resource::Resource() : Superclass(smtk::common::UUIDGenerator::instance().random()) - , m_nameCounter(-1) , m_internals(new InternalImpl()) { queries().registerQueries(); @@ -63,7 +62,6 @@ Resource::Resource() Resource::Resource(const smtk::common::UUID& resourceID) : smtk::resource::DerivedFrom(resourceID) - , m_nameCounter(-1) , m_internals(new InternalImpl()) { queries().registerQueries(); @@ -73,7 +71,6 @@ Resource::Resource(const smtk::common::UUID& resourceID) Resource::Resource(smtk::mesh::InterfacePtr interface) : smtk::resource::DerivedFrom( smtk::common::UUIDGenerator::instance().random()) - , m_nameCounter(-1) , m_internals(new InternalImpl(interface)) { queries().registerQueries(); @@ -82,7 +79,6 @@ Resource::Resource(smtk::mesh::InterfacePtr interface) Resource::Resource(const smtk::common::UUID& resourceID, smtk::mesh::InterfacePtr interface) : smtk::resource::DerivedFrom(resourceID) - , m_nameCounter(-1) , m_internals(new InternalImpl(interface)) { queries().registerQueries(); diff --git a/smtk/mesh/core/Resource.h b/smtk/mesh/core/Resource.h index cbcd9fe64d814cc9319748198d80340c3045d8ef..95430edbf5ce53056b6ccfa04c5948e518d4c310 100644 --- a/smtk/mesh/core/Resource.h +++ b/smtk/mesh/core/Resource.h @@ -328,7 +328,7 @@ private: smtk::model::WeakResourcePtr m_modelResource; - int m_nameCounter; + int m_nameCounter{ -1 }; friend std::shared_ptr Component::create( const ResourcePtr&, diff --git a/smtk/mesh/core/TypeSet.cxx b/smtk/mesh/core/TypeSet.cxx index 3f9f4d8a23db3057f0881891cba0011be15a36b2..2112370856ca420e5a52faf5b66b2996ececc665 100644 --- a/smtk/mesh/core/TypeSet.cxx +++ b/smtk/mesh/core/TypeSet.cxx @@ -33,11 +33,7 @@ namespace smtk namespace mesh { -TypeSet::TypeSet() - : m_hasMesh(false) - , m_hasCell(false) -{ -} +TypeSet::TypeSet() = default; TypeSet::TypeSet(smtk::mesh::CellTypes ctypes, bool hasM, bool hasC) : m_cellTypes(ctypes) diff --git a/smtk/mesh/core/TypeSet.h b/smtk/mesh/core/TypeSet.h index 1fed7526aab34caf79d88b2aea3b96036092bf17..b69a8e4ab3610777cf268e40cbaf10eaa914a3e5 100644 --- a/smtk/mesh/core/TypeSet.h +++ b/smtk/mesh/core/TypeSet.h @@ -51,8 +51,8 @@ public: private: smtk::mesh::CellTypes m_cellTypes; smtk::mesh::DimensionTypes m_dimTypes; - bool m_hasMesh; - bool m_hasCell; + bool m_hasMesh{ false }; + bool m_hasCell{ false }; }; } // namespace mesh } // namespace smtk diff --git a/smtk/mesh/json/Interface.cxx b/smtk/mesh/json/Interface.cxx index 900de1fdb2cf3c4f170a4cb06f0fc12c64e6b1db..d5eb98710b56b97f4e41382b8ae81d2a10cec3b3 100644 --- a/smtk/mesh/json/Interface.cxx +++ b/smtk/mesh/json/Interface.cxx @@ -38,14 +38,12 @@ smtk::mesh::json::InterfacePtr make_interface() Interface::Interface() : m_associated_model(smtk::common::UUID::null()) - , m_modified(false) { } Interface::Interface(const std::vector& info) : m_meshInfo(info) , m_associated_model(smtk::common::UUID::null()) - , m_modified(false) { } diff --git a/smtk/mesh/json/Interface.h b/smtk/mesh/json/Interface.h index be1d915252213ea58fb15b337d0e53f3af93f14e..b86226ead262b29c13d1bf9fba9b082d5bdbdfaf 100644 --- a/smtk/mesh/json/Interface.h +++ b/smtk/mesh/json/Interface.h @@ -280,7 +280,7 @@ public: bool setCellField( const smtk::mesh::HandleRange& meshsets, const smtk::mesh::CellFieldTag& cfTag, - const void* const data) override; + const void* data) override; bool getField( const smtk::mesh::HandleRange& cells, @@ -290,7 +290,7 @@ public: bool setField( const smtk::mesh::HandleRange& cells, const smtk::mesh::CellFieldTag& cfTag, - const void* const data) override; + const void* data) override; std::set computeCellFieldTags( const smtk::mesh::Handle& handle) const override; @@ -325,7 +325,7 @@ public: bool setPointField( const smtk::mesh::HandleRange& meshsets, const smtk::mesh::PointFieldTag& pfTag, - const void* const data) override; + const void* data) override; bool getField( const smtk::mesh::HandleRange& points, @@ -335,7 +335,7 @@ public: bool setField( const smtk::mesh::HandleRange& points, const smtk::mesh::PointFieldTag& pfTag, - const void* const data) override; + const void* data) override; std::set computePointFieldTags( const smtk::mesh::Handle& handle) const override; @@ -380,7 +380,7 @@ private: //with it. If we start adding more member variables, we should offload it //all to an internal class mutable smtk::common::UUID m_associated_model; - mutable bool m_modified; + mutable bool m_modified{ false }; }; } // namespace json } // namespace mesh diff --git a/smtk/mesh/json/MeshInfo.cxx b/smtk/mesh/json/MeshInfo.cxx index aa115a658da3798e6c8ec23d991b55256011d9bd..0f9448ccbcf36e31d7b7996e1e0a03c60856f2ac 100644 --- a/smtk/mesh/json/MeshInfo.cxx +++ b/smtk/mesh/json/MeshInfo.cxx @@ -21,10 +21,7 @@ namespace mesh namespace json { -MeshInfo::MeshInfo() - : m_mesh() -{ -} +MeshInfo::MeshInfo() = default; MeshInfo::MeshInfo( smtk::mesh::Handle meshId, diff --git a/smtk/mesh/moab/Interface.cxx b/smtk/mesh/moab/Interface.cxx index 8a6308261622f1a496906cc7a5a17080a482ca36..6f42a57c4323027e630ac52275cbac1d97896b06 100644 --- a/smtk/mesh/moab/Interface.cxx +++ b/smtk/mesh/moab/Interface.cxx @@ -240,7 +240,6 @@ smtk::mesh::moab::InterfacePtr extract_interface(const smtk::mesh::ResourcePtr& Interface::Interface() : m_iface(new ::moab::Core()) - , m_modified(false) { m_alloc.reset(new smtk::mesh::moab::Allocator(m_iface.get())); m_bcAlloc.reset(new smtk::mesh::moab::BufferedCellAllocator(m_iface.get())); diff --git a/smtk/mesh/moab/Interface.h b/smtk/mesh/moab/Interface.h index da30c48a6a0bde1aa5fdd0593c4e0d171679721e..95e93e301a5369d586e9026a553daff2c8a48356 100644 --- a/smtk/mesh/moab/Interface.h +++ b/smtk/mesh/moab/Interface.h @@ -397,7 +397,7 @@ private: smtk::mesh::AllocatorPtr m_alloc; smtk::mesh::BufferedCellAllocatorPtr m_bcAlloc; smtk::mesh::IncrementalAllocatorPtr m_iAlloc; - mutable bool m_modified; + mutable bool m_modified{ false }; }; } // namespace moab } // namespace mesh diff --git a/smtk/mesh/moab/ModelEntityPointLocator.h b/smtk/mesh/moab/ModelEntityPointLocator.h index 06c285ce29af42ff3cb3a648f0dacf104d1714d0..746e2d48738776bb365f82104166efb511916984 100644 --- a/smtk/mesh/moab/ModelEntityPointLocator.h +++ b/smtk/mesh/moab/ModelEntityPointLocator.h @@ -43,9 +43,9 @@ public: // https://arxiv.org/abs/0802.2960 bool randomPoint( const smtk::model::EntityRef& entity, - const std::size_t nPoints, + std::size_t nPoints, std::vector& points, - const std::size_t seed) override; + std::size_t seed) override; protected: ModelEntityPointLocator(); diff --git a/smtk/mesh/moab/RandomPoint.h b/smtk/mesh/moab/RandomPoint.h index 4121326d83d4d77461ada79d938a38ab87bb8445..2acc91358864089d6f4439f481d2f83b72e69e9f 100644 --- a/smtk/mesh/moab/RandomPoint.h +++ b/smtk/mesh/moab/RandomPoint.h @@ -33,10 +33,7 @@ namespace moab struct SMTKCORE_EXPORT RandomPoint : public smtk::resource::query::DerivedFrom { - RandomPoint() - : m_seed(0) - { - } + RandomPoint() = default; std::array operator()(const smtk::resource::Component::Ptr&) const override; @@ -45,7 +42,7 @@ struct SMTKCORE_EXPORT RandomPoint void seed(std::size_t seed) override { m_seed = seed; } private: - std::size_t m_seed; + std::size_t m_seed{ 0 }; }; } // namespace moab } // namespace mesh diff --git a/smtk/mesh/operators/DeleteMesh.cxx b/smtk/mesh/operators/DeleteMesh.cxx index 182cb676a6da3773268534918bf18c2d7fa89bb5..ef6984a46af3cbe8b70fc59dbedd8341c2d51fef 100644 --- a/smtk/mesh/operators/DeleteMesh.cxx +++ b/smtk/mesh/operators/DeleteMesh.cxx @@ -28,10 +28,7 @@ namespace smtk namespace mesh { -DeleteMesh::DeleteMesh() - : m_suppressOutput(false) -{ -} +DeleteMesh::DeleteMesh() = default; smtk::mesh::DeleteMesh::Result DeleteMesh::operateInternal() { diff --git a/smtk/mesh/operators/DeleteMesh.h b/smtk/mesh/operators/DeleteMesh.h index 6808afe3c09c6fa230d986839a4d2516813dd477..a941c4bc3433e0e06dffc42a4f97d6e26c4fffc5 100644 --- a/smtk/mesh/operators/DeleteMesh.h +++ b/smtk/mesh/operators/DeleteMesh.h @@ -36,7 +36,7 @@ protected: void generateSummary(smtk::operation::Operation::Result&) override; - bool m_suppressOutput; + bool m_suppressOutput{ false }; }; } //namespace mesh diff --git a/smtk/mesh/pybind11/PybindApplyToMesh.h b/smtk/mesh/pybind11/PybindApplyToMesh.h index af732e07a4ebf3133d1d918f7110f0e9b2f74653..f3e00bc4015c3a51002919c9cc2426e4099d9ad6 100644 --- a/smtk/mesh/pybind11/PybindApplyToMesh.h +++ b/smtk/mesh/pybind11/PybindApplyToMesh.h @@ -19,32 +19,32 @@ namespace py = pybind11; -void pybind11_init_smtk_mesh_utility_applyScalarCellField(py::module &m) +inline void pybind11_init_smtk_mesh_utility_applyScalarCellField(py::module &m) { m.def("applyScalarCellField", &smtk::mesh::utility::applyScalarCellField, "", py::arg("arg0"), py::arg("name"), py::arg("ms")); } -void pybind11_init_smtk_mesh_utility_applyScalarPointField(py::module &m) +inline void pybind11_init_smtk_mesh_utility_applyScalarPointField(py::module &m) { m.def("applyScalarPointField", &smtk::mesh::utility::applyScalarPointField, "", py::arg("arg0"), py::arg("name"), py::arg("ms")); } -void pybind11_init_smtk_mesh_utility_applyVectorCellField(py::module &m) +inline void pybind11_init_smtk_mesh_utility_applyVectorCellField(py::module &m) { m.def("applyVectorCellField", &smtk::mesh::utility::applyVectorCellField, "", py::arg("arg0"), py::arg("name"), py::arg("ms")); } -void pybind11_init_smtk_mesh_utility_applyVectorPointField(py::module &m) +inline void pybind11_init_smtk_mesh_utility_applyVectorPointField(py::module &m) { m.def("applyVectorPointField", &smtk::mesh::utility::applyVectorPointField, "", py::arg("arg0"), py::arg("name"), py::arg("ms")); } -void pybind11_init_smtk_mesh_utility_applyWarp(py::module &m) +inline void pybind11_init_smtk_mesh_utility_applyWarp(py::module &m) { m.def("applyWarp", &smtk::mesh::utility::applyWarp, "", py::arg("arg0"), py::arg("ms"), py::arg("storePriorCoordinates") = false); } -void pybind11_init_smtk_mesh_utility_undoWarp(py::module &m) +inline void pybind11_init_smtk_mesh_utility_undoWarp(py::module &m) { m.def("undoWarp", &smtk::mesh::utility::undoWarp, "", py::arg("ms")); } diff --git a/smtk/mesh/pybind11/PybindCellField.h b/smtk/mesh/pybind11/PybindCellField.h index c637547d10a7ed32e80dd0a03f02ae79c6607aa9..c4a24ff95ba16de3a1937f7a4172f3d1d82210b7 100644 --- a/smtk/mesh/pybind11/PybindCellField.h +++ b/smtk/mesh/pybind11/PybindCellField.h @@ -21,7 +21,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::CellField > pybind11_init_smtk_mesh_CellField(py::module &m) +inline PySharedPtrClass< smtk::mesh::CellField > pybind11_init_smtk_mesh_CellField(py::module &m) { PySharedPtrClass< smtk::mesh::CellField > instance(m, "CellField"); instance diff --git a/smtk/mesh/pybind11/PybindCellSet.h b/smtk/mesh/pybind11/PybindCellSet.h index c56b70cc24b2a6e38325b6948f6bceaa38db7bc5..c5fd9d1c51f679713e9e1f98e9dae39cf5ce54d7 100644 --- a/smtk/mesh/pybind11/PybindCellSet.h +++ b/smtk/mesh/pybind11/PybindCellSet.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::CellSet > pybind11_init_smtk_mesh_CellSet(py::module &m) +inline PySharedPtrClass< smtk::mesh::CellSet > pybind11_init_smtk_mesh_CellSet(py::module &m) { PySharedPtrClass< smtk::mesh::CellSet > instance(m, "CellSet"); instance @@ -43,32 +43,32 @@ PySharedPtrClass< smtk::mesh::CellSet > pybind11_init_smtk_mesh_CellSet(py::modu return instance; } -void pybind11_init_smtk_mesh_cell_for_each(py::module &m) +inline void pybind11_init_smtk_mesh_cell_for_each(py::module &m) { m.def("for_each", (void (*)(const smtk::mesh::CellSet&, smtk::mesh::CellForEach&)) &smtk::mesh::for_each, "", py::arg("a"), py::arg("filter")); } -void pybind11_init_smtk_mesh_cell_point_difference(py::module &m) +inline void pybind11_init_smtk_mesh_cell_point_difference(py::module &m) { m.def("point_difference", (smtk::mesh::CellSet (*)(const smtk::mesh::CellSet&, const smtk::mesh::CellSet&, smtk::mesh::ContainmentType)) &smtk::mesh::point_difference, "", py::arg("a"), py::arg("b"), py::arg("t")); } -void pybind11_init_smtk_mesh_cell_point_intersect(py::module &m) +inline void pybind11_init_smtk_mesh_cell_point_intersect(py::module &m) { m.def("point_intersect", (smtk::mesh::CellSet (*)(const smtk::mesh::CellSet&, const smtk::mesh::CellSet&, smtk::mesh::ContainmentType)) &smtk::mesh::point_intersect, "", py::arg("a"), py::arg("b"), py::arg("t")); } -void pybind11_init_smtk_mesh_cell_set_difference(py::module &m) +inline void pybind11_init_smtk_mesh_cell_set_difference(py::module &m) { m.def("set_difference", (smtk::mesh::CellSet (*)(const smtk::mesh::CellSet&, const smtk::mesh::CellSet&)) &smtk::mesh::set_difference, "", py::arg("a"), py::arg("b")); } -void pybind11_init_smtk_mesh_cell_set_intersect(py::module &m) +inline void pybind11_init_smtk_mesh_cell_set_intersect(py::module &m) { m.def("set_intersect", (smtk::mesh::CellSet (*)(const smtk::mesh::CellSet&, const smtk::mesh::CellSet&)) &smtk::mesh::set_intersect, "", py::arg("a"), py::arg("b")); } -void pybind11_init_smtk_mesh_cell_set_union(py::module &m) +inline void pybind11_init_smtk_mesh_cell_set_union(py::module &m) { m.def("set_union", (smtk::mesh::CellSet (*)(const smtk::mesh::CellSet&, const smtk::mesh::CellSet&)) &smtk::mesh::set_union, "", py::arg("a"), py::arg("b")); } diff --git a/smtk/mesh/pybind11/PybindCellTypes.h b/smtk/mesh/pybind11/PybindCellTypes.h index aba51ad8bb377b31d5b2fe7e09652aad9839854d..7e043222861f2dcd5fd6bd9b55e1b2db415240a8 100644 --- a/smtk/mesh/pybind11/PybindCellTypes.h +++ b/smtk/mesh/pybind11/PybindCellTypes.h @@ -18,7 +18,7 @@ namespace py = pybind11; -void pybind11_init_smtk_mesh_CellType(py::module &m) +inline void pybind11_init_smtk_mesh_CellType(py::module &m) { py::enum_(m, "CellType") .value("Vertex", smtk::mesh::CellType::Vertex) @@ -34,12 +34,12 @@ void pybind11_init_smtk_mesh_CellType(py::module &m) .export_values(); } -void pybind11_init_smtk_mesh_verticesPerCell(py::module &m) +inline void pybind11_init_smtk_mesh_verticesPerCell(py::module &m) { m.def("verticesPerCell", &smtk::mesh::verticesPerCell, "", py::arg("ctype")); } -void pybind11_init_smtk_mesh_cellTypeSummary(py::module &m) +inline void pybind11_init_smtk_mesh_cellTypeSummary(py::module &m) { m.def("cellTypeSummary", &smtk::mesh::cellTypeSummary, "", py::arg("ctype"), py::arg("flag") = 0); } diff --git a/smtk/mesh/pybind11/PybindComponent.h b/smtk/mesh/pybind11/PybindComponent.h index e6040b26e8ca41c6426185abe293f56745763047..9a96618c1c8e6e14da1097b33a276032b22c0dc3 100644 --- a/smtk/mesh/pybind11/PybindComponent.h +++ b/smtk/mesh/pybind11/PybindComponent.h @@ -22,7 +22,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::Component, smtk::resource::Component > pybind11_init_smtk_mesh_Component(py::module &m) +inline PySharedPtrClass< smtk::mesh::Component, smtk::resource::Component > pybind11_init_smtk_mesh_Component(py::module &m) { PySharedPtrClass< smtk::mesh::Component, smtk::resource::Component > instance(m, "Component"); instance diff --git a/smtk/mesh/pybind11/PybindDeleteMesh.h b/smtk/mesh/pybind11/PybindDeleteMesh.h index dbf5cf200152620c01cdf62b9a3472ea82b20a5e..be400746205fc61c3e6ecc639cae85af8f394f8a 100644 --- a/smtk/mesh/pybind11/PybindDeleteMesh.h +++ b/smtk/mesh/pybind11/PybindDeleteMesh.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::DeleteMesh, smtk::operation::XMLOperation > pybind11_init_smtk_mesh_DeleteMesh(py::module &m) +inline PySharedPtrClass< smtk::mesh::DeleteMesh, smtk::operation::XMLOperation > pybind11_init_smtk_mesh_DeleteMesh(py::module &m) { PySharedPtrClass< smtk::mesh::DeleteMesh, smtk::operation::XMLOperation > instance(m, "DeleteMesh"); instance diff --git a/smtk/mesh/pybind11/PybindDimensionTypes.h b/smtk/mesh/pybind11/PybindDimensionTypes.h index 42ced50ed6589a5dc2c21800f33be170a393b88c..795642eaf9a263e3bfd6f23b00dd69bd6f0495c5 100644 --- a/smtk/mesh/pybind11/PybindDimensionTypes.h +++ b/smtk/mesh/pybind11/PybindDimensionTypes.h @@ -17,7 +17,7 @@ namespace py = pybind11; -void pybind11_init_smtk_mesh_DimensionType(py::module &m) +inline void pybind11_init_smtk_mesh_DimensionType(py::module &m) { py::enum_(m, "DimensionType") .value("Dims0", smtk::mesh::DimensionType::Dims0) diff --git a/smtk/mesh/pybind11/PybindElevateMesh.h b/smtk/mesh/pybind11/PybindElevateMesh.h index 8c19056f0a75cd177e1c1987c7d902e75cd50b93..df4662f7215ee315b1ba5b50848097a149a2926f 100644 --- a/smtk/mesh/pybind11/PybindElevateMesh.h +++ b/smtk/mesh/pybind11/PybindElevateMesh.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::ElevateMesh, smtk::operation::XMLOperation > pybind11_init_smtk_mesh_ElevateMesh(py::module &m) +inline PySharedPtrClass< smtk::mesh::ElevateMesh, smtk::operation::XMLOperation > pybind11_init_smtk_mesh_ElevateMesh(py::module &m) { PySharedPtrClass< smtk::mesh::ElevateMesh, smtk::operation::XMLOperation > instance(m, "ElevateMesh"); instance diff --git a/smtk/mesh/pybind11/PybindExport.h b/smtk/mesh/pybind11/PybindExport.h index a4c1aeceef9dea71c15eae033f0c41bbb4724155..11a2a8e8b2080daf513bdd78bf4ec6b6dbc9f93e 100644 --- a/smtk/mesh/pybind11/PybindExport.h +++ b/smtk/mesh/pybind11/PybindExport.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::Export, smtk::operation::XMLOperation > pybind11_init_smtk_mesh_Export(py::module &m) +inline PySharedPtrClass< smtk::mesh::Export, smtk::operation::XMLOperation > pybind11_init_smtk_mesh_Export(py::module &m) { PySharedPtrClass< smtk::mesh::Export, smtk::operation::XMLOperation > instance(m, "Export"); instance diff --git a/smtk/mesh/pybind11/PybindExtractCanonicalIndices.h b/smtk/mesh/pybind11/PybindExtractCanonicalIndices.h index 439bd2e723ed77a370ce3be43f472fa4e3f16d8f..cdc19e8e3adc02729536b75df3f6039b0e8f0686 100644 --- a/smtk/mesh/pybind11/PybindExtractCanonicalIndices.h +++ b/smtk/mesh/pybind11/PybindExtractCanonicalIndices.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::utility::PreAllocatedCanonicalIndices > pybind11_init_smtk_mesh_PreAllocatedCanonicalIndices(py::module &m) +inline PySharedPtrClass< smtk::mesh::utility::PreAllocatedCanonicalIndices > pybind11_init_smtk_mesh_PreAllocatedCanonicalIndices(py::module &m) { PySharedPtrClass< smtk::mesh::utility::PreAllocatedCanonicalIndices > instance(m, "PreAllocatedCanonicalIndices"); instance @@ -29,7 +29,7 @@ PySharedPtrClass< smtk::mesh::utility::PreAllocatedCanonicalIndices > pybind11_i return instance; } -PySharedPtrClass< smtk::mesh::utility::CanonicalIndices > pybind11_init_smtk_mesh_CanonicalIndices(py::module &m) +inline PySharedPtrClass< smtk::mesh::utility::CanonicalIndices > pybind11_init_smtk_mesh_CanonicalIndices(py::module &m) { PySharedPtrClass< smtk::mesh::utility::CanonicalIndices > instance(m, "CanonicalIndices"); instance @@ -43,7 +43,7 @@ PySharedPtrClass< smtk::mesh::utility::CanonicalIndices > pybind11_init_smtk_mes return instance; } -void pybind11_init__extractCanonicalIndices(py::module &m) +inline void pybind11_init__extractCanonicalIndices(py::module &m) { m.def("extractCanonicalIndices", (void (*)(::smtk::mesh::MeshSet const &, ::smtk::mesh::MeshSet const &, ::smtk::mesh::utility::PreAllocatedCanonicalIndices &)) &smtk::mesh::utility::extractCanonicalIndices, "", py::arg("arg0"), py::arg("arg1"), py::arg("arg2")); } diff --git a/smtk/mesh/pybind11/PybindExtractMeshConstants.h b/smtk/mesh/pybind11/PybindExtractMeshConstants.h index d2ceaeda42a06c70f1e919c539529e500a7c4513..8fbd226a9e012db204a816f3c6a83821e8737f70 100644 --- a/smtk/mesh/pybind11/PybindExtractMeshConstants.h +++ b/smtk/mesh/pybind11/PybindExtractMeshConstants.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::utility::PreAllocatedMeshConstants > pybind11_init_smtk_mesh_PreAllocatedMeshConstants(py::module &m) +inline PySharedPtrClass< smtk::mesh::utility::PreAllocatedMeshConstants > pybind11_init_smtk_mesh_PreAllocatedMeshConstants(py::module &m) { PySharedPtrClass< smtk::mesh::utility::PreAllocatedMeshConstants > instance(m, "PreAllocatedMeshConstants"); instance @@ -29,7 +29,7 @@ PySharedPtrClass< smtk::mesh::utility::PreAllocatedMeshConstants > pybind11_init return instance; } -PySharedPtrClass< smtk::mesh::utility::MeshConstants > pybind11_init_smtk_mesh_MeshConstants(py::module &m) +inline PySharedPtrClass< smtk::mesh::utility::MeshConstants > pybind11_init_smtk_mesh_MeshConstants(py::module &m) { PySharedPtrClass< smtk::mesh::utility::MeshConstants > instance(m, "MeshConstants"); instance @@ -48,32 +48,32 @@ PySharedPtrClass< smtk::mesh::utility::MeshConstants > pybind11_init_smtk_mesh_M return instance; } -void pybind11_init__ZN4smtk4mesh21extractDirichletMeshConstantsERKNS0_7MeshSetERNS0_17PreAllocatedMeshConstantsE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh21extractDirichletMeshConstantsERKNS0_7MeshSetERNS0_17PreAllocatedMeshConstantsE(py::module &m) { m.def("extractDirichletMeshConstants", (void (*)(::smtk::mesh::MeshSet const &, ::smtk::mesh::utility::PreAllocatedMeshConstants &)) &smtk::mesh::utility::extractDirichletMeshConstants, "", py::arg("arg0"), py::arg("arg1")); } -void pybind11_init__ZN4smtk4mesh21extractDirichletMeshConstantsERKNS0_7MeshSetERKNS0_8PointSetERNS0_17PreAllocatedMeshConstantsE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh21extractDirichletMeshConstantsERKNS0_7MeshSetERKNS0_8PointSetERNS0_17PreAllocatedMeshConstantsE(py::module &m) { m.def("extractDirichletMeshConstants", (void (*)(::smtk::mesh::MeshSet const &, ::smtk::mesh::PointSet const &, ::smtk::mesh::utility::PreAllocatedMeshConstants &)) &smtk::mesh::utility::extractDirichletMeshConstants, "", py::arg("arg0"), py::arg("arg1"), py::arg("arg2")); } -void pybind11_init__ZN4smtk4mesh18extractDomainMeshConstantsERKNS0_7MeshSetERNS0_17PreAllocatedMeshConstantsE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh18extractDomainMeshConstantsERKNS0_7MeshSetERNS0_17PreAllocatedMeshConstantsE(py::module &m) { m.def("extractDomainMeshConstants", (void (*)(::smtk::mesh::MeshSet const &, ::smtk::mesh::utility::PreAllocatedMeshConstants &)) &smtk::mesh::utility::extractDomainMeshConstants, "", py::arg("arg0"), py::arg("arg1")); } -void pybind11_init__ZN4smtk4mesh18extractDomainMeshConstantsERKNS0_7MeshSetERKNS0_8PointSetERNS0_17PreAllocatedMeshConstantsE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh18extractDomainMeshConstantsERKNS0_7MeshSetERKNS0_8PointSetERNS0_17PreAllocatedMeshConstantsE(py::module &m) { m.def("extractDomainMeshConstants", (void (*)(::smtk::mesh::MeshSet const &, ::smtk::mesh::PointSet const &, ::smtk::mesh::utility::PreAllocatedMeshConstants &)) &smtk::mesh::utility::extractDomainMeshConstants, "", py::arg("arg0"), py::arg("arg1"), py::arg("arg2")); } -void pybind11_init__ZN4smtk4mesh19extractNeumannMeshConstantsERKNS0_7MeshSetERNS0_17PreAllocatedMeshConstantsE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh19extractNeumannMeshConstantsERKNS0_7MeshSetERNS0_17PreAllocatedMeshConstantsE(py::module &m) { m.def("extractNeumannMeshConstants", (void (*)(::smtk::mesh::MeshSet const &, ::smtk::mesh::utility::PreAllocatedMeshConstants &)) &smtk::mesh::utility::extractNeumannMeshConstants, "", py::arg("arg0"), py::arg("arg1")); } -void pybind11_init__ZN4smtk4mesh19extractNeumannMeshConstantsERKNS0_7MeshSetERKNS0_8PointSetERNS0_17PreAllocatedMeshConstantsE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh19extractNeumannMeshConstantsERKNS0_7MeshSetERKNS0_8PointSetERNS0_17PreAllocatedMeshConstantsE(py::module &m) { m.def("extractNeumannMeshConstants", (void (*)(::smtk::mesh::MeshSet const &, ::smtk::mesh::PointSet const &, ::smtk::mesh::utility::PreAllocatedMeshConstants &)) &smtk::mesh::utility::extractNeumannMeshConstants, "", py::arg("arg0"), py::arg("arg1"), py::arg("arg2")); } diff --git a/smtk/mesh/pybind11/PybindExtractTessellation.h b/smtk/mesh/pybind11/PybindExtractTessellation.h index 2c8ab9d13345ed5fbf1d1fd27a9b7bd3e6b2dbed..69467fdcfc7cf5c43939eaf4684a1fab8ea3a2f3 100644 --- a/smtk/mesh/pybind11/PybindExtractTessellation.h +++ b/smtk/mesh/pybind11/PybindExtractTessellation.h @@ -20,7 +20,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::utility::PreAllocatedTessellation > pybind11_init_smtk_mesh_PreAllocatedTessellation(py::module &m) +inline PySharedPtrClass< smtk::mesh::utility::PreAllocatedTessellation > pybind11_init_smtk_mesh_PreAllocatedTessellation(py::module &m) { PySharedPtrClass< smtk::mesh::utility::PreAllocatedTessellation > instance(m, "PreAllocatedTessellation"); instance @@ -49,7 +49,7 @@ PySharedPtrClass< smtk::mesh::utility::PreAllocatedTessellation > pybind11_init_ return instance; } -PySharedPtrClass< smtk::mesh::utility::Tessellation > pybind11_init_smtk_mesh_Tessellation(py::module &m) +inline PySharedPtrClass< smtk::mesh::utility::Tessellation > pybind11_init_smtk_mesh_Tessellation(py::module &m) { PySharedPtrClass< smtk::mesh::utility::Tessellation > instance(m, "Tessellation"); instance @@ -71,57 +71,57 @@ PySharedPtrClass< smtk::mesh::utility::Tessellation > pybind11_init_smtk_mesh_Te return instance; } -void pybind11_init__ZN4smtk4mesh26extractOrderedTessellationERKNS_5model4EdgeERKNSt3__110shared_ptrINS0_10ResourceEEERNS0_24PreAllocatedTessellationE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh26extractOrderedTessellationERKNS_5model4EdgeERKNSt3__110shared_ptrINS0_10ResourceEEERNS0_24PreAllocatedTessellationE(py::module &m) { m.def("extractOrderedTessellation", (void (*)(::smtk::model::EdgeUse const &, ::smtk::mesh::ResourcePtr const &, ::smtk::mesh::utility::PreAllocatedTessellation &)) &smtk::mesh::utility::extractOrderedTessellation, "", py::arg("arg0"), py::arg("arg1"), py::arg("arg2")); } -void pybind11_init__ZN4smtk4mesh26extractOrderedTessellationERKNS_5model4LoopERKNSt3__110shared_ptrINS0_10ResourceEEERNS0_24PreAllocatedTessellationE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh26extractOrderedTessellationERKNS_5model4LoopERKNSt3__110shared_ptrINS0_10ResourceEEERNS0_24PreAllocatedTessellationE(py::module &m) { m.def("extractOrderedTessellation", (void (*)(::smtk::model::Loop const &, ::smtk::mesh::ResourcePtr const &, ::smtk::mesh::utility::PreAllocatedTessellation &)) &smtk::mesh::utility::extractOrderedTessellation, "", py::arg("arg0"), py::arg("arg1"), py::arg("arg2")); } -void pybind11_init__ZN4smtk4mesh26extractOrderedTessellationERKNS_5model4EdgeERKNSt3__110shared_ptrINS0_10ResourceEEERKNS0_8PointSetERNS0_24PreAllocatedTessellationE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh26extractOrderedTessellationERKNS_5model4EdgeERKNSt3__110shared_ptrINS0_10ResourceEEERKNS0_8PointSetERNS0_24PreAllocatedTessellationE(py::module &m) { m.def("extractOrderedTessellation", (void (*)(::smtk::model::EdgeUse const &, ::smtk::mesh::ResourcePtr const &, ::smtk::mesh::PointSet const &, ::smtk::mesh::utility::PreAllocatedTessellation &)) &smtk::mesh::utility::extractOrderedTessellation, "", py::arg("arg0"), py::arg("arg1"), py::arg("arg2"), py::arg("arg3")); } -void pybind11_init__ZN4smtk4mesh26extractOrderedTessellationERKNS_5model4LoopERKNSt3__110shared_ptrINS0_10ResourceEEERKNS0_8PointSetERNS0_24PreAllocatedTessellationE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh26extractOrderedTessellationERKNS_5model4LoopERKNSt3__110shared_ptrINS0_10ResourceEEERKNS0_8PointSetERNS0_24PreAllocatedTessellationE(py::module &m) { m.def("extractOrderedTessellation", (void (*)(::smtk::model::Loop const &, ::smtk::mesh::ResourcePtr const &, ::smtk::mesh::PointSet const &, ::smtk::mesh::utility::PreAllocatedTessellation &)) &smtk::mesh::utility::extractOrderedTessellation, "", py::arg("arg0"), py::arg("arg1"), py::arg("arg2"), py::arg("arg3")); } -void pybind11_init__ZN4smtk4mesh19extractTessellationERKNS0_7MeshSetERNS0_24PreAllocatedTessellationE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh19extractTessellationERKNS0_7MeshSetERNS0_24PreAllocatedTessellationE(py::module &m) { m.def("extractTessellation", (void (*)(::smtk::mesh::MeshSet const &, ::smtk::mesh::utility::PreAllocatedTessellation &)) &smtk::mesh::utility::extractTessellation, "", py::arg("arg0"), py::arg("arg1")); } -void pybind11_init__ZN4smtk4mesh19extractTessellationERKNS0_7CellSetERNS0_24PreAllocatedTessellationE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh19extractTessellationERKNS0_7CellSetERNS0_24PreAllocatedTessellationE(py::module &m) { m.def("extractTessellation", (void (*)(::smtk::mesh::CellSet const &, ::smtk::mesh::utility::PreAllocatedTessellation &)) &smtk::mesh::utility::extractTessellation, "", py::arg("arg0"), py::arg("arg1")); } -void pybind11_init__ZN4smtk4mesh19extractTessellationERKNS_5model9EntityRefERKNSt3__110shared_ptrINS0_10ResourceEEERNS0_24PreAllocatedTessellationE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh19extractTessellationERKNS_5model9EntityRefERKNSt3__110shared_ptrINS0_10ResourceEEERNS0_24PreAllocatedTessellationE(py::module &m) { m.def("extractTessellation", (void (*)(::smtk::model::EntityRef const &, ::smtk::mesh::ResourcePtr const &, ::smtk::mesh::utility::PreAllocatedTessellation &)) &smtk::mesh::utility::extractTessellation, "", py::arg("arg0"), py::arg("arg1"), py::arg("arg2")); } -void pybind11_init__ZN4smtk4mesh19extractTessellationERKNS0_7MeshSetERKNS0_8PointSetERNS0_24PreAllocatedTessellationE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh19extractTessellationERKNS0_7MeshSetERKNS0_8PointSetERNS0_24PreAllocatedTessellationE(py::module &m) { m.def("extractTessellation", (void (*)(::smtk::mesh::MeshSet const &, ::smtk::mesh::PointSet const &, ::smtk::mesh::utility::PreAllocatedTessellation &)) &smtk::mesh::utility::extractTessellation, "", py::arg("arg0"), py::arg("arg1"), py::arg("arg2")); } -void pybind11_init__ZN4smtk4mesh19extractTessellationERKNS0_7CellSetERKNS0_8PointSetERNS0_24PreAllocatedTessellationE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh19extractTessellationERKNS0_7CellSetERKNS0_8PointSetERNS0_24PreAllocatedTessellationE(py::module &m) { m.def("extractTessellation", (void (*)(::smtk::mesh::CellSet const &, ::smtk::mesh::PointSet const &, ::smtk::mesh::utility::PreAllocatedTessellation &)) &smtk::mesh::utility::extractTessellation, "", py::arg("arg0"), py::arg("arg1"), py::arg("arg2")); } -void pybind11_init__ZN4smtk4mesh19extractTessellationERNS0_17PointConnectivityERKNS0_8PointSetERNS0_24PreAllocatedTessellationE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh19extractTessellationERNS0_17PointConnectivityERKNS0_8PointSetERNS0_24PreAllocatedTessellationE(py::module &m) { m.def("extractTessellation", (void (*)(::smtk::mesh::PointConnectivity &, ::smtk::mesh::PointSet const &, ::smtk::mesh::utility::PreAllocatedTessellation &)) &smtk::mesh::utility::extractTessellation, "", py::arg("arg0"), py::arg("arg1"), py::arg("arg2")); } -void pybind11_init__ZN4smtk4mesh19extractTessellationERKNS_5model9EntityRefERKNSt3__110shared_ptrINS0_10ResourceEEERKNS0_8PointSetERNS0_24PreAllocatedTessellationE(py::module &m) +inline void pybind11_init__ZN4smtk4mesh19extractTessellationERKNS_5model9EntityRefERKNSt3__110shared_ptrINS0_10ResourceEEERKNS0_8PointSetERNS0_24PreAllocatedTessellationE(py::module &m) { m.def("extractTessellation", (void (*)(::smtk::model::EntityRef const &, ::smtk::mesh::ResourcePtr const &, ::smtk::mesh::PointSet const &, ::smtk::mesh::utility::PreAllocatedTessellation &)) &smtk::mesh::utility::extractTessellation, "", py::arg("arg0"), py::arg("arg1"), py::arg("arg2"), py::arg("arg3")); } diff --git a/smtk/mesh/pybind11/PybindFieldTypes.h b/smtk/mesh/pybind11/PybindFieldTypes.h index 958631684e72907f2da43105d203bafa590faed4..8ecd0f056d4b78f7ce6e11d32722ca799b7aa675 100644 --- a/smtk/mesh/pybind11/PybindFieldTypes.h +++ b/smtk/mesh/pybind11/PybindFieldTypes.h @@ -17,7 +17,7 @@ namespace py = pybind11; -void pybind11_init_smtk_mesh_FieldType(py::module &m) +inline void pybind11_init_smtk_mesh_FieldType(py::module &m) { py::enum_(m, "FieldType") .value("Integer", smtk::mesh::FieldType::Integer) diff --git a/smtk/mesh/pybind11/PybindForEachTypes.h b/smtk/mesh/pybind11/PybindForEachTypes.h index 8ec8d88d0116496571fb14ebe0737ca824b96aa0..7b4335b595b11c3f770137a46ee6bd0d95daba3e 100644 --- a/smtk/mesh/pybind11/PybindForEachTypes.h +++ b/smtk/mesh/pybind11/PybindForEachTypes.h @@ -55,7 +55,7 @@ public: } }; -PySharedPtrClass< smtk::mesh::MeshForEach > pybind11_init_smtk_mesh_MeshForEach(py::module &m) +inline PySharedPtrClass< smtk::mesh::MeshForEach > pybind11_init_smtk_mesh_MeshForEach(py::module &m) { py::class_, PyMeshForEach > instance(m, "MeshForEach"); instance @@ -68,7 +68,7 @@ PySharedPtrClass< smtk::mesh::MeshForEach > pybind11_init_smtk_mesh_MeshForEach( return std::move(instance); } -PySharedPtrClass< smtk::mesh::CellForEach > pybind11_init_smtk_mesh_CellForEach(py::module &m) +inline PySharedPtrClass< smtk::mesh::CellForEach > pybind11_init_smtk_mesh_CellForEach(py::module &m) { py::class_, PyCellForEach > instance(m, "CellForEach"); instance @@ -88,7 +88,7 @@ PySharedPtrClass< smtk::mesh::CellForEach > pybind11_init_smtk_mesh_CellForEach( return std::move(instance); } -PySharedPtrClass< smtk::mesh::PointForEach > pybind11_init_smtk_mesh_PointForEach(py::module &m) +inline PySharedPtrClass< smtk::mesh::PointForEach > pybind11_init_smtk_mesh_PointForEach(py::module &m) { py::class_, PyPointForEach > instance(m, "PointForEach"); instance diff --git a/smtk/mesh/pybind11/PybindHandle.h b/smtk/mesh/pybind11/PybindHandle.h index 00540074812e6eab45579262c2ac862a2a969a01..81abedc15d0aa6203e1001acd761eaaa85896d64 100644 --- a/smtk/mesh/pybind11/PybindHandle.h +++ b/smtk/mesh/pybind11/PybindHandle.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::mesh::HandleInterval > pybind11_init_HandleInterval(py::module &m) +inline py::class_< smtk::mesh::HandleInterval > pybind11_init_HandleInterval(py::module &m) { py::class_< smtk::mesh::HandleInterval > instance(m, "HandleInterval"); instance @@ -34,7 +34,7 @@ py::class_< smtk::mesh::HandleInterval > pybind11_init_HandleInterval(py::module return instance; } -PySharedPtrClass< smtk::mesh::const_element_iterator > pybind11_init_const_element_iterator(py::module &m) +inline PySharedPtrClass< smtk::mesh::const_element_iterator > pybind11_init_const_element_iterator(py::module &m) { PySharedPtrClass< smtk::mesh::const_element_iterator > instance(m, "const_element_iterator"); instance @@ -45,7 +45,7 @@ PySharedPtrClass< smtk::mesh::const_element_iterator > pybind11_init_const_eleme return instance; } -py::class_< smtk::mesh::HandleRange > pybind11_init_HandleRange(py::module &m) +inline py::class_< smtk::mesh::HandleRange > pybind11_init_HandleRange(py::module &m) { py::class_< smtk::mesh::HandleRange > instance(m, "HandleRange"); instance @@ -64,38 +64,38 @@ py::class_< smtk::mesh::HandleRange > pybind11_init_HandleRange(py::module &m) return instance; } -void pybind11_init_smtk_mesh_rangeElementsBegin(py::module &m) +inline void pybind11_init_smtk_mesh_rangeElementsBegin(py::module &m) { m.def("rangeElementsBegin", &smtk::mesh::rangeElementsBegin, "", py::arg("arg0")); } -void pybind11_init_smtk_mesh_rangeElementsEnd(py::module &m) +inline void pybind11_init_smtk_mesh_rangeElementsEnd(py::module &m) { m.def("rangeElementsEnd", &smtk::mesh::rangeElementsEnd, "", py::arg("arg0")); } -void pybind11_init_smtk_mesh_rangeElement(py::module &m) +inline void pybind11_init_smtk_mesh_rangeElement(py::module &m) { m.def("rangeElement", &smtk::mesh::rangeElement, "", py::arg("arg0"), py::arg("arg1")); } -void pybind11_init_smtk_mesh_rangeContains(py::module &m) +inline void pybind11_init_smtk_mesh_rangeContains(py::module &m) { m.def("rangeContains", (bool (*)(smtk::mesh::HandleRange const &, smtk::mesh::Handle)) &smtk::mesh::rangeContains, "", py::arg("arg0"), py::arg("arg1")); m.def("rangeContains", (bool (*)(smtk::mesh::HandleRange const &, smtk::mesh::HandleRange const &)) &smtk::mesh::rangeContains, "", py::arg("super"), py::arg("sub")); } -void pybind11_init_smtk_mesh_rangeIndex(py::module &m) +inline void pybind11_init_smtk_mesh_rangeIndex(py::module &m) { m.def("rangeIndex", &smtk::mesh::rangeIndex, "", py::arg("arg0"), py::arg("arg1")); } -void pybind11_init_smtk_mesh_rangeIntervalCount(py::module &m) +inline void pybind11_init_smtk_mesh_rangeIntervalCount(py::module &m) { m.def("rangeIntervalCount", &smtk::mesh::rangeIntervalCount, "", py::arg("arg0")); } -void pybind11_init_smtk_mesh_rangesEqual(py::module &m) +inline void pybind11_init_smtk_mesh_rangesEqual(py::module &m) { m.def("rangesEqual", &smtk::mesh::rangesEqual, "", py::arg("arg0"), py::arg("arg1")); } diff --git a/smtk/mesh/pybind11/PybindImport.h b/smtk/mesh/pybind11/PybindImport.h index d4fad2006f47fff787bcc981b75fb77c3ea1fb65..2e54d72de5d7e7280716065aeb5e9c6c89c9fbf5 100644 --- a/smtk/mesh/pybind11/PybindImport.h +++ b/smtk/mesh/pybind11/PybindImport.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::Import, smtk::operation::XMLOperation > pybind11_init_smtk_mesh_Import(py::module &m) +inline PySharedPtrClass< smtk::mesh::Import, smtk::operation::XMLOperation > pybind11_init_smtk_mesh_Import(py::module &m) { PySharedPtrClass< smtk::mesh::Import, smtk::operation::XMLOperation > instance(m, "Import"); instance diff --git a/smtk/mesh/pybind11/PybindInterface.h b/smtk/mesh/pybind11/PybindInterface.h index c871e284b8b0e3acd88234e933237da927d603ee..6ab40fb659f488dc4304d388b7844a29808290d5 100644 --- a/smtk/mesh/pybind11/PybindInterface.h +++ b/smtk/mesh/pybind11/PybindInterface.h @@ -24,7 +24,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::Allocator > pybind11_init_smtk_mesh_Allocator(py::module &m) +inline PySharedPtrClass< smtk::mesh::Allocator > pybind11_init_smtk_mesh_Allocator(py::module &m) { PySharedPtrClass< smtk::mesh::Allocator > instance(m, "Allocator"); instance @@ -36,7 +36,7 @@ PySharedPtrClass< smtk::mesh::Allocator > pybind11_init_smtk_mesh_Allocator(py:: return instance; } -PySharedPtrClass< smtk::mesh::BufferedCellAllocator > pybind11_init_smtk_mesh_BufferedCellAllocator(py::module &m) +inline PySharedPtrClass< smtk::mesh::BufferedCellAllocator > pybind11_init_smtk_mesh_BufferedCellAllocator(py::module &m) { PySharedPtrClass< smtk::mesh::BufferedCellAllocator > instance(m, "BufferedCellAllocator"); instance @@ -56,7 +56,7 @@ PySharedPtrClass< smtk::mesh::BufferedCellAllocator > pybind11_init_smtk_mesh_Bu return instance; } -PySharedPtrClass< smtk::mesh::ConnectivityStorage > pybind11_init_smtk_mesh_ConnectivityStorage(py::module &m) +inline PySharedPtrClass< smtk::mesh::ConnectivityStorage > pybind11_init_smtk_mesh_ConnectivityStorage(py::module &m) { PySharedPtrClass< smtk::mesh::ConnectivityStorage > instance(m, "ConnectivityStorage"); instance @@ -77,7 +77,7 @@ PySharedPtrClass< smtk::mesh::ConnectivityStorage > pybind11_init_smtk_mesh_Conn return instance; } -PySharedPtrClass< smtk::mesh::IncrementalAllocator > pybind11_init_smtk_mesh_IncrementalAllocator(py::module &m) +inline PySharedPtrClass< smtk::mesh::IncrementalAllocator > pybind11_init_smtk_mesh_IncrementalAllocator(py::module &m) { PySharedPtrClass< smtk::mesh::IncrementalAllocator > instance(m, "IncrementalAllocator"); instance @@ -100,7 +100,7 @@ PySharedPtrClass< smtk::mesh::IncrementalAllocator > pybind11_init_smtk_mesh_Inc return instance; } -PySharedPtrClass< smtk::mesh::Interface > pybind11_init_smtk_mesh_Interface(py::module &m) +inline PySharedPtrClass< smtk::mesh::Interface > pybind11_init_smtk_mesh_Interface(py::module &m) { PySharedPtrClass< smtk::mesh::Interface > instance(m, "Interface"); instance @@ -177,7 +177,7 @@ PySharedPtrClass< smtk::mesh::Interface > pybind11_init_smtk_mesh_Interface(py:: return instance; } -PySharedPtrClass< smtk::mesh::PointLocatorImpl > pybind11_init_smtk_mesh_PointLocatorImpl(py::module &m) +inline PySharedPtrClass< smtk::mesh::PointLocatorImpl > pybind11_init_smtk_mesh_PointLocatorImpl(py::module &m) { PySharedPtrClass< smtk::mesh::PointLocatorImpl > instance(m, "PointLocatorImpl"); instance diff --git a/smtk/mesh/pybind11/PybindInterpolateOntoMesh.h b/smtk/mesh/pybind11/PybindInterpolateOntoMesh.h index 37910b1793c6fae367c0e0bcfb4cf49f5d737f9d..c00203f0cf0fca5180165002c007eed065832cd3 100644 --- a/smtk/mesh/pybind11/PybindInterpolateOntoMesh.h +++ b/smtk/mesh/pybind11/PybindInterpolateOntoMesh.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::InterpolateOntoMesh, smtk::operation::XMLOperation > pybind11_init_smtk_mesh_InterpolateOntoMesh(py::module &m) +inline PySharedPtrClass< smtk::mesh::InterpolateOntoMesh, smtk::operation::XMLOperation > pybind11_init_smtk_mesh_InterpolateOntoMesh(py::module &m) { PySharedPtrClass< smtk::mesh::InterpolateOntoMesh, smtk::operation::XMLOperation > instance(m, "InterpolateOntoMesh"); instance diff --git a/smtk/mesh/pybind11/PybindMeshSet.h b/smtk/mesh/pybind11/PybindMeshSet.h index fb807275d4989db07b7e334cbffc2d8d3ccaa318..1e0e55825503777bc3486c88e9b2ef5c9ea8f251 100644 --- a/smtk/mesh/pybind11/PybindMeshSet.h +++ b/smtk/mesh/pybind11/PybindMeshSet.h @@ -30,7 +30,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::MeshSet > pybind11_init_smtk_mesh_MeshSet(py::module &m) +inline PySharedPtrClass< smtk::mesh::MeshSet > pybind11_init_smtk_mesh_MeshSet(py::module &m) { PySharedPtrClass< smtk::mesh::MeshSet > instance(m, "MeshSet"); instance @@ -95,22 +95,22 @@ PySharedPtrClass< smtk::mesh::MeshSet > pybind11_init_smtk_mesh_MeshSet(py::modu return instance; } -void pybind11_init_smtk_mesh_mesh_for_each(py::module &m) +inline void pybind11_init_smtk_mesh_mesh_for_each(py::module &m) { m.def("for_each", (void (*)(const smtk::mesh::MeshSet&, smtk::mesh::MeshForEach&)) &smtk::mesh::for_each, "", py::arg("a"), py::arg("filter")); } -void pybind11_init_smtk_mesh_mesh_set_difference(py::module &m) +inline void pybind11_init_smtk_mesh_mesh_set_difference(py::module &m) { m.def("set_difference", (smtk::mesh::MeshSet (*)(const smtk::mesh::MeshSet&, const smtk::mesh::MeshSet&)) &smtk::mesh::set_difference, "", py::arg("a"), py::arg("b")); } -void pybind11_init_smtk_mesh_mesh_set_intersect(py::module &m) +inline void pybind11_init_smtk_mesh_mesh_set_intersect(py::module &m) { m.def("set_intersect", (smtk::mesh::MeshSet (*)(const smtk::mesh::MeshSet&, const smtk::mesh::MeshSet&)) &smtk::mesh::set_intersect, "", py::arg("a"), py::arg("b")); } -void pybind11_init_smtk_mesh_mesh_set_union(py::module &m) +inline void pybind11_init_smtk_mesh_mesh_set_union(py::module &m) { m.def("set_union", (smtk::mesh::MeshSet (*)(const smtk::mesh::MeshSet&, const smtk::mesh::MeshSet&)) &smtk::mesh::set_union, "", py::arg("a"), py::arg("b")); } diff --git a/smtk/mesh/pybind11/PybindMetrics.h b/smtk/mesh/pybind11/PybindMetrics.h index 6281ef0f09f0689f5debdceeb5b1c1e8a18255ec..3546bb3a4f38e28510ec84262cf54fa626a63e5f 100644 --- a/smtk/mesh/pybind11/PybindMetrics.h +++ b/smtk/mesh/pybind11/PybindMetrics.h @@ -19,7 +19,7 @@ namespace py = pybind11; -void pybind11_init_smtk_mesh_metrics(py::module &m) +inline void pybind11_init_smtk_mesh_metrics(py::module &m) { m.def("extent", &smtk::mesh::utility::extent); m.def("highestDimension", &smtk::mesh::utility::highestDimension); diff --git a/smtk/mesh/pybind11/PybindPointCloud.h b/smtk/mesh/pybind11/PybindPointCloud.h index 992e659e22c6f624e681bd7eefb1019dd5fd2eea..3495af77f3005e96ec27a64d8e423818cab58c61 100644 --- a/smtk/mesh/pybind11/PybindPointCloud.h +++ b/smtk/mesh/pybind11/PybindPointCloud.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::mesh::PointCloud > pybind11_init_smtk_mesh_PointCloud(py::module &m) +inline py::class_< smtk::mesh::PointCloud > pybind11_init_smtk_mesh_PointCloud(py::module &m) { py::class_< smtk::mesh::PointCloud > instance(m, "PointCloud"); instance diff --git a/smtk/mesh/pybind11/PybindPointCloudGenerator.h b/smtk/mesh/pybind11/PybindPointCloudGenerator.h index 09d10c3e981e79d6c3f945307c38e816872b6a49..c318004bae56915c69950ff59eace100606eb626 100644 --- a/smtk/mesh/pybind11/PybindPointCloudGenerator.h +++ b/smtk/mesh/pybind11/PybindPointCloudGenerator.h @@ -18,7 +18,7 @@ namespace py = pybind11; -py::class_ pybind11_init_smtk_mesh_PointCloudGenerator(py::module &m) +inline py::class_ pybind11_init_smtk_mesh_PointCloudGenerator(py::module &m) { py::class_ instance(m, "PointCloudGenerator"); instance diff --git a/smtk/mesh/pybind11/PybindPointConnectivity.h b/smtk/mesh/pybind11/PybindPointConnectivity.h index 129f6d299e0a52f42c286f7c6bdb7cb29060f1d5..4738bf2c65df814b7072e72460db48e7386204ef 100644 --- a/smtk/mesh/pybind11/PybindPointConnectivity.h +++ b/smtk/mesh/pybind11/PybindPointConnectivity.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::PointConnectivity > pybind11_init_smtk_mesh_PointConnectivity(py::module &m) +inline PySharedPtrClass< smtk::mesh::PointConnectivity > pybind11_init_smtk_mesh_PointConnectivity(py::module &m) { PySharedPtrClass< smtk::mesh::PointConnectivity > instance(m, "PointConnectivity"); instance diff --git a/smtk/mesh/pybind11/PybindPointField.h b/smtk/mesh/pybind11/PybindPointField.h index 4933d4bffc95c000c11e29ba675692110e7bbcfe..e25b1e61a96b61bb23d4ae56ade445fa3e1345b8 100644 --- a/smtk/mesh/pybind11/PybindPointField.h +++ b/smtk/mesh/pybind11/PybindPointField.h @@ -20,7 +20,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::PointField > pybind11_init_smtk_mesh_PointField(py::module &m) +inline PySharedPtrClass< smtk::mesh::PointField > pybind11_init_smtk_mesh_PointField(py::module &m) { PySharedPtrClass< smtk::mesh::PointField > instance(m, "PointField"); instance diff --git a/smtk/mesh/pybind11/PybindPointLocator.h b/smtk/mesh/pybind11/PybindPointLocator.h index 852402894eabf98261c2af47adcd0a890688fbaa..8fbdebaf126e91669103254dd0de1d61195b4b67 100644 --- a/smtk/mesh/pybind11/PybindPointLocator.h +++ b/smtk/mesh/pybind11/PybindPointLocator.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::PointLocator > pybind11_init_smtk_mesh_PointLocator(py::module &m) +inline PySharedPtrClass< smtk::mesh::PointLocator > pybind11_init_smtk_mesh_PointLocator(py::module &m) { PySharedPtrClass< smtk::mesh::PointLocator > instance(m, "PointLocator"); instance diff --git a/smtk/mesh/pybind11/PybindPointSet.h b/smtk/mesh/pybind11/PybindPointSet.h index f4eb0f2ce52af06aa7eca04ae938ad4a76451e23..e03120f2e0bf1f27e9798459b591f2af2f458c5a 100644 --- a/smtk/mesh/pybind11/PybindPointSet.h +++ b/smtk/mesh/pybind11/PybindPointSet.h @@ -18,7 +18,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::PointSet > pybind11_init_smtk_mesh_PointSet(py::module &m) +inline PySharedPtrClass< smtk::mesh::PointSet > pybind11_init_smtk_mesh_PointSet(py::module &m) { PySharedPtrClass< smtk::mesh::PointSet > instance(m, "PointSet"); instance @@ -49,22 +49,22 @@ PySharedPtrClass< smtk::mesh::PointSet > pybind11_init_smtk_mesh_PointSet(py::mo return instance; } -void pybind11_init_smtk_mesh_point_for_each(py::module &m) +inline void pybind11_init_smtk_mesh_point_for_each(py::module &m) { m.def("for_each", (void (*)(const smtk::mesh::PointSet&, smtk::mesh::PointForEach&)) &smtk::mesh::for_each, "", py::arg("a"), py::arg("filter")); } -void pybind11_init_smtk_mesh_point_set_difference(py::module &m) +inline void pybind11_init_smtk_mesh_point_set_difference(py::module &m) { m.def("set_difference", (smtk::mesh::PointSet (*)(const smtk::mesh::PointSet&, const smtk::mesh::PointSet&)) &smtk::mesh::set_difference, "", py::arg("a"), py::arg("b")); } -void pybind11_init_smtk_mesh_point_set_intersect(py::module &m) +inline void pybind11_init_smtk_mesh_point_set_intersect(py::module &m) { m.def("set_intersect", (smtk::mesh::PointSet (*)(const smtk::mesh::PointSet&, const smtk::mesh::PointSet&)) &smtk::mesh::set_intersect, "", py::arg("a"), py::arg("b")); } -void pybind11_init_smtk_mesh_point_set_union(py::module &m) +inline void pybind11_init_smtk_mesh_point_set_union(py::module &m) { m.def("set_union", (smtk::mesh::PointSet (*)(const smtk::mesh::PointSet&, const smtk::mesh::PointSet&)) &smtk::mesh::set_union, "", py::arg("a"), py::arg("b")); } diff --git a/smtk/mesh/pybind11/PybindQueryTypes.h b/smtk/mesh/pybind11/PybindQueryTypes.h index 79a13c4c86606af848838a6f72aba827e062d19b..615691be08593c798ce7347618b093a08bbdeb13 100644 --- a/smtk/mesh/pybind11/PybindQueryTypes.h +++ b/smtk/mesh/pybind11/PybindQueryTypes.h @@ -17,7 +17,7 @@ namespace py = pybind11; -void pybind11_init_smtk_mesh_ContainmentType(py::module &m) +inline void pybind11_init_smtk_mesh_ContainmentType(py::module &m) { py::enum_(m, "ContainmentType") .value("PartiallyContained", smtk::mesh::ContainmentType::PartiallyContained) @@ -25,7 +25,7 @@ void pybind11_init_smtk_mesh_ContainmentType(py::module &m) .export_values(); } -PySharedPtrClass< smtk::mesh::Dirichlet > pybind11_init_smtk_mesh_Dirichlet(py::module &m, PySharedPtrClass< smtk::mesh::IntegerTag >& parent) +inline PySharedPtrClass< smtk::mesh::Dirichlet > pybind11_init_smtk_mesh_Dirichlet(py::module &m, PySharedPtrClass< smtk::mesh::IntegerTag >& parent) { PySharedPtrClass< smtk::mesh::Dirichlet > instance(m, "Dirichlet", parent); instance @@ -36,7 +36,7 @@ PySharedPtrClass< smtk::mesh::Dirichlet > pybind11_init_smtk_mesh_Dirichlet(py:: return instance; } -PySharedPtrClass< smtk::mesh::Domain > pybind11_init_smtk_mesh_Domain(py::module &m, PySharedPtrClass< smtk::mesh::IntegerTag >& parent) +inline PySharedPtrClass< smtk::mesh::Domain > pybind11_init_smtk_mesh_Domain(py::module &m, PySharedPtrClass< smtk::mesh::IntegerTag >& parent) { PySharedPtrClass< smtk::mesh::Domain > instance(m, "Domain", parent); instance @@ -47,7 +47,7 @@ PySharedPtrClass< smtk::mesh::Domain > pybind11_init_smtk_mesh_Domain(py::module return instance; } -PySharedPtrClass< smtk::mesh::IntegerTag > pybind11_init_smtk_mesh_IntegerTag(py::module &m) +inline PySharedPtrClass< smtk::mesh::IntegerTag > pybind11_init_smtk_mesh_IntegerTag(py::module &m) { PySharedPtrClass< smtk::mesh::IntegerTag > instance(m, "IntegerTag"); instance @@ -62,7 +62,7 @@ PySharedPtrClass< smtk::mesh::IntegerTag > pybind11_init_smtk_mesh_IntegerTag(py return instance; } -PySharedPtrClass< smtk::mesh::Model > pybind11_init_smtk_mesh_Model(py::module &m, PySharedPtrClass< smtk::mesh::UUIDTag >& parent) +inline PySharedPtrClass< smtk::mesh::Model > pybind11_init_smtk_mesh_Model(py::module &m, PySharedPtrClass< smtk::mesh::UUIDTag >& parent) { PySharedPtrClass< smtk::mesh::Model > instance(m, "Model", parent); instance @@ -73,7 +73,7 @@ PySharedPtrClass< smtk::mesh::Model > pybind11_init_smtk_mesh_Model(py::module & return instance; } -PySharedPtrClass< smtk::mesh::Neumann > pybind11_init_smtk_mesh_Neumann(py::module &m, PySharedPtrClass< smtk::mesh::IntegerTag >& parent) +inline PySharedPtrClass< smtk::mesh::Neumann > pybind11_init_smtk_mesh_Neumann(py::module &m, PySharedPtrClass< smtk::mesh::IntegerTag >& parent) { PySharedPtrClass< smtk::mesh::Neumann > instance(m, "Neumann", parent); instance @@ -84,7 +84,7 @@ PySharedPtrClass< smtk::mesh::Neumann > pybind11_init_smtk_mesh_Neumann(py::modu return instance; } -PySharedPtrClass< smtk::mesh::OpaqueTag<16> > pybind11_init_smtk_mesh_OpaqueTag_16_(py::module &m) +inline PySharedPtrClass< smtk::mesh::OpaqueTag<16> > pybind11_init_smtk_mesh_OpaqueTag_16_(py::module &m) { PySharedPtrClass< smtk::mesh::OpaqueTag<16> > instance(m, "OpaqueTag_16_"); instance @@ -100,7 +100,7 @@ PySharedPtrClass< smtk::mesh::OpaqueTag<16> > pybind11_init_smtk_mesh_OpaqueTag_ return instance; } -PySharedPtrClass< smtk::mesh::UUIDTag > pybind11_init_smtk_mesh_UUIDTag(py::module &m, PySharedPtrClass< smtk::mesh::OpaqueTag<16> >& parent) +inline PySharedPtrClass< smtk::mesh::UUIDTag > pybind11_init_smtk_mesh_UUIDTag(py::module &m, PySharedPtrClass< smtk::mesh::OpaqueTag<16> >& parent) { PySharedPtrClass< smtk::mesh::UUIDTag > instance(m, "UUIDTag", parent); instance diff --git a/smtk/mesh/pybind11/PybindRead.h b/smtk/mesh/pybind11/PybindRead.h index 3a4118b797d20ae399b58d300ba37608d9fa721a..cd402f3f164c40d091ab919f93b820bfc39ea683 100644 --- a/smtk/mesh/pybind11/PybindRead.h +++ b/smtk/mesh/pybind11/PybindRead.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::Read, smtk::operation::XMLOperation > pybind11_init_smtk_mesh_Read(py::module &m) +inline PySharedPtrClass< smtk::mesh::Read, smtk::operation::XMLOperation > pybind11_init_smtk_mesh_Read(py::module &m) { PySharedPtrClass< smtk::mesh::Read, smtk::operation::XMLOperation > instance(m, "Read"); instance diff --git a/smtk/mesh/pybind11/PybindReclassify.h b/smtk/mesh/pybind11/PybindReclassify.h index 404eb8563c5bb56f8859414556f099b098df7460..f51379c4165ae67e0aedb7b563cfe266886cbe2f 100644 --- a/smtk/mesh/pybind11/PybindReclassify.h +++ b/smtk/mesh/pybind11/PybindReclassify.h @@ -17,22 +17,22 @@ namespace py = pybind11; -void pybind11_init_smtk_mesh_split(py::module &m) +inline void pybind11_init_smtk_mesh_split(py::module &m) { m.def("split", &smtk::mesh::utility::split, "", py::arg("arg0"), py::arg("orignalEdge"), py::arg("newEdge"), py::arg("promotedVertex")); } -void pybind11_init_smtk_mesh_merge(py::module &m) +inline void pybind11_init_smtk_mesh_merge(py::module &m) { m.def("merge", &smtk::mesh::utility::merge, "", py::arg("arg0"), py::arg("toRemoveVert"), py::arg("toRemoveEdge"), py::arg("toAddTo")); } -void pybind11_init_smtk_mesh_make_disjoint(py::module &m) +inline void pybind11_init_smtk_mesh_make_disjoint(py::module &m) { m.def("make_disjoint", &smtk::mesh::utility::make_disjoint, "", py::arg("arg0"), py::arg("a"), py::arg("b"), py::arg("modelAssoc")); } -void pybind11_init_smtk_mesh_fuse(py::module &m) +inline void pybind11_init_smtk_mesh_fuse(py::module &m) { m.def("fuse", &smtk::mesh::utility::fuse, "", py::arg("arg0"), py::arg("toRemove"), py::arg("toAddTo"), py::arg("assoc")); } diff --git a/smtk/mesh/pybind11/PybindRegistrar.h b/smtk/mesh/pybind11/PybindRegistrar.h index b786dff0ae8c8ebee382e4b64e0ff1822dc3d23a..9caf211d489105d07ab6e2598b982285015c1b97 100644 --- a/smtk/mesh/pybind11/PybindRegistrar.h +++ b/smtk/mesh/pybind11/PybindRegistrar.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::mesh::Registrar > pybind11_init_smtk_mesh_Registrar(py::module &m) +inline py::class_< smtk::mesh::Registrar > pybind11_init_smtk_mesh_Registrar(py::module &m) { py::class_< smtk::mesh::Registrar > instance(m, "Registrar"); instance diff --git a/smtk/mesh/pybind11/PybindResource.h b/smtk/mesh/pybind11/PybindResource.h index 4587555901f2ce368b762c3e34d600cd60f544a0..72b025e8a284a17e98359216d7ac823ed79ae949 100644 --- a/smtk/mesh/pybind11/PybindResource.h +++ b/smtk/mesh/pybind11/PybindResource.h @@ -22,7 +22,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::Resource> pybind11_init_smtk_mesh_Resource(py::module &m) +inline PySharedPtrClass< smtk::mesh::Resource> pybind11_init_smtk_mesh_Resource(py::module &m) { PySharedPtrClass< smtk::mesh::Resource, smtk::resource::Resource > instance(m, "Resource"); instance diff --git a/smtk/mesh/pybind11/PybindSelection.h b/smtk/mesh/pybind11/PybindSelection.h index 09cf54b90132825b0de73af149ebda52a0c0fab4..9e27d6c560f7486eafc2bdcc8e5cfa0a5f0b6cfe 100644 --- a/smtk/mesh/pybind11/PybindSelection.h +++ b/smtk/mesh/pybind11/PybindSelection.h @@ -20,7 +20,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::Selection, smtk::mesh::Component > pybind11_init_smtk_mesh_Selection(py::module &m) +inline PySharedPtrClass< smtk::mesh::Selection, smtk::mesh::Component > pybind11_init_smtk_mesh_Selection(py::module &m) { PySharedPtrClass< smtk::mesh::Selection, smtk::mesh::Component > instance(m, "Selection"); instance diff --git a/smtk/mesh/pybind11/PybindStructuredGrid.h b/smtk/mesh/pybind11/PybindStructuredGrid.h index b447cefa78cf806b96bb312be3d69f53819bb185..731928cc49763a3e6dd34211ecb9b639cb21688a 100644 --- a/smtk/mesh/pybind11/PybindStructuredGrid.h +++ b/smtk/mesh/pybind11/PybindStructuredGrid.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::mesh::StructuredGrid > pybind11_init_smtk_mesh_StructuredGrid(py::module &m) +inline py::class_< smtk::mesh::StructuredGrid > pybind11_init_smtk_mesh_StructuredGrid(py::module &m) { py::class_< smtk::mesh::StructuredGrid > instance(m, "StructuredGrid"); instance diff --git a/smtk/mesh/pybind11/PybindStructuredGridGenerator.h b/smtk/mesh/pybind11/PybindStructuredGridGenerator.h index 0855301697c7064fef5f2dc19413cb7df59362f1..d32364b5e183198eb7c91988b9b6d534f1ad8996 100644 --- a/smtk/mesh/pybind11/PybindStructuredGridGenerator.h +++ b/smtk/mesh/pybind11/PybindStructuredGridGenerator.h @@ -18,7 +18,7 @@ namespace py = pybind11; -py::class_ pybind11_init_smtk_mesh_StructuredGridGenerator(py::module &m) +inline py::class_ pybind11_init_smtk_mesh_StructuredGridGenerator(py::module &m) { py::class_ instance(m, "StructuredGridGenerator"); instance diff --git a/smtk/mesh/pybind11/PybindTypeSet.h b/smtk/mesh/pybind11/PybindTypeSet.h index 36459565bd74737c8de27f1fe3030fb91b61829f..371b03f5c0cc981884a1da5cbf622720646eee2b 100644 --- a/smtk/mesh/pybind11/PybindTypeSet.h +++ b/smtk/mesh/pybind11/PybindTypeSet.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::TypeSet > pybind11_init_smtk_mesh_TypeSet(py::module &m) +inline PySharedPtrClass< smtk::mesh::TypeSet > pybind11_init_smtk_mesh_TypeSet(py::module &m) { PySharedPtrClass< smtk::mesh::TypeSet > instance(m, "TypeSet"); instance diff --git a/smtk/mesh/pybind11/PybindWrite.h b/smtk/mesh/pybind11/PybindWrite.h index f2f56370182b4c10cb8e20090439fc2f43758f07..83c6259021bb602afa9c75970aeedd7a064bade2 100644 --- a/smtk/mesh/pybind11/PybindWrite.h +++ b/smtk/mesh/pybind11/PybindWrite.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::mesh::Write, smtk::operation::XMLOperation > pybind11_init_smtk_mesh_Write(py::module &m) +inline PySharedPtrClass< smtk::mesh::Write, smtk::operation::XMLOperation > pybind11_init_smtk_mesh_Write(py::module &m) { PySharedPtrClass< smtk::mesh::Write, smtk::operation::XMLOperation > instance(m, "Write"); instance diff --git a/smtk/mesh/resource/Registrar.cxx b/smtk/mesh/resource/Registrar.cxx index 2314ba1bbfe25ed8580e006038d04b2aaedfd038..fb3da56bc40cc4f538d98b266d57d28965a8e67d 100644 --- a/smtk/mesh/resource/Registrar.cxx +++ b/smtk/mesh/resource/Registrar.cxx @@ -41,6 +41,7 @@ #include "smtk/operation/groups/ExporterGroup.h" #include "smtk/operation/groups/ImporterGroup.h" #include "smtk/operation/groups/InternalGroup.h" +#include "smtk/operation/groups/NamingGroup.h" #include "smtk/operation/groups/ReaderGroup.h" #include "smtk/operation/groups/WriterGroup.h" @@ -92,6 +93,9 @@ void Registrar::registerTo(const smtk::operation::Manager::Ptr& operationManager smtk::operation::DeleterGroup(operationManager).registerOperation(); + smtk::operation::NamingGroup(operationManager) + .registerOperation(); + smtk::operation::InternalGroup(operationManager).registerOperation(); } diff --git a/smtk/mesh/utility/ExtractMeshConstants.h b/smtk/mesh/utility/ExtractMeshConstants.h index 54a77e8a3ea601de6694b72f0fc2ebf8054a8ddc..d3ed4e0f4211738a296dca17361ea022bdda7496 100644 --- a/smtk/mesh/utility/ExtractMeshConstants.h +++ b/smtk/mesh/utility/ExtractMeshConstants.h @@ -107,6 +107,7 @@ SMTKCORE_EXPORT void extractDomainMeshConstants( PreAllocatedMeshConstants&); template +// NOLINTNEXTLINE(readability-redundant-declaration) SMTKCORE_EXPORT void extractMeshConstants( const smtk::mesh::MeshSet&, const smtk::mesh::PointSet&, diff --git a/smtk/mesh/utility/ExtractTessellation.cxx b/smtk/mesh/utility/ExtractTessellation.cxx index 15f073423b525cde329876e58f0e8504574ca479..3e6238b0b3a6019e6d22ebb53f3e1fa0311430e5 100644 --- a/smtk/mesh/utility/ExtractTessellation.cxx +++ b/smtk/mesh/utility/ExtractTessellation.cxx @@ -240,11 +240,7 @@ PreAllocatedTessellation::PreAllocatedTessellation( { } -Tessellation::Tessellation() - : m_useVTKConnectivity(true) - , m_useVTKCellTypes(true) -{ -} +Tessellation::Tessellation() = default; Tessellation::Tessellation(bool useVTKConnectivity, bool useVTKCellTypes) : m_useVTKConnectivity(useVTKConnectivity) diff --git a/smtk/mesh/utility/ExtractTessellation.h b/smtk/mesh/utility/ExtractTessellation.h index a7d1bf8f510cb58fdd95e1752e3aa8673ac4f7ad..12f9f0fadec213365b4c8339b15c17c4b2f80a47 100644 --- a/smtk/mesh/utility/ExtractTessellation.h +++ b/smtk/mesh/utility/ExtractTessellation.h @@ -162,8 +162,8 @@ private: std::vector m_points; - bool m_useVTKConnectivity; - bool m_useVTKCellTypes; + bool m_useVTKConnectivity{ true }; + bool m_useVTKCellTypes{ true }; }; //Don't wrap these for python, instead python should use the Tessellation class diff --git a/smtk/model/Arrangement.h b/smtk/model/Arrangement.h index 534e899dd0c2d46c6b46175645fad5343834406c..54a1ca8b8ae8350b09735cf09096bacbe8a54449 100644 --- a/smtk/model/Arrangement.h +++ b/smtk/model/Arrangement.h @@ -152,11 +152,7 @@ public: { } /// Construct an invalid reference. - ArrangementReference() - : kind(KINDS_OF_ARRANGEMENTS) - , index(-1) - { - } + ArrangementReference() = default; /// Indicate whether a reference is valid or not: bool isValid() const @@ -165,8 +161,8 @@ public: } smtk::common::UUID entityId; //!< The ID of the entity on which the arrangement is defined. - ArrangementKind kind; //!< The kind of the arrangement. - int index; //!< The index of the arrangement. + ArrangementKind kind{ KINDS_OF_ARRANGEMENTS }; //!< The kind of the arrangement. + int index{ -1 }; //!< The index of the arrangement. }; /// A vector of Arrangements is associated to each Manager entity. diff --git a/smtk/model/Entity.cxx b/smtk/model/Entity.cxx index b81dfbca6bdbc44ccf62be6ce1b14b242c44f6b5..0c40c5ac91405227f2f37097c3cd13d0da25b191 100644 --- a/smtk/model/Entity.cxx +++ b/smtk/model/Entity.cxx @@ -91,9 +91,7 @@ static const char* entityTypeNames[] = { "cell", "use", "shell", "gro /// The default constructor creates an invalid link. Entity::Entity() - : m_entityFlags(INVALID) - , m_firstInvalid(-1) - , m_id(smtk::common::UUIDGenerator::instance().random()) + : m_id(smtk::common::UUIDGenerator::instance().random()) { } diff --git a/smtk/model/Entity.h b/smtk/model/Entity.h index 6f5a51a7c01589a3d51e12da5a3f5f674e0b1bce..f9fdf08b43b9c67127f6e67f0a99995af7deb516 100644 --- a/smtk/model/Entity.h +++ b/smtk/model/Entity.h @@ -177,11 +177,11 @@ protected: Entity(); int consumeInvalidIndex(const smtk::common::UUID& uid); - BitFlags m_entityFlags; + BitFlags m_entityFlags{ INVALID }; smtk::common::UUIDArray m_relations; smtk::model::WeakResourcePtr m_resource; KindsToArrangements m_arrangements; - int m_firstInvalid; + int m_firstInvalid{ -1 }; smtk::common::UUID m_id; }; diff --git a/smtk/model/EntityRef.cxx b/smtk/model/EntityRef.cxx index 021dc14cdaec1fe7bf2c77ab0eadd62d95884f00..5a6cd3b70fb1090398351fd50d74ab821c7f6d1e 100644 --- a/smtk/model/EntityRef.cxx +++ b/smtk/model/EntityRef.cxx @@ -1588,8 +1588,9 @@ EntityRef& EntityRef::embedEntity(const EntityRef& thingToEmbed, bool checkExist } else { - EntityRefArrangementOps::addSimpleRelationship(*this, INCLUDES, thingToEmbed); - EntityRefArrangementOps::addSimpleRelationship(thingToEmbed, EMBEDDED_IN, *this); + EntityRefArrangementOps::addSimpleRelationship(*this, INCLUDES, thingToEmbed, checkExistence); + EntityRefArrangementOps::addSimpleRelationship( + thingToEmbed, EMBEDDED_IN, *this, checkExistence); } rsrc->trigger(event, *this, thingToEmbed); } diff --git a/smtk/model/EntityRefArrangementOps.cxx b/smtk/model/EntityRefArrangementOps.cxx index 38104b5d331a2848f0d36662ab25bceff9218b6b..fb9937f8737c2751d06047f8d7f92215b439a231 100644 --- a/smtk/model/EntityRefArrangementOps.cxx +++ b/smtk/model/EntityRefArrangementOps.cxx @@ -63,13 +63,14 @@ int EntityRefArrangementOps::findOrAddSimpleRelationship( int EntityRefArrangementOps::addSimpleRelationship( const EntityRef& a, ArrangementKind k, - const EntityRef& b) + const EntityRef& b, + bool find) { int relidx = -1; EntityPtr ent = a.resource()->findEntity(a.entity()); if (ent) { - int offset = ent->findOrAppendRelation(b.entity()); + int offset = find ? ent->findOrAppendRelation(b.entity()) : ent->appendRelation(b.entity()); relidx = a.resource()->arrangeEntity(a.entity(), k, Arrangement::SimpleIndex(offset)); } return relidx; diff --git a/smtk/model/EntityRefArrangementOps.h b/smtk/model/EntityRefArrangementOps.h index 1ef9395193e0e049dae2b165a269584f2da32b42..83ff2d6b6ec946d415d130baeba72cf73aa45c42 100644 --- a/smtk/model/EntityRefArrangementOps.h +++ b/smtk/model/EntityRefArrangementOps.h @@ -26,7 +26,11 @@ class SMTKCORE_EXPORT EntityRefArrangementOps public: static int findSimpleRelationship(const EntityRef& a, ArrangementKind k, const EntityRef& b); static int findOrAddSimpleRelationship(const EntityRef& a, ArrangementKind k, const EntityRef& b); - static int addSimpleRelationship(const EntityRef& a, ArrangementKind k, const EntityRef& b); + static int addSimpleRelationship( + const EntityRef& a, + ArrangementKind k, + const EntityRef& b, + bool find = true); /// Return the first relation of kind \a k as the specified entityref type \a T. template diff --git a/smtk/model/GridInfo.h b/smtk/model/GridInfo.h index d09b963d947d1874257f5c20643ff17ba06e97b0..9915cea5e2d977e87f578886ca1f9c1f0f22bc4e 100644 --- a/smtk/model/GridInfo.h +++ b/smtk/model/GridInfo.h @@ -52,12 +52,9 @@ public: { ApiReturnType returnType; std::string errorMessage; - smtk::io::Logger* logger; + smtk::io::Logger* logger{ nullptr }; - ApiStatus() - : logger(0) - { - } + ApiStatus() = default; }; /// Enum for specifying point set closure. diff --git a/smtk/model/LimitingClause.h b/smtk/model/LimitingClause.h index 5b1631535857752a59a3f8b849a836972dfaf8df..5a7cd59f928dfdd3e997264afe9a2952d8082c74 100644 --- a/smtk/model/LimitingClause.h +++ b/smtk/model/LimitingClause.h @@ -30,12 +30,9 @@ namespace model */ struct SMTKCORE_EXPORT LimitingClause { - LimitingClause() - : m_propType(smtk::resource::PropertyType::INVALID_PROPERTY) - { - } + LimitingClause() = default; - smtk::resource::PropertyType m_propType; + smtk::resource::PropertyType m_propType{ smtk::resource::PropertyType::INVALID_PROPERTY }; std::string m_propName; bool m_propNameIsRegex{ false }; std::vector m_propStringValues; diff --git a/smtk/model/PointLocatorExtension.h b/smtk/model/PointLocatorExtension.h index d2ce7a6e454a4b40b7bc2a545b7add99d2028da1..eb6a0d010466a62c845571d9ff240c5e4bc5e67a 100644 --- a/smtk/model/PointLocatorExtension.h +++ b/smtk/model/PointLocatorExtension.h @@ -48,7 +48,7 @@ public: const EntityRef& entity, std::size_t nPoints, std::vector& points, - const std::size_t seed) = 0; + std::size_t seed) = 0; /// Same as above, but seeded with a hardware-supplied random integer. bool randomPoint(const EntityRef& entity, std::size_t nPoints, std::vector& points); diff --git a/smtk/model/Session.cxx b/smtk/model/Session.cxx index ad9e070a16659e58d7ba5261c26a60d44b601f9b..cb404052aa4f4bb196a445d2106e921ee7887c99 100644 --- a/smtk/model/Session.cxx +++ b/smtk/model/Session.cxx @@ -41,7 +41,6 @@ namespace model /// Default constructor. This assigns a random session ID to each Session instance. Session::Session() : m_sessionId(smtk::common::UUID::random()) - , m_resource(nullptr) { } diff --git a/smtk/model/Session.h b/smtk/model/Session.h index b6d79d986145b75047c4f8834ab564ce1e7babe7..b5288986cd85872f4d6b6daf457f0fc42b7e3df6 100644 --- a/smtk/model/Session.h +++ b/smtk/model/Session.h @@ -237,7 +237,7 @@ protected: DanglingEntities m_dangling; smtk::common::UUID m_sessionId; - Resource* m_resource; + Resource* m_resource{ nullptr }; }; } // namespace model diff --git a/smtk/model/pybind11/PybindAddAuxiliaryGeometry.h b/smtk/model/pybind11/PybindAddAuxiliaryGeometry.h index 864a0fcf623f17b42c43411285713a791c7a1c1b..35c0d26f8bb208140a9d050fa3c566f844955022 100644 --- a/smtk/model/pybind11/PybindAddAuxiliaryGeometry.h +++ b/smtk/model/pybind11/PybindAddAuxiliaryGeometry.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::model::AddAuxiliaryGeometry, smtk::operation::XMLOperation > pybind11_init_smtk_model_AddAuxiliaryGeometry(py::module &m) +inline PySharedPtrClass< smtk::model::AddAuxiliaryGeometry, smtk::operation::XMLOperation > pybind11_init_smtk_model_AddAuxiliaryGeometry(py::module &m) { PySharedPtrClass< smtk::model::AddAuxiliaryGeometry, smtk::operation::XMLOperation > instance(m, "AddAuxiliaryGeometry"); instance diff --git a/smtk/model/pybind11/PybindArrangement.h b/smtk/model/pybind11/PybindArrangement.h index 398bbdb049baffb26330fceba76cf8d841d63c1e..aa2ae8795be07608b066286915696dd5c9e6ef42 100644 --- a/smtk/model/pybind11/PybindArrangement.h +++ b/smtk/model/pybind11/PybindArrangement.h @@ -23,7 +23,7 @@ namespace py = pybind11; -py::class_< smtk::model::Arrangement > pybind11_init_smtk_model_Arrangement(py::module &m) +inline py::class_< smtk::model::Arrangement > pybind11_init_smtk_model_Arrangement(py::module &m) { py::class_< smtk::model::Arrangement > instance(m, "Arrangement"); instance @@ -71,7 +71,7 @@ py::class_< smtk::model::Arrangement > pybind11_init_smtk_model_Arrangement(py:: return instance; } -py::class_< smtk::model::ArrangementReference > pybind11_init_smtk_model_ArrangementReference(py::module &m) +inline py::class_< smtk::model::ArrangementReference > pybind11_init_smtk_model_ArrangementReference(py::module &m) { py::class_< smtk::model::ArrangementReference > instance(m, "ArrangementReference"); instance diff --git a/smtk/model/pybind11/PybindArrangementHelper.h b/smtk/model/pybind11/PybindArrangementHelper.h index b3ffe3acc751e955771dd8ed86c5dfc0e5611b0c..72a5f3a04acdc6b14c43a0c0eb3edf0123b0879f 100644 --- a/smtk/model/pybind11/PybindArrangementHelper.h +++ b/smtk/model/pybind11/PybindArrangementHelper.h @@ -20,7 +20,7 @@ namespace py = pybind11; -py::class_< smtk::model::ArrangementHelper > pybind11_init_smtk_model_ArrangementHelper(py::module &m) +inline py::class_< smtk::model::ArrangementHelper > pybind11_init_smtk_model_ArrangementHelper(py::module &m) { py::class_< smtk::model::ArrangementHelper > instance(m, "ArrangementHelper"); instance diff --git a/smtk/model/pybind11/PybindArrangementKind.h b/smtk/model/pybind11/PybindArrangementKind.h index 18900efb4f002ba34a980ea5a172b037949cfa0b..e5586b82c4277a8c882b9694e63a204cad8a75dd 100644 --- a/smtk/model/pybind11/PybindArrangementKind.h +++ b/smtk/model/pybind11/PybindArrangementKind.h @@ -19,7 +19,7 @@ namespace py = pybind11; -void pybind11_init_smtk_model_Orientation(py::module &m) +inline void pybind11_init_smtk_model_Orientation(py::module &m) { py::enum_(m, "Orientation") .value("NEGATIVE", smtk::model::Orientation::NEGATIVE) @@ -28,7 +28,7 @@ void pybind11_init_smtk_model_Orientation(py::module &m) .export_values(); } -void pybind11_init_smtk_model_ArrangementKind(py::module &m) +inline void pybind11_init_smtk_model_ArrangementKind(py::module &m) { py::enum_(m, "ArrangementKind") .value("INCLUDES", smtk::model::ArrangementKind::INCLUDES) @@ -44,27 +44,27 @@ void pybind11_init_smtk_model_ArrangementKind(py::module &m) .export_values(); } -void pybind11_init_smtk_model_ArrangementKindFromName(py::module &m) +inline void pybind11_init_smtk_model_ArrangementKindFromName(py::module &m) { m.def("ArrangementKindFromName", &smtk::model::ArrangementKindFromName, "", py::arg("name")); } -void pybind11_init_smtk_model_NameForArrangementKind(py::module &m) +inline void pybind11_init_smtk_model_NameForArrangementKind(py::module &m) { m.def("NameForArrangementKind", &smtk::model::NameForArrangementKind, "", py::arg("k")); } -void pybind11_init_smtk_model_ArrangementKindFromAbbreviation(py::module &m) +inline void pybind11_init_smtk_model_ArrangementKindFromAbbreviation(py::module &m) { m.def("ArrangementKindFromAbbreviation", &smtk::model::ArrangementKindFromAbbreviation, "", py::arg("abbr")); } -void pybind11_init_smtk_model_AbbreviationForArrangementKind(py::module &m) +inline void pybind11_init_smtk_model_AbbreviationForArrangementKind(py::module &m) { m.def("AbbreviationForArrangementKind", &smtk::model::AbbreviationForArrangementKind, "", py::arg("k")); } -void pybind11_init_smtk_model_Dual(py::module &m) +inline void pybind11_init_smtk_model_Dual(py::module &m) { m.def("Dual", &smtk::model::Dual, "", py::arg("entType"), py::arg("k")); } diff --git a/smtk/model/pybind11/PybindAttributeAssignments.h b/smtk/model/pybind11/PybindAttributeAssignments.h index 461c27026d9fba4ebe685236bae7d903319d0748..55a270b2a92b87dc293e6c83d2f9306bb1dd7e84 100644 --- a/smtk/model/pybind11/PybindAttributeAssignments.h +++ b/smtk/model/pybind11/PybindAttributeAssignments.h @@ -20,7 +20,7 @@ namespace py = pybind11; -py::class_< smtk::model::AttributeAssignments > pybind11_init_smtk_model_AttributeAssignments(py::module &m) +inline py::class_< smtk::model::AttributeAssignments > pybind11_init_smtk_model_AttributeAssignments(py::module &m) { py::class_< smtk::model::AttributeAssignments > instance(m, "AttributeAssignments"); instance diff --git a/smtk/model/pybind11/PybindAuxiliaryGeometry.h b/smtk/model/pybind11/PybindAuxiliaryGeometry.h index 36ec48fdcdec0c280faf308fbefe9e9b3b264f66..f87d6b04681bce2eb2bacb666eb68e47984e09b1 100644 --- a/smtk/model/pybind11/PybindAuxiliaryGeometry.h +++ b/smtk/model/pybind11/PybindAuxiliaryGeometry.h @@ -23,7 +23,7 @@ namespace py = pybind11; -py::class_< smtk::model::AuxiliaryGeometry, smtk::model::EntityRef > pybind11_init_smtk_model_AuxiliaryGeometry(py::module &m) +inline py::class_< smtk::model::AuxiliaryGeometry, smtk::model::EntityRef > pybind11_init_smtk_model_AuxiliaryGeometry(py::module &m) { py::class_< smtk::model::AuxiliaryGeometry, smtk::model::EntityRef > instance(m, "AuxiliaryGeometry"); instance diff --git a/smtk/model/pybind11/PybindCellEntity.h b/smtk/model/pybind11/PybindCellEntity.h index 53be0d52396dd74cce5dac64113310aa46e98902..21301829bc8f75e3d1b842586e7b773e9709a6d4 100644 --- a/smtk/model/pybind11/PybindCellEntity.h +++ b/smtk/model/pybind11/PybindCellEntity.h @@ -26,7 +26,7 @@ namespace py = pybind11; -py::class_< smtk::model::CellEntity, smtk::model::EntityRef > pybind11_init_smtk_model_CellEntity(py::module &m) +inline py::class_< smtk::model::CellEntity, smtk::model::EntityRef > pybind11_init_smtk_model_CellEntity(py::module &m) { py::class_< smtk::model::CellEntity, smtk::model::EntityRef > instance(m, "CellEntity"); instance diff --git a/smtk/model/pybind11/PybindChain.h b/smtk/model/pybind11/PybindChain.h index b03f4a17e3d6508dda744ade3c6dd5c38995f626..eb87b3b5f74054214fdc310966dbe441a46ff7ac 100644 --- a/smtk/model/pybind11/PybindChain.h +++ b/smtk/model/pybind11/PybindChain.h @@ -25,7 +25,7 @@ namespace py = pybind11; -py::class_< smtk::model::Chain, smtk::model::ShellEntity > pybind11_init_smtk_model_Chain(py::module &m) +inline py::class_< smtk::model::Chain, smtk::model::ShellEntity > pybind11_init_smtk_model_Chain(py::module &m) { py::class_< smtk::model::Chain, smtk::model::ShellEntity > instance(m, "Chain"); instance diff --git a/smtk/model/pybind11/PybindCloseModel.h b/smtk/model/pybind11/PybindCloseModel.h index 9c959e4dd0b0d4b4383aed0cc7448e57859cf9f0..7167f61c1b8e45bdedcda4c864265776e1231643 100644 --- a/smtk/model/pybind11/PybindCloseModel.h +++ b/smtk/model/pybind11/PybindCloseModel.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::model::CloseModel, smtk::operation::XMLOperation > pybind11_init_smtk_model_CloseModel(py::module &m) +inline PySharedPtrClass< smtk::model::CloseModel, smtk::operation::XMLOperation > pybind11_init_smtk_model_CloseModel(py::module &m) { PySharedPtrClass< smtk::model::CloseModel, smtk::operation::XMLOperation > instance(m, "CloseModel"); instance diff --git a/smtk/model/pybind11/PybindCreateInstances.h b/smtk/model/pybind11/PybindCreateInstances.h index a42d452dba9686cda54a75df7668ab3e54fbe2e6..9a5a13291108281a31a3212dff801227d0379eb7 100644 --- a/smtk/model/pybind11/PybindCreateInstances.h +++ b/smtk/model/pybind11/PybindCreateInstances.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::model::CreateInstances, smtk::operation::XMLOperation > pybind11_init_smtk_model_CreateInstances(py::module &m) +inline PySharedPtrClass< smtk::model::CreateInstances, smtk::operation::XMLOperation > pybind11_init_smtk_model_CreateInstances(py::module &m) { PySharedPtrClass< smtk::model::CreateInstances, smtk::operation::XMLOperation > instance(m, "CreateInstances"); instance diff --git a/smtk/model/pybind11/PybindDefaultSession.h b/smtk/model/pybind11/PybindDefaultSession.h index 246b1a9eeba3f2d7ae6381676dd829de769a2aa0..4048d96b410179fc46146edfde546ee401a92929 100644 --- a/smtk/model/pybind11/PybindDefaultSession.h +++ b/smtk/model/pybind11/PybindDefaultSession.h @@ -21,7 +21,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::model::DefaultSession, smtk::model::Session > pybind11_init_smtk_model_DefaultSession(py::module &m) +inline PySharedPtrClass< smtk::model::DefaultSession, smtk::model::Session > pybind11_init_smtk_model_DefaultSession(py::module &m) { PySharedPtrClass< smtk::model::DefaultSession, smtk::model::Session > instance(m, "DefaultSession"); instance diff --git a/smtk/model/pybind11/PybindDelete.h b/smtk/model/pybind11/PybindDelete.h index e4942a5721d605bcbb99eef19f1d95c04459d8dc..21922018b34b6f3dfebb123173b6f39919c8173f 100644 --- a/smtk/model/pybind11/PybindDelete.h +++ b/smtk/model/pybind11/PybindDelete.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::model::Delete, smtk::operation::XMLOperation > pybind11_init_smtk_model_Delete(py::module &m) +inline PySharedPtrClass< smtk::model::Delete, smtk::operation::XMLOperation > pybind11_init_smtk_model_Delete(py::module &m) { PySharedPtrClass< smtk::model::Delete, smtk::operation::XMLOperation > instance(m, "Delete"); instance diff --git a/smtk/model/pybind11/PybindEdge.h b/smtk/model/pybind11/PybindEdge.h index 86da7e96477a52e9df93995a89ace88eccaab23e..aa17619a6080d257969eaf3d614ea452bce6de16 100644 --- a/smtk/model/pybind11/PybindEdge.h +++ b/smtk/model/pybind11/PybindEdge.h @@ -25,7 +25,7 @@ namespace py = pybind11; -py::class_< smtk::model::Edge, smtk::model::CellEntity > pybind11_init_smtk_model_Edge(py::module &m) +inline py::class_< smtk::model::Edge, smtk::model::CellEntity > pybind11_init_smtk_model_Edge(py::module &m) { py::class_< smtk::model::Edge, smtk::model::CellEntity > instance(m, "Edge"); instance diff --git a/smtk/model/pybind11/PybindEdgeUse.h b/smtk/model/pybind11/PybindEdgeUse.h index 2ee40f3e90db0c1d75b921d2916bd18633c9d333..1501206c64852a9f1d945453bd2fc1ee40584dd6 100644 --- a/smtk/model/pybind11/PybindEdgeUse.h +++ b/smtk/model/pybind11/PybindEdgeUse.h @@ -27,7 +27,7 @@ namespace py = pybind11; -py::class_< smtk::model::EdgeUse, smtk::model::UseEntity > pybind11_init_smtk_model_EdgeUse(py::module &m) +inline py::class_< smtk::model::EdgeUse, smtk::model::UseEntity > pybind11_init_smtk_model_EdgeUse(py::module &m) { py::class_< smtk::model::EdgeUse, smtk::model::UseEntity > instance(m, "EdgeUse"); instance diff --git a/smtk/model/pybind11/PybindEntity.h b/smtk/model/pybind11/PybindEntity.h index ae433e349006d9cb2750bc02ae4c6799fdef49bc..9091342d4d2041f716aa237a5a233440ad1abb51 100644 --- a/smtk/model/pybind11/PybindEntity.h +++ b/smtk/model/pybind11/PybindEntity.h @@ -23,7 +23,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::model::Entity, smtk::resource::Component > pybind11_init_smtk_model_Entity(py::module &m) +inline PySharedPtrClass< smtk::model::Entity, smtk::resource::Component > pybind11_init_smtk_model_Entity(py::module &m) { PySharedPtrClass< smtk::model::Entity, smtk::resource::Component > instance(m, "Entity"); instance diff --git a/smtk/model/pybind11/PybindEntityIterator.h b/smtk/model/pybind11/PybindEntityIterator.h index 53b89e29e670d3fd679d2186fb9f69d23dddb1ba..af47305dbb7318a41579f4ee9abfcdcd4889873b 100644 --- a/smtk/model/pybind11/PybindEntityIterator.h +++ b/smtk/model/pybind11/PybindEntityIterator.h @@ -19,7 +19,7 @@ namespace py = pybind11; -void pybind11_init_smtk_model_IteratorStyle(py::module &m) +inline void pybind11_init_smtk_model_IteratorStyle(py::module &m) { py::enum_(m, "IteratorStyle") .value("ITERATE_BARE", smtk::model::IteratorStyle::ITERATE_BARE) @@ -28,7 +28,7 @@ void pybind11_init_smtk_model_IteratorStyle(py::module &m) .export_values(); } -py::class_< smtk::model::EntityIterator > pybind11_init_smtk_model_EntityIterator(py::module &m) +inline py::class_< smtk::model::EntityIterator > pybind11_init_smtk_model_EntityIterator(py::module &m) { py::class_< smtk::model::EntityIterator > instance(m, "EntityIterator"); instance diff --git a/smtk/model/pybind11/PybindEntityRef.h b/smtk/model/pybind11/PybindEntityRef.h index b46ddd3063324e59e218e76bf9910294fc2215fd..513fe0da3c21ea6d1c36ed65b44e2be554793daf 100644 --- a/smtk/model/pybind11/PybindEntityRef.h +++ b/smtk/model/pybind11/PybindEntityRef.h @@ -30,7 +30,7 @@ #include "smtk/model/Tessellation.h" namespace py = pybind11; -void pybind11_init_smtk_model_Exclusions(py::module &m) +inline void pybind11_init_smtk_model_Exclusions(py::module &m) { py::enum_(m, "Exclusions") .value("Nothing", smtk::model::Exclusions::Nothing) @@ -40,7 +40,7 @@ void pybind11_init_smtk_model_Exclusions(py::module &m) .export_values(); } -py::class_< smtk::model::EntityRef > pybind11_init_smtk_model_EntityRef(py::module &m) +inline py::class_< smtk::model::EntityRef > pybind11_init_smtk_model_EntityRef(py::module &m) { py::class_< smtk::model::EntityRef > instance(m, "EntityRef"); instance @@ -177,7 +177,7 @@ py::class_< smtk::model::EntityRef > pybind11_init_smtk_model_EntityRef(py::modu return instance; } -void pybind11_init_smtk_model_entityrefHash(py::module &m) +inline void pybind11_init_smtk_model_entityrefHash(py::module &m) { m.def("entityrefHash", &smtk::model::entityrefHash, "", py::arg("c")); } diff --git a/smtk/model/pybind11/PybindEntityRefArrangementOps.h b/smtk/model/pybind11/PybindEntityRefArrangementOps.h index 20887b10fba673a4645b03e12c761a346ad1ee9f..b84785c824fd9f8ce8650c4d125134e69bbc07e6 100644 --- a/smtk/model/pybind11/PybindEntityRefArrangementOps.h +++ b/smtk/model/pybind11/PybindEntityRefArrangementOps.h @@ -20,7 +20,7 @@ namespace py = pybind11; -py::class_< smtk::model::EntityRefArrangementOps > pybind11_init_smtk_model_EntityRefArrangementOps(py::module &m) +inline py::class_< smtk::model::EntityRefArrangementOps > pybind11_init_smtk_model_EntityRefArrangementOps(py::module &m) { py::class_< smtk::model::EntityRefArrangementOps > instance(m, "EntityRefArrangementOps"); instance diff --git a/smtk/model/pybind11/PybindEntityTypeBits.h b/smtk/model/pybind11/PybindEntityTypeBits.h index ff7464a1641d86847df7def0b650b843fb8248ef..7153fb33b51a5179309984124a0774968d733bf6 100644 --- a/smtk/model/pybind11/PybindEntityTypeBits.h +++ b/smtk/model/pybind11/PybindEntityTypeBits.h @@ -17,7 +17,7 @@ namespace py = pybind11; -void pybind11_init_smtk_model_EntityTypeBits(py::module &m) +inline void pybind11_init_smtk_model_EntityTypeBits(py::module &m) { py::enum_(m, "EntityTypeBits") .value("DIMENSION_0", smtk::model::EntityTypeBits::DIMENSION_0) @@ -93,7 +93,7 @@ void pybind11_init_smtk_model_EntityTypeBits(py::module &m) ; } -void pybind11_init_smtk_model_ModelGeometryStyle(py::module &m) +inline void pybind11_init_smtk_model_ModelGeometryStyle(py::module &m) { py::enum_(m, "ModelGeometryStyle") .value("DISCRETE", smtk::model::ModelGeometryStyle::DISCRETE) @@ -101,112 +101,112 @@ void pybind11_init_smtk_model_ModelGeometryStyle(py::module &m) .export_values(); } -void pybind11_init_smtk_model_isCellEntity(py::module &m) +inline void pybind11_init_smtk_model_isCellEntity(py::module &m) { m.def("isCellEntity", &smtk::model::isCellEntity, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isVertex(py::module &m) +inline void pybind11_init_smtk_model_isVertex(py::module &m) { m.def("isVertex", &smtk::model::isVertex, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isEdge(py::module &m) +inline void pybind11_init_smtk_model_isEdge(py::module &m) { m.def("isEdge", &smtk::model::isEdge, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isFace(py::module &m) +inline void pybind11_init_smtk_model_isFace(py::module &m) { m.def("isFace", &smtk::model::isFace, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isVolume(py::module &m) +inline void pybind11_init_smtk_model_isVolume(py::module &m) { m.def("isVolume", &smtk::model::isVolume, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isUseEntity(py::module &m) +inline void pybind11_init_smtk_model_isUseEntity(py::module &m) { m.def("isUseEntity", &smtk::model::isUseEntity, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isVertexUse(py::module &m) +inline void pybind11_init_smtk_model_isVertexUse(py::module &m) { m.def("isVertexUse", &smtk::model::isVertexUse, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isEdgeUse(py::module &m) +inline void pybind11_init_smtk_model_isEdgeUse(py::module &m) { m.def("isEdgeUse", &smtk::model::isEdgeUse, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isFaceUse(py::module &m) +inline void pybind11_init_smtk_model_isFaceUse(py::module &m) { m.def("isFaceUse", &smtk::model::isFaceUse, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isVolumeUse(py::module &m) +inline void pybind11_init_smtk_model_isVolumeUse(py::module &m) { m.def("isVolumeUse", &smtk::model::isVolumeUse, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isShellEntity(py::module &m) +inline void pybind11_init_smtk_model_isShellEntity(py::module &m) { m.def("isShellEntity", &smtk::model::isShellEntity, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isChain(py::module &m) +inline void pybind11_init_smtk_model_isChain(py::module &m) { m.def("isChain", &smtk::model::isChain, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isLoop(py::module &m) +inline void pybind11_init_smtk_model_isLoop(py::module &m) { m.def("isLoop", &smtk::model::isLoop, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isShell(py::module &m) +inline void pybind11_init_smtk_model_isShell(py::module &m) { m.def("isShell", &smtk::model::isShell, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isGroup(py::module &m) +inline void pybind11_init_smtk_model_isGroup(py::module &m) { m.def("isGroup", &smtk::model::isGroup, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isModel(py::module &m) +inline void pybind11_init_smtk_model_isModel(py::module &m) { m.def("isModel", &smtk::model::isModel, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isInstance(py::module &m) +inline void pybind11_init_smtk_model_isInstance(py::module &m) { m.def("isInstance", &smtk::model::isInstance, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isAuxiliaryGeometry(py::module &m) +inline void pybind11_init_smtk_model_isAuxiliaryGeometry(py::module &m) { m.def("isAuxiliaryGeometry", &smtk::model::isAuxiliaryGeometry, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isConcept(py::module &m) +inline void pybind11_init_smtk_model_isConcept(py::module &m) { m.def("isConcept", &smtk::model::isConcept, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_isSessionRef(py::module &m) +inline void pybind11_init_smtk_model_isSessionRef(py::module &m) { m.def("isSessionRef", &smtk::model::isSessionRef, "", py::arg("entityFlags")); } -void pybind11_init_smtk_model_ModelGeometryStyleName(py::module &m) +inline void pybind11_init_smtk_model_ModelGeometryStyleName(py::module &m) { m.def("ModelGeometryStyleName", &smtk::model::ModelGeometryStyleName, "", py::arg("s")); } -void pybind11_init_smtk_model_NamedModelGeometryStyle(py::module &m) +inline void pybind11_init_smtk_model_NamedModelGeometryStyle(py::module &m) { m.def("NamedModelGeometryStyle", &smtk::model::NamedModelGeometryStyle, "", py::arg("s")); } diff --git a/smtk/model/pybind11/PybindEvents.h b/smtk/model/pybind11/PybindEvents.h index ee5dd09472c94c7cfb45b5811630ef16abd920ab..8c5e77a8ef0b89729710f7eef1401e51283451e0 100644 --- a/smtk/model/pybind11/PybindEvents.h +++ b/smtk/model/pybind11/PybindEvents.h @@ -17,7 +17,7 @@ namespace py = pybind11; -void pybind11_init_smtk_model_ResourceEventChangeType(py::module &m) +inline void pybind11_init_smtk_model_ResourceEventChangeType(py::module &m) { py::enum_(m, "ResourceEventChangeType") .value("ADD_EVENT", smtk::model::ResourceEventChangeType::ADD_EVENT) @@ -27,7 +27,7 @@ void pybind11_init_smtk_model_ResourceEventChangeType(py::module &m) .export_values(); } -void pybind11_init_smtk_model_ResourceEventRelationType(py::module &m) +inline void pybind11_init_smtk_model_ResourceEventRelationType(py::module &m) { py::enum_(m, "ResourceEventRelationType") .value("ENTITY_ENTRY", smtk::model::ResourceEventRelationType::ENTITY_ENTRY) diff --git a/smtk/model/pybind11/PybindExportModelJSON.h b/smtk/model/pybind11/PybindExportModelJSON.h index 84dcf1f2b55d420e513791578004a082c83ba58b..87fafcd78d307dad6f5ea10e96f5be8a43fd9a72 100644 --- a/smtk/model/pybind11/PybindExportModelJSON.h +++ b/smtk/model/pybind11/PybindExportModelJSON.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::model::ExportModelJSON, smtk::operation::XMLOperation > pybind11_init_smtk_model_ExportModelJSON(py::module &m) +inline PySharedPtrClass< smtk::model::ExportModelJSON, smtk::operation::XMLOperation > pybind11_init_smtk_model_ExportModelJSON(py::module &m) { PySharedPtrClass< smtk::model::ExportModelJSON, smtk::operation::XMLOperation > instance(m, "ExportModelJSON"); instance diff --git a/smtk/model/pybind11/PybindFace.h b/smtk/model/pybind11/PybindFace.h index 78b83432324b3d16c7ed89040009ec37bcfc09e6..565d1af600f87db26a91337e331209ac7c962dca 100644 --- a/smtk/model/pybind11/PybindFace.h +++ b/smtk/model/pybind11/PybindFace.h @@ -25,7 +25,7 @@ namespace py = pybind11; -py::class_< smtk::model::Face, smtk::model::CellEntity > pybind11_init_smtk_model_Face(py::module &m) +inline py::class_< smtk::model::Face, smtk::model::CellEntity > pybind11_init_smtk_model_Face(py::module &m) { py::class_< smtk::model::Face, smtk::model::CellEntity > instance(m, "Face"); instance diff --git a/smtk/model/pybind11/PybindFaceUse.h b/smtk/model/pybind11/PybindFaceUse.h index a519b3194c77e2f61d627b85236d8b4700370126..a35c7b5d0354507ae0d69308182debbfbd197255 100644 --- a/smtk/model/pybind11/PybindFaceUse.h +++ b/smtk/model/pybind11/PybindFaceUse.h @@ -27,7 +27,7 @@ namespace py = pybind11; -py::class_< smtk::model::FaceUse, smtk::model::UseEntity > pybind11_init_smtk_model_FaceUse(py::module &m) +inline py::class_< smtk::model::FaceUse, smtk::model::UseEntity > pybind11_init_smtk_model_FaceUse(py::module &m) { py::class_< smtk::model::FaceUse, smtk::model::UseEntity > instance(m, "FaceUse"); instance diff --git a/smtk/model/pybind11/PybindGroup.h b/smtk/model/pybind11/PybindGroup.h index 085840d9760400eba88ff8477d99c602abcacb18..561296780228f65e2e6dfe80f6472a519661eb38 100644 --- a/smtk/model/pybind11/PybindGroup.h +++ b/smtk/model/pybind11/PybindGroup.h @@ -24,7 +24,7 @@ namespace py = pybind11; -py::class_< smtk::model::Group, smtk::model::EntityRef > pybind11_init_smtk_model_Group(py::module &m) +inline py::class_< smtk::model::Group, smtk::model::EntityRef > pybind11_init_smtk_model_Group(py::module &m) { py::class_< smtk::model::Group, smtk::model::EntityRef > instance(m, "Group"); instance diff --git a/smtk/model/pybind11/PybindInstance.h b/smtk/model/pybind11/PybindInstance.h index f604130288c7820e2d4d7cdcfb8fa108ec206488..6a26094168d4fc9959021e82967ba6716e43dd3b 100644 --- a/smtk/model/pybind11/PybindInstance.h +++ b/smtk/model/pybind11/PybindInstance.h @@ -23,7 +23,7 @@ namespace py = pybind11; -py::class_< smtk::model::Instance, smtk::model::EntityRef > pybind11_init_smtk_model_Instance(py::module &m) +inline py::class_< smtk::model::Instance, smtk::model::EntityRef > pybind11_init_smtk_model_Instance(py::module &m) { py::class_< smtk::model::Instance, smtk::model::EntityRef > instance(m, "Instance"); instance diff --git a/smtk/model/pybind11/PybindLoop.h b/smtk/model/pybind11/PybindLoop.h index 798a050ba51fb09cf710c6e0879a789660b73c43..99fce3bf883d617b3843f630267fda0dda93309f 100644 --- a/smtk/model/pybind11/PybindLoop.h +++ b/smtk/model/pybind11/PybindLoop.h @@ -27,7 +27,7 @@ namespace py = pybind11; -py::class_< smtk::model::Loop, smtk::model::ShellEntity > pybind11_init_smtk_model_Loop(py::module &m) +inline py::class_< smtk::model::Loop, smtk::model::ShellEntity > pybind11_init_smtk_model_Loop(py::module &m) { py::class_< smtk::model::Loop, smtk::model::ShellEntity > instance(m, "Loop"); instance diff --git a/smtk/model/pybind11/PybindModel.h b/smtk/model/pybind11/PybindModel.h index fc1918757c3f45aac4e75123b9c992f5d58fd8a5..b6bb0f324a9b6bfd1badfc02bbcd8a3985d14047 100644 --- a/smtk/model/pybind11/PybindModel.h +++ b/smtk/model/pybind11/PybindModel.h @@ -27,7 +27,7 @@ namespace py = pybind11; -py::class_< smtk::model::Model, smtk::model::EntityRef > pybind11_init_smtk_model_Model(py::module &m) +inline py::class_< smtk::model::Model, smtk::model::EntityRef > pybind11_init_smtk_model_Model(py::module &m) { py::class_< smtk::model::Model, smtk::model::EntityRef > instance(m, "Model"); instance diff --git a/smtk/model/pybind11/PybindRegistrar.h b/smtk/model/pybind11/PybindRegistrar.h index 71aac2515daa416ceaece2919e9a7987443b228b..758fe9521ed30d149b929f2e76e6684a67c7922b 100644 --- a/smtk/model/pybind11/PybindRegistrar.h +++ b/smtk/model/pybind11/PybindRegistrar.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::model::Registrar > pybind11_init_smtk_model_Registrar(py::module &m) +inline py::class_< smtk::model::Registrar > pybind11_init_smtk_model_Registrar(py::module &m) { py::class_< smtk::model::Registrar > instance(m, "Registrar"); instance diff --git a/smtk/model/pybind11/PybindResource.h b/smtk/model/pybind11/PybindResource.h index af7ee2abe1140ffece6a2d961fd1b021d480668c..4998f5fc83d2fc119e15d78b6f7a02e6eeeba3eb 100644 --- a/smtk/model/pybind11/PybindResource.h +++ b/smtk/model/pybind11/PybindResource.h @@ -47,7 +47,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::model::Resource> pybind11_init_smtk_model_Resource(py::module &m) +inline PySharedPtrClass< smtk::model::Resource> pybind11_init_smtk_model_Resource(py::module &m) { PySharedPtrClass< smtk::model::Resource, smtk::resource::Resource > instance(m, "Resource"); instance diff --git a/smtk/model/pybind11/PybindSession.h b/smtk/model/pybind11/PybindSession.h index 2d70b4b8a7964a1d282d089804b019848ae967ad..50a9172bcef003f2ce0990b1a65ee5c8a5fdb4d8 100644 --- a/smtk/model/pybind11/PybindSession.h +++ b/smtk/model/pybind11/PybindSession.h @@ -24,7 +24,7 @@ namespace py = pybind11; -void pybind11_init_smtk_model_SessionInformation(py::module &m) +inline void pybind11_init_smtk_model_SessionInformation(py::module &m) { py::enum_(m, "SessionInformation") .value("SESSION_ENTITY_TYPE", smtk::model::SessionInformation::SESSION_ENTITY_TYPE) @@ -45,7 +45,7 @@ void pybind11_init_smtk_model_SessionInformation(py::module &m) .export_values(); } -PySharedPtrClass< smtk::model::Session > pybind11_init_smtk_model_Session(py::module &m) +inline PySharedPtrClass< smtk::model::Session > pybind11_init_smtk_model_Session(py::module &m) { PySharedPtrClass< smtk::model::Session > instance(m, "Session"); instance @@ -65,7 +65,7 @@ PySharedPtrClass< smtk::model::Session > pybind11_init_smtk_model_Session(py::mo .def("removeGeneratedProperties", &smtk::model::Session::removeGeneratedProperties, py::arg("entity"), py::arg("propFlags")) .def("splitProperties", &smtk::model::Session::splitProperties, py::arg("from"), py::arg("to")) .def("mergeProperties", &smtk::model::Session::mergeProperties, py::arg("from"), py::arg("to")) - .def_static("CastTo", [](const std::shared_ptr i) { return i; }) + .def_static("CastTo", [](std::shared_ptr i) { return i; }) ; return instance; } diff --git a/smtk/model/pybind11/PybindSessionIO.h b/smtk/model/pybind11/PybindSessionIO.h index 8b01545943fd881d1a47fd624404769425937204..ca0adcd1789fa2d1981a60c685b94c5291176f35 100644 --- a/smtk/model/pybind11/PybindSessionIO.h +++ b/smtk/model/pybind11/PybindSessionIO.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::model::SessionIO > pybind11_init_smtk_model_SessionIO(py::module &m) +inline py::class_< smtk::model::SessionIO > pybind11_init_smtk_model_SessionIO(py::module &m) { py::class_< smtk::model::SessionIO > instance(m, "SessionIO"); instance diff --git a/smtk/model/pybind11/PybindSessionIOJSON.h b/smtk/model/pybind11/PybindSessionIOJSON.h index 80ce51c686fc0d5d2cf216d9588eeaf9cba3d376..3ab86fc20598ecd45cd65a507ba0e6c210403bbb 100644 --- a/smtk/model/pybind11/PybindSessionIOJSON.h +++ b/smtk/model/pybind11/PybindSessionIOJSON.h @@ -20,7 +20,7 @@ namespace py = pybind11; -py::class_< smtk::model::SessionIOJSON, smtk::model::SessionIO > pybind11_init_smtk_model_SessionIOJSON(py::module &m) +inline py::class_< smtk::model::SessionIOJSON, smtk::model::SessionIO > pybind11_init_smtk_model_SessionIOJSON(py::module &m) { py::class_< smtk::model::SessionIOJSON, smtk::model::SessionIO > instance(m, "SessionIOJSON"); instance diff --git a/smtk/model/pybind11/PybindSessionRef.h b/smtk/model/pybind11/PybindSessionRef.h index cf8d660e0783791925e588beb5c1f58fb20dfafe..4328a5e27538b1029ea1eccdd8081ebd7f9dbea0 100644 --- a/smtk/model/pybind11/PybindSessionRef.h +++ b/smtk/model/pybind11/PybindSessionRef.h @@ -27,7 +27,7 @@ namespace py = pybind11; -py::class_< smtk::model::SessionRef, smtk::model::EntityRef > pybind11_init_smtk_model_SessionRef(py::module &m) +inline py::class_< smtk::model::SessionRef, smtk::model::EntityRef > pybind11_init_smtk_model_SessionRef(py::module &m) { py::class_< smtk::model::SessionRef, smtk::model::EntityRef > instance(m, "SessionRef"); instance diff --git a/smtk/model/pybind11/PybindShell.h b/smtk/model/pybind11/PybindShell.h index 8c295fdf65cd43e45b26f5c5b72633de0815a63d..006a9c9546f5bc668a752f92b8503b2943e2b030 100644 --- a/smtk/model/pybind11/PybindShell.h +++ b/smtk/model/pybind11/PybindShell.h @@ -25,7 +25,7 @@ namespace py = pybind11; -py::class_< smtk::model::Shell, smtk::model::ShellEntity > pybind11_init_smtk_model_Shell(py::module &m) +inline py::class_< smtk::model::Shell, smtk::model::ShellEntity > pybind11_init_smtk_model_Shell(py::module &m) { py::class_< smtk::model::Shell, smtk::model::ShellEntity > instance(m, "Shell"); instance diff --git a/smtk/model/pybind11/PybindShellEntity.h b/smtk/model/pybind11/PybindShellEntity.h index f79d7786a28d20d3ff295561f08c08a2e17de823..aaf5e8b38b598344876844d3e781ab728ffe5bcc 100644 --- a/smtk/model/pybind11/PybindShellEntity.h +++ b/smtk/model/pybind11/PybindShellEntity.h @@ -25,7 +25,7 @@ namespace py = pybind11; -py::class_< smtk::model::ShellEntity, smtk::model::EntityRef > pybind11_init_smtk_model_ShellEntity(py::module &m) +inline py::class_< smtk::model::ShellEntity, smtk::model::EntityRef > pybind11_init_smtk_model_ShellEntity(py::module &m) { py::class_< smtk::model::ShellEntity, smtk::model::EntityRef > instance(m, "ShellEntity"); instance diff --git a/smtk/model/pybind11/PybindTessellation.h b/smtk/model/pybind11/PybindTessellation.h index 19f7401b53d5f383f039b2da03957411b1eee324..10cd2eaba9b745dfdc843f92afd8c7d247661870 100644 --- a/smtk/model/pybind11/PybindTessellation.h +++ b/smtk/model/pybind11/PybindTessellation.h @@ -17,7 +17,7 @@ namespace py = pybind11; -void pybind11_init_smtk_model_TessellationCellType(py::module &m) +inline void pybind11_init_smtk_model_TessellationCellType(py::module &m) { py::enum_(m, "TessellationCellType") .value("TESS_VERTEX", smtk::model::TessellationCellType::TESS_VERTEX) @@ -41,7 +41,7 @@ void pybind11_init_smtk_model_TessellationCellType(py::module &m) .export_values(); } -py::class_< smtk::model::Tessellation > pybind11_init_smtk_model_Tessellation(py::module &m) +inline py::class_< smtk::model::Tessellation > pybind11_init_smtk_model_Tessellation(py::module &m) { py::class_< smtk::model::Tessellation > instance(m, "Tessellation"); instance diff --git a/smtk/model/pybind11/PybindUseEntity.h b/smtk/model/pybind11/PybindUseEntity.h index 634100bd3927ca7460739495504e0e159ece96fb..b105dad9587fd584f3365cb3df15a32742b543cf 100644 --- a/smtk/model/pybind11/PybindUseEntity.h +++ b/smtk/model/pybind11/PybindUseEntity.h @@ -25,7 +25,7 @@ namespace py = pybind11; -py::class_< smtk::model::UseEntity, smtk::model::EntityRef > pybind11_init_smtk_model_UseEntity(py::module &m) +inline py::class_< smtk::model::UseEntity, smtk::model::EntityRef > pybind11_init_smtk_model_UseEntity(py::module &m) { py::class_< smtk::model::UseEntity, smtk::model::EntityRef > instance(m, "UseEntity"); instance diff --git a/smtk/model/pybind11/PybindVertex.h b/smtk/model/pybind11/PybindVertex.h index 3765697c9a00b0c421baae2931bf9f31320ddab3..a4adfd5784d3b20ff8dd7c0942cd8569e2b51c59 100644 --- a/smtk/model/pybind11/PybindVertex.h +++ b/smtk/model/pybind11/PybindVertex.h @@ -25,7 +25,7 @@ namespace py = pybind11; -py::class_< smtk::model::Vertex, smtk::model::CellEntity > pybind11_init_smtk_model_Vertex(py::module &m) +inline py::class_< smtk::model::Vertex, smtk::model::CellEntity > pybind11_init_smtk_model_Vertex(py::module &m) { py::class_< smtk::model::Vertex, smtk::model::CellEntity > instance(m, "Vertex"); instance diff --git a/smtk/model/pybind11/PybindVertexUse.h b/smtk/model/pybind11/PybindVertexUse.h index 87d44d73a12bd389b1c763c5a4252ffee76dc1e5..6fb003b295808810349b39827ef5319839ac49f1 100644 --- a/smtk/model/pybind11/PybindVertexUse.h +++ b/smtk/model/pybind11/PybindVertexUse.h @@ -25,7 +25,7 @@ namespace py = pybind11; -py::class_< smtk::model::VertexUse, smtk::model::UseEntity > pybind11_init_smtk_model_VertexUse(py::module &m) +inline py::class_< smtk::model::VertexUse, smtk::model::UseEntity > pybind11_init_smtk_model_VertexUse(py::module &m) { py::class_< smtk::model::VertexUse, smtk::model::UseEntity > instance(m, "VertexUse"); instance diff --git a/smtk/model/pybind11/PybindVolume.h b/smtk/model/pybind11/PybindVolume.h index 2a528463bc3d630f5ce2e0e169500f7e1dce6a9f..90d59179ef6d8c6089bfc600e47628e704278ec4 100644 --- a/smtk/model/pybind11/PybindVolume.h +++ b/smtk/model/pybind11/PybindVolume.h @@ -25,7 +25,7 @@ namespace py = pybind11; -py::class_< smtk::model::Volume, smtk::model::CellEntity > pybind11_init_smtk_model_Volume(py::module &m) +inline py::class_< smtk::model::Volume, smtk::model::CellEntity > pybind11_init_smtk_model_Volume(py::module &m) { py::class_< smtk::model::Volume, smtk::model::CellEntity > instance(m, "Volume"); instance diff --git a/smtk/model/pybind11/PybindVolumeUse.h b/smtk/model/pybind11/PybindVolumeUse.h index 3ae5ecb4ae2a41adaf51b0983fdf18b18abd43f1..4a663cc310dbd3c8e965169ba43b213a29658d49 100644 --- a/smtk/model/pybind11/PybindVolumeUse.h +++ b/smtk/model/pybind11/PybindVolumeUse.h @@ -25,7 +25,7 @@ namespace py = pybind11; -py::class_< smtk::model::VolumeUse, smtk::model::UseEntity > pybind11_init_smtk_model_VolumeUse(py::module &m) +inline py::class_< smtk::model::VolumeUse, smtk::model::UseEntity > pybind11_init_smtk_model_VolumeUse(py::module &m) { py::class_< smtk::model::VolumeUse, smtk::model::UseEntity > instance(m, "VolumeUse"); instance diff --git a/smtk/model/testing/cxx/CMakeLists.txt b/smtk/model/testing/cxx/CMakeLists.txt index 864312477111d89609d6aa04e662a83ef6fda5ae..9341652b0f0c47a021cd500894b2680fb6e4daea 100644 --- a/smtk/model/testing/cxx/CMakeLists.txt +++ b/smtk/model/testing/cxx/CMakeLists.txt @@ -46,7 +46,7 @@ target_link_libraries(benchmarkModel smtkCore smtkCoreModelTesting) #add_test(NAME benchmarkModel COMMAND benchmarkModel) set(unit_tests - unitDeleterGroup + unitDeleterGroup.cxx ) ################################################################################ diff --git a/smtk/model/testing/cxx/unitDeleterGroup.cxx b/smtk/model/testing/cxx/unitDeleterGroup.cxx index 057bc04f34a96a98829572dc8f461a31a02620c0..3af67a26b47e30919f1acba825fd578a05b19162 100644 --- a/smtk/model/testing/cxx/unitDeleterGroup.cxx +++ b/smtk/model/testing/cxx/unitDeleterGroup.cxx @@ -20,6 +20,8 @@ #include "smtk/resource/Manager.h" +#include "smtk/plugin/Registry.h" + #include "smtk/common/testing/cxx/helpers.h" #include "smtk/model/testing/cxx/helpers.h" @@ -30,8 +32,8 @@ int unitDeleterGroup(int argc, char* argv[]) auto resourceManager = smtk::resource::Manager::create(); auto operationManager = smtk::operation::Manager::create(); - smtk::model::Registrar::registerTo(resourceManager); - smtk::model::Registrar::registerTo(operationManager); + auto modelRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); smtk::operation::DeleterGroup deleters(operationManager); diff --git a/smtk/model/testing/cxx/unitEntity.cxx b/smtk/model/testing/cxx/unitEntity.cxx index bcd0f62e9a9d664356fdf45f2d7abf68e356622b..372d495c3de1b8f05162c4d1e6aab3934429c751 100644 --- a/smtk/model/testing/cxx/unitEntity.cxx +++ b/smtk/model/testing/cxx/unitEntity.cxx @@ -21,6 +21,8 @@ #include "smtk/common/testing/cxx/helpers.h" +#include "smtk/plugin/Registry.h" + #include "smtk/session/polygon/Registrar.h" #include "smtk/session/polygon/Resource.h" @@ -491,14 +493,10 @@ int TestEntityQueryFunctor() std::cout << "\nTesting Entity::filterStringToQueryFunctor()\n\n"; // I. Load in a test model smtk::resource::Manager::Ptr rsrcMgr = smtk::resource::Manager::create(); - { - smtk::session::polygon::Registrar::registerTo(rsrcMgr); - } smtk::operation::Manager::Ptr operMgr = smtk::operation::Manager::create(); - { - smtk::operation::Registrar::registerTo(operMgr); - smtk::session::polygon::Registrar::registerTo(operMgr); - } + auto polygonRegistry = + smtk::plugin::addToManagers(rsrcMgr, operMgr); + auto operationRegistry = smtk::plugin::addToManagers(operMgr); // Register the resource manager to the operation manager (newly created // resources will be automatically registered to the resource manager). operMgr->registerResourceManager(rsrcMgr); diff --git a/smtk/operation/CMakeLists.txt b/smtk/operation/CMakeLists.txt index 2fa76dad5accbce2d347bd27e52693683d4c4ad2..db0d48f38665a8da76160125a95464d552fc5c97 100644 --- a/smtk/operation/CMakeLists.txt +++ b/smtk/operation/CMakeLists.txt @@ -15,6 +15,7 @@ set(operationSrcs groups/ImporterGroup.cxx groups/InternalGroup.cxx groups/ExporterGroup.cxx + groups/NamingGroup.cxx groups/ReaderGroup.cxx groups/ResourceIOGroup.cxx groups/WriterGroup.cxx @@ -43,6 +44,7 @@ set(operationHeaders groups/ImporterGroup.h groups/InternalGroup.h groups/ExporterGroup.h + groups/NamingGroup.h groups/ReaderGroup.h groups/ResourceIOGroup.h groups/WriterGroup.h diff --git a/smtk/operation/Operation.cxx b/smtk/operation/Operation.cxx index 208727d7e9332e9ec2e9489de6bac858a3b6c756..f1b8eb8ea4799c90ba03b207a38479bff4aa862e 100644 --- a/smtk/operation/Operation.cxx +++ b/smtk/operation/Operation.cxx @@ -46,8 +46,7 @@ namespace operation { Operation::Operation() - : m_debugLevel(0) - , m_specification(nullptr) + : m_specification(nullptr) , m_parameters(nullptr) , m_resultDefinition(nullptr) { diff --git a/smtk/operation/Operation.h b/smtk/operation/Operation.h index 64b02d2b61f2e92c7a24fda4de6dc3ab307cdcc6..7bbc08b219ca9e6d2bbca91cd08e34a10fd98508 100644 --- a/smtk/operation/Operation.h +++ b/smtk/operation/Operation.h @@ -168,7 +168,7 @@ protected: // an attribute .sbt file. Specification createBaseSpecification() const; - int m_debugLevel; + int m_debugLevel{ 0 }; std::weak_ptr m_manager; // Operations need the ability to execute Operations without going through diff --git a/smtk/operation/groups/NamingGroup.cxx b/smtk/operation/groups/NamingGroup.cxx new file mode 100644 index 0000000000000000000000000000000000000000..651f62c21ad40d1ebb46cfa49479bc7d06e5dc69 --- /dev/null +++ b/smtk/operation/groups/NamingGroup.cxx @@ -0,0 +1,47 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#include "smtk/operation/groups/NamingGroup.h" + +#include "smtk/attribute/Attribute.h" +#include "smtk/attribute/ReferenceItemDefinition.h" + +#include "smtk/operation/Manager.h" +#include "smtk/operation/SpecificationOps.h" + +#include +#include + +namespace smtk +{ +namespace operation +{ + +Operation::Index NamingGroup::matchingOperation(const smtk::resource::PersistentObject& obj) const +{ + Operation::Index index = 0; + std::size_t indexGen = std::numeric_limits::max(); + for (const auto& candidate : this->operations()) + { + std::size_t gen = this->operationObjectDistance(candidate, obj); + if (gen < indexGen) + { + indexGen = gen; + index = candidate; + if (gen == 0) + { // This is the most exact + break; + } + } + } + return index; +} +} // namespace operation +} // namespace smtk diff --git a/smtk/operation/groups/NamingGroup.h b/smtk/operation/groups/NamingGroup.h new file mode 100644 index 0000000000000000000000000000000000000000..9a9d15e92cb4bcbbdbb3922436187d942d919e14 --- /dev/null +++ b/smtk/operation/groups/NamingGroup.h @@ -0,0 +1,92 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#ifndef smtk_operation_NamingGroup_h +#define smtk_operation_NamingGroup_h + +#include "smtk/CoreExports.h" + +#include "smtk/common/TypeName.h" + +#include "smtk/operation/Manager.h" +#include "smtk/operation/Operation.h" + +#include "smtk/operation/groups/ResourceIOGroup.h" + +#include +#include + +namespace smtk +{ +namespace operation +{ +class Manager; + +/**\brief A group that holds operations which can name Component. + * + * All operations added to this group must have a StringItem whose name is "name" and only 1 component association + * + */ +class SMTKCORE_EXPORT NamingGroup : protected Group +{ +public: + static constexpr const char* const type_name = "naming"; + + NamingGroup(std::shared_ptr manager) + : Group(type_name, manager) + { + } + + template + bool registerOperation(); + + using Group::unregisterOperation; + + /// Given an object return an operation that can delete it. + Operation::Index matchingOperation(const smtk::resource::PersistentObject& obj) const; +}; + +template +bool NamingGroup::registerOperation() +{ + auto manager = m_manager.lock(); + if (manager == nullptr) + { + return false; + } + + auto metadata = + manager->metadata().get().find(std::type_index(typeid(OperationType)).hash_code()); + if (metadata == manager->metadata().get().end()) + { + return false; + } + + Operation::Specification spec = specification(metadata->typeName()); + if (spec == nullptr) + { + return false; + } + + Operation::Parameters parameters = extractParameters(spec, metadata->typeName()); + if ( + parameters == nullptr || parameters->findString("name") == nullptr || + parameters->associations() == nullptr || + parameters->associations()->numberOfRequiredValues() != 1) + { + return false; + } + return Group::registerOperation( + std::type_index(typeid(OperationType)).hash_code(), { smtk::common::typeName() }); +} +} // namespace operation +} // namespace smtk + +#endif // smtk_operation_NamingGroup_h diff --git a/smtk/operation/pybind11/PybindManager.h b/smtk/operation/pybind11/PybindManager.h index b6ea75185000a36e0ff16b4b09dafd8ade0de788..ff1cc51f902f6b7ec61245fccbf5b4b5f6d8ceaf 100644 --- a/smtk/operation/pybind11/PybindManager.h +++ b/smtk/operation/pybind11/PybindManager.h @@ -30,7 +30,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::operation::Manager > pybind11_init_smtk_operation_Manager(py::module &m) +inline PySharedPtrClass< smtk::operation::Manager > pybind11_init_smtk_operation_Manager(py::module &m) { PySharedPtrClass< smtk::operation::Manager > instance(m, "Manager"); instance diff --git a/smtk/operation/pybind11/PybindMetadata.h b/smtk/operation/pybind11/PybindMetadata.h index 8d7dd0eac72a6e72ecabbecc2043aa352d9d2b26..9d83c55334b21606eb596d61bbc629fcec9a440a 100644 --- a/smtk/operation/pybind11/PybindMetadata.h +++ b/smtk/operation/pybind11/PybindMetadata.h @@ -22,7 +22,7 @@ namespace py = pybind11; -py::class_< smtk::operation::Metadata > pybind11_init_smtk_operation_Metadata(py::module &m) +inline py::class_< smtk::operation::Metadata > pybind11_init_smtk_operation_Metadata(py::module &m) { py::class_< smtk::operation::Metadata > instance(m, "Metadata"); instance diff --git a/smtk/operation/pybind11/PybindMetadataContainer.h b/smtk/operation/pybind11/PybindMetadataContainer.h index 596a5c81bb909bc122a2bfb7708b9ebf0374c0c4..e7f0293a83c3c165c2802c7ba5716802fd4e0182 100644 --- a/smtk/operation/pybind11/PybindMetadataContainer.h +++ b/smtk/operation/pybind11/PybindMetadataContainer.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::operation::IndexTag > pybind11_init_smtk_operation_IndexTag(py::module &m) +inline py::class_< smtk::operation::IndexTag > pybind11_init_smtk_operation_IndexTag(py::module &m) { py::class_< smtk::operation::IndexTag > instance(m, "IndexTag"); instance @@ -28,7 +28,7 @@ py::class_< smtk::operation::IndexTag > pybind11_init_smtk_operation_IndexTag(py return instance; } -py::class_< smtk::operation::NameTag > pybind11_init_smtk_operation_NameTag(py::module &m) +inline py::class_< smtk::operation::NameTag > pybind11_init_smtk_operation_NameTag(py::module &m) { py::class_< smtk::operation::NameTag > instance(m, "NameTag"); instance diff --git a/smtk/operation/pybind11/PybindMetadataObserver.h b/smtk/operation/pybind11/PybindMetadataObserver.h index 70ca2d7a4665a368d995b663b4c3ac763670f64c..2c86e0a11ea086bc5b2f74f3280da7723c10c935 100644 --- a/smtk/operation/pybind11/PybindMetadataObserver.h +++ b/smtk/operation/pybind11/PybindMetadataObserver.h @@ -19,7 +19,7 @@ namespace py = pybind11; -py::class_< smtk::operation::MetadataObservers > pybind11_init_smtk_operation_MetadataObservers(py::module &m) +inline py::class_< smtk::operation::MetadataObservers > pybind11_init_smtk_operation_MetadataObservers(py::module &m) { py::class_< smtk::operation::MetadataObservers > instance(m, "MetadataObservers"); instance diff --git a/smtk/operation/pybind11/PybindObserver.h b/smtk/operation/pybind11/PybindObserver.h index f8a8e3a1463b878a3321893b6ac9270797b9f047..f58768114aa05a0655a22612afff536582fb38a8 100644 --- a/smtk/operation/pybind11/PybindObserver.h +++ b/smtk/operation/pybind11/PybindObserver.h @@ -19,7 +19,7 @@ namespace py = pybind11; -void pybind11_init_smtk_operation_EventType(py::module &m) +inline void pybind11_init_smtk_operation_EventType(py::module &m) { py::enum_(m, "EventType") .value("WILL_OPERATE", smtk::operation::EventType::WILL_OPERATE) @@ -27,7 +27,7 @@ void pybind11_init_smtk_operation_EventType(py::module &m) .export_values(); } -py::class_< smtk::operation::Observers > pybind11_init_smtk_operation_Observers(py::module &m) +inline py::class_< smtk::operation::Observers > pybind11_init_smtk_operation_Observers(py::module &m) { py::class_< smtk::operation::Observers > instance(m, "Observers"); instance diff --git a/smtk/operation/pybind11/PybindOperation.h b/smtk/operation/pybind11/PybindOperation.h index df55c0bc0a944a20ca1ef2896799258833aa7faf..b5898f6725489cb34f2d55817c003e2025e0550c 100644 --- a/smtk/operation/pybind11/PybindOperation.h +++ b/smtk/operation/pybind11/PybindOperation.h @@ -23,7 +23,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::operation::Operation, smtk::operation::PyOperation > pybind11_init_smtk_operation_Operation(py::module &m) +inline PySharedPtrClass< smtk::operation::Operation, smtk::operation::PyOperation > pybind11_init_smtk_operation_Operation(py::module &m) { PySharedPtrClass< smtk::operation::Operation, smtk::operation::PyOperation > instance(m, "Operation"); instance diff --git a/smtk/operation/pybind11/PybindReadResource.h b/smtk/operation/pybind11/PybindReadResource.h index b4693e0f97f8563c871e63299d12b1e2412a3f50..22e57381016f83e841bad7100147667b484b804e 100644 --- a/smtk/operation/pybind11/PybindReadResource.h +++ b/smtk/operation/pybind11/PybindReadResource.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::operation::ReadResource, smtk::operation::XMLOperation > pybind11_init_smtk_operation_ReadResource(py::module &m) +inline PySharedPtrClass< smtk::operation::ReadResource, smtk::operation::XMLOperation > pybind11_init_smtk_operation_ReadResource(py::module &m) { PySharedPtrClass< smtk::operation::ReadResource, smtk::operation::XMLOperation > instance(m, "ReadResource"); instance diff --git a/smtk/operation/pybind11/PybindRegistrar.h b/smtk/operation/pybind11/PybindRegistrar.h index 88150e33b4d4372ae6a4f82820724364d29afb6e..2c0eec159577e52a7cfb9bed75df90dd7d7e6e95 100644 --- a/smtk/operation/pybind11/PybindRegistrar.h +++ b/smtk/operation/pybind11/PybindRegistrar.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::operation::Registrar > pybind11_init_smtk_operation_Registrar(py::module &m) +inline py::class_< smtk::operation::Registrar > pybind11_init_smtk_operation_Registrar(py::module &m) { py::class_< smtk::operation::Registrar > instance(m, "Registrar"); instance diff --git a/smtk/operation/pybind11/PybindRemoveResource.h b/smtk/operation/pybind11/PybindRemoveResource.h index d7427e3a31507d432bc42a47b32264958ea3697f..edb6de9498bac7fd369563f185d3c7f023134439 100644 --- a/smtk/operation/pybind11/PybindRemoveResource.h +++ b/smtk/operation/pybind11/PybindRemoveResource.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::operation::RemoveResource, smtk::operation::XMLOperation > pybind11_init_smtk_operation_RemoveResource(py::module &m) +inline PySharedPtrClass< smtk::operation::RemoveResource, smtk::operation::XMLOperation > pybind11_init_smtk_operation_RemoveResource(py::module &m) { PySharedPtrClass< smtk::operation::RemoveResource, smtk::operation::XMLOperation > instance(m, "RemoveResource"); instance diff --git a/smtk/operation/pybind11/PybindResourceManagerOperation.h b/smtk/operation/pybind11/PybindResourceManagerOperation.h index edd7c770197dc516f1657e9bc294162badd19800..9d3d85f8c753767b9277311fdb3c817398edfc3a 100644 --- a/smtk/operation/pybind11/PybindResourceManagerOperation.h +++ b/smtk/operation/pybind11/PybindResourceManagerOperation.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::operation::ResourceManagerOperation, smtk::operation::XMLOperation > pybind11_init_smtk_operation_ResourceManagerOperation(py::module &m) +inline PySharedPtrClass< smtk::operation::ResourceManagerOperation, smtk::operation::XMLOperation > pybind11_init_smtk_operation_ResourceManagerOperation(py::module &m) { PySharedPtrClass< smtk::operation::ResourceManagerOperation, smtk::operation::XMLOperation > instance(m, "ResourceManagerOperation"); instance diff --git a/smtk/operation/pybind11/PybindSetProperty.h b/smtk/operation/pybind11/PybindSetProperty.h index 37e1f9de81036fdbbf3150792ba5f46a060e6813..2e0d964431dd996fb3f4bdafe8ef76eb793ad58b 100644 --- a/smtk/operation/pybind11/PybindSetProperty.h +++ b/smtk/operation/pybind11/PybindSetProperty.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::operation::SetProperty, smtk::operation::XMLOperation > pybind11_init_smtk_operation_SetProperty(py::module &m) +inline PySharedPtrClass< smtk::operation::SetProperty, smtk::operation::XMLOperation > pybind11_init_smtk_operation_SetProperty(py::module &m) { PySharedPtrClass< smtk::operation::SetProperty, smtk::operation::XMLOperation > instance(m, "SetProperty"); instance diff --git a/smtk/operation/pybind11/PybindWriteResource.h b/smtk/operation/pybind11/PybindWriteResource.h index 32c3a47b8dab64967fb98a5a2d59dbc9e532cc7c..f54bbefa6b22d4f592b53ec0e36777b26de3db1e 100644 --- a/smtk/operation/pybind11/PybindWriteResource.h +++ b/smtk/operation/pybind11/PybindWriteResource.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::operation::WriteResource, smtk::operation::XMLOperation > pybind11_init_smtk_operation_WriteResource(py::module &m) +inline PySharedPtrClass< smtk::operation::WriteResource, smtk::operation::XMLOperation > pybind11_init_smtk_operation_WriteResource(py::module &m) { PySharedPtrClass< smtk::operation::WriteResource, smtk::operation::XMLOperation > instance(m, "WriteResource"); instance diff --git a/smtk/operation/pybind11/PybindXMLOperation.h b/smtk/operation/pybind11/PybindXMLOperation.h index 91678ecac2c4f236be4ecce03a17efc864317214..5bad73ffdc45fd2d4f26a3a2491c8eccaaf8f1de 100644 --- a/smtk/operation/pybind11/PybindXMLOperation.h +++ b/smtk/operation/pybind11/PybindXMLOperation.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::operation::XMLOperation, smtk::operation::Operation > pybind11_init_smtk_operation_XMLOperation(py::module &m) +inline PySharedPtrClass< smtk::operation::XMLOperation, smtk::operation::Operation > pybind11_init_smtk_operation_XMLOperation(py::module &m) { PySharedPtrClass< smtk::operation::XMLOperation, smtk::operation::Operation > instance(m, "XMLOperation"); instance diff --git a/smtk/operation/testing/cxx/CMakeLists.txt b/smtk/operation/testing/cxx/CMakeLists.txt index feb0718fca3ff357e2e05dd7637c284942e70bd5..b6103d2e697f4f37a5e4489f222221404e071698 100644 --- a/smtk/operation/testing/cxx/CMakeLists.txt +++ b/smtk/operation/testing/cxx/CMakeLists.txt @@ -1,18 +1,19 @@ set(unit_tests - TestAsyncOperation - TestAvailableOperations - TestMutexedOperation - unitOperation - TestOperationGroup - TestOperationLauncher - TestRemoveResource - TestThreadSafeLazyEvaluation + TestAsyncOperation.cxx + TestAvailableOperations.cxx + TestMutexedOperation.cxx + unitOperation.cxx + unitNamingGroup.cxx + TestOperationGroup.cxx + TestOperationLauncher.cxx + TestRemoveResource.cxx + TestThreadSafeLazyEvaluation.cxx ) find_package(Threads REQUIRED) smtk_unit_tests( - Label "operation" + LABEL "Operation" SOURCES ${unit_tests} LIBRARIES smtkCore ) diff --git a/smtk/operation/testing/cxx/TestRemoveResource.cxx b/smtk/operation/testing/cxx/TestRemoveResource.cxx index ca24e711fdb367bc40b3b585c22a465b255a794f..a12e8a8f48d97e7c2c8c981cd6378cc72d494e5a 100644 --- a/smtk/operation/testing/cxx/TestRemoveResource.cxx +++ b/smtk/operation/testing/cxx/TestRemoveResource.cxx @@ -17,6 +17,8 @@ #include "smtk/operation/Registrar.h" #include "smtk/operation/operators/RemoveResource.h" +#include "smtk/plugin/Registry.h" + #include "smtk/resource/Component.h" #include "smtk/resource/DerivedFrom.h" #include "smtk/resource/Manager.h" @@ -58,18 +60,17 @@ int TestRemoveResource(int /*unused*/, char** const /*unused*/) auto managers = smtk::common::Managers::create(); // Construct smtk managers - { - smtk::resource::Registrar::registerTo(managers); - smtk::operation::Registrar::registerTo(managers); - } + auto resourceRegistry = smtk::plugin::addToManagers(managers); + auto operationRegistry = smtk::plugin::addToManagers(managers); // access smtk managers auto resourceManager = managers->get(); auto operationManager = managers->get(); // Initialize smtk managers + auto operationOpRegistry = + smtk::plugin::addToManagers(operationManager); { - smtk::operation::Registrar::registerTo(operationManager); operationManager->registerResourceManager(resourceManager); } diff --git a/smtk/operation/testing/cxx/unitNamingGroup.cxx b/smtk/operation/testing/cxx/unitNamingGroup.cxx new file mode 100644 index 0000000000000000000000000000000000000000..27943e5ac58d96f194064d86597a7dfaff6a7d8f --- /dev/null +++ b/smtk/operation/testing/cxx/unitNamingGroup.cxx @@ -0,0 +1,201 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +#include "smtk/common/testing/cxx/helpers.h" + +#include "smtk/resource/DerivedFrom.h" +#include +#include +#include +#include +#include + +class ResourceA : public smtk::resource::DerivedFrom +{ +public: + smtkTypeMacro(ResourceA); + smtkCreateMacro(ResourceA); + smtkSharedFromThisMacro(smtk::resource::PersistentObject); + + smtk::resource::ComponentPtr find(const smtk::common::UUID& /*compId*/) const override + { + return smtk::resource::ComponentPtr(); + } + + std::function queryOperation( + const std::string& /*unused*/) const override + { + return [](const smtk::resource::Component& /*unused*/) { return true; }; + } + + void visit(smtk::resource::Component::Visitor& /*v*/) const override {} + +protected: + ResourceA() + : smtk::resource::DerivedFrom() + { + } +}; + +class MyComponent : public smtk::resource::Component +{ +public: + smtkTypeMacro(MyComponent); + smtkCreateMacro(MyComponent); + smtkSharedFromThisMacro(smtk::resource::Component); + + const smtk::common::UUID& id() const override { return myId; } + bool setId(const smtk::common::UUID& anId) override + { + myId = anId; + return true; + } + + const smtk::resource::ResourcePtr resource() const override { return myResource; } + void setResource(smtk::resource::Resource::Ptr& r) { myResource = r; } + +private: + smtk::resource::Resource::Ptr myResource; + smtk::common::UUID myId; +}; + +const std::string setNameOp_xml = R"***( + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + )***"; +class SetNameOp : public smtk::operation::XMLOperation +{ +public: + smtkTypeMacro(SetNameOp); + smtkCreateMacro(SetNameOp); + smtkSharedFromThisMacro(smtk::operation::Operation); + + SetNameOp() = default; + ~SetNameOp() override = default; + + Result operateInternal() override { return this->createResult(Outcome::SUCCEEDED); } + + const char* xmlDescription() const override { return setNameOp_xml.c_str(); } +}; + +const std::string nonCompliantOp_xml = R"***( + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + )***"; + +class NonCompliantOp : public smtk::operation::XMLOperation +{ +public: + smtkTypeMacro(NonCompliantOp); + smtkCreateMacro(NonCompliantOp); + smtkSharedFromThisMacro(smtk::operation::Operation); + + NonCompliantOp() = default; + ~NonCompliantOp() override = default; + + Result operateInternal() override { return this->createResult(Outcome::SUCCEEDED); } + + const char* xmlDescription() const override { return nonCompliantOp_xml.c_str(); } +}; + +int unitNamingGroup(int /*argc*/, char** const /*argv*/) +{ + // Create an operation manager + smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); + + // Register NonCompliantOp to the manager + operationManager->registerOperation("NonCompliantOp"); + operationManager->registerOperation("SetNameOp"); + + // Create a naming group + smtk::operation::NamingGroup namingGroup(operationManager); + + // Register OperationA to the group and test for success + bool success = namingGroup.registerOperation(); + smtkTest(!success, "Registered a non compliant operation to naming group"); + + success = namingGroup.registerOperation(); + smtkTest(success, "Compliant operation should have registered") + + // Check that the operation manager has one available group. This shows up only after first successful operation is registered + auto availableGroups = operationManager->availableGroups(); + smtkTest(availableGroups.size() == 1, "Operation manager should have one available group."); + + // Create a resource manager + smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); + resourceManager->registerResource(); + auto resourceA = resourceManager->create(); + auto component = MyComponent::create(); + auto rsrc = std::static_pointer_cast(resourceA); + component->setResource(rsrc); + + auto index = namingGroup.matchingOperation(*component); + auto op = operationManager->create(index); + smtkTest(op != nullptr, "Should return a SetNameOp"); + smtkTest(op->typeName() == "SetNameOp", "Should return a SetNameOp"); + // Query the operation + return 0; +} diff --git a/smtk/plugin/Registry.h b/smtk/plugin/Registry.h index e56e8d3e05ec5d1e3af34cde893fced493f678f5..3def3b3dbccd5f42d4d93ec6fe1d99b0c9c10f16 100644 --- a/smtk/plugin/Registry.h +++ b/smtk/plugin/Registry.h @@ -145,16 +145,16 @@ public: { if (ManagerCount::instance().operator[](manager.get())++ == 0) { - Registrar().registerTo(manager); + Registrar().registerTo(m_Manager); } } ~MaybeRegister() { - std::shared_ptr manager = m_Manager.lock(); - if (manager && --ManagerCount::instance().operator[](manager.get()) == 0) + if ( + m_Manager && --ManagerCount::instance().operator[](m_Manager.get()) == 0) { - Registrar().unregisterFrom(manager); + Registrar().unregisterFrom(m_Manager); } } @@ -164,14 +164,10 @@ public: return false; } - bool contains(const std::shared_ptr& manager) const - { - auto m = m_Manager.lock(); - return m && m == manager; - } + bool contains(const std::shared_ptr& manager) const { return manager == m_Manager; } private: - std::weak_ptr m_Manager; + std::shared_ptr m_Manager; }; /// Registrars may declare dependencies to other Registrars by defining a type @@ -430,6 +426,13 @@ public: }; #endif + +template +static Registry addToManagers(const std::shared_ptr&... manager) +{ + return Registry(manager...); +} + } // namespace plugin } // namespace smtk diff --git a/smtk/plugin/testing/cxx/CMakeLists.txt b/smtk/plugin/testing/cxx/CMakeLists.txt index 66f1dfa7eeb68bbf7e147f26d7e89c2feb87eca1..6aebf70357a86611a400796496782a898711d73d 100644 --- a/smtk/plugin/testing/cxx/CMakeLists.txt +++ b/smtk/plugin/testing/cxx/CMakeLists.txt @@ -1,12 +1,12 @@ set(unit_tests - UnitTestRegistry + UnitTestRegistry.cxx ) set(unit_tests_which_require_data ) smtk_unit_tests( - Label "Plugin" + LABEL "Plugin" SOURCES ${unit_tests} SOURCES_REQUIRE_DATA ${unit_tests_which_require_data} LIBRARIES smtkCore diff --git a/smtk/plugin/testing/python/CMakeLists.txt b/smtk/plugin/testing/python/CMakeLists.txt index b2b775524a4793cb0c5ff9e08fbe406bb1422a9a..851c0701808226723dd8d6211c2e7a844f88a2b1 100644 --- a/smtk/plugin/testing/python/CMakeLists.txt +++ b/smtk/plugin/testing/python/CMakeLists.txt @@ -30,7 +30,7 @@ foreach(test ${smtkPVPluginSupportPythonTests}) else() smtk_add_test_python(${test}Py ${testfile}) endif() - set_tests_properties( ${test}Py PROPERTIES LABELS "PVPluginSupport" ) + set_tests_properties( ${test}Py PROPERTIES LABELS "Plugin" ) endforeach() if (SMTK_DATA_DIR) @@ -45,6 +45,6 @@ if (SMTK_DATA_DIR) smtk_add_test_python(${test}Py ${test}.py --data-dir=${SMTK_DATA_DIR} ) endif() - set_tests_properties( ${test}Py PROPERTIES LABELS "PVPluginSupport" ) + set_tests_properties( ${test}Py PROPERTIES LABELS "Plugin" ) endforeach() endif() diff --git a/smtk/project/CMakeLists.txt b/smtk/project/CMakeLists.txt index 8fde79126737a59831c5420058a5674cddcdaed3..c531f335b313a78cac4201395b6d4dc3c2cfa148 100644 --- a/smtk/project/CMakeLists.txt +++ b/smtk/project/CMakeLists.txt @@ -3,7 +3,6 @@ set(projectSrcs Operation.cxx OperationFactory.cxx Project.cxx - RegisterPythonProject.cxx Registrar.cxx ResourceContainer.cxx @@ -27,7 +26,6 @@ set(projectHeaders Operation.h OperationFactory.h Project.h - RegisterPythonProject.h Registrar.h ResourceContainer.h Tags.h @@ -52,7 +50,7 @@ foreach (iconFile ${iconFiles}) get_filename_component(genFileBase "${iconFile}" NAME_WE) set(genFile "${CMAKE_CURRENT_BINARY_DIR}/view/icons/${genFileBase}_svg.h") configureFileAsCVariable("${CMAKE_CURRENT_SOURCE_DIR}/${iconFile}" "${genFile}" "${genFileBase}_svg" "") -endforeach() +endforeach () set(projectOperators Add @@ -70,7 +68,7 @@ foreach (operator ${projectOperators}) list(APPEND projectSrcs operators/${operator}.cxx) list(APPEND projectHeaders operators/${operator}.h) list(APPEND _projectDependencies ${headerName}) -endforeach() +endforeach () add_custom_target(projectGenHeaders DEPENDS ${_projectDependencies}) set(projectDependencies ${_projectDependencies} PARENT_SCOPE) @@ -78,7 +76,7 @@ set(projectDependencies ${_projectDependencies} PARENT_SCOPE) smtk_public_headers(smtkCore ${projectHeaders}) cmake_dependent_option( - SMTK_ENABLE_PROJECT_UI "Build plugin with smtk::project UI elements" OFF SMTK_ENABLE_PARAVIEW_SUPPORT OFF) + SMTK_ENABLE_PROJECT_UI "Build plugin with smtk::project UI elements" ON SMTK_ENABLE_PARAVIEW_SUPPORT OFF) mark_as_advanced(SMTK_ENABLE_PROJECT_UI) if(SMTK_ENABLE_PARAVIEW_SUPPORT) @@ -87,6 +85,10 @@ if(SMTK_ENABLE_PARAVIEW_SUPPORT) endif() if (SMTK_ENABLE_PYTHON_WRAPPING) + list(APPEND projectSrcs + RegisterPythonProject.cxx) + list(APPEND projectHeaders + RegisterPythonProject.h) add_subdirectory(pybind11) endif() diff --git a/smtk/project/Metadata.h b/smtk/project/Metadata.h index 65e95083fccaee4385b43b104bd7354fb2817c71..233771e2365027d6a8d3efc877996df860d454b6 100644 --- a/smtk/project/Metadata.h +++ b/smtk/project/Metadata.h @@ -41,9 +41,9 @@ public: const std::set& resources = std::set(), const std::set& operations = std::set(), const std::string& version = "0.0.0") - : m_typeName(typeName) + : create(createFunctor) + , m_typeName(typeName) , m_index(index) - , create(createFunctor) , m_resources(resources) , m_operations(operations) , m_version(version) diff --git a/smtk/project/Project.cxx b/smtk/project/Project.cxx index d455d7c80d4f3c91da17e187eeecce87d26de104..62b4a513af84e497f0fe20da7154d661cf4ffa9c 100644 --- a/smtk/project/Project.cxx +++ b/smtk/project/Project.cxx @@ -19,7 +19,6 @@ Project::Project(const std::string& typeName) : m_resources(this, smtk::resource::Resource::m_manager) , m_operations(std::weak_ptr()) , m_typeName(typeName) - , m_manager(nullptr) { } diff --git a/smtk/project/Project.h b/smtk/project/Project.h index 81e348ac82eca73699b3512e5b16c76206750248..dc9d2eccfbde833718ccdcecafa78cffe8ab08ad 100644 --- a/smtk/project/Project.h +++ b/smtk/project/Project.h @@ -103,7 +103,7 @@ private: OperationFactory m_operations; std::string m_typeName; std::string m_version; - smtk::project::Manager* m_manager; + smtk::project::Manager* m_manager{ nullptr }; }; } // namespace project } // namespace smtk diff --git a/smtk/project/Registrar.cxx b/smtk/project/Registrar.cxx index d57a7b9db8028a1d0fc3f865ca43ba99e6d62bf9..761925db0e3305e7606dadc87297e0339e3fe6b2 100644 --- a/smtk/project/Registrar.cxx +++ b/smtk/project/Registrar.cxx @@ -69,11 +69,15 @@ void Registrar::unregisterFrom(const smtk::common::Managers::Ptr& managers) void Registrar::registerTo(const smtk::operation::Manager::Ptr& operationManager) { + (void)operationManager; /// Defer the registration of project operations until there is a project /// manager available. } -void Registrar::unregisterFrom(const smtk::operation::Manager::Ptr& operationManager) {} +void Registrar::unregisterFrom(const smtk::operation::Manager::Ptr& operationManager) +{ + (void)operationManager; +} void Registrar::registerTo(const smtk::project::Manager::Ptr& projectManager) { diff --git a/smtk/project/ResourceContainer.cxx b/smtk/project/ResourceContainer.cxx index 50dda442b9673ee1a14436434768fd12a7899d19..faea200e71ef0eadaf0051b24c74046e327f1a4a 100644 --- a/smtk/project/ResourceContainer.cxx +++ b/smtk/project/ResourceContainer.cxx @@ -220,34 +220,45 @@ smtk::resource::ConstResourcePtr ResourceContainer::get(const std::string& url) return smtk::resource::ConstResourcePtr(); } -smtk::resource::ResourcePtr ResourceContainer::getByRole(const std::string& role) +std::set ResourceContainer::findByRole(const std::string& role) { - // No type casting is required, so we simply find and return the resource by - // key. + std::set resource_set; + + // Get the resources by role typedef Container::index::type ResourcesByRole; ResourcesByRole& resources = m_resources.get(); ResourcesByRole::iterator resourceIt = resources.find(role); - if (resourceIt != resources.end()) + for (; resourceIt != resources.end(); ++resourceIt) { - return *resourceIt; + if (detail::role(*resourceIt) != role) + { + break; + } + resource_set.insert(*resourceIt); } - return smtk::resource::ResourcePtr(); + return resource_set; } -smtk::resource::ConstResourcePtr ResourceContainer::getByRole(const std::string& role) const +std::set ResourceContainer::findByRole( + const std::string& role) const { - // No type casting is required, so we simply find and return the resource by - // key. + std::set resource_set; + + // Get the resources by role typedef Container::index::type ResourcesByRole; const ResourcesByRole& resources = m_resources.get(); - ResourcesByRole::const_iterator resourceIt = resources.find(role); - if (resourceIt != resources.end()) + ResourcesByRole::iterator resourceIt = resources.find(role); + for (; resourceIt != resources.end(); ++resourceIt) { - return *resourceIt; + if (detail::role(*resourceIt) != role) + { + break; + } + resource_set.insert(*resourceIt); } - return smtk::resource::ConstResourcePtr(); + return resource_set; } std::set ResourceContainer::find(const std::string& typeName) const diff --git a/smtk/project/ResourceContainer.h b/smtk/project/ResourceContainer.h index 616988b913ea994377363a5a54c43f97bed8c88b..5b4eef13c51fa1caddd30ceee183549b23050973 100644 --- a/smtk/project/ResourceContainer.h +++ b/smtk/project/ResourceContainer.h @@ -14,6 +14,7 @@ #include "smtk/CoreExports.h" #include "smtk/PublicPointerDefs.h" +#include "smtk/common/Deprecation.h" #include "smtk/common/TypeName.h" #include "smtk/project/Tags.h" @@ -67,7 +68,7 @@ public: const smtk::resource::ResourcePtr&, const std::string&, &smtk::resource::detail::location>>, - boost::multi_index::ordered_unique< + boost::multi_index::ordered_non_unique< boost::multi_index::tag, boost::multi_index::global_fun< const smtk::resource::ResourcePtr&, @@ -75,6 +76,9 @@ public: &smtk::project::detail::role>>>> Container; + using iterator = typename Container::iterator; + using const_iterator = typename Container::const_iterator; + /// A property key for accessing string-valued roles assigned to a resource /// held by a project. static constexpr const char* const role_name = "project_role"; @@ -118,12 +122,54 @@ public: /// Returns the resource that relates to the given role. If no association /// exists this will return a null pointer - smtk::resource::ResourcePtr getByRole(const std::string&); - smtk::resource::ConstResourcePtr getByRole(const std::string&) const; + SMTK_DEPRECATED_IN_21_07("New API is findByRole and returns a std::set") + smtk::resource::ResourcePtr getByRole(const std::string& role) + { + auto resource_set = this->findByRole(role); + if (resource_set.empty()) + { + return smtk::resource::ResourcePtr(nullptr); + } + else + { + return *(resource_set.begin()); + } + } + + SMTK_DEPRECATED_IN_21_07("New API is findByRole and returns a std::set") + smtk::resource::ConstResourcePtr getByRole(const std::string& role) const + { + auto resource_set = this->findByRole(role); + if (resource_set.empty()) + { + return smtk::resource::ConstResourcePtr(nullptr); + } + else + { + return *(resource_set.begin()); + } + } + template - smtk::shared_ptr getByRole(const std::string&); + SMTK_DEPRECATED_IN_21_07("New API is findByRole and returns a std::set") + smtk::shared_ptr getByRole(const std::string& role) + { + return std::dynamic_pointer_cast(this->getByRole(role)); + } + + template + SMTK_DEPRECATED_IN_21_07("New API is findByRole and returns a std::set") + smtk::shared_ptr getByRole(const std::string& role) const + { + return std::dynamic_pointer_cast(this->getByRole(role)); + } + + std::set findByRole(const std::string&); + std::set findByRole(const std::string&) const; template - smtk::shared_ptr getByRole(const std::string&) const; + std::set> findByRole(const std::string&); + template + std::set> findByRole(const std::string&) const; /// Returns a set of resources that have a given typename, type index or class /// type. @@ -152,17 +198,14 @@ public: const std::set& types() const { return m_types; } std::set& types() { return m_types; } - const Container& resources() const { return m_resources; } - Container& resources() { return m_resources; } - std::shared_ptr manager() const { return m_manager.lock(); } void setManager(const std::weak_ptr& manager) { m_manager = manager; } - Container::const_iterator begin() const { return m_resources.begin(); } - Container::iterator begin() { return m_resources.begin(); } + const_iterator begin() const { return m_resources.begin(); } + iterator begin() { return m_resources.begin(); } - Container::const_iterator end() const { return m_resources.end(); } - Container::iterator end() { return m_resources.end(); } + const_iterator end() const { return m_resources.end(); } + iterator end() { return m_resources.end(); } bool empty() const { return m_resources.empty(); } std::size_t size() const { return m_resources.size(); } @@ -215,15 +258,26 @@ smtk::shared_ptr ResourceContainer::get(const std::string& u } template -smtk::shared_ptr ResourceContainer::getByRole(const std::string& role) +std::set> ResourceContainer::findByRole(const std::string& role) { - return smtk::static_pointer_cast(this->getByRole(role)); + std::set> cast_set; + for (const auto& resourceptr : this->findByRole(role)) + { + cast_set.insert(smtk::dynamic_pointer_cast(resourceptr)); + } + return cast_set; } template -smtk::shared_ptr ResourceContainer::getByRole(const std::string& role) const +std::set> ResourceContainer::findByRole( + const std::string& role) const { - return smtk::static_pointer_cast(this->getByRole(role)); + std::set> cast_set; + for (auto resourceptr : this->findByRole(role)) + { + cast_set.insert(smtk::dynamic_pointer_cast(resourceptr)); + } + return cast_set; } template diff --git a/smtk/project/examples/cxx/browseProject.cxx b/smtk/project/examples/cxx/browseProject.cxx index 18636d6bf6240d918bfa1f88759e25551b17d351..806e1e01151c4ed96e47ea03dc6e450aec77e2e0 100644 --- a/smtk/project/examples/cxx/browseProject.cxx +++ b/smtk/project/examples/cxx/browseProject.cxx @@ -24,6 +24,8 @@ #include "smtk/attribute/Registrar.h" +#include "smtk/plugin/Registry.h" + #include "smtk/project/examples/cxx/ProjectBrowser.h" #include "smtk/project/Manager.h" @@ -76,15 +78,25 @@ protected: struct Registrar { - static void registerTo(smtk::resource::Manager::Ptr& resourceManager) + static void registerTo(const smtk::resource::Manager::Ptr& resourceManager) { resourceManager->registerResource(); } - static void registerTo(smtk::project::Manager::Ptr& projectManager) + static void unregisterFrom(const smtk::resource::Manager::Ptr& resourceManager) + { + resourceManager->unregisterResource(); + } + + static void registerTo(const smtk::project::Manager::Ptr& projectManager) { projectManager->registerProject("MyProject", { "MyResource" }, {}); } + + static void unregisterFrom(const smtk::project::Manager::Ptr& projectManager) + { + // projectManager->unregisterProject("MyProject"); + } }; } // namespace @@ -105,24 +117,19 @@ int main(int argc, char* argv[]) // Create a resource manager smtk::resource::ManagerPtr resourceManager = smtk::resource::Manager::create(); - // Register project resources with the resource manager - smtk::project::Registrar::registerTo(resourceManager); - - // Register MyResource - ::Registrar::registerTo(resourceManager); - // Create an operation manager smtk::operation::ManagerPtr operationManager = smtk::operation::Manager::create(); - // Register project operations with the operation manager - smtk::project::Registrar::registerTo(operationManager); + // Register project resources and operations with their managers + auto projectRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); // Create a project manager smtk::project::ManagerPtr projectManager = smtk::project::Manager::create(resourceManager, operationManager); - // Register our not-so-custom Project with the manager. - ::Registrar::registerTo(projectManager); + // Register MyResource our not-so-custom Project with the manager. + auto registry = smtk::plugin::addToManagers<::Registrar>(resourceManager, projectManager); // Create an instance of smtk::project::Project auto project = projectManager->create("MyProject"); @@ -135,10 +142,10 @@ int main(int argc, char* argv[]) project->resources().add(myResource); auto viewManager = smtk::view::Manager::create(); - smtk::view::Registrar::registerTo(viewManager); - smtk::model::Registrar::registerTo(resourceManager); - smtk::attribute::Registrar::registerTo(resourceManager); - smtk::project::Registrar::registerTo(viewManager); + auto viewRegistry = smtk::plugin::addToManagers(viewManager); + auto modelRegistry = smtk::plugin::addToManagers(resourceManager); + auto attributeRegistry = smtk::plugin::addToManagers(resourceManager); + auto projectViewRegistry = smtk::plugin::addToManagers(viewManager); nlohmann::json jconfig; if (configname) diff --git a/smtk/project/json/jsonResourceContainer.cxx b/smtk/project/json/jsonResourceContainer.cxx index eb8a4e599febaeae7c19f9f1aeab7896e0aa4351..031a66006115bc9cf1fc9eff85fc61241ede4330 100644 --- a/smtk/project/json/jsonResourceContainer.cxx +++ b/smtk/project/json/jsonResourceContainer.cxx @@ -20,7 +20,8 @@ namespace project void to_json(json& j, const ResourceContainer& resourceContainer) { j["types"] = resourceContainer.types(); - for (const auto& resource : resourceContainer.resources()) + j["resources"] = json::array(); + for (const auto& resource : resourceContainer) { j["resources"].push_back(resource); } diff --git a/smtk/project/operators/Write.cxx b/smtk/project/operators/Write.cxx index 5fe995bbe56d754a2532ee68fa360c4a3b638dd6..56fc974bd19f1e08cf5017ffb8ff99ebf320d403 100644 --- a/smtk/project/operators/Write.cxx +++ b/smtk/project/operators/Write.cxx @@ -100,7 +100,7 @@ Write::Result Write::operateInternal() if (resource->location().empty()) { - std::string filename = role + ".smtk"; + std::string filename = role + "-" + resource->id().toString() + ".smtk"; boost::filesystem::path location = resourcesFolderPath / filename; resource->setLocation(location.string()); } diff --git a/smtk/project/plugin/AutoStart.cxx b/smtk/project/plugin/AutoStart.cxx index 4936de3465dfb85c3aa5bfea5ef4a76bd4994737..87c300351855e4d8efc6417aec2c08cdc60d34d1 100644 --- a/smtk/project/plugin/AutoStart.cxx +++ b/smtk/project/plugin/AutoStart.cxx @@ -61,9 +61,9 @@ AutoStart::~AutoStart() = default; void AutoStart::startup() { #ifdef ENABLE_PROJECT_UI - auto projectMenuMgr = pqSMTKProjectMenu::instance(this); + auto* projectMenuMgr = pqSMTKProjectMenu::instance(this); - auto pqCore = pqApplicationCore::instance(); + auto* pqCore = pqApplicationCore::instance(); if (pqCore) { pqCore->registerManager("smtk project menu", projectMenuMgr); @@ -77,7 +77,7 @@ void AutoStart::startup() void AutoStart::shutdown() { - auto pqCore = pqApplicationCore::instance(); + auto* pqCore = pqApplicationCore::instance(); if (pqCore) { pqCore->unRegisterManager("smtk project menu"); diff --git a/smtk/project/plugin/CMakeLists.txt b/smtk/project/plugin/CMakeLists.txt index 501c0056d4eb90ec573d62a9c1dd19002ffe4325..e02adc5404b08347302f7423a5165656ed19e3b4 100644 --- a/smtk/project/plugin/CMakeLists.txt +++ b/smtk/project/plugin/CMakeLists.txt @@ -1,5 +1,5 @@ if (SMTK_ENABLE_PROJECT_UI) - set(ui_classes + set(uiClasses AutoStart pqSMTKProjectBrowser pqSMTKProjectMenu @@ -7,6 +7,9 @@ if (SMTK_ENABLE_PROJECT_UI) ) set(uiFiles) + foreach(class ${uiClasses}) + list(APPEND uiFiles ${class}.cxx) + endforeach() smtk_encode_file("${CMAKE_CURRENT_SOURCE_DIR}/ProjectPanelConfiguration.json" TYPE "_json" @@ -42,7 +45,6 @@ endif () smtk_add_plugin(smtkProjectPlugin REGISTRAR smtk::project::plugin::Registrar - REGISTRAR_HEADER smtk/project/plugin/Registrar.h MANAGERS smtk::common::Managers smtk::operation::Manager @@ -52,7 +54,7 @@ smtk_add_plugin(smtkProjectPlugin PARAVIEW_PLUGIN_ARGS VERSION 1.0 SOURCES - Registrar + Registrar.cxx ${ui_classes} ${plugin_ui_srcs} UI_INTERFACES diff --git a/smtk/project/plugin/Registrar.cxx b/smtk/project/plugin/Registrar.cxx index ee18bcb5fab1d842800e08e61f6c215e400a7671..33824bd98ed8e8fb536aa1b11e9f272caf7bf249 100644 --- a/smtk/project/plugin/Registrar.cxx +++ b/smtk/project/plugin/Registrar.cxx @@ -31,6 +31,7 @@ void Registrar::unregisterFrom(const smtk::project::Manager::Ptr& projectManager void Registrar::registerTo(const smtk::view::Manager::Ptr& viewManager) { + (void)viewManager; #ifdef ENABLE_PROJECT_UI viewManager->viewWidgetFactory().registerType(); #endif @@ -38,6 +39,7 @@ void Registrar::registerTo(const smtk::view::Manager::Ptr& viewManager) void Registrar::unregisterFrom(const smtk::view::Manager::Ptr& viewManager) { + (void)viewManager; #ifdef ENABLE_PROJECT_UI viewManager->viewWidgetFactory().unregisterType(); #endif diff --git a/smtk/project/plugin/pqSMTKProjectBrowser.cxx b/smtk/project/plugin/pqSMTKProjectBrowser.cxx index b2b97f089fa769cb53f6855dc4df627c46bb1233..e03320b0b652b16b058af33c9c45254da38cf28c 100644 --- a/smtk/project/plugin/pqSMTKProjectBrowser.cxx +++ b/smtk/project/plugin/pqSMTKProjectBrowser.cxx @@ -85,7 +85,7 @@ pqSMTKProjectBrowser::pqSMTKProjectBrowser(const smtk::view::Information& info) // Ensure the phrase model is configured to listen to the proper managers. // Listen for resources on current connections: - auto smtkBehavior = pqSMTKBehavior::instance(); + auto* smtkBehavior = pqSMTKBehavior::instance(); smtkBehavior->visitResourceManagersOnServers([this](pqSMTKWrapper* r, pqServer* s) { this->sourceAdded(r, s); return false; @@ -143,6 +143,6 @@ void pqSMTKProjectBrowser::sourceRemoved(pqSMTKWrapper* mgr, pqServer* server) void pqSMTKProjectBrowser::updateSettings() { - auto smtkSettings = vtkSMTKSettings::GetInstance(); + auto* smtkSettings = vtkSMTKSettings::GetInstance(); this->setHighlightOnHover(smtkSettings->GetHighlightOnHover()); } diff --git a/smtk/project/plugin/pqSMTKProjectMenu.cxx b/smtk/project/plugin/pqSMTKProjectMenu.cxx index 9628cd409745f91093abcd91195a9348c3eaee1b..a2394ea020b2176552c5d85a58e61b32088e8f2c 100644 --- a/smtk/project/plugin/pqSMTKProjectMenu.cxx +++ b/smtk/project/plugin/pqSMTKProjectMenu.cxx @@ -106,8 +106,8 @@ void pqNewProjectReaction::newProject() if (!typeName.empty()) { - auto pqCore = pqApplicationCore::instance(); - auto builder = pqCore->getObjectBuilder(); + auto* pqCore = pqApplicationCore::instance(); + auto* builder = pqCore->getObjectBuilder(); pqSMTKResource* src = static_cast(builder->createSource("sources", "SMTKResourceCreator", server)); @@ -155,12 +155,10 @@ static pqSMTKProjectMenu* g_instance = nullptr; pqSMTKProjectMenu::pqSMTKProjectMenu(QObject* parent) : Superclass(parent) { - // Wait until the event loop starts, ensuring that the main window will be - // accessible. - QTimer::singleShot(10, this, [this]() { - auto pqCore = pqApplicationCore::instance(); - if (pqCore) - { + auto* pqCore = pqApplicationCore::instance(); + if (pqCore) + { + QObject::connect(pqCore, &pqApplicationCore::clientEnvironmentDone, [this]() { QMainWindow* mainWindow = qobject_cast(pqCoreUtilities::mainWidget()); QList menuBarActions = mainWindow->menuBar()->actions(); @@ -231,8 +229,8 @@ pqSMTKProjectMenu::pqSMTKProjectMenu(QObject* parent) mainWindow->menuBar()->insertMenu(::findHelpMenuAction(mainWindow->menuBar()), menu); } new pqNewProjectReaction(newProjectAction); - } - }); + }); + } } pqSMTKProjectMenu* pqSMTKProjectMenu::instance(QObject* parent) diff --git a/smtk/project/plugin/pqSMTKProjectPanel.cxx b/smtk/project/plugin/pqSMTKProjectPanel.cxx index 3631a16bc3955de9e16edd0e4cbf74d538770a21..c9203d80a1dc06704cacc2f0475a6771874eb73b 100644 --- a/smtk/project/plugin/pqSMTKProjectPanel.cxx +++ b/smtk/project/plugin/pqSMTKProjectPanel.cxx @@ -23,15 +23,13 @@ pqSMTKProjectPanel::pqSMTKProjectPanel(QWidget* parent) : Superclass(parent) - , m_browser(nullptr) - , m_viewUIMgr(nullptr) { // Parse a json representation of our default config, save it. nlohmann::json j = nlohmann::json::parse(pqSMTKProjectBrowser::getJSONConfiguration()); smtk::view::ConfigurationPtr config = j[0]; this->setView(config); - auto smtkBehavior = pqSMTKBehavior::instance(); + auto* smtkBehavior = pqSMTKBehavior::instance(); // Now listen for future connections. QObject::connect( smtkBehavior, @@ -56,7 +54,7 @@ void pqSMTKProjectPanel::setView(const smtk::view::ConfigurationPtr& view) { m_view = view; - auto smtkBehavior = pqSMTKBehavior::instance(); + auto* smtkBehavior = pqSMTKBehavior::instance(); smtkBehavior->visitResourceManagersOnServers([this](pqSMTKWrapper* r, pqServer* s) { this->sourceAdded(r, s); @@ -93,7 +91,7 @@ void pqSMTKProjectPanel::sourceAdded(pqSMTKWrapper* wrapper, pqServer* server) smtk::extension::ViewInfo resinfo(m_view, this, m_viewUIMgr); // the top-level "Type" in m_view should be pqSMTKProjectBrowser or compatible. - auto baseview = m_viewUIMgr->setSMTKView(resinfo); + auto* baseview = m_viewUIMgr->setSMTKView(resinfo); m_browser = dynamic_cast(baseview); if (!m_browser) { diff --git a/smtk/project/plugin/pqSMTKProjectPanel.h b/smtk/project/plugin/pqSMTKProjectPanel.h index 52012e9edcf2eef29e90cdfe5f96272cb40957d5..f22cb70a7dcc7b842ab1f25deb244d2f328416f4 100644 --- a/smtk/project/plugin/pqSMTKProjectPanel.h +++ b/smtk/project/plugin/pqSMTKProjectPanel.h @@ -35,9 +35,9 @@ protected slots: virtual void sourceRemoved(pqSMTKWrapper* mgr, pqServer* server); protected: - pqSMTKProjectBrowser* m_browser; + pqSMTKProjectBrowser* m_browser{ nullptr }; smtk::view::ConfigurationPtr m_view; - smtk::extension::qtUIManager* m_viewUIMgr; + smtk::extension::qtUIManager* m_viewUIMgr{ nullptr }; }; #endif diff --git a/smtk/project/pybind11/PybindContainer.h b/smtk/project/pybind11/PybindContainer.h index b98bf181789b7c488baf109455fd31b2e7fe138e..ab82971d48213c0cb468de1b6c9123c55604be9b 100644 --- a/smtk/project/pybind11/PybindContainer.h +++ b/smtk/project/pybind11/PybindContainer.h @@ -21,22 +21,22 @@ namespace py = pybind11; -void pybind11_init_smtk_project_detail_id(py::module &m) +inline void pybind11_init_smtk_project_detail_id(py::module &m) { m.def("id", &smtk::project::detail::id, "", py::arg("r")); } -void pybind11_init_smtk_project_detail_index(py::module &m) +inline void pybind11_init_smtk_project_detail_index(py::module &m) { m.def("index", &smtk::project::detail::index, "", py::arg("r")); } -void pybind11_init_smtk_project_detail_location(py::module &m) +inline void pybind11_init_smtk_project_detail_location(py::module &m) { m.def("location", &smtk::project::detail::location, "", py::arg("r")); } -void pybind11_init_smtk_project_detail_name(py::module &m) +inline void pybind11_init_smtk_project_detail_name(py::module &m) { m.def("name", &smtk::project::detail::name, "", py::arg("r")); } diff --git a/smtk/project/pybind11/PybindManager.h b/smtk/project/pybind11/PybindManager.h index 054ab222360bd15f9269b329d580a77b10811e44..860de408eb167b1711edea78532c55c59b8fbc90 100644 --- a/smtk/project/pybind11/PybindManager.h +++ b/smtk/project/pybind11/PybindManager.h @@ -25,7 +25,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::project::Manager > pybind11_init_smtk_project_Manager(py::module &m) +inline PySharedPtrClass< smtk::project::Manager > pybind11_init_smtk_project_Manager(py::module &m) { PySharedPtrClass< smtk::project::Manager > instance(m, "Manager"); instance diff --git a/smtk/project/pybind11/PybindMetadata.h b/smtk/project/pybind11/PybindMetadata.h index 0fdeabaff0f42e56a614cf6b764df18af27a7e7d..d548da6d61c36f9a2cda41ab2786e0cc960ad48f 100644 --- a/smtk/project/pybind11/PybindMetadata.h +++ b/smtk/project/pybind11/PybindMetadata.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::project::Metadata > pybind11_init_smtk_project_Metadata(py::module &m) +inline py::class_< smtk::project::Metadata > pybind11_init_smtk_project_Metadata(py::module &m) { py::class_< smtk::project::Metadata > instance(m, "Metadata"); instance diff --git a/smtk/project/pybind11/PybindObserver.h b/smtk/project/pybind11/PybindObserver.h index 5d361fbc07a4fc6b5572131e3a0b970cb0ef05cc..7c826b6757cce97cbf0dcc480ea7f7ddf9607b7d 100644 --- a/smtk/project/pybind11/PybindObserver.h +++ b/smtk/project/pybind11/PybindObserver.h @@ -17,7 +17,7 @@ namespace py = pybind11; -void pybind11_init_smtk_project_EventType(py::module &m) +inline void pybind11_init_smtk_project_EventType(py::module &m) { py::enum_(m, "EventType") .value("ADDED", smtk::project::EventType::ADDED) diff --git a/smtk/project/pybind11/PybindOperation.h b/smtk/project/pybind11/PybindOperation.h index a6d324a16eb5c9483b08239a70f01acdbdfce640..306815c304ca624a9320e82234b8c0e647584a64 100644 --- a/smtk/project/pybind11/PybindOperation.h +++ b/smtk/project/pybind11/PybindOperation.h @@ -20,7 +20,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::project::Operation, smtk::operation::XMLOperation > pybind11_init_smtk_project_Operation(py::module &m) +inline PySharedPtrClass< smtk::project::Operation, smtk::operation::XMLOperation > pybind11_init_smtk_project_Operation(py::module &m) { py::module::import("smtk.operation"); diff --git a/smtk/project/pybind11/PybindOperationFactory.h b/smtk/project/pybind11/PybindOperationFactory.h index e2079aeed55b584b410f5eac4dfaef27fee1a7da..d77141e37adee6bf4eefcc090c696a05e348b479 100644 --- a/smtk/project/pybind11/PybindOperationFactory.h +++ b/smtk/project/pybind11/PybindOperationFactory.h @@ -19,7 +19,7 @@ namespace py = pybind11; -py::class_< smtk::project::OperationFactory > pybind11_init_smtk_project_OperationFactory(py::module &m) +inline py::class_< smtk::project::OperationFactory > pybind11_init_smtk_project_OperationFactory(py::module &m) { py::class_< smtk::project::OperationFactory > instance(m, "OperationFactory"); instance diff --git a/smtk/project/pybind11/PybindProject.cxx b/smtk/project/pybind11/PybindProject.cxx index d8f79b602cf1136a81b4fe9f851d6c0b20ff1927..47c577ee1c71d05596d5d23540644c8057420b93 100644 --- a/smtk/project/pybind11/PybindProject.cxx +++ b/smtk/project/pybind11/PybindProject.cxx @@ -8,6 +8,8 @@ // PURPOSE. See the above copyright notice for more information. //========================================================================= +#define SMTK_DEPRECATION_LEVEL 0 + #include "smtk/common/CompilerInformation.h" SMTK_THIRDPARTY_PRE_INCLUDE diff --git a/smtk/project/pybind11/PybindProject.h b/smtk/project/pybind11/PybindProject.h index a3892d1506d966418531fa8f124b07d8e2c64e66..bd38ce7abdf418446acf8f38cf27ea3c3eeaae7c 100644 --- a/smtk/project/pybind11/PybindProject.h +++ b/smtk/project/pybind11/PybindProject.h @@ -26,7 +26,7 @@ namespace py = pybind11; -PySharedPtrClass pybind11_init_smtk_project_Project(py::module& m) +inline PySharedPtrClass pybind11_init_smtk_project_Project(py::module& m) { PySharedPtrClass instance(m, "Project"); diff --git a/smtk/project/pybind11/PybindRegistrar.h b/smtk/project/pybind11/PybindRegistrar.h index c8695e06843aa84be49d63684d1943410a50443d..6d3ccc1fcb0dfe2bac93bd64664c06beea1827b7 100644 --- a/smtk/project/pybind11/PybindRegistrar.h +++ b/smtk/project/pybind11/PybindRegistrar.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::project::Registrar > pybind11_init_smtk_project_Registrar(py::module &m) +inline py::class_< smtk::project::Registrar > pybind11_init_smtk_project_Registrar(py::module &m) { py::class_< smtk::project::Registrar > instance(m, "Registrar"); instance diff --git a/smtk/project/pybind11/PybindResourceContainer.h b/smtk/project/pybind11/PybindResourceContainer.h index 852c6215869f3818a6b89a2178482a44f324f44a..f2f9abccce7152e7f7bb179ff66e02b1ebd6b442 100644 --- a/smtk/project/pybind11/PybindResourceContainer.h +++ b/smtk/project/pybind11/PybindResourceContainer.h @@ -22,7 +22,7 @@ namespace py = pybind11; -py::class_< smtk::project::ResourceContainer > pybind11_init_smtk_project_ResourceContainer(py::module &m) +inline py::class_< smtk::project::ResourceContainer > pybind11_init_smtk_project_ResourceContainer(py::module &m) { py::class_< smtk::project::ResourceContainer > instance(m, "ResourceContainer"); instance @@ -48,6 +48,8 @@ py::class_< smtk::project::ResourceContainer > pybind11_init_smtk_project_Resour .def("get", (smtk::resource::ConstResourcePtr (smtk::project::ResourceContainer::*)(::smtk::common::UUID const &) const) &smtk::project::ResourceContainer::get, py::arg("id")) .def("get", (smtk::resource::ResourcePtr (smtk::project::ResourceContainer::*)(::std::string const &)) &smtk::project::ResourceContainer::get, py::arg("arg0")) .def("get", (smtk::resource::ConstResourcePtr (smtk::project::ResourceContainer::*)(::std::string const &) const) &smtk::project::ResourceContainer::get, py::arg("arg0")) + .def("findByRole", (std::set (smtk::project::ResourceContainer::*)(::std::string const &)) &smtk::project::ResourceContainer::findByRole, py::arg("arg0")) + .def("findByRole", (std::set (smtk::project::ResourceContainer::*)(::std::string const &) const) &smtk::project::ResourceContainer::findByRole, py::arg("arg0")) .def("getByRole", (smtk::resource::ResourcePtr (smtk::project::ResourceContainer::*)(::std::string const &)) &smtk::project::ResourceContainer::getByRole, py::arg("arg0")) .def("getByRole", (smtk::resource::ConstResourcePtr (smtk::project::ResourceContainer::*)(::std::string const &) const) &smtk::project::ResourceContainer::getByRole, py::arg("arg0")) .def("manager", &smtk::project::ResourceContainer::manager) @@ -55,8 +57,8 @@ py::class_< smtk::project::ResourceContainer > pybind11_init_smtk_project_Resour .def("registerResource", (bool (smtk::project::ResourceContainer::*)(::smtk::resource::Resource::Index const &)) &smtk::project::ResourceContainer::registerResource, py::arg("arg0")) .def("registerResources", &smtk::project::ResourceContainer::registerResources, py::arg("arg0")) .def("remove", &smtk::project::ResourceContainer::remove, py::arg("arg0")) - .def("resources", (smtk::project::ResourceContainer::Container const & (smtk::project::ResourceContainer::*)() const) &smtk::project::ResourceContainer::resources) - .def("resources", (smtk::project::ResourceContainer::Container & (smtk::project::ResourceContainer::*)()) &smtk::project::ResourceContainer::resources) + //.def("resources", (smtk::project::ResourceContainer::Container const & (smtk::project::ResourceContainer::*)() const) &smtk::project::ResourceContainer::resources) + //.def("resources", (smtk::project::ResourceContainer::Container & (smtk::project::ResourceContainer::*)()) &smtk::project::ResourceContainer::resources) .def("setManager", &smtk::project::ResourceContainer::setManager, py::arg("manager")) .def("size", &smtk::project::ResourceContainer::size) .def("types", (std::set, std::less >, std::allocator > > const & (smtk::project::ResourceContainer::*)() const) &smtk::project::ResourceContainer::types) @@ -67,7 +69,7 @@ py::class_< smtk::project::ResourceContainer > pybind11_init_smtk_project_Resour return instance; } -void pybind11_init_smtk_project_detail_role(py::module &m) +inline void pybind11_init_smtk_project_detail_role(py::module &m) { m.def("role", &smtk::project::detail::role, "", py::arg("r")); } diff --git a/smtk/project/pybind11/PybindTags.h b/smtk/project/pybind11/PybindTags.h index a303474f5b6ccea2abd93f97559e5a79c63551e6..2b121829a40550bbf53ad10572e391fec557c4b9 100644 --- a/smtk/project/pybind11/PybindTags.h +++ b/smtk/project/pybind11/PybindTags.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::project::IdTag > pybind11_init_smtk_project_IdTag(py::module &m) +inline py::class_< smtk::project::IdTag > pybind11_init_smtk_project_IdTag(py::module &m) { py::class_< smtk::project::IdTag > instance(m, "IdTag"); instance @@ -28,7 +28,7 @@ py::class_< smtk::project::IdTag > pybind11_init_smtk_project_IdTag(py::module & return instance; } -py::class_< smtk::project::IndexTag > pybind11_init_smtk_project_IndexTag(py::module &m) +inline py::class_< smtk::project::IndexTag > pybind11_init_smtk_project_IndexTag(py::module &m) { py::class_< smtk::project::IndexTag > instance(m, "IndexTag"); instance @@ -39,7 +39,7 @@ py::class_< smtk::project::IndexTag > pybind11_init_smtk_project_IndexTag(py::mo return instance; } -py::class_< smtk::project::LocationTag > pybind11_init_smtk_project_LocationTag(py::module &m) +inline py::class_< smtk::project::LocationTag > pybind11_init_smtk_project_LocationTag(py::module &m) { py::class_< smtk::project::LocationTag > instance(m, "LocationTag"); instance @@ -50,7 +50,7 @@ py::class_< smtk::project::LocationTag > pybind11_init_smtk_project_LocationTag( return instance; } -py::class_< smtk::project::NameTag > pybind11_init_smtk_project_NameTag(py::module &m) +inline py::class_< smtk::project::NameTag > pybind11_init_smtk_project_NameTag(py::module &m) { py::class_< smtk::project::NameTag > instance(m, "NameTag"); instance @@ -61,7 +61,7 @@ py::class_< smtk::project::NameTag > pybind11_init_smtk_project_NameTag(py::modu return instance; } -py::class_< smtk::project::RoleTag > pybind11_init_smtk_project_RoleTag(py::module &m) +inline py::class_< smtk::project::RoleTag > pybind11_init_smtk_project_RoleTag(py::module &m) { py::class_< smtk::project::RoleTag > instance(m, "RoleTag"); instance diff --git a/smtk/project/testing/cxx/CMakeLists.txt b/smtk/project/testing/cxx/CMakeLists.txt index 91bb55781e4efbd92d4956016a0409d7bc1d5592..f075c73d8c4ea849755c0f6615a521045a6c61aa 100644 --- a/smtk/project/testing/cxx/CMakeLists.txt +++ b/smtk/project/testing/cxx/CMakeLists.txt @@ -1,15 +1,19 @@ # Using smtk test harness set(unit_tests - TestDefineOp - TestProject - TestProjectAssociation - TestProjectLifeCycle - TestProjectResources + TestDefineOp.cxx + TestProject.cxx + TestProjectAssociation.cxx + TestProjectLifeCycle.cxx + TestProjectLifeCycle_Deprecated.cxx + TestProjectResources.cxx ) set(unit_tests_which_require_data - TestProjectReadWrite - TestProjectReadWrite2 + TestProjectReadWrite.cxx + TestProjectReadWrite_Deprecated.cxx + TestProjectReadWrite2.cxx + TestProjectReadWrite2_Deprecated.cxx + TestProjectReadWriteEmpty.cxx ) set(extra_libs) if (SMTK_ENABLE_VTK_SUPPORT) diff --git a/smtk/project/testing/cxx/TestDefineOp.cxx b/smtk/project/testing/cxx/TestDefineOp.cxx index 6d9791e6ef2af1491398b879f5be50a1d98079b3..97c17f895e4c1e24f798eec2de0d700f11611d65 100644 --- a/smtk/project/testing/cxx/TestDefineOp.cxx +++ b/smtk/project/testing/cxx/TestDefineOp.cxx @@ -20,6 +20,8 @@ #include "smtk/project/Registrar.h" #include "smtk/project/operators/Define.h" +#include "smtk/plugin/Registry.h" + #include "smtk/common/testing/cxx/helpers.h" // This test registers a project type ("MyProject") with a resource whitelist with @@ -59,15 +61,25 @@ protected: struct Registrar { - static void registerTo(smtk::resource::Manager::Ptr& resourceManager) + static void registerTo(const smtk::resource::Manager::Ptr& resourceManager) { resourceManager->registerResource(); } - static void registerTo(smtk::project::Manager::Ptr& projectManager) + static void unregisterFrom(const smtk::resource::Manager::Ptr& resourceManager) + { + resourceManager->unregisterResource(); + } + + static void registerTo(const smtk::project::Manager::Ptr& projectManager) { projectManager->registerProject("MyProject", { "MyResource" }, {}); } + + static void unregisterFrom(const smtk::project::Manager::Ptr& projectManager) + { + // projectManager->unregisterProject("MyProject"); + } }; } // namespace @@ -80,7 +92,7 @@ int TestDefineOp(int /*unused*/, char** const /*unused*/) smtkTest(resourceManager->empty(), "New resource manager should have no resources."); // Register MyResource - ::Registrar::registerTo(resourceManager); + auto registry = smtk::plugin::addToManagers<::Registrar>(resourceManager); smtkTest( resourceManager->metadata().size() == 1, "Resource manager should have registered a type."); @@ -92,7 +104,7 @@ int TestDefineOp(int /*unused*/, char** const /*unused*/) smtk::project::Manager::create(resourceManager, operationManager); // Register project operations with the project manager - smtk::project::Registrar::registerTo(projectManager); + auto projectRegistry = smtk::plugin::addToManagers(projectManager); auto createProjectTypeOp = operationManager->create(); diff --git a/smtk/project/testing/cxx/TestProjectAssociation.cxx b/smtk/project/testing/cxx/TestProjectAssociation.cxx index 0bde21581ceb2ebfc23a57bf0d29d5fab95e7621..ccd60c301ddabd6fe3ebac642f49dc909c9e1ba3 100644 --- a/smtk/project/testing/cxx/TestProjectAssociation.cxx +++ b/smtk/project/testing/cxx/TestProjectAssociation.cxx @@ -13,6 +13,7 @@ #include "smtk/attribute/Resource.h" #include "smtk/io/AttributeReader.h" #include "smtk/io/Logger.h" +#include "smtk/plugin/Registry.h" #include "smtk/project/Manager.h" #include "smtk/project/Project.h" #include "smtk/project/Registrar.h" @@ -44,10 +45,10 @@ int TestProjectAssociation(int /*unused*/, char** const /*unused*/) std::cout << templateString << std::endl; // Create managers smtk::resource::ManagerPtr resManager = smtk::resource::Manager::create(); - smtk::attribute::Registrar::registerTo(resManager); + auto attributeRegistry = smtk::plugin::addToManagers(resManager); smtk::operation::ManagerPtr opManager = smtk::operation::Manager::create(); smtk::project::ManagerPtr prjManager = smtk::project::Manager::create(resManager, opManager); - smtk::project::Registrar::registerTo(prjManager); + auto projectRegistry = smtk::plugin::addToManagers(prjManager); // Register and create test project // The process of registering our foo project also registers a resource with the same name. diff --git a/smtk/project/testing/cxx/TestProjectLifeCycle.cxx b/smtk/project/testing/cxx/TestProjectLifeCycle.cxx index d003a154a5da0f7f154151697a31688fb2435e16..eba0f8d3f8d46a611446ee9a183bf72d9f82cdbf 100644 --- a/smtk/project/testing/cxx/TestProjectLifeCycle.cxx +++ b/smtk/project/testing/cxx/TestProjectLifeCycle.cxx @@ -18,6 +18,7 @@ #include "smtk/operation/Manager.h" #include "smtk/operation/Operation.h" #include "smtk/operation/XMLOperation.h" +#include "smtk/plugin/Registry.h" #include "smtk/project/Manager.h" #include "smtk/project/Project.h" #include "smtk/project/Registrar.h" @@ -124,10 +125,9 @@ int TestProjectLifeCycle(int /*unused*/, char** const /*unused*/) { // Create managers smtk::resource::ManagerPtr resManager = smtk::resource::Manager::create(); - smtk::attribute::Registrar::registerTo(resManager); - smtk::operation::ManagerPtr opManager = smtk::operation::Manager::create(); - smtk::attribute::Registrar::registerTo(opManager); + auto attributeRegistry = + smtk::plugin::addToManagers(resManager, opManager); #if 0 // This line changes behavior such that projects ARE stored in resource manager @@ -137,7 +137,7 @@ int TestProjectLifeCycle(int /*unused*/, char** const /*unused*/) opManager->registerOperation("CreateProjectOp"); smtk::project::ManagerPtr projManager = smtk::project::Manager::create(resManager, opManager); - smtk::project::Registrar::registerTo(projManager); + auto projectRegistry = smtk::plugin::addToManagers(projManager); projManager->registerProject(PROJECT_TYPE); smtkTest(resManager->empty(), "resource manager size is " << resManager->size()); @@ -166,8 +166,8 @@ int TestProjectLifeCycle(int /*unused*/, char** const /*unused*/) smtkTest(res == nullptr, "resource manager contains project") smtkTest(resManager->size() == 1, "resource manager size not 1"); - auto attRes = project->resources().getByRole(ATT_ROLE_NAME); - smtkTest(attRes != nullptr, "project missing attribute resource"); + auto attRes = project->resources().findByRole(ATT_ROLE_NAME); + smtkTest(!attRes.empty(), "project missing attribute resource with role: " << ATT_ROLE_NAME); // Release the project, check that resource manager unchanged std::cout << "Removing project" << std::endl; @@ -175,7 +175,7 @@ int TestProjectLifeCycle(int /*unused*/, char** const /*unused*/) smtkTest(resManager->size() == 1, "resource manager size not 1"); // And remove the attribute resource - resManager->remove(attRes); + resManager->remove(*(attRes.begin())); smtkTest(resManager->empty(), "resource manager not empty"); } diff --git a/smtk/project/testing/cxx/TestProjectLifeCycle_Deprecated.cxx b/smtk/project/testing/cxx/TestProjectLifeCycle_Deprecated.cxx new file mode 100644 index 0000000000000000000000000000000000000000..27fd9c728a0e498e1346063658aa3288c8d0ca47 --- /dev/null +++ b/smtk/project/testing/cxx/TestProjectLifeCycle_Deprecated.cxx @@ -0,0 +1,186 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#define SMTK_DEPRECATION_LEVEL 2105 + +#include "smtk/attribute/Attribute.h" +#include "smtk/attribute/IntItem.h" +#include "smtk/attribute/Registrar.h" +#include "smtk/attribute/Resource.h" +#include "smtk/attribute/ResourceItem.h" +#include "smtk/io/AttributeReader.h" +#include "smtk/io/Logger.h" +#include "smtk/operation/Manager.h" +#include "smtk/operation/Operation.h" +#include "smtk/operation/XMLOperation.h" +#include "smtk/plugin/Registry.h" +#include "smtk/project/Manager.h" +#include "smtk/project/Project.h" +#include "smtk/project/Registrar.h" +#include "smtk/project/operators/Create.h" + +#include "smtk/common/testing/cxx/helpers.h" + +#include + +#define ATT_ROLE_NAME "attributes" +#define OP_NAME "create-project-op" +#define PROJECT_TYPE "foo" + +// This test verifies that projects can be instantiated outside of the +// SMTK resource manager. + +namespace +{ +const int OP_SUCCEEDED = static_cast(smtk::operation::Operation::Outcome::SUCCEEDED); + +class CreateProjectOp : public smtk::operation::XMLOperation +{ +public: + smtkTypeMacro(CreateProjectOp); + smtkCreateMacro(CreateProjectOp); + smtkSharedFromThisMacro(smtk::operation::Operation); + + CreateProjectOp() = default; + ~CreateProjectOp() override = default; + + bool ableToOperate() override + { + if (m_projManager == nullptr) + { + smtkErrorMacro(this->log(), "Project Manager not set"); + return false; + } + return smtk::operation::XMLOperation::ableToOperate(); + } + + Result operateInternal() override + { + auto project = m_projManager->create(PROJECT_TYPE); + + auto attRes = m_projManager->resourceManager()->create(); + project->resources().add(attRes, ATT_ROLE_NAME); + + auto result = this->createResult(Outcome::SUCCEEDED); + result->findResource("resource")->setValue(project); + return result; + } + + const char* xmlDescription() const override; + + smtk::project::Manager::Ptr m_projManager; +}; + +const char CreateProjectOpXML[] = + "" + "" + " " + " " + " " + " " + " 0" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " 0" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; + +const char* CreateProjectOp::xmlDescription() const +{ + return CreateProjectOpXML; +} + +} // namespace + +int TestProjectLifeCycle_Deprecated(int /*unused*/, char** const /*unused*/) +{ + // Create managers + smtk::resource::ManagerPtr resManager = smtk::resource::Manager::create(); + smtk::operation::ManagerPtr opManager = smtk::operation::Manager::create(); + auto attributeRegistry = + smtk::plugin::addToManagers(resManager, opManager); + +#if 0 + // This line changes behavior such that projects ARE stored in resource manager + opManager->registerResourceManager(resManager); +#endif + + opManager->registerOperation("CreateProjectOp"); + + smtk::project::ManagerPtr projManager = smtk::project::Manager::create(resManager, opManager); + auto projectRegistry = smtk::plugin::addToManagers(projManager); + projManager->registerProject(PROJECT_TYPE); + + smtkTest(resManager->empty(), "resource manager size is " << resManager->size()); + + smtk::resource::Resource::Ptr resource; + smtk::project::Project::Ptr project; + { + std::cout << "Creating project" << std::endl; + + auto createOp = opManager->create(); + smtkTest(createOp != nullptr, "create operation not created") createOp->m_projManager = + projManager; // back door + + auto result = createOp->operate(); + int outcome = result->findInt("outcome")->value(); + smtkTest(outcome == OP_SUCCEEDED, "create operation failed"); + + auto res = result->findResource("resource")->value(); + project = std::dynamic_pointer_cast(res); + smtkTest(res != nullptr, "project not created"); + } + + { + // Is project contained by resource manager? + auto res = resManager->get(project->id()); + smtkTest(res == nullptr, "resource manager contains project") + smtkTest(resManager->size() == 1, "resource manager size not 1"); + + auto attRes = project->resources().getByRole(ATT_ROLE_NAME); + smtkTest(attRes != nullptr, "project missing attribute resource"); + + // Release the project, check that resource manager unchanged + std::cout << "Removing project" << std::endl; + projManager->remove(project); + smtkTest(resManager->size() == 1, "resource manager size not 1"); + + // And remove the attribute resource + resManager->remove(attRes); + smtkTest(resManager->empty(), "resource manager not empty"); + } + + std::cout << "Finis" << std::endl; + return 0; +} diff --git a/smtk/project/testing/cxx/TestProjectReadWrite.cxx b/smtk/project/testing/cxx/TestProjectReadWrite.cxx index da6519bdedf8580f3a8beffaf88ab6f5e4e3f745..2ba2ac80e61aaaaf6473610216a8d5e7a6462f45 100644 --- a/smtk/project/testing/cxx/TestProjectReadWrite.cxx +++ b/smtk/project/testing/cxx/TestProjectReadWrite.cxx @@ -27,6 +27,8 @@ #include "smtk/operation/operators/ReadResource.h" #include "smtk/operation/operators/WriteResource.h" +#include "smtk/plugin/Registry.h" + #include "smtk/project/Manager.h" #include "smtk/project/Project.h" #include "smtk/project/Registrar.h" @@ -53,10 +55,10 @@ void cleanup(const std::string& file_path) { //first verify the file exists ::boost::filesystem::path path(file_path); - if (::boost::filesystem::is_regular_file(path)) + if (::boost::filesystem::exists(path)) { //remove the file_path if it exists. - ::boost::filesystem::remove(path); + ::boost::filesystem::remove_all(path); } } } // namespace @@ -66,18 +68,15 @@ int TestProjectReadWrite(int /*unused*/, char** const /*unused*/) // Create a resource manager smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); - { - smtk::mesh::Registrar::registerTo(resourceManager); - smtk::project::Registrar::registerTo(resourceManager); - } - // Create an operation manager smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); - { - smtk::mesh::Registrar::registerTo(operationManager); - smtk::operation::Registrar::registerTo(operationManager); - } + auto attributeRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); + auto meshRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); + auto operationRegistry = + smtk::plugin::addToManagers(operationManager); // Register the resource manager to the operation manager (newly created // resources will be automatically registered to the resource manager). @@ -87,14 +86,14 @@ int TestProjectReadWrite(int /*unused*/, char** const /*unused*/) smtk::project::ManagerPtr projectManager = smtk::project::Manager::create(resourceManager, operationManager); - { - smtk::project::Registrar::registerTo(projectManager); - } + auto projectRegistry = + smtk::plugin::addToManagers(resourceManager, projectManager); // Register a new project type projectManager->registerProject("foo"); // Create a project and write it to disk. + std::string projectDirectory = write_root + "/TestProjectReadWrite/"; std::string projectLocation; std::size_t numberOfMeshes; { @@ -139,18 +138,54 @@ int TestProjectReadWrite(int /*unused*/, char** const /*unused*/) project->resources().add( std::dynamic_pointer_cast(resourceItem->value()), "my mesh"); + + // Create resource with non-unique role + for (int i = 0; i < 2; i++) + { + auto resource = resourceManager->create("smtk::attribute::Resource"); + resource->setName("common" + std::to_string(i)); + project->resources().add(resource, "common"); + } + { + auto resource = resourceManager->create("smtk::attribute::Resource"); + resource->setName("common" + std::to_string(2)); + project->resources().add(resource, "uncommon"); + } } - if (project->resources().size() != 1) + if (project->resources().size() != 4) { std::cerr << "Failed to add a resource to the project\n"; return 1; } { - smtk::mesh::Resource::Ptr myMesh = - project->resources().getByRole("my mesh"); - numberOfMeshes = myMesh->meshes().size(); + std::set myMesh = + project->resources().findByRole("my mesh"); + numberOfMeshes = (*(myMesh.begin()))->meshes().size(); + } + + { + std::set commonResources = + project->resources().findByRole("common"); + smtkTest(commonResources.size() == 2, "Expected two(2) resources with the role \"common\""); + + // Make sure all and only the added resources with the common role exist in the project + std::map check_names{ { "common0", false }, { "common1", false } }; + for (const auto& res : commonResources) + { + auto it = check_names.find(res->name()); + smtkTest( + it != check_names.end(), + "Found unexpected smtk::attribute::Resource with project_role \"common\""); + it->second = true; + } + for (const auto& check : check_names) + { + smtkTest( + check.second, + "Did not find expected smtk::attribute::Resource with name: " << check.first); + } } { @@ -165,7 +200,7 @@ int TestProjectReadWrite(int /*unused*/, char** const /*unused*/) } // Set the file path - projectLocation = write_root + "/" + smtk::common::UUID::random().toString() + ".smtk"; + projectLocation = projectDirectory + smtk::common::UUID::random().toString() + ".smtk"; writeOp->parameters()->associate(project); writeOp->parameters()->findFile("filename")->setIsEnabled(true); @@ -243,15 +278,22 @@ int TestProjectReadWrite(int /*unused*/, char** const /*unused*/) } } - smtk::mesh::Resource::Ptr myMesh = - project->resources().getByRole("my mesh"); + std::set myMeshSet = + project->resources().findByRole("my mesh"); - if (!myMesh) + if (myMeshSet.empty()) { std::cerr << "Resulting project does not contain mesh resource\n"; return 1; } + if (myMeshSet.size() > 1) + { + std::cerr + << "Resulting project contains more than one(1) mesh resource with role \"my mesh\"\n"; + return 1; + } + smtk::mesh::Resource::Ptr myMesh = *(myMeshSet.begin()); if (myMesh->meshes().size() != numberOfMeshes) { std::cerr << "Resulting project's mesh resource was incorrectly transcribed\n"; @@ -275,7 +317,9 @@ int TestProjectReadWrite(int /*unused*/, char** const /*unused*/) std::cout << readOp->log().convertToString(); } - cleanup(projectLocation); +#ifdef NDEBUG + cleanup(projectDirectory); +#endif return 0; } diff --git a/smtk/project/testing/cxx/TestProjectReadWrite2.cxx b/smtk/project/testing/cxx/TestProjectReadWrite2.cxx index ad0cf4e7c8851bea923b8e09f815558b6c6f347c..f947dabd40779f9505e0eb6f76a6f2c5adf5ae39 100644 --- a/smtk/project/testing/cxx/TestProjectReadWrite2.cxx +++ b/smtk/project/testing/cxx/TestProjectReadWrite2.cxx @@ -28,6 +28,8 @@ #include "smtk/operation/operators/ReadResource.h" #include "smtk/operation/operators/WriteResource.h" +#include "smtk/plugin/Registry.h" + #include "smtk/project/Manager.h" #include "smtk/project/Project.h" #include "smtk/project/Registrar.h" @@ -59,8 +61,10 @@ void cleanup(const std::string& location) { //first verify the file exists ::boost::filesystem::path path(location); + printf("Removing: %s...\n", location.c_str()); if (::boost::filesystem::exists(path)) { + printf("Removing: %s...Success\n", location.c_str()); //remove the file_path if it exists. ::boost::filesystem::remove_all(path); } @@ -77,25 +81,9 @@ int TestProjectReadWrite2(int /*unused*/, char** const /*unused*/) // Create a resource manager smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); - { - smtk::attribute::Registrar::registerTo(resourceManager); -#ifdef VTK_SUPPORT - smtk::session::vtk::Registrar::registerTo(resourceManager); -#endif - smtk::project::Registrar::registerTo(resourceManager); - } - // Create an operation manager smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); - { - smtk::attribute::Registrar::registerTo(operationManager); -#ifdef VTK_SUPPORT - smtk::session::vtk::Registrar::registerTo(operationManager); -#endif - smtk::operation::Registrar::registerTo(operationManager); - } - // Register the resource manager to the operation manager (newly created // resources will be automatically registered to the resource manager). operationManager->registerResourceManager(resourceManager); @@ -104,15 +92,21 @@ int TestProjectReadWrite2(int /*unused*/, char** const /*unused*/) smtk::project::ManagerPtr projectManager = smtk::project::Manager::create(resourceManager, operationManager); - { - smtk::project::Registrar::registerTo(projectManager); - } + auto attributeRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); +#ifdef VTK_SUPPORT + auto vtkRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); +#endif + auto operationRegistry = smtk::plugin::addToManagers(operationManager); + auto projectRegistry = + smtk::plugin::addToManagers(resourceManager, projectManager); // Register a new project type projectManager->registerProject("foo"); // Create a project and write it to disk. - int numberOfResources = 0; + size_t numberOfResources = 0; { smtk::project::Project::Ptr project = projectManager->create("foo"); if (!project) @@ -182,16 +176,16 @@ int TestProjectReadWrite2(int /*unused*/, char** const /*unused*/) } // for (path) } - if (project->resources().size() != numberOfResources) + if (project->resources().size() != static_cast(numberOfResources)) { std::cerr << "Failed to add a resource to the project\n"; return 1; } { - smtk::attribute::Resource::Ptr myAtts = - project->resources().getByRole("my attributes"); - numberOfResources = myAtts == nullptr ? 0 : 1; + std::set myAtts = + project->resources().findByRole("my attributes"); + numberOfResources = myAtts.size(); } { @@ -274,15 +268,24 @@ int TestProjectReadWrite2(int /*unused*/, char** const /*unused*/) } } - smtk::attribute::Resource::Ptr myAtts = - project->resources().getByRole("my attributes"); + std::set myAttSet = + project->resources().findByRole("my attributes"); - if (myAtts == nullptr) + if (myAttSet.empty()) { std::cerr << "Resulting project does not contain attribute resource\n"; return 1; } + if (myAttSet.size() > 1) + { + std::cerr << "Resulting project contains more than one(1) attribute resource with role \"my " + "attributes\"\n"; + return 1; + } + + smtk::attribute::Resource::Ptr myAtts = *(myAttSet.begin()); + if (!myAtts->clean()) { std::cerr << "Attribute resource is marked modified\n"; diff --git a/smtk/project/testing/cxx/TestProjectReadWrite2_Deprecated.cxx b/smtk/project/testing/cxx/TestProjectReadWrite2_Deprecated.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f2bfff7cd488b7ae2dba4a5ce0b0a060146a6cd3 --- /dev/null +++ b/smtk/project/testing/cxx/TestProjectReadWrite2_Deprecated.cxx @@ -0,0 +1,313 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#define SMTK_DEPRECATION_LEVEL 2105 + +#include "smtk/attribute/Attribute.h" +#include "smtk/attribute/FileItem.h" +#include "smtk/attribute/IntItem.h" +#include "smtk/attribute/Registrar.h" +#include "smtk/attribute/Resource.h" +#include "smtk/attribute/ResourceItem.h" +#include "smtk/attribute/operators/Import.h" + +#include "smtk/common/UUIDGenerator.h" +#include "smtk/io/Logger.h" +#include "smtk/resource/Component.h" +#include "smtk/resource/DerivedFrom.h" +#include "smtk/resource/Manager.h" + +#include "smtk/operation/Manager.h" +#include "smtk/operation/Registrar.h" +#include "smtk/operation/operators/ImportResource.h" +#include "smtk/operation/operators/ReadResource.h" +#include "smtk/operation/operators/WriteResource.h" + +#include "smtk/plugin/Registry.h" + +#include "smtk/project/Manager.h" +#include "smtk/project/Project.h" +#include "smtk/project/Registrar.h" +#include "smtk/project/operators/Define.h" + +#ifdef VTK_SUPPORT +#include "smtk/session/vtk/Registrar.h" +#endif + +#include "smtk/common/testing/cxx/helpers.h" + +//force to use filesystem version 3 +#define BOOST_FILESYSTEM_VERSION 3 +#include +using namespace boost::filesystem; + +// This test verifies that projects can be serialized to the file system +// and unserialized back. The test project contains an SMTK attribute +// resource plus (if vtk support is built) an SMTK vtk model resource. + +namespace +{ + +//SMTK_DATA_DIR is a define setup by cmake +std::string data_root = SMTK_DATA_DIR; +std::string write_root = SMTK_SCRATCH_DIR; + +void cleanup(const std::string& location) +{ + //first verify the file exists + ::boost::filesystem::path path(location); + if (::boost::filesystem::exists(path)) + { + //remove the file_path if it exists. + ::boost::filesystem::remove_all(path); + } +} +} // namespace + +int TestProjectReadWrite2_Deprecated(int /*unused*/, char** const /*unused*/) +{ + // Set the file path + std::string projectDirectory = write_root + "/TestProjectReadWrite2_Deprecated"; + cleanup(projectDirectory); + std::string projectFileLocation = projectDirectory + "/foo.smtk"; + + // Create a resource manager + smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); + + // Create an operation manager + smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); + + auto attributeRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); +#ifdef VTK_SUPPORT + auto vtkRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); +#endif + auto operationRegistry = smtk::plugin::addToManagers(operationManager); + + // Register the resource manager to the operation manager (newly created + // resources will be automatically registered to the resource manager). + operationManager->registerResourceManager(resourceManager); + + // Create a project manager + smtk::project::ManagerPtr projectManager = + smtk::project::Manager::create(resourceManager, operationManager); + + auto projectRegistry = + smtk::plugin::addToManagers(resourceManager, projectManager); + + // Register a new project type + projectManager->registerProject("foo"); + + // Create a project and write it to disk. + int numberOfResources = 0; + { + smtk::project::Project::Ptr project = projectManager->create("foo"); + if (!project) + { + std::cerr << "Failed to create a project\n"; + return 1; + } + + { + // Create an import operator + smtk::operation::Operation::Ptr importAnyOp = + operationManager->create(); + smtk::operation::Operation::Ptr importSBTOp = + operationManager->create(); + + if (!importSBTOp) + { + std::cerr << "No sbt import operator\n"; + return 1; + } + if (!importAnyOp) + { + std::cerr << "No any import operator\n"; + return 1; + } + + // Input data files + std::map importPaths = { + { "my attributes", "/attribute/attribute_collection/DoubleItemExample.sbt" } + }; +#ifdef VTK_SUPPORT + importPaths["my model"] = "/model/3d/genesis/casting-mesh1.gen"; +#endif + for (auto& keyval : importPaths) + { + auto role = keyval.first; + auto path = keyval.second; + + std::string importFilePath(data_root); + importFilePath += path; + std::string ext = boost::filesystem::path(importFilePath).extension().string(); + + smtk::operation::Operation::Result importOpResult; + if (ext == ".sbt") + { + importSBTOp->parameters()->findFile("filename")->setValue(importFilePath); + importOpResult = importSBTOp->operate(); + } + else + { + importAnyOp->parameters()->findFile("filename")->setValue(importFilePath); + importOpResult = importAnyOp->operate(); + } + + // Test for success + if ( + importOpResult->findInt("outcome")->value() != + static_cast(smtk::operation::Operation::Outcome::SUCCEEDED)) + { + std::cerr << "Import operation failed\n"; + return 1; + } + + auto resourceItem = importOpResult->findResource("resource"); + project->resources().add(resourceItem->value(), role); + ++numberOfResources; + } // for (path) + } + + if (project->resources().size() != numberOfResources) + { + std::cerr << "Failed to add a resource to the project\n"; + return 1; + } + + { + smtk::attribute::Resource::Ptr myAtts = + project->resources().getByRole("my attributes"); + numberOfResources = myAtts == nullptr ? 0 : 1; + } + + { + // Create a write operator + smtk::operation::WriteResource::Ptr writeOp = + operationManager->create(); + + if (!writeOp) + { + std::cerr << "No write operator\n"; + return 1; + } + + writeOp->parameters()->associate(project); + writeOp->parameters()->findFile("filename")->setIsEnabled(true); + writeOp->parameters()->findFile("filename")->setValue(projectFileLocation); + + if (!writeOp->ableToOperate()) + { + std::cerr << "Write operation unable to operate\n"; + return 1; + } + + // Execute the operation + smtk::operation::Operation::Result writeOpResult = writeOp->operate(); + + // Test for success + if ( + writeOpResult->findInt("outcome")->value() != + static_cast(smtk::operation::Operation::Outcome::SUCCEEDED)) + { + std::cerr << "Write operation failed\n"; + std::cerr << writeOp->log().convertToString(); + return 1; + } + } + projectManager->remove(project); + } + + // Read the project + smtk::project::Project::Ptr project; + { + // Create a read operator + smtk::operation::ReadResource::Ptr readOp = + operationManager->create(); + + if (!readOp) + { + std::cerr << "No read operator\n"; + return 1; + } + + readOp->parameters()->findFile("filename")->setValue(projectFileLocation); + + if (!readOp->ableToOperate()) + { + std::cerr << "Read operation unable to operate\n"; + return 1; + } + + // Execute the operation + smtk::operation::Operation::Result readOpResult = readOp->operate(); + + // Test for success + if ( + readOpResult->findInt("outcome")->value() != + static_cast(smtk::operation::Operation::Outcome::SUCCEEDED)) + { + std::cerr << "Read operation failed\n"; + std::cerr << readOp->log().convertToString(); + return 1; + } + + project = readOpResult->findResource("resource")->valueAs(); + + if (!project) + { + std::cerr << "Resulting project is invalid\n"; + return 1; + } + } + + smtk::attribute::Resource::Ptr myAtts = + project->resources().getByRole("my attributes"); + + if (myAtts == nullptr) + { + std::cerr << "Resulting project does not contain attribute resource\n"; + return 1; + } + + if (!myAtts->clean()) + { + std::cerr << "Attribute resource is marked modified\n"; + return 1; + } + + { + boost::filesystem::path myAttsPath(myAtts->location()); + boost::filesystem::path projectPath(projectDirectory); + boost::filesystem::path resourcesPath = projectPath / "resources"; + if (myAttsPath.parent_path().compare(resourcesPath) != 0) + { + std::cerr << "Wrong attribute resource location: " << myAtts->location() << "\n"; + return 1; + } + } + + { + std::vector defList; + myAtts->definitions(defList); + if (defList.size() != 2) + { + std::cerr << "Attribute resource missing definitions\n"; + return 1; + } + } + +#ifdef NDEBUG + cleanup(projectDirectory); +#endif + + return 0; +} diff --git a/smtk/project/testing/cxx/TestProjectReadWriteEmpty.cxx b/smtk/project/testing/cxx/TestProjectReadWriteEmpty.cxx new file mode 100644 index 0000000000000000000000000000000000000000..245d7306f313a355893301db1827a29c72085509 --- /dev/null +++ b/smtk/project/testing/cxx/TestProjectReadWriteEmpty.cxx @@ -0,0 +1,108 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#include "smtk/attribute/Attribute.h" +#include "smtk/attribute/FileItem.h" +#include "smtk/attribute/IntItem.h" +#include "smtk/attribute/ResourceItem.h" +#include "smtk/common/testing/cxx/helpers.h" +#include "smtk/operation/Manager.h" +#include "smtk/operation/Operation.h" +#include "smtk/operation/Registrar.h" +#include "smtk/operation/operators/ReadResource.h" +#include "smtk/operation/operators/WriteResource.h" +#include "smtk/plugin/Registry.h" +#include "smtk/project/Manager.h" +#include "smtk/project/Project.h" +#include "smtk/project/Registrar.h" +#include "smtk/resource/Manager.h" + +#include + +// This test verifies that *empty* projects can be serialized to the file system +// and unserialized back. + +namespace +{ +const int OP_SUCCEEDED = static_cast(smtk::operation::Operation::Outcome::SUCCEEDED); + +//SMTK_DATA_DIR is a define setup by cmake +std::string data_root = SMTK_DATA_DIR; +std::string write_root = SMTK_SCRATCH_DIR; + +void cleanup(const std::string& file_path) +{ + //first verify the file exists + ::boost::filesystem::path path(file_path); + if (::boost::filesystem::is_regular_file(path)) + { + //remove the file_path if it exists. + ::boost::filesystem::remove(path); + } +} +} // namespace + +int TestProjectReadWriteEmpty(int /*unused*/, char** const /*unused*/) +{ + // Create smtk managers + smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); + + smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); + auto operationRegistry = + smtk::plugin::addToManagers(operationManager); + operationManager->registerResourceManager(resourceManager); + + smtk::project::ManagerPtr projectManager = + smtk::project::Manager::create(resourceManager, operationManager); + auto projectRegistry = + smtk::plugin::addToManagers(resourceManager, projectManager); + projectManager->registerProject("foo"); + + std::string projectLocation = write_root + "/empty-project.smtk"; + + // Create empty project and write it to disk. + { + smtk::project::Project::Ptr project = projectManager->create("foo"); + + smtk::operation::WriteResource::Ptr writeOp = + operationManager->create(); + + auto att = writeOp->parameters(); + bool ok = att->associate(project); // , "failed to associate project to writeOp"); + smtkTest(ok, "failed to associate project to writeOp"); + writeOp->parameters()->findFile("filename")->setIsEnabled(true); + smtkTest( + writeOp->parameters()->findFile("filename")->setValue(projectLocation), + "failed to set filename item"); + + smtk::operation::Operation::Result writeResult = writeOp->operate(); + int writeOutcome = writeResult->findInt("outcome")->value(); + smtkTest(writeOutcome == OP_SUCCEEDED, "failed to write project, outcome " << writeOutcome); + } + + // Read the project back in + { + smtk::operation::ReadResource::Ptr readOp = + operationManager->create(); + readOp->parameters()->findFile("filename")->setValue(projectLocation); + smtk::operation::Operation::Result readResult = readOp->operate(); + int readOutcome = readResult->findInt("outcome")->value(); + smtkTest(readOutcome == OP_SUCCEEDED, "failed to read project, outcome " << readOutcome); + + // Make sure project is there too + auto project = readResult->findResource("resource")->valueAs(); + smtkTest(project != nullptr, "failed to return project"); + smtkTest(project->clean(), "project is marked modified"); + } + + cleanup(projectLocation); + + return 0; +} diff --git a/smtk/project/testing/cxx/TestProjectReadWrite_Deprecated.cxx b/smtk/project/testing/cxx/TestProjectReadWrite_Deprecated.cxx new file mode 100644 index 0000000000000000000000000000000000000000..149671f5de2ee0f9321f7ee33a90fd503699d19c --- /dev/null +++ b/smtk/project/testing/cxx/TestProjectReadWrite_Deprecated.cxx @@ -0,0 +1,256 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#define SMTK_DEPRECATION_LEVEL 2105 + +#include "smtk/attribute/Attribute.h" +#include "smtk/attribute/FileItem.h" +#include "smtk/attribute/IntItem.h" +#include "smtk/attribute/ResourceItem.h" + +#include "smtk/common/UUIDGenerator.h" +#include "smtk/resource/Component.h" +#include "smtk/resource/DerivedFrom.h" +#include "smtk/resource/Manager.h" + +#include "smtk/mesh/core/Resource.h" +#include "smtk/mesh/resource/Registrar.h" + +#include "smtk/operation/Manager.h" +#include "smtk/operation/Registrar.h" +#include "smtk/operation/operators/ImportResource.h" +#include "smtk/operation/operators/ReadResource.h" +#include "smtk/operation/operators/WriteResource.h" + +#include "smtk/plugin/Registry.h" + +#include "smtk/project/Manager.h" +#include "smtk/project/Project.h" +#include "smtk/project/Registrar.h" +#include "smtk/project/operators/Define.h" + +#include "smtk/common/testing/cxx/helpers.h" + +//force to use filesystem version 3 +#define BOOST_FILESYSTEM_VERSION 3 +#include +using namespace boost::filesystem; + +// This test verifies that projects can be serialized to the file system +// and unserialized back. The test project contains an SMTK mesh resource. + +namespace +{ + +//SMTK_DATA_DIR is a define setup by cmake +std::string data_root = SMTK_DATA_DIR; +std::string write_root = SMTK_SCRATCH_DIR; + +void cleanup(const std::string& file_path) +{ + //first verify the file exists + ::boost::filesystem::path path(file_path); + if (::boost::filesystem::exists(path)) + { + //remove the file_path if it exists. + ::boost::filesystem::remove_all(path); + } +} +} // namespace + +int TestProjectReadWrite_Deprecated(int /*unused*/, char** const /*unused*/) +{ + // Create a resource manager + smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); + + // Create an operation manager + smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); + + auto meshRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); + auto operationRegistry = smtk::plugin::addToManagers(operationManager); + + // Register the resource manager to the operation manager (newly created + // resources will be automatically registered to the resource manager). + operationManager->registerResourceManager(resourceManager); + + // Create a project manager + smtk::project::ManagerPtr projectManager = + smtk::project::Manager::create(resourceManager, operationManager); + + auto projectRegistry = + smtk::plugin::addToManagers(resourceManager, projectManager); + + // Register a new project type + projectManager->registerProject("foo"); + + // Create a project and write it to disk. + std::string projectDirectory = write_root + "/TestProjectReadWrite_Deprecated/"; + std::string projectLocation; + std::size_t numberOfMeshes; + { + smtk::project::Project::Ptr project = projectManager->create("foo"); + if (!project) + { + std::cerr << "Failed to create a project\n"; + return 1; + } + + { + // Create an import operator + smtk::operation::ImportResource::Ptr importOp = + operationManager->create(); + if (!importOp) + { + std::cerr << "No import operator\n"; + return 1; + } + + // Set the file path + std::string importFilePath(data_root); + importFilePath += "/model/3d/exodus/SimpleReactorCore/SimpleReactorCore.exo"; + importOp->parameters()->findFile("filename")->setValue(importFilePath); + + // Execute the operation + smtk::operation::Operation::Result importOpResult = importOp->operate(); + + // Test for success + if ( + importOpResult->findInt("outcome")->value() != + static_cast(smtk::operation::Operation::Outcome::SUCCEEDED)) + { + std::cerr << "Import operation failed\n"; + return 1; + } + + // Add the mesh resource to the project + smtk::attribute::ResourceItemPtr resourceItem = + std::dynamic_pointer_cast( + importOpResult->findResource("resource")); + + project->resources().add( + std::dynamic_pointer_cast(resourceItem->value()), "my mesh"); + } + + if (project->resources().size() != 1) + { + std::cerr << "Failed to add a resource to the project\n"; + return 1; + } + + { + smtk::mesh::Resource::Ptr myMesh = + project->resources().getByRole("my mesh"); + numberOfMeshes = myMesh->meshes().size(); + } + + { + // Create a write operator + smtk::operation::WriteResource::Ptr writeOp = + operationManager->create(); + + if (!writeOp) + { + std::cerr << "No write operator\n"; + return 1; + } + + // Set the file path + projectLocation = projectDirectory + smtk::common::UUID::random().toString() + ".smtk"; + + writeOp->parameters()->associate(project); + writeOp->parameters()->findFile("filename")->setIsEnabled(true); + writeOp->parameters()->findFile("filename")->setValue(projectLocation); + + if (!writeOp->ableToOperate()) + { + std::cerr << "Write operation unable to operate\n"; + return 1; + } + + // Execute the operation + smtk::operation::Operation::Result writeOpResult = writeOp->operate(); + + // Test for success + if ( + writeOpResult->findInt("outcome")->value() != + static_cast(smtk::operation::Operation::Outcome::SUCCEEDED)) + { + std::cerr << "Write operation failed\n"; + std::cerr << writeOp->log().convertToString(); + return 1; + } + } + + projectManager->remove(project); + } + + // Read the project + smtk::project::Project::Ptr project; + { + // Create a read operator + smtk::operation::ReadResource::Ptr readOp = + operationManager->create(); + + if (!readOp) + { + std::cerr << "No read operator\n"; + return 1; + } + + readOp->parameters()->findFile("filename")->setValue(projectLocation); + + if (!readOp->ableToOperate()) + { + std::cerr << "Read operation unable to operate\n"; + return 1; + } + + // Execute the operation + smtk::operation::Operation::Result readOpResult = readOp->operate(); + + // Test for success + if ( + readOpResult->findInt("outcome")->value() != + static_cast(smtk::operation::Operation::Outcome::SUCCEEDED)) + { + std::cerr << "Read operation failed\n"; + std::cerr << readOp->log().convertToString(); + return 1; + } + + project = readOpResult->findResource("resource")->valueAs(); + + if (!project) + { + std::cerr << "Resulting project is invalid\n"; + return 1; + } + } + + smtk::mesh::Resource::Ptr myMesh = + project->resources().getByRole("my mesh"); + + if (!myMesh) + { + std::cerr << "Resulting project does not contain mesh resource\n"; + return 1; + } + + if (myMesh->meshes().size() != numberOfMeshes) + { + std::cerr << "Resulting project's mesh resource was incorrectly transcribed\n"; + return 1; + } + + cleanup(projectDirectory); + + return 0; +} diff --git a/smtk/project/view/PhraseContent.cxx b/smtk/project/view/PhraseContent.cxx index f771ff4a1b794a44d039f39ea8f674ae519fc042..5e1a9cc66ad24cfbf6b1d119ec7a0b1a7c0245d0 100644 --- a/smtk/project/view/PhraseContent.cxx +++ b/smtk/project/view/PhraseContent.cxx @@ -29,11 +29,7 @@ namespace project namespace view { -PhraseContent::PhraseContent() - : m_isProject(false) - , m_mutability(0) -{ -} +PhraseContent::PhraseContent() = default; PhraseContent::~PhraseContent() = default; diff --git a/smtk/project/view/PhraseContent.h b/smtk/project/view/PhraseContent.h index fcebf45a8bdfdb649244c7ea2fa39a9ce89c562c..9b7c8a1de495476761dd1c9b23b6c1022f0c1780 100644 --- a/smtk/project/view/PhraseContent.h +++ b/smtk/project/view/PhraseContent.h @@ -73,8 +73,8 @@ protected: PhraseContent(); std::weak_ptr m_resource; - bool m_isProject; - int m_mutability; + bool m_isProject{ false }; + int m_mutability{ 0 }; }; } // namespace view } // namespace project diff --git a/smtk/project/view/SubphraseGenerator.cxx b/smtk/project/view/SubphraseGenerator.cxx index 41da89af8b1cdc766f060a9bf0f2a5a122edfb69..19188d308ed9d1a17cfcfb24f2ba9eae8c8799f8 100644 --- a/smtk/project/view/SubphraseGenerator.cxx +++ b/smtk/project/view/SubphraseGenerator.cxx @@ -53,7 +53,7 @@ void SubphraseGenerator::childrenOfProject( smtk::view::DescriptivePhrases& result) { constexpr int mutability = static_cast(smtk::view::PhraseContent::ContentType::TITLE); - for (const auto& resource : project->resources().resources()) + for (const auto& resource : project->resources()) { result.push_back(smtk::project::view::PhraseContent::createPhrase(resource, mutability, src)); } diff --git a/smtk/pybind11/__init__.py.in b/smtk/pybind11/__init__.py.in index 11497166359c93d4d5c596b8d7cfd2ea4b355c84..2769a99ad8ec69f7150861366db66d33f612b07e 100644 --- a/smtk/pybind11/__init__.py.in +++ b/smtk/pybind11/__init__.py.in @@ -18,7 +18,7 @@ import site import sys __all__ = ('common', 'attribute', 'extension', 'model', - 'mesh', 'io', 'project', 'session', 'simulation') + 'mesh', 'io', 'project', 'session', 'simulation', 'task') def _windows_dll_path(): diff --git a/smtk/resource/DerivedFrom.h b/smtk/resource/DerivedFrom.h index ba3ec8a6aca3fe6f4dad0cdf25c656000099246f..9639bc0b15402e0d463fe442542528d914f104d2 100644 --- a/smtk/resource/DerivedFrom.h +++ b/smtk/resource/DerivedFrom.h @@ -72,10 +72,7 @@ protected: { } - DerivedFrom(DerivedFrom&& rhs) noexcept - : Parent(std::move(rhs)) - { - } + DerivedFrom(DerivedFrom&& rhs) noexcept = default; }; template diff --git a/smtk/resource/Lock.cxx b/smtk/resource/Lock.cxx index 27ec8bb27e1e809e369408e24a44e652d3c0b12f..73109d13a9fc3c28242ab43db7790496e8bf90a5 100644 --- a/smtk/resource/Lock.cxx +++ b/smtk/resource/Lock.cxx @@ -14,12 +14,7 @@ namespace smtk namespace resource { -Lock::Lock() - : m_activeReaders(0) - , m_waitingWriters(0) - , m_activeWriters(0) -{ -} +Lock::Lock() = default; void Lock::lock(LockType lockType) { diff --git a/smtk/resource/Lock.h b/smtk/resource/Lock.h index c0d0882a5ea263e9c7c42cfb2a3f83ad6d1f065f..3c23753d310bf7c74b61ef618779d303195a68aa 100644 --- a/smtk/resource/Lock.h +++ b/smtk/resource/Lock.h @@ -51,9 +51,9 @@ private: std::mutex m_mutex; std::condition_variable m_readerCondition; std::condition_variable m_writerCondition; - std::size_t m_activeReaders; - std::size_t m_waitingWriters; - std::size_t m_activeWriters; + std::size_t m_activeReaders{ 0 }; + std::size_t m_waitingWriters{ 0 }; + std::size_t m_activeWriters{ 0 }; }; /// A scope-guarded utility for handling locks. diff --git a/smtk/resource/Properties.h b/smtk/resource/Properties.h index ce60892365c944b4521198e1a07d6fee85b85985..bb61d26937aef44bf475bb30f316a7b3e9735dcd 100644 --- a/smtk/resource/Properties.h +++ b/smtk/resource/Properties.h @@ -17,6 +17,8 @@ #include "smtk/common/json/jsonUUID.h" +#include + namespace smtk { namespace resource @@ -183,14 +185,13 @@ public: /// Check if any properties of this type are associated with m_id. bool empty() const { - for (auto& pair : m_properties.data()) - { - if (pair.second.find(m_id) != pair.second.end()) - { - return false; - } - } - return true; + using PropertyDataMap = + std::unordered_map>; + const PropertyDataMap& data = m_properties.data(); + return std::all_of( + data.begin(), data.end(), [this](const typename PropertyDataMap::value_type& pair) { + return pair.second.find(m_id) == pair.second.end(); + }); } std::set keys() const @@ -411,9 +412,13 @@ class SMTKCORE_EXPORT ResourceProperties : public smtk::resource::Properties /// The default value types for all resources and components are int, double, /// string, and vectors of these types. typedef std::tuple< + Indexed, + Indexed, Indexed, Indexed, Indexed, + Indexed>, + Indexed>, Indexed>, Indexed>, Indexed>> diff --git a/smtk/resource/filter/Rule.h b/smtk/resource/filter/Rule.h index c70af31c8a10b26b57f091ecbd75df6a465d6406..80238c56587c9d10b19318f1a4c43dbe4f785723 100644 --- a/smtk/resource/filter/Rule.h +++ b/smtk/resource/filter/Rule.h @@ -12,6 +12,8 @@ #include "smtk/resource/PersistentObject.h" +#include + namespace smtk { namespace resource @@ -43,14 +45,11 @@ public: bool operator()(const PersistentObject& object) const override { - for (const auto& key : acceptableKeys(object)) - { - if (acceptableValue(object.properties().at(key))) - { - return true; - } - } - return false; + auto acceptable = acceptableKeys(object); + return std::any_of( + acceptable.begin(), acceptable.end(), [this, &object](const std::string& key) { + return acceptableValue(object.properties().at(key)); + }); } // Given a persistent object, return a vector of keys that match the diff --git a/smtk/resource/filter/Rules.h b/smtk/resource/filter/Rules.h index c78a4a3cf355c5a7668460d348e5283bf482cbd0..7b0c9e7d621cee258bef97b7f7e3da806f32fe37 100644 --- a/smtk/resource/filter/Rules.h +++ b/smtk/resource/filter/Rules.h @@ -14,6 +14,8 @@ #include "smtk/resource/filter/Rule.h" +#include + namespace smtk { namespace resource @@ -36,14 +38,9 @@ public: bool operator()(const PersistentObject& object) const { - for (const auto& rule : m_data) - { - if (!(*rule)(object)) - { - return false; - } - } - return true; + return std::all_of(m_data.begin(), m_data.end(), [&object](const std::unique_ptr& rule) { + return (*rule)(object); + }); } template diff --git a/smtk/resource/pybind11/PybindComponent.h b/smtk/resource/pybind11/PybindComponent.h index f150f3bbf9035db65274d1804bf9b05c57124573..e511e745574fe1cce7421d3189b290cd967c0fd8 100644 --- a/smtk/resource/pybind11/PybindComponent.h +++ b/smtk/resource/pybind11/PybindComponent.h @@ -24,7 +24,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::resource::Component, smtk::resource::PyComponent, smtk::resource::PersistentObject > pybind11_init_smtk_resource_Component(py::module &m) +inline PySharedPtrClass< smtk::resource::Component, smtk::resource::PyComponent, smtk::resource::PersistentObject > pybind11_init_smtk_resource_Component(py::module &m) { PySharedPtrClass< smtk::resource::Component, smtk::resource::PyComponent, smtk::resource::PersistentObject > instance(m, "Component"); instance diff --git a/smtk/resource/pybind11/PybindManager.h b/smtk/resource/pybind11/PybindManager.h index 30dfbde2daef35e9266c434fd6ecefe793c77943..92822db8f6b1969001ed25f8ae629e9ad7294502 100644 --- a/smtk/resource/pybind11/PybindManager.h +++ b/smtk/resource/pybind11/PybindManager.h @@ -21,7 +21,7 @@ namespace py = pybind11; -PySharedPtrClass pybind11_init_smtk_resource_Manager(py::module& m) +inline PySharedPtrClass pybind11_init_smtk_resource_Manager(py::module& m) { PySharedPtrClass instance(m, "Manager"); instance diff --git a/smtk/resource/pybind11/PybindObserver.h b/smtk/resource/pybind11/PybindObserver.h index c2713e470f7719a7dfbfc9ce4d6e8ba71e7aa6f4..18fad50459f8e4635a0927844813c5c20678cb74 100644 --- a/smtk/resource/pybind11/PybindObserver.h +++ b/smtk/resource/pybind11/PybindObserver.h @@ -19,7 +19,7 @@ namespace py = pybind11; -void pybind11_init_smtk_resource_EventType(py::module &m) +inline void pybind11_init_smtk_resource_EventType(py::module &m) { py::enum_(m, "EventType") .value("ADDED", smtk::resource::EventType::ADDED) @@ -28,7 +28,7 @@ void pybind11_init_smtk_resource_EventType(py::module &m) .export_values(); } -py::class_< smtk::resource::Observers > pybind11_init_smtk_resource_Observers(py::module &m) +inline py::class_< smtk::resource::Observers > pybind11_init_smtk_resource_Observers(py::module &m) { py::class_< smtk::resource::Observers > instance(m, "Observers"); instance diff --git a/smtk/resource/pybind11/PybindPersistentObject.h b/smtk/resource/pybind11/PybindPersistentObject.h index a82a16c083306e61daf9a2f3a2b7b06a2bb5fe42..a332116973f9fb27f48c50824fb06e15b07b56e5 100644 --- a/smtk/resource/pybind11/PybindPersistentObject.h +++ b/smtk/resource/pybind11/PybindPersistentObject.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::resource::PersistentObject > pybind11_init_smtk_resource_PersistentObject(py::module &m) +inline PySharedPtrClass< smtk::resource::PersistentObject > pybind11_init_smtk_resource_PersistentObject(py::module &m) { PySharedPtrClass< smtk::resource::PersistentObject > instance(m, "PersistentObject"); instance diff --git a/smtk/resource/pybind11/PybindPropertyType.h b/smtk/resource/pybind11/PybindPropertyType.h index a1d5b4c00ccedb083d92a8cbaef24465a9dd9074..812978b49b446a4d22c243828a57b6bb785f1223 100644 --- a/smtk/resource/pybind11/PybindPropertyType.h +++ b/smtk/resource/pybind11/PybindPropertyType.h @@ -17,7 +17,7 @@ namespace py = pybind11; -void pybind11_init_smtk_resource_PropertyType(py::module &m) +inline void pybind11_init_smtk_resource_PropertyType(py::module &m) { py::enum_(m, "PropertyType") .value("FLOAT_PROPERTY", smtk::resource::PropertyType::FLOAT_PROPERTY) diff --git a/smtk/resource/pybind11/PybindResource.h b/smtk/resource/pybind11/PybindResource.h index 9bda831ddfbc0b1fb224790110c2c146a8efb45f..ed7d95fdb30616c9f7d5c188c22264cbe9ce74dd 100644 --- a/smtk/resource/pybind11/PybindResource.h +++ b/smtk/resource/pybind11/PybindResource.h @@ -20,7 +20,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::resource::Resource, smtk::resource::PyResource, smtk::resource::PersistentObject > pybind11_init_smtk_resource_Resource(py::module &m) +inline PySharedPtrClass< smtk::resource::Resource, smtk::resource::PyResource, smtk::resource::PersistentObject > pybind11_init_smtk_resource_Resource(py::module &m) { PySharedPtrClass< smtk::resource::Resource, smtk::resource::PyResource, smtk::resource::PersistentObject > instance(m, "Resource"); instance diff --git a/smtk/resource/testing/cxx/CMakeLists.txt b/smtk/resource/testing/cxx/CMakeLists.txt index 4413c274b11894c0e0cd030c58ba5be4f5bd3173..ef666a19938fdaa6975f735cbb503575cb284361 100644 --- a/smtk/resource/testing/cxx/CMakeLists.txt +++ b/smtk/resource/testing/cxx/CMakeLists.txt @@ -21,7 +21,7 @@ set(unit_tests ) smtk_unit_tests( - Label "Resource" + LABEL "Resource" SOURCES ${unit_tests} LIBRARIES smtkCore ) diff --git a/smtk/resource/testing/cxx/TestQuery.cxx b/smtk/resource/testing/cxx/TestQuery.cxx index 8fa20eb3a32e853932300a0a05b37b4ce8ef5aa0..93c22f6729b7e3b2d234a9dc6fa05a8f2e8c7a26 100644 --- a/smtk/resource/testing/cxx/TestQuery.cxx +++ b/smtk/resource/testing/cxx/TestQuery.cxx @@ -50,7 +50,7 @@ int TestQuery(int /*unused*/, char** const /*unused*/) test(factory.registerQuery(), "Could not register QueryA"); { std::unique_ptr queryA = factory.create(); - test(fabs(queryA->foo() - QueryA().foo()) < EPSILON, "Unexpected query result"); + test(std::abs(queryA->foo() - QueryA().foo()) < EPSILON, "Unexpected query result"); } test(factory.unregisterQuery(), "Could not unregister QueryA"); @@ -64,26 +64,26 @@ int TestQuery(int /*unused*/, char** const /*unused*/) { std::unique_ptr queryB = factory.create(); test(queryB != nullptr, "Could not create an instance of QueryB"); - test(fabs(queryB->foo() - QueryB().foo()) < EPSILON, "Unexpected query result"); - test(fabs(queryB->bar() - QueryB().bar()) < EPSILON, "Unexpected query result"); + test(std::abs(queryB->foo() - QueryB().foo()) < EPSILON, "Unexpected query result"); + test(std::abs(queryB->bar() - QueryB().bar()) < EPSILON, "Unexpected query result"); } test(factory.registerQuery(), "Could not register QueryA"); { std::unique_ptr queryA = factory.create(); - test(fabs(queryA->foo() - QueryA().foo()) < EPSILON, "Unexpected query result"); + test(std::abs(queryA->foo() - QueryA().foo()) < EPSILON, "Unexpected query result"); } test(factory.registerQuery(), "Could not register QueryC"); { std::unique_ptr queryC = factory.create(); - test(fabs(queryC->foo() - QueryC().foo()) < EPSILON, "Unexpected query result"); + test(std::abs(queryC->foo() - QueryC().foo()) < EPSILON, "Unexpected query result"); } test(factory.registerQuery(), "Could not register QueryD"); { std::unique_ptr queryD = factory.create(); - test(fabs(queryD->foo() - QueryD().foo()) < EPSILON, "Unexpected query result"); + test(std::abs(queryD->foo() - QueryD().foo()) < EPSILON, "Unexpected query result"); } return 0; diff --git a/smtk/resource/testing/cxx/helpers.cxx b/smtk/resource/testing/cxx/helpers.cxx index 5030082007cf71ea0fc997f5004f035f4353fef9..5c27d90144e0f7bad93115034fbcae335e4f390e 100644 --- a/smtk/resource/testing/cxx/helpers.cxx +++ b/smtk/resource/testing/cxx/helpers.cxx @@ -19,6 +19,8 @@ #include "smtk/operation/operators/ReadResource.h" +#include "smtk/plugin/Registry.h" + #include "smtk/resource/Metadata.h" namespace smtk @@ -31,7 +33,7 @@ namespace testing ResourceArray loadTestResources(smtk::resource::Manager::Ptr resourceManager, int argc, char* argv[]) { - smtk::model::Registrar::registerTo(resourceManager); + auto registry = smtk::plugin::addToManagers(resourceManager); ResourceArray result; if (argc < 2) diff --git a/smtk/session/mesh/operators/Write.cxx b/smtk/session/mesh/operators/Write.cxx index d5eb2d5248c952b40cc3bffd218b2ac5a66f461d..8bb79bca3fe8eff58dd65bb02b732532934125b2 100644 --- a/smtk/session/mesh/operators/Write.cxx +++ b/smtk/session/mesh/operators/Write.cxx @@ -38,20 +38,6 @@ SMTK_THIRDPARTY_POST_INCLUDE using namespace smtk::model; -namespace -{ -void cleanup(const std::string& file_path) -{ - //first verify the file exists - ::boost::filesystem::path path(file_path); - if (::boost::filesystem::is_regular_file(path)) - { - //remove the file_path if it exists. - ::boost::filesystem::remove(path); - } -} -} // namespace - namespace smtk { namespace session diff --git a/smtk/session/mesh/pybind11/PybindCreateUniformGrid.h b/smtk/session/mesh/pybind11/PybindCreateUniformGrid.h index a4e451fdaccff33f582f5e3da77c25086e5622b6..8d307ef0eed2850d7c507b8ec5b90b8e3e2bef76 100644 --- a/smtk/session/mesh/pybind11/PybindCreateUniformGrid.h +++ b/smtk/session/mesh/pybind11/PybindCreateUniformGrid.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::mesh::CreateUniformGrid, smtk::operation::XMLOperation > pybind11_init_smtk_session_mesh_CreateUniformGrid(py::module &m) +inline PySharedPtrClass< smtk::session::mesh::CreateUniformGrid, smtk::operation::XMLOperation > pybind11_init_smtk_session_mesh_CreateUniformGrid(py::module &m) { PySharedPtrClass< smtk::session::mesh::CreateUniformGrid, smtk::operation::XMLOperation > instance(m, "CreateUniformGrid"); instance diff --git a/smtk/session/mesh/pybind11/PybindEulerCharacteristicRatio.h b/smtk/session/mesh/pybind11/PybindEulerCharacteristicRatio.h index 6090fb4478305a208ee1116f322a07e06183894c..f138013f3a82ead4dec0eb9017b65ce5986b7072 100644 --- a/smtk/session/mesh/pybind11/PybindEulerCharacteristicRatio.h +++ b/smtk/session/mesh/pybind11/PybindEulerCharacteristicRatio.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::mesh::EulerCharacteristicRatio, smtk::operation::XMLOperation > pybind11_init_smtk_session_mesh_EulerCharacteristicRatio(py::module &m) +inline PySharedPtrClass< smtk::session::mesh::EulerCharacteristicRatio, smtk::operation::XMLOperation > pybind11_init_smtk_session_mesh_EulerCharacteristicRatio(py::module &m) { PySharedPtrClass< smtk::session::mesh::EulerCharacteristicRatio, smtk::operation::XMLOperation > instance(m, "EulerCharacteristicRatio"); instance diff --git a/smtk/session/mesh/pybind11/PybindExport.h b/smtk/session/mesh/pybind11/PybindExport.h index 32d51c6bf269b4779c23f67808b306c5cf8b026e..631c8e6aeb370f61a54eafb80c73361d99d7b526 100644 --- a/smtk/session/mesh/pybind11/PybindExport.h +++ b/smtk/session/mesh/pybind11/PybindExport.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::mesh::Export, smtk::operation::XMLOperation > pybind11_init_smtk_session_mesh_Export(py::module &m) +inline PySharedPtrClass< smtk::session::mesh::Export, smtk::operation::XMLOperation > pybind11_init_smtk_session_mesh_Export(py::module &m) { PySharedPtrClass< smtk::session::mesh::Export, smtk::operation::XMLOperation > instance(m, "Export"); instance diff --git a/smtk/session/mesh/pybind11/PybindImport.h b/smtk/session/mesh/pybind11/PybindImport.h index 9a80edbe982e8d3911034b2beda1224be4ad59ba..8c48f8bfaf4e4408419fd2ac27b2fc10f9a74654 100644 --- a/smtk/session/mesh/pybind11/PybindImport.h +++ b/smtk/session/mesh/pybind11/PybindImport.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::mesh::Import, smtk::operation::XMLOperation > pybind11_init_smtk_session_mesh_Import(py::module &m) +inline PySharedPtrClass< smtk::session::mesh::Import, smtk::operation::XMLOperation > pybind11_init_smtk_session_mesh_Import(py::module &m) { PySharedPtrClass< smtk::session::mesh::Import, smtk::operation::XMLOperation > instance(m, "Import"); instance diff --git a/smtk/session/mesh/pybind11/PybindRead.h b/smtk/session/mesh/pybind11/PybindRead.h index 2179e7763dfabecedd4e2d4dba0571633cce5517..8c96454785c4b3f69835201e3a9f9c96341e524a 100644 --- a/smtk/session/mesh/pybind11/PybindRead.h +++ b/smtk/session/mesh/pybind11/PybindRead.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::mesh::Read, smtk::operation::XMLOperation > pybind11_init_smtk_session_mesh_Read(py::module &m) +inline PySharedPtrClass< smtk::session::mesh::Read, smtk::operation::XMLOperation > pybind11_init_smtk_session_mesh_Read(py::module &m) { PySharedPtrClass< smtk::session::mesh::Read, smtk::operation::XMLOperation > instance(m, "Read"); instance diff --git a/smtk/session/mesh/pybind11/PybindRegistrar.h b/smtk/session/mesh/pybind11/PybindRegistrar.h index 6fbdc73b787ce5e54357bec8210b66f452fff37c..67b7d76ad40cb13d76a9a7c8e7ca3d2e3a8641ce 100644 --- a/smtk/session/mesh/pybind11/PybindRegistrar.h +++ b/smtk/session/mesh/pybind11/PybindRegistrar.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::session::mesh::Registrar > pybind11_init_smtk_session_mesh_Registrar(py::module &m) +inline py::class_< smtk::session::mesh::Registrar > pybind11_init_smtk_session_mesh_Registrar(py::module &m) { py::class_< smtk::session::mesh::Registrar > instance(m, "Registrar"); instance diff --git a/smtk/session/mesh/pybind11/PybindResource.h b/smtk/session/mesh/pybind11/PybindResource.h index eb6675c8f773394c545f11837e17d131ff984388..054d4e6fd9fedcb3d951f04c6cc7e51da585b5d2 100644 --- a/smtk/session/mesh/pybind11/PybindResource.h +++ b/smtk/session/mesh/pybind11/PybindResource.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::mesh::Resource> pybind11_init_smtk_session_mesh_Resource(py::module &m) +inline PySharedPtrClass< smtk::session::mesh::Resource> pybind11_init_smtk_session_mesh_Resource(py::module &m) { PySharedPtrClass< smtk::session::mesh::Resource, smtk::model::Resource > instance(m, "Resource"); instance diff --git a/smtk/session/mesh/pybind11/PybindSession.h b/smtk/session/mesh/pybind11/PybindSession.h index f227500340825907fabb155f79a9a67543191b78..be97602615801b89c96fa89dd77794a6d6c2e5c4 100644 --- a/smtk/session/mesh/pybind11/PybindSession.h +++ b/smtk/session/mesh/pybind11/PybindSession.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::mesh::Session, smtk::model::Session > pybind11_init_smtk_session_mesh_Session(py::module &m) +inline PySharedPtrClass< smtk::session::mesh::Session, smtk::model::Session > pybind11_init_smtk_session_mesh_Session(py::module &m) { PySharedPtrClass< smtk::session::mesh::Session, smtk::model::Session > instance(m, "Session"); instance diff --git a/smtk/session/mesh/pybind11/PybindTopology.h b/smtk/session/mesh/pybind11/PybindTopology.h index 4c8b5093d5b2bdd5dcdd782d7839a08bca486290..21c6f32aa30cb5d56cf5e4256bc519335c20a389 100644 --- a/smtk/session/mesh/pybind11/PybindTopology.h +++ b/smtk/session/mesh/pybind11/PybindTopology.h @@ -18,7 +18,7 @@ namespace py = pybind11; -py::class_< smtk::session::mesh::Topology > pybind11_init_smtk_session_mesh_Topology(py::module &m) +inline py::class_< smtk::session::mesh::Topology > pybind11_init_smtk_session_mesh_Topology(py::module &m) { py::class_< smtk::session::mesh::Topology > instance(m, "Topology"); instance diff --git a/smtk/session/mesh/pybind11/PybindWrite.h b/smtk/session/mesh/pybind11/PybindWrite.h index c1d9c2e7777fb3ae20e6aa2d74aa61266c82064d..2ef73cddc78c23eba7e52bcffd5d5c0bf8d6fef6 100644 --- a/smtk/session/mesh/pybind11/PybindWrite.h +++ b/smtk/session/mesh/pybind11/PybindWrite.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::mesh::Write, smtk::operation::XMLOperation > pybind11_init_smtk_session_mesh_Write(py::module &m) +inline PySharedPtrClass< smtk::session::mesh::Write, smtk::operation::XMLOperation > pybind11_init_smtk_session_mesh_Write(py::module &m) { PySharedPtrClass< smtk::session::mesh::Write, smtk::operation::XMLOperation > instance(m, "Write"); instance diff --git a/smtk/session/mesh/queries/RandomPoint.h b/smtk/session/mesh/queries/RandomPoint.h index 96017e2e3899b80061f86d87eaaf3c9cba7da572..477cecd174dce710d115c694b82730f8226179e2 100644 --- a/smtk/session/mesh/queries/RandomPoint.h +++ b/smtk/session/mesh/queries/RandomPoint.h @@ -31,10 +31,7 @@ namespace mesh struct SMTKMESHSESSION_EXPORT RandomPoint : public smtk::resource::query::DerivedFrom { - RandomPoint() - : m_seed(0) - { - } + RandomPoint() = default; std::array operator()(const smtk::resource::Component::Ptr& component) const override { @@ -59,7 +56,7 @@ struct SMTKMESHSESSION_EXPORT RandomPoint void seed(std::size_t i) override { m_seed = i; } private: - std::size_t m_seed; + std::size_t m_seed{ 0 }; }; } // namespace mesh } // namespace session diff --git a/smtk/session/mesh/testing/cxx/TestCreateUniformGridOp.cxx b/smtk/session/mesh/testing/cxx/TestCreateUniformGridOp.cxx index 0ea3b75ded29f562c49606dad7dcffba4388c9dc..0da7e22511669fc8df9d387471dbff14c9574fc2 100644 --- a/smtk/session/mesh/testing/cxx/TestCreateUniformGridOp.cxx +++ b/smtk/session/mesh/testing/cxx/TestCreateUniformGridOp.cxx @@ -32,6 +32,8 @@ #include "smtk/operation/Manager.h" +#include "smtk/plugin/Registry.h" + #ifdef SMTK_ENABLE_VTK_SUPPORT #include "smtk/extension/vtk/source/vtkModelMultiBlockSource.h" @@ -142,18 +144,12 @@ smtkComponentInitMacro(smtk_extension_vtk_io_mesh_MeshIOVTK) // Create a resource manager smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); - // Register mesh resources to the resource manager - { - smtk::session::mesh::Registrar::registerTo(resourceManager); - } - // Create an operation manager smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); - // Register mesh operators to the operation manager - { - smtk::session::mesh::Registrar::registerTo(operationManager); - } + // Register mesh operators to the resource and operation managers + auto meshRegistry = smtk::plugin::addToManagers( + resourceManager, operationManager); // Register the resource manager to the operation manager (newly created // resources will be automatically registered to the resource manager). @@ -219,18 +215,12 @@ smtkComponentInitMacro(smtk_extension_vtk_io_mesh_MeshIOVTK) // Create a resource manager smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); - // Register mesh resources to the resource manager - { - smtk::session::mesh::Registrar::registerTo(resourceManager); - } - // Create an operation manager smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); - // Register mesh operators to the operation manager - { - smtk::session::mesh::Registrar::registerTo(operationManager); - } + // Register mesh operators to the resource and operation managers + auto meshRegistry = smtk::plugin::addToManagers( + resourceManager, operationManager); // Register the resource manager to the operation manager (newly created // resources will be automatically registered to the resource manager). diff --git a/smtk/session/mesh/testing/cxx/TestMergeOp.cxx b/smtk/session/mesh/testing/cxx/TestMergeOp.cxx index 40eab75081f0009aabe11dcab7fee8936f1bdcfe..790e48acc1f842d909659e875d5aef6c0a470268 100644 --- a/smtk/session/mesh/testing/cxx/TestMergeOp.cxx +++ b/smtk/session/mesh/testing/cxx/TestMergeOp.cxx @@ -31,6 +31,8 @@ #include "smtk/model/Group.h" #include "smtk/model/Resource.h" +#include "smtk/plugin/Registry.h" + #include "smtk/resource/Manager.h" #include "smtk/operation/Manager.h" @@ -151,18 +153,12 @@ int TestMergeOp(int argc, char* argv[]) // Create a resource manager smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); - // Register mesh resources to the resource manager - { - smtk::session::mesh::Registrar::registerTo(resourceManager); - } - // Create an operation manager smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); - // Register mesh operators to the operation manager - { - smtk::session::mesh::Registrar::registerTo(operationManager); - } + // Register mesh operators to the resource and operation managers + auto meshRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); // Register the resource manager to the operation manager (newly created // resources will be automatically registered to the resource manager). diff --git a/smtk/session/mesh/testing/cxx/TestMeshSessionReadWrite.cxx b/smtk/session/mesh/testing/cxx/TestMeshSessionReadWrite.cxx index 113fc9b1fe0d9e2bc0c60ffb6c0449fabc64cd11..e9e1f2e2fe34434617ad31d2e88e373979d35fc4 100644 --- a/smtk/session/mesh/testing/cxx/TestMeshSessionReadWrite.cxx +++ b/smtk/session/mesh/testing/cxx/TestMeshSessionReadWrite.cxx @@ -25,6 +25,8 @@ #include "smtk/operation/operators/ReadResource.h" #include "smtk/operation/operators/WriteResource.h" +#include "smtk/plugin/Registry.h" + #include "smtk/session/mesh/Registrar.h" #include "smtk/session/mesh/Resource.h" @@ -115,17 +117,12 @@ int TestMeshSessionReadWrite(int argc, char* argv[]) // Create a resource manager smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); - { - smtk::session::mesh::Registrar::registerTo(resourceManager); - } - // Create an operation manager smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); - { - smtk::operation::Registrar::registerTo(operationManager); - smtk::session::mesh::Registrar::registerTo(operationManager); - } + auto meshRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); + auto modelRegistry = smtk::plugin::addToManagers(operationManager); // Register the resource manager to the operation manager (newly created // resources will be automatically registered to the resource manager). diff --git a/smtk/session/mesh/testing/cxx/TestTransformOp.cxx b/smtk/session/mesh/testing/cxx/TestTransformOp.cxx index c23892f0e762ec0cc80018a8ac87ab408df42f8c..1a9f69d282ecb5c58c2cb04c65842af7356ef55f 100644 --- a/smtk/session/mesh/testing/cxx/TestTransformOp.cxx +++ b/smtk/session/mesh/testing/cxx/TestTransformOp.cxx @@ -33,6 +33,8 @@ #include "smtk/model/Group.h" #include "smtk/model/Resource.h" +#include "smtk/plugin/Registry.h" + #include "smtk/resource/Manager.h" #include "smtk/operation/Manager.h" @@ -50,18 +52,12 @@ int TestTransformOp(int argc, char* argv[]) // Create a resource manager smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); - // Register mesh resources to the resource manager - { - smtk::session::mesh::Registrar::registerTo(resourceManager); - } - // Create an operation manager smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); - // Register mesh operators to the operation manager - { - smtk::session::mesh::Registrar::registerTo(operationManager); - } + // Register mesh operators to the resource and operation managers + auto meshRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); // Register the resource manager to the operation manager (newly created // resources will be automatically registered to the resource manager). diff --git a/smtk/session/mesh/testing/xml/CMakeLists.txt b/smtk/session/mesh/testing/xml/CMakeLists.txt index 611602bd0475fb5fb77fafdad460610c301e4817..4952669d1a662aebb0dfec583df507d38b76f29b 100644 --- a/smtk/session/mesh/testing/xml/CMakeLists.txt +++ b/smtk/session/mesh/testing/xml/CMakeLists.txt @@ -8,7 +8,7 @@ set(OpenExodusFile_USES_DIRECT_DATA ON) if (SMTK_DATA_DIR) smtk_add_client_tests( -# LABEL "pv_meshsession" + #LABEL "MeshSession" TEST_SCRIPTS ${TESTS_WITH_BASELINES} LOAD_PLUGINS smtkResourcePlugin diff --git a/smtk/session/oscillator/testing/cxx/CMakeLists.txt b/smtk/session/oscillator/testing/cxx/CMakeLists.txt index 917a1ecc70b54cd952969fe7d712d09ddf03e687..56686977b22036384fd7e5b6ed235b27197bccdd 100644 --- a/smtk/session/oscillator/testing/cxx/CMakeLists.txt +++ b/smtk/session/oscillator/testing/cxx/CMakeLists.txt @@ -15,7 +15,7 @@ # set (unit_tests_which_require_data) # # smtk_unit_tests( -# LABEL "oscillator session" +# LABEL "OscillatorSession" # SOURCES ${unit_tests} # SOURCES_REQUIRE_DATA ${unit_tests_which_require_data} # LIBRARIES smtkCore smtkOscillatorSession) diff --git a/smtk/session/oscillator/testing/python/CMakeLists.txt b/smtk/session/oscillator/testing/python/CMakeLists.txt index 7bfda5d9ca349710c9a1942953eb6ad33b102e9f..ba43be250e6ba8f98faa8da5dbb10813b66834c3 100644 --- a/smtk/session/oscillator/testing/python/CMakeLists.txt +++ b/smtk/session/oscillator/testing/python/CMakeLists.txt @@ -6,6 +6,6 @@ # foreach (test ${smtkOscillatorPythonDataTests}) # smtk_add_test_python(${test}Py ${test}.py # --data-dir=${SMTK_DATA_DIR} ) -# set_tests_properties( ${test}Py PROPERTIES LABELS "oscillator session" ) +# set_tests_properties( ${test}Py PROPERTIES LABELS "OscillatorSession" ) # endforeach() # endif() diff --git a/smtk/session/polygon/CMakeLists.txt b/smtk/session/polygon/CMakeLists.txt index f16cb59ffebc4e023e56b7a4374ca94af5790334..c64eb60b5269bbabf705575e35a28852271702cc 100644 --- a/smtk/session/polygon/CMakeLists.txt +++ b/smtk/session/polygon/CMakeLists.txt @@ -59,6 +59,7 @@ set(polygonOperators Delete DemoteVertex ForceCreateFace + ImportPPG LegacyRead Read SplitEdge diff --git a/smtk/session/polygon/Registrar.cxx b/smtk/session/polygon/Registrar.cxx index 1ecafb83fa2db6e869301e6708a349be56a0b5bd..fc2cf92c5b84c013a3e51587b3d20e8ed90b8622 100644 --- a/smtk/session/polygon/Registrar.cxx +++ b/smtk/session/polygon/Registrar.cxx @@ -22,6 +22,7 @@ #include "smtk/session/polygon/operators/Delete.h" #include "smtk/session/polygon/operators/DemoteVertex.h" #include "smtk/session/polygon/operators/ForceCreateFace.h" +#include "smtk/session/polygon/operators/ImportPPG.h" #include "smtk/session/polygon/operators/LegacyRead.h" #include "smtk/session/polygon/operators/Read.h" #include "smtk/session/polygon/operators/SplitEdge.h" @@ -65,6 +66,7 @@ typedef std::tuple< ExtractContours, Import, #endif + ImportPPG, LegacyRead, Read, SplitEdge, @@ -85,6 +87,8 @@ void Registrar::registerTo(const smtk::operation::Manager::Ptr& operationManager smtk::operation::CreatorGroup(operationManager) .registerOperation(); + smtk::operation::CreatorGroup(operationManager) + .registerOperation(); #ifdef VTK_SUPPORT smtk::operation::ImporterGroup(operationManager) @@ -109,6 +113,8 @@ void Registrar::unregisterFrom(const smtk::operation::Manager::Ptr& operationMan { smtk::operation::CreatorGroup(operationManager) .unregisterOperation(); + smtk::operation::CreatorGroup(operationManager) + .unregisterOperation(); #ifdef VTK_SUPPORT smtk::operation::ImporterGroup(operationManager) diff --git a/smtk/session/polygon/Session.cxx b/smtk/session/polygon/Session.cxx index 5edbe276f54e991740f67228aef047004b7312f0..783ebc6115c5c0757e8b88883e368101e977521b 100644 --- a/smtk/session/polygon/Session.cxx +++ b/smtk/session/polygon/Session.cxx @@ -50,10 +50,7 @@ namespace polygon { /// Default constructor. -Session::Session() - : m_nextModelNumber(0) -{ -} +Session::Session() = default; /// Virtual destructor. Here because Session overrides virtual methods from Session. Session::~Session() = default; diff --git a/smtk/session/polygon/Session.h b/smtk/session/polygon/Session.h index f2719ca411b7ef7968af02c441756856fcb88662..fb2c63141e97ff287762145b0225b1a330edc189 100644 --- a/smtk/session/polygon/Session.h +++ b/smtk/session/polygon/Session.h @@ -124,7 +124,7 @@ protected: internal::EntityIdToPtr::iterator findStorageIterator(const smtk::common::UUID& uid); internal::EntityIdToPtr m_storage; - int m_nextModelNumber; + int m_nextModelNumber{ 0 }; }; } // namespace polygon diff --git a/smtk/session/polygon/internal/Entity.h b/smtk/session/polygon/internal/Entity.h index 0658c1e87a9513e99625c3eadcf6368e0cea9327..7578ed9880286ad37e79f8d3b97852b9a36b77c7 100644 --- a/smtk/session/polygon/internal/Entity.h +++ b/smtk/session/polygon/internal/Entity.h @@ -48,10 +48,7 @@ public: } protected: - entity() - : m_parent(nullptr) - { - } + entity() = default; entity(const Id& uid, entity* p) : m_parent(p) , m_id(uid) @@ -59,7 +56,7 @@ protected: } virtual ~entity() { m_parent = nullptr; } - entity* m_parent; + entity* m_parent{ nullptr }; Id m_id; }; diff --git a/smtk/session/polygon/internal/Model.cxx b/smtk/session/polygon/internal/Model.cxx index 249e8f0b45e35bfc1f5b8a21cb339adfdf490076..951ed1d24f56e80b6c6dc8ea82981148e71a65e2 100644 --- a/smtk/session/polygon/internal/Model.cxx +++ b/smtk/session/polygon/internal/Model.cxx @@ -48,7 +48,6 @@ typedef std::vector> SegmentSplitsT; pmodel::pmodel() : m_session(nullptr) - , m_featureSize(1e-8) { for (int i = 0; i < 3; ++i) { diff --git a/smtk/session/polygon/internal/Model.h b/smtk/session/polygon/internal/Model.h index 42a28c0078490fa945c7f2d5b72a9fea97adc013..176fb6a669ffd8985fd7571b69cde7a3966a8e72 100644 --- a/smtk/session/polygon/internal/Model.h +++ b/smtk/session/polygon/internal/Model.h @@ -226,7 +226,7 @@ protected: SessionPtr m_session; // Parent session of this pmodel. long long m_scale; // Recommend this be a large composite number w/ factors 2, 3, 5 (e.g., 15360, 231000, or 1182720) - double m_featureSize; + double m_featureSize{ 1e-8 }; double m_origin[3]; // Base point of plane for pmodel diff --git a/smtk/session/polygon/internal/Region.cxx b/smtk/session/polygon/internal/Region.cxx index 94564cb4a0afc1361e6a2477102aeef2913afe9f..8d3a35c12677a86b88576d27c96594d34bec5a34 100644 --- a/smtk/session/polygon/internal/Region.cxx +++ b/smtk/session/polygon/internal/Region.cxx @@ -18,7 +18,6 @@ namespace polygon Region::Region() : m_seedFragment(static_cast(-1)) - , m_seedSense(true) { } diff --git a/smtk/session/polygon/internal/Region.h b/smtk/session/polygon/internal/Region.h index 297c7a0a55888cb660efdd204b100c98dfacc3db..849681ab3d60d6abcb53fb6276e9f3007f877ca9 100644 --- a/smtk/session/polygon/internal/Region.h +++ b/smtk/session/polygon/internal/Region.h @@ -36,7 +36,7 @@ class SMTKPOLYGONSESSION_EXPORT Region { public: FragmentId m_seedFragment; - bool m_seedSense; + bool m_seedSense{ true }; //std::deque > m_boundary; // size_t = fragment id, bool = sense rel to fragment std::set m_innerLoops; diff --git a/smtk/session/polygon/internal/Vertex.cxx b/smtk/session/polygon/internal/Vertex.cxx index 6253315d323de9b611a1a0d5f1ddd3b16a5c039c..00b6c419ef30ec3cf08d94445ed35bab6aad173a 100644 --- a/smtk/session/polygon/internal/Vertex.cxx +++ b/smtk/session/polygon/internal/Vertex.cxx @@ -214,7 +214,7 @@ bool vertex::setFaceAdjacency( { it->m_adjacentFace = adjacentFace; } - this->dump(); + // this->dump(); return true; } } diff --git a/smtk/session/polygon/internal/Vertex.h b/smtk/session/polygon/internal/Vertex.h index 08d456dcbca091fd5129d52eb87b05104b5c6489..c3195499baf4007addbce8a732f3e00d12f10562 100644 --- a/smtk/session/polygon/internal/Vertex.h +++ b/smtk/session/polygon/internal/Vertex.h @@ -40,8 +40,9 @@ public: { Id m_edgeId; // Should never be nullptr Id m_adjacentFace; // Face immediately CW of m_edgeId. May be nullptr. - bool - m_edgeOut; // True when edge points outward from vertex (i.e., edge oriented so beginning vertex is this vertex) + bool m_edgeOut{ + false + }; // True when edge points outward from vertex (i.e., edge oriented so beginning vertex is this vertex) incident_edge_data(Id edgeId, bool isEdgeOut) : m_edgeId(edgeId) @@ -64,10 +65,7 @@ public: , m_edgeOut(other.isEdgeOutgoing()) { } - incident_edge_data() - : m_edgeOut(false) - { - } + incident_edge_data() = default; Id edgeId() const { return m_edgeId; } Id clockwiseFaceId() const { return m_adjacentFace; } @@ -127,15 +125,13 @@ public: protected: friend class pmodel; - vertex() - : m_insideSplit(false) - { - } + vertex() = default; Point m_coords; // position in the plane. incident_edges m_edges; // CCW list of incident edges - bool - m_insideSplit; // Is an edge attached here being split? If so, canInsertEdge will behave differently. + bool m_insideSplit{ + false + }; // Is an edge attached here being split? If so, canInsertEdge will behave differently. // NB: One extension to this structure would be: // Ptr m_prev; // Previous model vertex located at this exact point in the plane diff --git a/smtk/session/polygon/operators/CreateFaces.cxx b/smtk/session/polygon/operators/CreateFaces.cxx index a4b980104ccb18e73658d7096e0c4e3761abe378..7734e5d8e732deda7d13e3cfb6c384f2e55ae5a5 100644 --- a/smtk/session/polygon/operators/CreateFaces.cxx +++ b/smtk/session/polygon/operators/CreateFaces.cxx @@ -258,8 +258,8 @@ CreateFaces::Result CreateFaces::operateInternal() if (m_debugLevel > 0) { DumpEventQueue("Initial", eventQueue); + std::cout << "Bounds: " << xblo << " " << yblo << " " << xbhi << " " << ybhi << "\n"; } - std::cout << "Bounds: " << xblo << " " << yblo << " " << xbhi << " " << ybhi << "\n"; // The first event in eventQueue had better be a segment-start event. // So the first thing this event-loop should do is start processing edges. diff --git a/smtk/session/polygon/operators/CreateFaces.h b/smtk/session/polygon/operators/CreateFaces.h index 83efb7dadae37a661daf4961853b433311d54968..26a2496c2ed6be48b9a281b3416a65f544226d4a 100644 --- a/smtk/session/polygon/operators/CreateFaces.h +++ b/smtk/session/polygon/operators/CreateFaces.h @@ -36,11 +36,7 @@ class Neighborhood; /// An internal structure used when discovering edge loops. struct SMTKPOLYGONSESSION_EXPORT ModelEdgeInfo { - ModelEdgeInfo() - : m_allowedOrientations(0) - { - m_visited[0] = m_visited[1] = false; - } + ModelEdgeInfo() { m_visited[0] = m_visited[1] = false; } ModelEdgeInfo(int allowedOrientations) { m_allowedOrientations = allowedOrientations > 0 ? +1 : allowedOrientations < 0 ? -1 : 0; @@ -53,7 +49,7 @@ struct SMTKPOLYGONSESSION_EXPORT ModelEdgeInfo m_visited[i] = other.m_visited[i]; } - int m_allowedOrientations; // 0: all, -1: only negative, +1: only positive + int m_allowedOrientations{ 0 }; // 0: all, -1: only negative, +1: only positive bool m_visited [2]; // has the [0]: negative, [1]: positive orientation of the edge been visited already? }; diff --git a/smtk/session/polygon/operators/ImportPPG.cxx b/smtk/session/polygon/operators/ImportPPG.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6e1108dc212b61c10b1bf169dbbcfb9305eb46f6 --- /dev/null +++ b/smtk/session/polygon/operators/ImportPPG.cxx @@ -0,0 +1,708 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +#include "ImportPPG.h" + +#include "smtk/attribute/Attribute.h" +#include "smtk/attribute/ComponentItem.h" +#include "smtk/attribute/DoubleItem.h" +#include "smtk/attribute/FileItem.h" +#include "smtk/attribute/GroupItem.h" +#include "smtk/attribute/IntItem.h" +#include "smtk/attribute/ResourceItem.h" +#include "smtk/attribute/StringItem.h" +#include "smtk/common/StringUtil.h" +#include "smtk/common/UUID.h" +#include "smtk/io/Logger.h" +#include "smtk/model/Edge.h" +#include "smtk/model/Entity.h" +#include "smtk/model/EntityRef.h" +#include "smtk/model/EntityTypeBits.h" +#include "smtk/model/Face.h" +#include "smtk/model/Model.h" +#include "smtk/model/Resource.h" +#include "smtk/model/Vertex.h" +#include "smtk/operation/Operation.h" +#include "smtk/resource/Component.h" +#include "smtk/session/polygon/Resource.h" +#include "smtk/session/polygon/internal/Model.h" +#include "smtk/session/polygon/internal/Model.txx" +#include "smtk/session/polygon/operators/CreateEdgeFromVertices.h" +#include "smtk/session/polygon/operators/CreateFacesFromEdges.h" +#include "smtk/session/polygon/operators/CreateModel.h" +#include "smtk/session/polygon/operators/Delete.h" + +#include "smtk/session/polygon/ImportPPG_xml.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ +constexpr std::size_t INVALID_INDEX = std::numeric_limits::max(); +constexpr int OP_SUCCEEDED = static_cast(smtk::operation::Operation::Outcome::SUCCEEDED); + +// Macro for returning on error +#define errorMacro(msg) \ + do \ + { \ + smtkErrorMacro(this->log(), msg); \ + return this->createResult(smtk::operation::Operation::Outcome::FAILED); \ + } while (0) + +// Macro for returning error from Internal +#define errorMacroFalse(msg) \ + do \ + { \ + smtkErrorMacro(m_log, msg); \ + return false; \ + } while (0) + +enum class LoopType +{ + FACE = 0, // outer loop + EMBEDDED, // inner loop as embedded face + HOLE // inner loop as hole +}; + +struct PPGVertex +{ + std::size_t userId; + double x; + double y; + + PPGVertex(std::size_t inputId, double xcoord, double ycoord) + : userId(inputId) + , x(xcoord) + , y(ycoord) + { + } + + void dump() const + { + std::cout << "PPGVertex userId: " << userId << ", x: " << x << ", y: " << y << std::endl; + } +}; + +struct PPGFace +{ + std::size_t userId; + std::vector vertexIds; // from input + LoopType loopType; + std::size_t innerLoopCount; + std::vector edges; + double center[2]; + + PPGFace( + std::size_t inputId, + const std::vector& inputVertexIds, + LoopType lt, + double centerCoords[2]) + : userId(inputId) + , loopType(lt) + , innerLoopCount(0) + { + vertexIds = std::move(inputVertexIds); + center[0] = centerCoords[0]; + center[1] = centerCoords[1]; + } + + void dump() const + { + std::cout << "PPGFace userId: " << userId << ", loop type: " << static_cast(loopType) + << ", inner loops: " << innerLoopCount << ", center: " << center[0] << ", " + << center[1] << '\n' + << "vertex ids:"; + for (auto vid : vertexIds) + { + std::cout << " " << vid; + } + std::cout << std::endl; + } +}; +} // namespace + +namespace smtk +{ +namespace session +{ +namespace polygon +{ +class ImportPPG::Internal +{ +public: + Internal(smtk::io::Logger& logger) + : m_log(logger) + , m_holeCount(0) + , m_outerLoopIndex(INVALID_INDEX) + { + } + ~Internal() = default; + + void clear() + { + m_ppgFaceList.clear(); + m_ppgVertexList.clear(); + + m_resource.reset(); + m_modelEntity.reset(); + } + + // Build model entities + bool createModel(); + bool createVertices(); + bool createEdges(); + bool createFaces(); + + // Finds PPGFace index matching input model face + std::size_t findInnerLoop(smtk::model::EntityRef& faceRef, std::size_t outerIndex) const; + + // Parse input line + bool parseInputLine(const std::string& line, unsigned lineNum); + + void print() const + { + std::cout << "PPG input vertex count: " << m_ppgVertexList.size() << std::endl; + std::cout << "PPG input face count: " << m_ppgFaceList.size() - m_holeCount << std::endl; + std::cout << "PPG input hole count: " << m_holeCount << std::endl; + + for (const auto& ppgFace : m_ppgFaceList) + { + ppgFace.dump(); + } + } + + smtk::model::ResourcePtr resource() const { return m_resource; } + +protected: + bool parsePPGVertex(const std::vector& symbols, unsigned lineNum); + bool parsePPGFace(const std::vector& symbols, unsigned lineNum); + + smtk::io::Logger& m_log; + std::vector m_ppgFaceList; + std::vector m_ppgVertexList; + unsigned int m_holeCount; + std::size_t m_outerLoopIndex; // used parsing input to store current outer edge loop + + // List of smtk vertices + std::vector m_smtkVertexList; + + // Track vertex-pairs used to make edges, to avoid duplication + std::set> m_ppgVertexPairSet; + + smtk::model::ResourcePtr m_resource; + std::shared_ptr m_modelEntity; +}; + +bool ImportPPG::Internal::createModel() +{ +#ifndef NDEBUG + std::cout << "Creating Model..." << std::endl; +#endif + + // Initialize and run CreateModel operation. + auto createOp = smtk::session::polygon::CreateModel::create(); + auto result = createOp->operate(); + int outcome = result->findInt("outcome")->value(); + if (outcome != OP_SUCCEEDED) + { + errorMacroFalse( + "CreateModel operation failed with outcome " << outcome << ". " + << createOp->log().convertToString()); + } + + auto resourceItem = result->findResource("resource"); + auto resource = resourceItem->value(); + m_resource = std::dynamic_pointer_cast(resource); + + smtk::attribute::ComponentItemPtr compItem = result->findComponent("model"); + m_modelEntity = compItem->value(); + + // Set name + smtk::model::Model modelRef(m_resource, m_modelEntity->id()); + modelRef.setName("model 1"); + return true; +} + +bool ImportPPG::Internal::createVertices() +{ + if (m_ppgVertexList.empty()) + { + smtkWarningMacro(m_log, "No input vertices specified."); + return true; + } + +#ifndef NDEBUG + std::cout << "Creating Vertices..." << std::endl; +#endif + + // Initialize new vertex list with one no-op vertex, because indices start with 1 + m_smtkVertexList.clear(); + m_smtkVertexList.emplace(m_smtkVertexList.end()); + + auto polyResource = std::dynamic_pointer_cast(m_resource); + internal::pmodel::Ptr storage = polyResource->findStorage(m_modelEntity->id()); + + std::stringstream ss; + std::vector coords(2); + for (const auto& v : m_ppgVertexList) + { + coords[0] = v.x; + coords[1] = v.y; + smtk::session::polygon::internal::Point projected = + storage->projectPoint(coords.begin(), coords.begin() + 2); + smtk::model::Vertex newVertex = storage->addModelVertex(m_resource, projected); + + // Set the vertex name + ss.str(std::string()); + ss.clear(); + ss << "vertex " << v.userId; + newVertex.setName(ss.str()); + + // Update member data + m_smtkVertexList.push_back(newVertex); + smtk::common::UUID uuid = newVertex.entity(); + } + return true; +} + +bool ImportPPG::Internal::createEdges() +{ +#ifndef NDEBUG + std::cout << "Creating Edges..." << std::endl; +#endif + + std::size_t edgeId = 0; + std::stringstream ss; + + // Initialize and run CreateEdgeFromVertices operation. + auto createOp = smtk::session::polygon::CreateEdgeFromVertices::create(); + for (auto& ppgFace : m_ppgFaceList) + { + std::vector& vertexIds(ppgFace.vertexIds); // shorthand + // Temporarily add first vertex to the end of the list + vertexIds.push_back(vertexIds.front()); + for (std::size_t i = 1; i < vertexIds.size(); ++i) + { + createOp->parameters()->removeAllAssociations(); + std::size_t id1 = vertexIds[i - 1]; + std::size_t id2 = vertexIds[i]; + + // Check for duplicate + auto pair1 = std::make_pair(id1, id2); + if (m_ppgVertexPairSet.count(pair1)) + { + continue; + } + m_ppgVertexPairSet.insert(pair1); + m_ppgVertexPairSet.insert(std::make_pair(id2, id1)); + + auto v1 = m_smtkVertexList[id1]; + auto v2 = m_smtkVertexList[id2]; + + createOp->parameters()->associateEntity(v1); + createOp->parameters()->associateEntity(v2); + auto result = createOp->operate(); + int outcome = result->findInt("outcome")->value(); + if (outcome != OP_SUCCEEDED) + { + errorMacroFalse("Failed to create edge from vertex " << (i - 1) << " to " << i); + } + + // Get the new edge and assign name + auto createdItem = result->findComponent("created"); + smtk::resource::ComponentPtr pcomp = createdItem->value(); + smtk::model::EntityRef edgeRef(m_resource, pcomp->id()); + + ++edgeId; + ss.str(std::string()); + ss.clear(); + ss << "edge " << edgeId; + edgeRef.setName(ss.str()); + + ppgFace.edges.push_back(edgeRef.entityRecord()); + } // for (i) + + // Remove temp vertex added to end of list + vertexIds.pop_back(); + } // for (ppgFace) + + return true; +} + +bool ImportPPG::Internal::createFaces() +{ +#ifndef NDEBUG + std::cout << "Creating Faces..." << std::endl; +#endif + + // Initialize and run CreateFaces operation. + auto createOp = smtk::session::polygon::CreateFacesFromEdges::create(); + auto deleteOp = smtk::session::polygon::Delete::create(); + std::stringstream ss; + for (std::size_t i = 0; i < m_ppgFaceList.size(); ++i) + { + createOp->parameters()->removeAllAssociations(); + + // Add the next face (outer loop) + auto& outerPPGFace = m_ppgFaceList[i]; + // outerPPGFace.dump(); + + std::size_t outerPPGIndex = i; + for (auto& edge : outerPPGFace.edges) + { + createOp->parameters()->associate(edge); + } + + // Add inner edge loops + for (std::size_t n = 0; n < outerPPGFace.innerLoopCount; ++n) + { + ++i; + const auto& innerPPGFace = m_ppgFaceList[i]; + for (const auto& edge : innerPPGFace.edges) + { + createOp->parameters()->associate(edge); + } + } + + auto result = createOp->operate(); + int outcome = result->findInt("outcome")->value(); + if (outcome != OP_SUCCEEDED) + { + errorMacroFalse("Failed to create model faces."); + } + + // Deal with inner edge loops + auto createdItem = result->findComponent("created"); + for (std::size_t n = 0; n < createdItem->numberOfValues(); ++n) + { + smtk::resource::ComponentPtr pcomp = createdItem->value(n); + smtk::model::EntityRef faceRef(m_resource, pcomp->id()); + if (n == 0) + { + // First face is the outer loop + ss.str(std::string()); + ss.clear(); + ss << "face " << outerPPGFace.userId; + faceRef.setName(ss.str()); + + continue; + } + + // Find matching inner edge loop + std::size_t index = this->findInnerLoop(faceRef, outerPPGIndex); + if (index == INVALID_INDEX) + { + errorMacroFalse("Error: unabled to find inner face"); + } + + const auto& innerPPGFace = m_ppgFaceList[index]; + if (innerPPGFace.loopType == LoopType::HOLE) + { + deleteOp->parameters()->associate(faceRef.entityRecord()); + } + else + { + // First face is the outer loop + ss.str(std::string()); + ss.clear(); + ss << "face " << innerPPGFace.userId; + faceRef.setName(ss.str()); + } + } // for (n) + } // for (ppg faces) + + if (!deleteOp->ableToOperate()) + { + return true; // no faces to delete + } + + auto deleteResult = deleteOp->operate(); + int deleteOutcome = deleteResult->findInt("outcome")->value(); + if (deleteOutcome != OP_SUCCEEDED) + { + errorMacroFalse("Failed to create model faces."); + } + + return true; +} + +std::size_t ImportPPG::Internal::findInnerLoop( + smtk::model::EntityRef& faceRef, + std::size_t outerIndex) const +{ + const PPGFace& outerPPGFace = m_ppgFaceList[outerIndex]; + if (outerPPGFace.innerLoopCount < 1) + { + smtkErrorMacro(m_log, "Internal Error - PPGFace has no inner loops"); + return INVALID_INDEX; + } + + // Find which inner loop corresponds to this model face + // Uses the fact that faces are convex and don't intersect + std::vector bbox = faceRef.boundingBox(); + std::size_t index = outerIndex + 1; + for (int i = 0; i < outerPPGFace.innerLoopCount; ++i, ++index) + { + // Get xmean, ymean + const PPGFace& innerFace = m_ppgFaceList[index]; + double x = innerFace.center[0]; + double y = innerFace.center[1]; + if ((x >= bbox[0]) && (x <= bbox[1]) && (y >= bbox[2]) && (y <= bbox[3])) + { + return index; + } + } + return INVALID_INDEX; // not found +} + +bool ImportPPG::Internal::parseInputLine(const std::string& line, unsigned lineNum) +{ + // std::cout << line << std::endl; + std::vector symbols = smtk::common::StringUtil::split(line, " ", true, true); + if (symbols.empty() || "#" == symbols[0]) + { + return true; + } + + else if ("v" == symbols[0]) + { + return this->parsePPGVertex(symbols, lineNum); + } + else if (("f" == symbols[0]) || ("e" == symbols[0]) || ("h" == symbols[0])) + { + return this->parsePPGFace(symbols, lineNum); + } + else + { + errorMacroFalse("Unrecognized input line " << lineNum << ": " << line); + return false; + } + + return true; +} // parseInputLine() + +bool ImportPPG::Internal::parsePPGVertex(const std::vector& symbols, unsigned lineNum) +{ + if (symbols.size() < 3) + { + errorMacroFalse("Vertex on line " << lineNum << " not specified with x and y coords."); + } + + double x; + double y; + try + { + x = std::stod(symbols[1]); + y = std::stod(symbols[2]); + } + catch (const std::exception& e) + { + errorMacroFalse("Error parsing vertex on line " << lineNum << ": " << e.what()); + } + + auto userId = 1 + m_ppgVertexList.size(); + m_ppgVertexList.emplace(m_ppgVertexList.end(), userId, x, y); + return true; +} // parsePPGVertex() + +bool ImportPPG::Internal::parsePPGFace(const std::vector& symbols, unsigned lineNum) +{ + if (symbols.size() < 2) + { + errorMacroFalse("Face on line " << lineNum << " not specified with any vertex indices."); + } + + std::vector vertexIds; + std::size_t vertexId; + double xsum = 0.0; + double ysum = 0.0; + for (auto it = symbols.begin() + 1; it != symbols.end(); ++it) + { + std::string s = *it; + if (s.at(0) == '#') + { + break; // comment at end of line + } + + try + { + vertexId = std::stoi(s); + } + catch (const std::exception& e) + { + errorMacroFalse( + "Error parsing vertex id " << s << " in line " << lineNum << ": " << e.what()); + } + + if (vertexId == 0) + { + errorMacroFalse("Invalid vertex id 0 on line " << lineNum << ". (Vertex ids start at 1.)"); + } + else if (vertexId > m_ppgVertexList.size()) + { + errorMacroFalse( + "Invalid vertexId " << vertexId << " on line " << lineNum + << ". Greater than number of vertices specified (" + << m_ppgVertexList.size() << ")."); + } + + vertexIds.push_back(vertexId); + + xsum += m_ppgVertexList[vertexId - 1].x; + ysum += m_ppgVertexList[vertexId - 1].y; + } // for (it) + + double npoints = static_cast(vertexIds.size()); + double center[2] = { xsum / npoints, ysum / npoints }; + + LoopType lt = LoopType::FACE; + lt = symbols[0] == "e" ? LoopType::EMBEDDED : lt; + lt = symbols[0] == "h" ? LoopType::HOLE : lt; + bool isHole = lt == LoopType::HOLE; + + // Sanity check + if (m_ppgFaceList.empty() && lt != LoopType::FACE) + { + errorMacroFalse("First model face is not type 'f', on line " << lineNum); + } + + std::size_t inputId = isHole ? 0 : 1 + m_ppgFaceList.size() - m_holeCount; + m_ppgFaceList.emplace(m_ppgFaceList.end(), inputId, vertexIds, lt, center); + m_holeCount += isHole ? 1 : 0; + + // Handle outer and inner edge loops differently + if (lt == LoopType::FACE) + { + // Set the index for the current outer loop + m_outerLoopIndex = m_ppgFaceList.size() - 1; + } + else + { + // Increment inner loop count for the outer loop + auto& outerLoop = m_ppgFaceList[m_outerLoopIndex]; + outerLoop.innerLoopCount += 1; + m_ppgFaceList[m_outerLoopIndex] = outerLoop; + } + + return true; +} // parsePPGFace() + +ImportPPG::ImportPPG() +{ + m_internal = new Internal(this->log()); +} + +ImportPPG::~ImportPPG() +{ + delete m_internal; +} + +smtk::operation::Operation::Result ImportPPG::operateInternal() +{ + m_internal->clear(); + + std::stringstream ss; + + // Check for string input first + auto stringItem = this->parameters()->findString("string"); + if (stringItem->isEnabled()) + { + ss.str(stringItem->value()); + } + else + { + // Otherwise check for file input + std::string filename = this->parameters()->findFile("filename")->value(); + std::ifstream infile(filename); + if (!infile.good()) + { + errorMacro("Unable to find or read input file: " << filename); + } + + ss << infile.rdbuf(); + infile.close(); + } + + // Traverse the input + if (ss.rdbuf()->in_avail() > 0) + { + std::string line; + unsigned int lineNum = 0; + while (std::getline(ss, line, '\n')) + { + ++lineNum; + if (!m_internal->parseInputLine(line, lineNum)) + { + return this->createResult(smtk::operation::Operation::Outcome::FAILED); + } + } // while + } // if + +#ifndef NDEBUG + m_internal->print(); +#endif + + this->log().reset(); + if (!m_internal->createModel()) + { + return this->createResult(smtk::operation::Operation::Outcome::FAILED); + } + + this->log().reset(); + if (!m_internal->createVertices()) + { + return this->createResult(smtk::operation::Operation::Outcome::FAILED); + } + + this->log().reset(); + if (!m_internal->createEdges()) + { + return this->createResult(smtk::operation::Operation::Outcome::FAILED); + } + + this->log().reset(); + if (!m_internal->createFaces()) + { + return this->createResult(smtk::operation::Operation::Outcome::FAILED); + } + + auto result = this->createResult(smtk::operation::Operation::Outcome::SUCCEEDED); + result->findResource("resource")->setValue(m_internal->resource()); + return result; +} + +bool ImportPPG::ableToOperate() +{ + // Check if filename is set + if (this->parameters()->findFile("filename")->isValid()) + { + return true; + } + + // If no filename, check for string item (advanced level) + auto stringItem = this->parameters()->findString("string"); + return stringItem->isEnabled() && stringItem->isSet(); +} + +const char* ImportPPG::xmlDescription() const +{ + return ImportPPG_xml; +} + +} // namespace polygon +} // namespace session +} // namespace smtk diff --git a/smtk/session/polygon/operators/ImportPPG.h b/smtk/session/polygon/operators/ImportPPG.h new file mode 100644 index 0000000000000000000000000000000000000000..3bfdb388c44caa0339d5757e3ff5be6e08db3324 --- /dev/null +++ b/smtk/session/polygon/operators/ImportPPG.h @@ -0,0 +1,63 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#ifndef smtk_session_polygon_ImportPPG_h +#define smtk_session_polygon_ImportPPG_h + +#include "smtk/PublicPointerDefs.h" + +#include "smtk/operation/XMLOperation.h" +#include "smtk/session/polygon/Exports.h" + +namespace smtk +{ +namespace session +{ +namespace polygon +{ + +/**\brief Create a model resource from .ppg file input. + * + * SMTK supports a simple .ppg file format for specifying + * 2-D geometry. The file is used to specify a set of + * vertices as 2-D coordinates and a set of ploygon faces, + * each specified as a list of vertex indices. Model edges + * are internally created between adjacent vertices. + * Only convex polygons are supported. + * + */ +class SMTKPOLYGONSESSION_EXPORT ImportPPG : public smtk::operation::XMLOperation +{ +public: + smtkTypeMacro(smtk::session::polygon::ImportPPG); + smtkCreateMacro(ImportPPG); + smtkSharedFromThisMacro(smtk::operation::XMLOperation); + smtkSuperclassMacro(Operation); + + // Override ableToOperate() to support test mode + bool ableToOperate() override; + + ~ImportPPG() override; + +protected: + ImportPPG(); + smtk::operation::Operation::Result operateInternal() override; + const char* xmlDescription() const override; + +private: + class Internal; + Internal* m_internal; +}; + +} // namespace polygon +} // namespace session +} // namespace smtk + +#endif // smtk_session_polygon_ImportPPG_h diff --git a/smtk/session/polygon/operators/ImportPPG.sbt b/smtk/session/polygon/operators/ImportPPG.sbt new file mode 100644 index 0000000000000000000000000000000000000000..f2302b6914056dd6f4617b330945ae0594f1d221 --- /dev/null +++ b/smtk/session/polygon/operators/ImportPPG.sbt @@ -0,0 +1,36 @@ + + + + + + + + + + + Input file listing vertex and face specifications. + + + Intended for testing, overrides filename item + + + + + + + + + + + + + + + + + + + + diff --git a/smtk/session/polygon/pybind11/PybindCreateEdge.h b/smtk/session/polygon/pybind11/PybindCreateEdge.h index 5183408ad4de0505f4050c1bb67546c651aacd41..4e727a80518eca549054bb72271bf24a609e0688 100644 --- a/smtk/session/polygon/pybind11/PybindCreateEdge.h +++ b/smtk/session/polygon/pybind11/PybindCreateEdge.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::CreateEdge > pybind11_init_smtk_session_polygon_CreateEdge(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::CreateEdge > pybind11_init_smtk_session_polygon_CreateEdge(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::CreateEdge > instance(m, "CreateEdge", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindCreateEdgeFromPoints.h b/smtk/session/polygon/pybind11/PybindCreateEdgeFromPoints.h index 4168f8609f1e1684aaabe675c1a8f28a56241b5e..1935aeaceb9ea872513c43da37b011ea823878a4 100644 --- a/smtk/session/polygon/pybind11/PybindCreateEdgeFromPoints.h +++ b/smtk/session/polygon/pybind11/PybindCreateEdgeFromPoints.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::CreateEdgeFromPoints > pybind11_init_smtk_session_polygon_CreateEdgeFromPoints(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::CreateEdgeFromPoints > pybind11_init_smtk_session_polygon_CreateEdgeFromPoints(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::CreateEdgeFromPoints > instance(m, "CreateEdgeFromPoints", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindCreateEdgeFromVertices.h b/smtk/session/polygon/pybind11/PybindCreateEdgeFromVertices.h index 50b4826016073af88efc75344a935e800b9b0f59..5f293fe1ff466522018c2a0dfe2207ee687410a5 100644 --- a/smtk/session/polygon/pybind11/PybindCreateEdgeFromVertices.h +++ b/smtk/session/polygon/pybind11/PybindCreateEdgeFromVertices.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::CreateEdgeFromVertices > pybind11_init_smtk_session_polygon_CreateEdgeFromVertices(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::CreateEdgeFromVertices > pybind11_init_smtk_session_polygon_CreateEdgeFromVertices(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::CreateEdgeFromVertices > instance(m, "CreateEdgeFromVertices", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindCreateFaces.h b/smtk/session/polygon/pybind11/PybindCreateFaces.h index 49fbb5b3538c9bbfaf0ba2e355eec6c566e2c838..0232a87849f887b67ab5b155169dc87af0dbf742 100644 --- a/smtk/session/polygon/pybind11/PybindCreateFaces.h +++ b/smtk/session/polygon/pybind11/PybindCreateFaces.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::session::polygon::ModelEdgeInfo > pybind11_init_smtk_session_polygon_ModelEdgeInfo(py::module &m) +inline py::class_< smtk::session::polygon::ModelEdgeInfo > pybind11_init_smtk_session_polygon_ModelEdgeInfo(py::module &m) { py::class_< smtk::session::polygon::ModelEdgeInfo > instance(m, "ModelEdgeInfo"); instance @@ -30,7 +30,7 @@ py::class_< smtk::session::polygon::ModelEdgeInfo > pybind11_init_smtk_session_p return instance; } -PySharedPtrClass< smtk::session::polygon::CreateFaces > pybind11_init_smtk_session_polygon_CreateFaces(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::CreateFaces > pybind11_init_smtk_session_polygon_CreateFaces(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::CreateFaces > instance(m, "CreateFaces", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindCreateModel.h b/smtk/session/polygon/pybind11/PybindCreateModel.h index ae1dbfc3e9a811885197e103558614e40b523dca..c13f00b325222890a721e8a84204e7eebe258565 100644 --- a/smtk/session/polygon/pybind11/PybindCreateModel.h +++ b/smtk/session/polygon/pybind11/PybindCreateModel.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::CreateModel > pybind11_init_smtk_session_polygon_CreateModel(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::CreateModel > pybind11_init_smtk_session_polygon_CreateModel(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::CreateModel > instance(m, "CreateModel", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindCreateVertices.h b/smtk/session/polygon/pybind11/PybindCreateVertices.h index 69ae715236e629e1dc2c08dee564df4a70f77a78..fe29abbe64c25a96908e4b3382c55e16c96dfe10 100644 --- a/smtk/session/polygon/pybind11/PybindCreateVertices.h +++ b/smtk/session/polygon/pybind11/PybindCreateVertices.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::CreateVertices> pybind11_init_smtk_session_polygon_CreateVertices(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::CreateVertices> pybind11_init_smtk_session_polygon_CreateVertices(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::CreateVertices > instance(m, "CreateVertices", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindDelete.h b/smtk/session/polygon/pybind11/PybindDelete.h index f4e24fbd79f7e99da7733c182b4048ee95c0b325..68c61196d272781d697cc50b199669443e33288c 100644 --- a/smtk/session/polygon/pybind11/PybindDelete.h +++ b/smtk/session/polygon/pybind11/PybindDelete.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::Delete> pybind11_init_smtk_session_polygon_Delete(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::Delete> pybind11_init_smtk_session_polygon_Delete(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::Delete > instance(m, "Delete", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindDemoteVertex.h b/smtk/session/polygon/pybind11/PybindDemoteVertex.h index 52ab794eb8b967fa0d8333c8d0a86441f397c3d0..820101da1e4a4b9108d54fe5b39785f3fd357d6a 100644 --- a/smtk/session/polygon/pybind11/PybindDemoteVertex.h +++ b/smtk/session/polygon/pybind11/PybindDemoteVertex.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::DemoteVertex > pybind11_init_smtk_session_polygon_DemoteVertex(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::DemoteVertex > pybind11_init_smtk_session_polygon_DemoteVertex(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::DemoteVertex > instance(m, "DemoteVertex", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindExtractContours.h b/smtk/session/polygon/pybind11/PybindExtractContours.h index 148d75d1457ae3a38301c4d19b4e11e4fbc41294..eec43fff9ead594429d9b0eb985b139ef4de1e83 100644 --- a/smtk/session/polygon/pybind11/PybindExtractContours.h +++ b/smtk/session/polygon/pybind11/PybindExtractContours.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::ExtractContours > pybind11_init_smtk_session_polygon_ExtractContours(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::ExtractContours > pybind11_init_smtk_session_polygon_ExtractContours(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::ExtractContours > instance(m, "ExtractContours", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindForceCreateFace.h b/smtk/session/polygon/pybind11/PybindForceCreateFace.h index c54bd0eb57aba05d619a9be3dae4fa29ee2c6128..b380c71098c2a6cb707ade248e21c9c9b78a5598 100644 --- a/smtk/session/polygon/pybind11/PybindForceCreateFace.h +++ b/smtk/session/polygon/pybind11/PybindForceCreateFace.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::ForceCreateFace > pybind11_init_smtk_session_polygon_ForceCreateFace(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::ForceCreateFace > pybind11_init_smtk_session_polygon_ForceCreateFace(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::ForceCreateFace > instance(m, "ForceCreateFace", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindImport.h b/smtk/session/polygon/pybind11/PybindImport.h index 9803d63a922f654ae642386267966f0027446b31..2b943c00d47dfb96457c533da97715bfe1ef7ca8 100644 --- a/smtk/session/polygon/pybind11/PybindImport.h +++ b/smtk/session/polygon/pybind11/PybindImport.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::Import > pybind11_init_smtk_session_polygon_Import(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::Import > pybind11_init_smtk_session_polygon_Import(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::Import > instance(m, "Import", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindImportPPG.h b/smtk/session/polygon/pybind11/PybindImportPPG.h new file mode 100644 index 0000000000000000000000000000000000000000..4ff34a66529c417bf1f0c981c5eb24435f598d9c --- /dev/null +++ b/smtk/session/polygon/pybind11/PybindImportPPG.h @@ -0,0 +1,35 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#ifndef pybind_smtk_session_polygon_operators_ImportPPG_h +#define pybind_smtk_session_polygon_operators_ImportPPG_h + +#include + +#include "smtk/session/polygon/operators/ImportPPG.h" + +namespace py = pybind11; + +inline PySharedPtrClass< smtk::session::polygon::ImportPPG > pybind11_init_smtk_session_polygon_ImportPPG(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +{ + PySharedPtrClass< smtk::session::polygon::ImportPPG > instance(m, "ImportPPG", parent); + instance + .def(py::init<::smtk::session::polygon::ImportPPG const &>()) + .def("deepcopy", (smtk::session::polygon::ImportPPG & (smtk::session::polygon::ImportPPG::*)(::smtk::session::polygon::ImportPPG const &)) &smtk::session::polygon::ImportPPG::operator=) + .def("ableToOperate", &smtk::session::polygon::ImportPPG::ableToOperate) + .def_static("create", (std::shared_ptr (*)()) &smtk::session::polygon::ImportPPG::create) + .def_static("create", (std::shared_ptr (*)(::std::shared_ptr &)) &smtk::session::polygon::ImportPPG::create, py::arg("ref")) + .def("shared_from_this", (std::shared_ptr (smtk::session::polygon::ImportPPG::*)() const) &smtk::session::polygon::ImportPPG::shared_from_this) + .def("shared_from_this", (std::shared_ptr (smtk::session::polygon::ImportPPG::*)()) &smtk::session::polygon::ImportPPG::shared_from_this) + ; + return instance; +} + +#endif diff --git a/smtk/session/polygon/pybind11/PybindLegacyRead.h b/smtk/session/polygon/pybind11/PybindLegacyRead.h index 72764629818fd8351cc987795e7811a2687be5ba..9850b93a68138b1a5ffb5fa02cfc364beaeec81a 100644 --- a/smtk/session/polygon/pybind11/PybindLegacyRead.h +++ b/smtk/session/polygon/pybind11/PybindLegacyRead.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::LegacyRead > pybind11_init_smtk_session_polygon_LegacyRead(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::LegacyRead > pybind11_init_smtk_session_polygon_LegacyRead(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::LegacyRead > instance(m, "LegacyRead", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindOperation.h b/smtk/session/polygon/pybind11/PybindOperation.h index c1979db30a27d59e5aba241c4f726d45636ef954..a5063a4587b273d6d09a462775bcc79656592c64 100644 --- a/smtk/session/polygon/pybind11/PybindOperation.h +++ b/smtk/session/polygon/pybind11/PybindOperation.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation > pybind11_init_smtk_session_polygon_Operation(py::module &m) +inline PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation > pybind11_init_smtk_session_polygon_Operation(py::module &m) { PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation > instance(m, "Operation"); instance diff --git a/smtk/session/polygon/pybind11/PybindPolygonSession.cxx b/smtk/session/polygon/pybind11/PybindPolygonSession.cxx index 0b487630119d53bb88296493bb57ac73fd4bb5df..65670e67cfd2c1e738540cfd54a121f9f2b451d1 100644 --- a/smtk/session/polygon/pybind11/PybindPolygonSession.cxx +++ b/smtk/session/polygon/pybind11/PybindPolygonSession.cxx @@ -38,6 +38,7 @@ using PySharedPtrClass = py::class_, Args...>; #include "PybindDelete.h" #include "PybindDemoteVertex.h" #include "PybindForceCreateFace.h" +#include "PybindImportPPG.h" #include "PybindRead.h" #include "PybindLegacyRead.h" #include "PybindSplitEdge.h" @@ -73,6 +74,7 @@ PYBIND11_MODULE(_smtkPybindPolygonSession, polygon) PySharedPtrClass< smtk::session::polygon::Delete > smtk_session_polygon_Delete = pybind11_init_smtk_session_polygon_Delete(polygon, smtk_session_polygon_Operation); PySharedPtrClass< smtk::session::polygon::DemoteVertex > smtk_session_polygon_DemoteVertex = pybind11_init_smtk_session_polygon_DemoteVertex(polygon, smtk_session_polygon_Operation); PySharedPtrClass< smtk::session::polygon::ForceCreateFace > smtk_session_polygon_ForceCreateFace = pybind11_init_smtk_session_polygon_ForceCreateFace(polygon, smtk_session_polygon_Operation); + PySharedPtrClass< smtk::session::polygon::ImportPPG > smtk_session_polygon_ImportPPG = pybind11_init_smtk_session_polygon_ImportPPG(polygon, smtk_session_polygon_Operation); PySharedPtrClass< smtk::session::polygon::Read > smtk_session_polygon_Read = pybind11_init_smtk_session_polygon_Read(polygon, smtk_session_polygon_Operation); PySharedPtrClass< smtk::session::polygon::LegacyRead > smtk_session_polygon_LegacyRead = pybind11_init_smtk_session_polygon_LegacyRead(polygon, smtk_session_polygon_Operation); PySharedPtrClass< smtk::session::polygon::SplitEdge > smtk_session_polygon_SplitEdge = pybind11_init_smtk_session_polygon_SplitEdge(polygon, smtk_session_polygon_Operation); diff --git a/smtk/session/polygon/pybind11/PybindRead.h b/smtk/session/polygon/pybind11/PybindRead.h index 6856714a76627024380f83effe544c3f98b30381..2d246b783815f391c0b0d7fd5ee0ae897c66333c 100644 --- a/smtk/session/polygon/pybind11/PybindRead.h +++ b/smtk/session/polygon/pybind11/PybindRead.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::Read > pybind11_init_smtk_session_polygon_Read(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::Read > pybind11_init_smtk_session_polygon_Read(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::Read > instance(m, "Read", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindRegistrar.h b/smtk/session/polygon/pybind11/PybindRegistrar.h index 258c2d53be6836e4d7569fd0f1f957050059084e..c62a3af4357de8bda798095922b11d12286aebd9 100644 --- a/smtk/session/polygon/pybind11/PybindRegistrar.h +++ b/smtk/session/polygon/pybind11/PybindRegistrar.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::session::polygon::Registrar > pybind11_init_smtk_session_polygon_Registrar(py::module &m) +inline py::class_< smtk::session::polygon::Registrar > pybind11_init_smtk_session_polygon_Registrar(py::module &m) { py::class_< smtk::session::polygon::Registrar > instance(m, "Registrar"); instance diff --git a/smtk/session/polygon/pybind11/PybindSession.h b/smtk/session/polygon/pybind11/PybindSession.h index 52b8f2df56e0fb4fd81b2f51167e7a49b15b19e5..fa3c8196a7fea8849c9b3c58d1beaad839a7a81c 100644 --- a/smtk/session/polygon/pybind11/PybindSession.h +++ b/smtk/session/polygon/pybind11/PybindSession.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::Session, smtk::model::Session > pybind11_init_smtk_session_polygon_Session(py::module &m) +inline PySharedPtrClass< smtk::session::polygon::Session, smtk::model::Session > pybind11_init_smtk_session_polygon_Session(py::module &m) { PySharedPtrClass< smtk::session::polygon::Session, smtk::model::Session > instance(m, "Session"); instance diff --git a/smtk/session/polygon/pybind11/PybindSessionIOJSON.h b/smtk/session/polygon/pybind11/PybindSessionIOJSON.h index 4b2c0180d58fc7f6978164adec411b13403382bc..57a03074743fea0575d06545b0d5a0146d986bb7 100644 --- a/smtk/session/polygon/pybind11/PybindSessionIOJSON.h +++ b/smtk/session/polygon/pybind11/PybindSessionIOJSON.h @@ -19,7 +19,7 @@ namespace py = pybind11; -py::class_< smtk::session::polygon::SessionIOJSON, smtk::model::SessionIOJSON > pybind11_init_smtk_session_polygon_SessionIOJSON(py::module &m) +inline py::class_< smtk::session::polygon::SessionIOJSON, smtk::model::SessionIOJSON > pybind11_init_smtk_session_polygon_SessionIOJSON(py::module &m) { py::class_< smtk::session::polygon::SessionIOJSON, smtk::model::SessionIOJSON > instance(m, "SessionIOJSON"); instance diff --git a/smtk/session/polygon/pybind11/PybindSplitEdge.h b/smtk/session/polygon/pybind11/PybindSplitEdge.h index 0a52dc9a4553dc30e5627b76d8f4bf54717c4553..1e6527c1ba2b1547c2a9278a390f7ad9ac287a36 100644 --- a/smtk/session/polygon/pybind11/PybindSplitEdge.h +++ b/smtk/session/polygon/pybind11/PybindSplitEdge.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::SplitEdge > pybind11_init_smtk_session_polygon_SplitEdge(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::SplitEdge > pybind11_init_smtk_session_polygon_SplitEdge(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::SplitEdge > instance(m, "SplitEdge", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindTweakEdge.h b/smtk/session/polygon/pybind11/PybindTweakEdge.h index c1dec63147c978cf8fa3245834a989cd43227164..ec1467160f25c566440de6e4769b0b7e18f5d3dc 100644 --- a/smtk/session/polygon/pybind11/PybindTweakEdge.h +++ b/smtk/session/polygon/pybind11/PybindTweakEdge.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::TweakEdge > pybind11_init_smtk_session_polygon_TweakEdge(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::TweakEdge > pybind11_init_smtk_session_polygon_TweakEdge(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::TweakEdge > instance(m, "TweakEdge", parent); instance diff --git a/smtk/session/polygon/pybind11/PybindWrite.h b/smtk/session/polygon/pybind11/PybindWrite.h index 563487f52e6afc1942d289f9f53ad9e146604540..4710e771d31fce2f57f7355aa71d31092bd489ae 100644 --- a/smtk/session/polygon/pybind11/PybindWrite.h +++ b/smtk/session/polygon/pybind11/PybindWrite.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::polygon::Write > pybind11_init_smtk_session_polygon_Write(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::polygon::Write > pybind11_init_smtk_session_polygon_Write(py::module &m, PySharedPtrClass< smtk::session::polygon::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::polygon::Write > instance(m, "Write", parent); instance diff --git a/smtk/session/polygon/qt/pqArcWidgetPanel.cxx b/smtk/session/polygon/qt/pqArcWidgetPanel.cxx index 1f94c0209fc22092b5832cd7953d67baff0fd8f2..71703c29714e9929ea6d73ac71454afe31280903 100644 --- a/smtk/session/polygon/qt/pqArcWidgetPanel.cxx +++ b/smtk/session/polygon/qt/pqArcWidgetPanel.cxx @@ -216,10 +216,7 @@ pqArcWidgetPanel::pqArcWidgetPanel(QWidget* parent) : QWidget(parent) , Internals(new pqArcWidgetPanel::pqInternals) , Picker(parent) - , View(nullptr) - , Arc(nullptr) , ArcWidget(nullptr) - , ArcManager(nullptr) { Internals->setupUi(this); this->setObjectName("pqArcWidgetPanel"); diff --git a/smtk/session/polygon/qt/pqArcWidgetPanel.h b/smtk/session/polygon/qt/pqArcWidgetPanel.h index 2df24df5bb48573389b3fe172eb0c9d97c0c0397..97c414275d43a310fa21bef1b176a77f73d31bc0 100644 --- a/smtk/session/polygon/qt/pqArcWidgetPanel.h +++ b/smtk/session/polygon/qt/pqArcWidgetPanel.h @@ -33,14 +33,12 @@ namespace Ui struct PickInfo { - pqOutputPort* port; + pqOutputPort* port{ nullptr }; smtk::common::UUID EdgeId; - vtkIdType BlockIndex; + vtkIdType BlockIndex{ -1 }; PickInfo() - : port(nullptr) - , EdgeId(smtk::common::UUID::null()) - , BlockIndex(-1) + : EdgeId(smtk::common::UUID::null()) { } }; @@ -139,10 +137,10 @@ private: Ui::PickInfo ArcInfo; Ui::ArcPicker Picker; - pqRenderView* View; - pqPolygonArc* Arc; + pqRenderView* View{ nullptr }; + pqPolygonArc* Arc{ nullptr }; QPointer ArcWidget; - pqArcWidgetManager* ArcManager; + pqArcWidgetManager* ArcManager{ nullptr }; }; #endif // __smtk_polygon_pq_ArcWidgetPanel_h diff --git a/smtk/session/polygon/qt/pqSplitEdgeWidget.cxx b/smtk/session/polygon/qt/pqSplitEdgeWidget.cxx index 0c307b23c43246da7f70f8576df13cf9a1b03880..b6d4312071a54c9532aa71ccb5ebc17aba6e8be5 100644 --- a/smtk/session/polygon/qt/pqSplitEdgeWidget.cxx +++ b/smtk/session/polygon/qt/pqSplitEdgeWidget.cxx @@ -126,7 +126,6 @@ pqSplitEdgeWidget::pqSplitEdgeWidget(QWidget* prent) : QWidget(prent) , Internals(new pqSplitEdgeWidget::pqInternals) , m_edgePointPicker(new pqSplitEdgeWidgetInternals::EdgePointPicker(this)) - , View(nullptr) { this->setObjectName("pqSplitEdgeWidget"); QSizePolicy sizeFixedPolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); diff --git a/smtk/session/polygon/qt/pqSplitEdgeWidget.h b/smtk/session/polygon/qt/pqSplitEdgeWidget.h index ff07e22cf7dc7ff62424388932a1216820ed399e..840f37ec2c81e227fcc4921fb3fc70aa382be686 100644 --- a/smtk/session/polygon/qt/pqSplitEdgeWidget.h +++ b/smtk/session/polygon/qt/pqSplitEdgeWidget.h @@ -77,7 +77,7 @@ private: pqSplitEdgeWidgetInternals::EdgePointPicker* m_edgePointPicker; - pqRenderView* View; + pqRenderView* View{ nullptr }; smtk::weak_ptr m_edgeOp; }; diff --git a/smtk/session/polygon/testing/cxx/CMakeLists.txt b/smtk/session/polygon/testing/cxx/CMakeLists.txt index f4b16053df6e663d43538bf7cd8057ee0fed4f2d..30229400a0a3196b899ff479756a67a0f9fa3495 100644 --- a/smtk/session/polygon/testing/cxx/CMakeLists.txt +++ b/smtk/session/polygon/testing/cxx/CMakeLists.txt @@ -17,7 +17,8 @@ set (unit_tests UnitTestPolygonCreateFacesFromEdges.cxx UnitTestPolygonDemoteVertex.cxx UnitTestPolygonFindOperationAttItems.cxx - UnitTestPolygonCleanGeometry.cxx) + UnitTestPolygonCleanGeometry.cxx + UnitTestPolygonImportPPG.cxx) if(SMTK_ENABLE_VTK_SUPPORT) set (unit_tests_which_require_data diff --git a/smtk/session/polygon/testing/cxx/UnitTestPolygonImportPPG.cxx b/smtk/session/polygon/testing/cxx/UnitTestPolygonImportPPG.cxx new file mode 100644 index 0000000000000000000000000000000000000000..35d604059e051f902a084dd3a2cc5597c519e869 --- /dev/null +++ b/smtk/session/polygon/testing/cxx/UnitTestPolygonImportPPG.cxx @@ -0,0 +1,125 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#include "smtk/attribute/Attribute.h" +#include "smtk/attribute/FileItem.h" +#include "smtk/attribute/IntItem.h" +#include "smtk/attribute/ResourceItem.h" +#include "smtk/attribute/StringItem.h" +#include "smtk/common/testing/cxx/helpers.h" +#include "smtk/model/Resource.h" +#include "smtk/model/SessionRef.h" +#include "smtk/operation/Manager.h" +#include "smtk/operation/operators/WriteResource.h" +#include "smtk/plugin/Registry.h" +#include "smtk/resource/Manager.h" +#include "smtk/session/polygon/Registrar.h" +#include "smtk/session/polygon/Resource.h" +#include "smtk/session/polygon/operators/ImportPPG.h" + +#include + +#include + +namespace +{ +const int OP_SUCCEEDED = static_cast(smtk::operation::Operation::Outcome::SUCCEEDED); +const std::string resourceFilename("import-ppg.smtk"); + +const std::string ppgText = "# Test2D geometry\n" + "\n" + "# Vertices 1-8 for the outer polygon\n" + "v 0.0 2.0 # first vertex 1\n" + "v 1.0 0.0\n" + "v 9.0 0.0\n" + "v 9.0 2.0\n" + "v 8.0 4.0\n" + "v 6.0 5.0\n" + "v 3.0 5.0\n" + "v 1.0 4.0\n" + "\n" + "# Vertices 9-12 for the inner polygon (hole)\n" + "v 7.0 1.0\n" + "v 8.0 1.0\n" + "v 8.0 2.0\n" + "v 7.0 2.0\n" + "\n" + "# Outer polygon\n" + "f 1 2 3 4 5 6 7 8 # first face\n" + "\n" + "# Inner polygon (hole)\n" + "h 9 10 11 12\n"; +} // namespace + +int UnitTestPolygonImportPPG(int /*argc*/, char* /*argv*/[]) +{ + // Delete existing file + boost::filesystem::path folderPath(SMTK_SCRATCH_DIR); + boost::filesystem::path smtkPath = folderPath / resourceFilename; + if (boost::filesystem::exists(smtkPath)) + { + boost::filesystem::remove(smtkPath); + } + + // Initialize managers + smtk::resource::ManagerPtr resManager = smtk::resource::Manager::create(); + smtk::operation::ManagerPtr opManager = smtk::operation::Manager::create(); + + auto polygonRegistry = + smtk::plugin::addToManagers(resManager, opManager); + auto operationRegistry = smtk::plugin::addToManagers(opManager); + + opManager->registerResourceManager(resManager); + + // Create an "import" operation + auto importOp = opManager->create(); + test(importOp != nullptr, "No import operator"); + importOp->parameters()->findString("string")->setIsEnabled(true); + importOp->parameters()->findString("string")->setValue(ppgText); + + // Run the operation + auto importResult = importOp->operate(); + int importOutcome = importResult->findInt("outcome")->value(); + smtkTest( + importOutcome == OP_SUCCEEDED, + "Import operation failed. Returned outcome " << std::to_string(importOutcome) << ". " + << importOp->log().convertToString()); + + // Get the model resource + auto resourceItem = importResult->findResource("resource"); + auto resource = resourceItem->value(); + test(resource != nullptr, "Resource was not found."); + auto modelResource = std::dynamic_pointer_cast(resource); + test(modelResource != nullptr, "Model resource not found."); + + // Write model resource to file + std::cout << "Writing " << smtkPath << std::endl; + auto writeOp = opManager->create(); + test(writeOp != nullptr, "No write operator"); + writeOp->parameters()->associate(resource); + writeOp->parameters()->findFile("filename")->setIsEnabled(true); + writeOp->parameters()->findFile("filename")->setValue(smtkPath.string()); + auto writeResult = writeOp->operate(); + int writeOutcome = writeResult->findInt("outcome")->value(); + smtkTest( + writeOutcome == OP_SUCCEEDED, + "Write operation failed. Returned outcome " << std::to_string(writeOutcome) << ". " + << writeOp->log().convertToString()); + + // Check entity counts + auto vList = modelResource->entitiesMatchingFlags(smtk::model::VERTEX); + smtkTest(vList.size() == 12, "Expected 12 model vertices not " << vList.size() << "."); + auto eList = modelResource->entitiesMatchingFlags(smtk::model::EDGE); + smtkTest(eList.size() == 12, "Expected 12 model edges not " << eList.size() << "."); + auto fList = modelResource->entitiesMatchingFlags(smtk::model::FACE); + smtkTest(fList.size() == 1, "Expected 1 model face not " << fList.size() << "."); + + return 0; +} diff --git a/smtk/session/polygon/testing/cxx/UnitTestPolygonReadWrite.cxx b/smtk/session/polygon/testing/cxx/UnitTestPolygonReadWrite.cxx index beb66341c9e7d817270fabdc878d9d2b5de03af2..866e911261bcaa1efab68210079b17b9e272934e 100644 --- a/smtk/session/polygon/testing/cxx/UnitTestPolygonReadWrite.cxx +++ b/smtk/session/polygon/testing/cxx/UnitTestPolygonReadWrite.cxx @@ -25,6 +25,8 @@ #include "smtk/operation/operators/ReadResource.h" #include "smtk/operation/operators/WriteResource.h" +#include "smtk/plugin/Registry.h" + #include "smtk/session/polygon/Registrar.h" #include "smtk/session/polygon/Resource.h" @@ -117,17 +119,13 @@ int UnitTestPolygonReadWrite(int argc, char* argv[]) // Create a resource manager smtk::resource::Manager::Ptr resourceManager = smtk::resource::Manager::create(); - { - smtk::session::polygon::Registrar::registerTo(resourceManager); - } - // Create an operation manager smtk::operation::Manager::Ptr operationManager = smtk::operation::Manager::create(); - { - smtk::operation::Registrar::registerTo(operationManager); - smtk::session::polygon::Registrar::registerTo(operationManager); - } + auto polygonRegistry = smtk::plugin::addToManagers( + resourceManager, operationManager); + auto operationRegistry = + smtk::plugin::addToManagers(operationManager); // Register the resource manager to the operation manager (newly created // resources will be automatically registered to the resource manager). diff --git a/smtk/session/polygon/testing/python/CMakeLists.txt b/smtk/session/polygon/testing/python/CMakeLists.txt index f494e647ff1a7a85b62b4160c0a29144528d5f78..c275bda35ee3814ec286a5710f469acecf794a6b 100644 --- a/smtk/session/polygon/testing/python/CMakeLists.txt +++ b/smtk/session/polygon/testing/python/CMakeLists.txt @@ -1,4 +1,5 @@ set(smtkPolygonSessionPythonTests + polygonImportPPG ) # Additional tests that require SMTK_DATA_DIR @@ -12,12 +13,12 @@ set(smtkPolygonSessionPythonDataTests ) foreach (test ${smtkPolygonSessionPythonTests}) - smtk_add_test_python(${test}Py ${test}.py) + smtk_add_test_python(${test}Py ${test}.py --temp-dir=${CMAKE_BINARY_DIR}/Testing/Temporary) endforeach() if (SMTK_DATA_DIR) foreach (test ${smtkPolygonSessionPythonDataTests}) smtk_add_test_python(${test}Py ${test}.py - -D "${SMTK_DATA_DIR}") + --data-dir "${SMTK_DATA_DIR}" --temp-dir=${CMAKE_BINARY_DIR}/Testing/Temporary) endforeach() endif() diff --git a/smtk/session/polygon/testing/python/polygonImportPPG.py b/smtk/session/polygon/testing/python/polygonImportPPG.py new file mode 100644 index 0000000000000000000000000000000000000000..79ad57e67187accadc71aca4bbbe6c012a6fb8ca --- /dev/null +++ b/smtk/session/polygon/testing/python/polygonImportPPG.py @@ -0,0 +1,171 @@ +# ============================================================================= +# +# Copyright (c) Kitware, Inc. +# All rights reserved. +# See LICENSE.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even +# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the above copyright notice for more information. +# +# ============================================================================= +import os + +import smtk +import smtk.model +import smtk.operation +import smtk.session.polygon +import smtk.io +import smtk.testing + +test2d = """ +# Example input (Kitware's "Test2D" geometry) +# Note that vertex indices start with 1 +# Vertices 1-8 for the outer polygon +v 0.0 2.0 +v 1.0 0.0 +v 9.0 0.0 +v 9.0 2.0 +v 8.0 4.0 +v 6.0 5.0 +v 3.0 5.0 +v 1.0 4.0 +# Vertices 9-12 for the inner polygon (hole) +v 7.0 1.0 +v 8.0 1.0 +v 8.0 2.0 +v 7.0 2.0 +# Outer polygon +f 1 2 3 4 5 6 7 8 +# Inner polygon (hole) +h 9 10 11 12 +""" + +three_face = """ +v 0 0 +v 5 0 +v 5 4 +v 1 4 +v 0 4 +v 5 7 +v 1 7 + +v 3 1 +v 4 1 +v 3 3 + +v 2 5 +v 3 5 +v 4 6 +v 2 6 +f 1 2 3 4 5 # face 1 +f 3 6 7 4 # face 2 +h 8 9 10 # hole in face 2 +e 11 12 13 14 # face 3 embedded in face 2 +""" + +OP_SUCCEEDED = int(smtk.operation.Operation.Outcome.SUCCEEDED) + + +class TestImportPPG(smtk.testing.TestCase): + def setUp(self): + pass + + def test_test2d(self): + path = os.path.join(smtk.testing.TEMP_DIR, 'test2d.smtk') + + # Remove existing file + if os.path.isfile(path): + os.remove(path) + + # Create model + model_resource = self.create_model(test2d) + self.check_model(model_resource, 12, 12, 1) + + # Write to file system + self.write_model(model_resource, path) + del(model_resource) + + # Read from file system + model_res2 = self.read_model(path) + self.check_model(model_res2, 12, 12, 1) + + def test_three_face(self): + path = os.path.join(smtk.testing.TEMP_DIR, 'three-face.smtk') + + # Remove existing file + if os.path.isfile(path): + os.remove(path) + + # Create model + model_resource = self.create_model(three_face) + self.check_model(model_resource, 14, 15, 3) + + # Write to file system + self.write_model(model_resource, path) + del(model_resource) + + # Read from file system + model_res2 = self.read_model(path) + self.check_model(model_res2, 14, 15, 3) + + def check_model(self, model_resource, *expected): + """Check number of entities + + Arguments: + model_resource + expected: 3 args with expected numbers of vertices, edges, faces + """ + def check(model_resource, ent_type, expected, text): + """Internal function to check one dimension.""" + ent_list = model_resource.entitiesMatchingFlags(ent_type) + msg = 'Expected number of model {} {}, not {}'.format( + text, expected, len(ent_list)) + self.assertEqual(len(ent_list), expected, msg) + + check(model_resource, smtk.model.VERTEX, expected[0], 'vertices') + check(model_resource, smtk.model.EDGE, expected[1], 'edges') + check(model_resource, smtk.model.FACE, expected[2], 'faces') + + def create_model(self, input_ppg): + op = smtk.session.polygon.ImportPPG.create() + op.parameters().findString('string').setIsEnabled(True) + op.parameters().findString('string').setValue(input_ppg) + result = op.operate() + outcome = result.findInt('outcome').value() + self.assertEqual(outcome, OP_SUCCEEDED, + 'ImportPPG operation failed w/outcome {}'.format(outcome)) + + resource = result.findResource('resource').value() + model_resource = smtk.model.Resource.CastTo(resource) + return model_resource + + def read_model(self, path): + op = smtk.session.polygon.Read.create() + op.parameters().findFile('filename').setValue(path) + result = op.operate() + outcome = result.findInt('outcome').value() + self.assertEqual(outcome, OP_SUCCEEDED, + 'Read operation failed w/outcome {}'.format(outcome)) + + resource = result.findResource('resource').value() + model_resource = smtk.model.Resource.CastTo(resource) + return model_resource + + def write_model(self, model_resource, path): + model_resource.setLocation(path) + op = smtk.session.polygon.Write.create() + op.parameters().associate(model_resource) + result = op.operate() + outcome = result.findInt('outcome').value() + self.assertEqual(outcome, OP_SUCCEEDED, + 'Write operation failed w/outcome {}'.format(outcome)) + + # Sanity check + self.assertTrue(os.path.isfile(path)) + print('Wrote file', path) + + +if __name__ == '__main__': + smtk.testing.process_arguments() + smtk.testing.main() diff --git a/smtk/session/vtk/Session.cxx b/smtk/session/vtk/Session.cxx index 3894212c1bc129d9493812e32467067019cd2dc2..a3ac4d17cbdcaf839345031ce6e23e6e8df696ca 100644 --- a/smtk/session/vtk/Session.cxx +++ b/smtk/session/vtk/Session.cxx @@ -53,6 +53,8 @@ vtkInformationKeyMacro(Session, SMTK_OUTER_LABEL, Integer); vtkInformationKeyMacro(Session, SMTK_CHILDREN, ObjectBaseVector); vtkInformationKeyMacro(Session, SMTK_LABEL_VALUE, Double); +bool Session::s_transcriptionChecks = true; + enum smtkCellTessRole { SMTK_ROLE_VERTS, @@ -95,8 +97,7 @@ std::string EntityTypeNameString(EntityType etype) /// Construct an invalid handle. EntityHandle::EntityHandle() - : m_modelNumber(-1) - , m_object(nullptr) + : m_object(nullptr) , m_session(nullptr) { } @@ -407,15 +408,23 @@ SessionInfoBits Session::transcribeInternal( if (handle.entityType() == EXO_MODEL) { if (childEntityRef.isCellEntity()) - mutableEntityRef.as().addCell(childEntityRef); + { + auto model = mutableEntityRef.as(); + model.addCell(childEntityRef, s_transcriptionChecks); + } else if (childEntityRef.isGroup()) + { mutableEntityRef.as().addGroup(childEntityRef); + } } else { mutableEntityRef.as().addEntity(childEntityRef); if (childEntityRef.isCellEntity()) - mutableEntityRef.owningModel().addCell(childEntityRef); + { + auto model = mutableEntityRef.owningModel(); + model.addCell(childEntityRef, s_transcriptionChecks); + } } } diff --git a/smtk/session/vtk/Session.h b/smtk/session/vtk/Session.h index 661c44d86534afd9107b1ac51d256224237f26d9..cef844162d1f1cb6de246bb53dc073896d0aaa98 100644 --- a/smtk/session/vtk/Session.h +++ b/smtk/session/vtk/Session.h @@ -65,8 +65,9 @@ SMTKVTKSESSION_EXPORT std::string EntityTypeNameString(EntityType etype); /// A "handle" for a VTK entity (file, block, side set, or node set) struct SMTKVTKSESSION_EXPORT EntityHandle { - int - m_modelNumber; //!< An offset in the vector of models (m_models) owned by the session, whose model owns m_object. + int m_modelNumber{ + -1 + }; //!< An offset in the vector of models (m_models) owned by the session, whose model owns m_object. vtkSmartPointer m_object; //!< The dataset being presented as this entity. SessionPtr m_session; //!< The session owning this entity. @@ -172,6 +173,13 @@ public: size_t numberOfModels() const; + /// Get/set whether adding cells to models during transcription will check for pre-existing + /// entries to avoid adding duplicates. This defaults to true, but some operations such as + /// imports may wish to diable for efficiency (if adding many cells to a model that cannot + /// already be present on the model). + static bool transcriptionChecksEnabled() { return s_transcriptionChecks; } + static void setEnableTranscriptionChecks(bool doCheck) { s_transcriptionChecks = doCheck; } + protected: friend struct EntityHandle; @@ -188,6 +196,7 @@ protected: m_cpMap; // vtkMultiBlockDataSet doesn't provide a fast way to obtain parent of leaf datasets. // std::map m_fwdIdMap; // not needed; store UUID in vtkInformation. // -- 1 -- + static bool s_transcriptionChecks; vtkDataObject* modelOfHandle(const EntityHandle& h) const; vtkDataObject* parent(vtkDataObject* obj) const; diff --git a/smtk/session/vtk/pybind11/PybindExport.h b/smtk/session/vtk/pybind11/PybindExport.h index ded4f702fd205eff850d1c4f91ae3dbcd18f050b..4237b9400e513e16de1b31b28efd2f9d4ba47c51 100644 --- a/smtk/session/vtk/pybind11/PybindExport.h +++ b/smtk/session/vtk/pybind11/PybindExport.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::vtk::Export > pybind11_init_smtk_session_vtk_Export(py::module &m, PySharedPtrClass< smtk::session::vtk::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::vtk::Export > pybind11_init_smtk_session_vtk_Export(py::module &m, PySharedPtrClass< smtk::session::vtk::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::vtk::Export > instance(m, "Export", parent); instance diff --git a/smtk/session/vtk/pybind11/PybindImport.h b/smtk/session/vtk/pybind11/PybindImport.h index c650b188ad5afcd04f55bce1197dd254b2434db3..f63fa6a205b8b22cf8c54190270396a78fb93da3 100644 --- a/smtk/session/vtk/pybind11/PybindImport.h +++ b/smtk/session/vtk/pybind11/PybindImport.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::vtk::Import > pybind11_init_smtk_session_vtk_Import(py::module &m, PySharedPtrClass< smtk::session::vtk::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::vtk::Import > pybind11_init_smtk_session_vtk_Import(py::module &m, PySharedPtrClass< smtk::session::vtk::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::vtk::Import > instance(m, "Import", parent); instance diff --git a/smtk/session/vtk/pybind11/PybindLegacyRead.h b/smtk/session/vtk/pybind11/PybindLegacyRead.h index 075cabdaf2aad1f291388dd4ed4162cae71bd775..4e4b24dbb3c2ef3d1fb22c9307d2695e4a53e1a0 100644 --- a/smtk/session/vtk/pybind11/PybindLegacyRead.h +++ b/smtk/session/vtk/pybind11/PybindLegacyRead.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::vtk::LegacyRead > pybind11_init_smtk_session_vtk_LegacyRead(py::module &m, PySharedPtrClass< smtk::session::vtk::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::vtk::LegacyRead > pybind11_init_smtk_session_vtk_LegacyRead(py::module &m, PySharedPtrClass< smtk::session::vtk::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::vtk::LegacyRead > instance(m, "LegacyRead", parent); instance diff --git a/smtk/session/vtk/pybind11/PybindOperation.h b/smtk/session/vtk/pybind11/PybindOperation.h index 823c55031441146931dbd2195e69ff0d7b84f27b..239ebda656124e58b9e3e8c8a9236e9897b25c0e 100644 --- a/smtk/session/vtk/pybind11/PybindOperation.h +++ b/smtk/session/vtk/pybind11/PybindOperation.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::vtk::Operation, smtk::operation::XMLOperation > pybind11_init_smtk_session_vtk_Operation(py::module &m) +inline PySharedPtrClass< smtk::session::vtk::Operation, smtk::operation::XMLOperation > pybind11_init_smtk_session_vtk_Operation(py::module &m) { PySharedPtrClass< smtk::session::vtk::Operation, smtk::operation::XMLOperation > instance(m, "Operation"); instance diff --git a/smtk/session/vtk/pybind11/PybindRead.h b/smtk/session/vtk/pybind11/PybindRead.h index 59d9b07cc2dd0ed08a02f3b8c2f0b612e4aa75eb..6e99ecdabc1388dc7c09e5a561d8006575acfda8 100644 --- a/smtk/session/vtk/pybind11/PybindRead.h +++ b/smtk/session/vtk/pybind11/PybindRead.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::vtk::Read > pybind11_init_smtk_session_vtk_Read(py::module &m, PySharedPtrClass< smtk::session::vtk::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::vtk::Read > pybind11_init_smtk_session_vtk_Read(py::module &m, PySharedPtrClass< smtk::session::vtk::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::vtk::Read > instance(m, "Read", parent); instance diff --git a/smtk/session/vtk/pybind11/PybindRegistrar.h b/smtk/session/vtk/pybind11/PybindRegistrar.h index 779739de996d76c4f3ad7d1ab6787ffc12a17d87..952a2f49f46a806cd310318607172951afa516f0 100644 --- a/smtk/session/vtk/pybind11/PybindRegistrar.h +++ b/smtk/session/vtk/pybind11/PybindRegistrar.h @@ -17,7 +17,7 @@ namespace py = pybind11; -py::class_< smtk::session::vtk::Registrar > pybind11_init_smtk_session_vtk_Registrar(py::module &m) +inline py::class_< smtk::session::vtk::Registrar > pybind11_init_smtk_session_vtk_Registrar(py::module &m) { py::class_< smtk::session::vtk::Registrar > instance(m, "Registrar"); instance diff --git a/smtk/session/vtk/pybind11/PybindResource.h b/smtk/session/vtk/pybind11/PybindResource.h index 08bd4d7f6637b6560036c701b20edb148e901844..a82123c689f83ac975d660cbcb82d321c90569dd 100644 --- a/smtk/session/vtk/pybind11/PybindResource.h +++ b/smtk/session/vtk/pybind11/PybindResource.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::vtk::Resource> pybind11_init_smtk_session_vtk_Resource(py::module &m) +inline PySharedPtrClass< smtk::session::vtk::Resource> pybind11_init_smtk_session_vtk_Resource(py::module &m) { PySharedPtrClass< smtk::session::vtk::Resource, smtk::model::Resource > instance(m, "Resource"); instance diff --git a/smtk/session/vtk/pybind11/PybindSession.h b/smtk/session/vtk/pybind11/PybindSession.h index 78dc3c19b49befe2a4abd82d42a606b6e9f3aa22..4ce098abfdb3b25c0d2fb85a700c6dce65cb7a28 100644 --- a/smtk/session/vtk/pybind11/PybindSession.h +++ b/smtk/session/vtk/pybind11/PybindSession.h @@ -32,7 +32,7 @@ namespace py = pybind11; -void pybind11_init_smtk_session_vtk_EntityType(py::module &m) +inline void pybind11_init_smtk_session_vtk_EntityType(py::module &m) { py::enum_(m, "EntityType") .value("EXO_MODEL", smtk::session::vtk::EntityType::EXO_MODEL) @@ -48,7 +48,7 @@ void pybind11_init_smtk_session_vtk_EntityType(py::module &m) .export_values(); } -py::class_< smtk::session::vtk::EntityHandle > pybind11_init_smtk_session_vtk_EntityHandle(py::module &m) +inline py::class_< smtk::session::vtk::EntityHandle > pybind11_init_smtk_session_vtk_EntityHandle(py::module &m) { py::class_< smtk::session::vtk::EntityHandle > instance(m, "EntityHandle"); instance @@ -71,7 +71,7 @@ py::class_< smtk::session::vtk::EntityHandle > pybind11_init_smtk_session_vtk_En return instance; } -PySharedPtrClass< smtk::session::vtk::Session, smtk::model::Session > pybind11_init_smtk_session_vtk_Session(py::module &m) +inline PySharedPtrClass< smtk::session::vtk::Session, smtk::model::Session > pybind11_init_smtk_session_vtk_Session(py::module &m) { PySharedPtrClass< smtk::session::vtk::Session, smtk::model::Session > instance(m, "Session"); instance @@ -98,7 +98,7 @@ PySharedPtrClass< smtk::session::vtk::Session, smtk::model::Session > pybind11_i return instance; } -void pybind11_init_smtk_session_vtk_EntityTypeNameString(py::module &m) +inline void pybind11_init_smtk_session_vtk_EntityTypeNameString(py::module &m) { m.def("EntityTypeNameString", &smtk::session::vtk::EntityTypeNameString, "", py::arg("etype")); } diff --git a/smtk/session/vtk/pybind11/PybindWrite.h b/smtk/session/vtk/pybind11/PybindWrite.h index cc00407edeea518ab804eb017948b5400d5d24a1..434fe17a220e770b2c1ceac0a795d7244835826b 100644 --- a/smtk/session/vtk/pybind11/PybindWrite.h +++ b/smtk/session/vtk/pybind11/PybindWrite.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::session::vtk::Write > pybind11_init_smtk_session_vtk_Write(py::module &m, PySharedPtrClass< smtk::session::vtk::Operation, smtk::operation::XMLOperation >& parent) +inline PySharedPtrClass< smtk::session::vtk::Write > pybind11_init_smtk_session_vtk_Write(py::module &m, PySharedPtrClass< smtk::session::vtk::Operation, smtk::operation::XMLOperation >& parent) { PySharedPtrClass< smtk::session::vtk::Write > instance(m, "Write", parent); instance diff --git a/smtk/simulation/UserData.cxx b/smtk/simulation/UserData.cxx index c609157dcc9552bd87dee26ad3cc68bf09dc5d70..97b84b959914ccfbc20b2cccd09b7118d38a3de4 100644 --- a/smtk/simulation/UserData.cxx +++ b/smtk/simulation/UserData.cxx @@ -18,17 +18,11 @@ UserData::UserData() = default; UserData::~UserData() = default; -UserDataInt::UserDataInt() - : m_value(0) -{ -} +UserDataInt::UserDataInt() = default; UserDataInt::~UserDataInt() = default; -UserDataDouble::UserDataDouble() - : m_value(0.0) -{ -} +UserDataDouble::UserDataDouble() = default; UserDataDouble::~UserDataDouble() = default; diff --git a/smtk/simulation/UserData.h b/smtk/simulation/UserData.h index fde4e2b257d5705c6f41fdf7a72492e455cf0fb4..b5dd7a30e246fd6b12ab0b2c3afa06874985f83e 100644 --- a/smtk/simulation/UserData.h +++ b/smtk/simulation/UserData.h @@ -53,7 +53,7 @@ public: protected: UserDataInt(); - int m_value; + int m_value{ 0 }; }; // User Data Representing Doubles @@ -73,7 +73,7 @@ public: protected: UserDataDouble(); - double m_value; + double m_value{ 0.0 }; }; // User Data Representing Strings diff --git a/smtk/simulation/pybind11/PybindExportSpec.h b/smtk/simulation/pybind11/PybindExportSpec.h index 18701b6482727c2bbc168ddfe1fb66f4b5a0e4df..64efaf04d01b3cf001d24018b30a1c49a343b5f4 100644 --- a/smtk/simulation/pybind11/PybindExportSpec.h +++ b/smtk/simulation/pybind11/PybindExportSpec.h @@ -24,7 +24,7 @@ namespace py = pybind11; -py::class_< smtk::simulation::ExportSpec > pybind11_init_smtk_simulation_ExportSpec(py::module &m) +inline py::class_< smtk::simulation::ExportSpec > pybind11_init_smtk_simulation_ExportSpec(py::module &m) { py::class_< smtk::simulation::ExportSpec > instance(m, "ExportSpec"); instance diff --git a/smtk/simulation/pybind11/PybindUserData.h b/smtk/simulation/pybind11/PybindUserData.h index 6a1d532cb840111d1e5a5f0ee52b35599f796850..c8d30cc99bef43ab4b72c5456850abe9579bf36d 100644 --- a/smtk/simulation/pybind11/PybindUserData.h +++ b/smtk/simulation/pybind11/PybindUserData.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::simulation::UserData > pybind11_init_smtk_simulation_UserData(py::module &m) +inline PySharedPtrClass< smtk::simulation::UserData > pybind11_init_smtk_simulation_UserData(py::module &m) { PySharedPtrClass< smtk::simulation::UserData > instance(m, "UserData"); instance @@ -28,7 +28,7 @@ PySharedPtrClass< smtk::simulation::UserData > pybind11_init_smtk_simulation_Use return instance; } -PySharedPtrClass< smtk::simulation::UserDataInt, smtk::simulation::UserData > pybind11_init_smtk_simulation_UserDataInt(py::module &m) +inline PySharedPtrClass< smtk::simulation::UserDataInt, smtk::simulation::UserData > pybind11_init_smtk_simulation_UserDataInt(py::module &m) { PySharedPtrClass< smtk::simulation::UserDataInt, smtk::simulation::UserData > instance(m, "UserDataInt"); instance @@ -41,7 +41,7 @@ PySharedPtrClass< smtk::simulation::UserDataInt, smtk::simulation::UserData > py return instance; } -PySharedPtrClass< smtk::simulation::UserDataDouble, smtk::simulation::UserData > pybind11_init_smtk_simulation_UserDataDouble(py::module &m) +inline PySharedPtrClass< smtk::simulation::UserDataDouble, smtk::simulation::UserData > pybind11_init_smtk_simulation_UserDataDouble(py::module &m) { PySharedPtrClass< smtk::simulation::UserDataDouble, smtk::simulation::UserData > instance(m, "UserDataDouble"); instance @@ -54,7 +54,7 @@ PySharedPtrClass< smtk::simulation::UserDataDouble, smtk::simulation::UserData > return instance; } -PySharedPtrClass< smtk::simulation::UserDataString, smtk::simulation::UserData > pybind11_init_smtk_simulation_UserDataString(py::module &m) +inline PySharedPtrClass< smtk::simulation::UserDataString, smtk::simulation::UserData > pybind11_init_smtk_simulation_UserDataString(py::module &m) { PySharedPtrClass< smtk::simulation::UserDataString, smtk::simulation::UserData > instance(m, "UserDataString"); instance diff --git a/smtk/task/Active.cxx b/smtk/task/Active.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a5ce79d2fafb6785c982d8933d4ec4ed5c73ed1e --- /dev/null +++ b/smtk/task/Active.cxx @@ -0,0 +1,89 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +#include "smtk/task/Active.h" + +namespace smtk +{ +namespace task +{ + +Active::Active(smtk::task::Instances* instances) + : m_instances(instances) + , m_observers(/* initializer */ + [this](Observer& observer) { + auto active = m_active.lock(); + // Ony initialization will ever call an observer with the same value for both parameters. + observer(active.get(), active.get()); + }) +{ + if (m_instances) + { + m_instancesObserver = m_instances->observers().insert( + [this](smtk::common::InstanceEvent event, const std::shared_ptr& task) { + if (event == smtk::common::InstanceEvent::Unmanaged && task && task == m_active.lock()) + { + m_observers(task.get(), nullptr); + m_active.reset(); + } + }, + /* priority */ 0, + /* initialize */ false, + "Observe task deletion for task::Active"); + } +} + +Active::~Active() = default; + +smtk::task::Task* Active::task() const +{ + return m_active.lock().get(); +} + +bool Active::switchTo(smtk::task::Task* task) +{ + auto current = m_active.lock(); + if (current.get() == task) + { + return false; + } + if (!task) + { + if (current) + { + m_observers(current.get(), nullptr); + m_active.reset(); + m_activeObserver.release(); + return true; + } + return false; + } + if (task->state() == State::Unavailable) + { + return false; + } + auto sharedTask = task->shared_from_this(); + if (m_instances && !m_instances->contains(sharedTask)) + { + // Only managed tasks can be active if we have instances tracked. + return false; + } + m_observers(current.get(), task); + m_active = sharedTask; + m_activeObserver = task->observers().insert([this](Task&, State, State next) { + if (next == State::Unavailable) + { + this->switchTo(nullptr); + } + }); + return true; +} + +} // namespace task +} // namespace smtk diff --git a/smtk/task/Active.h b/smtk/task/Active.h new file mode 100644 index 0000000000000000000000000000000000000000..7e2f5cdf1efa09d489dda275a7fde57407fcf7f4 --- /dev/null +++ b/smtk/task/Active.h @@ -0,0 +1,76 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#ifndef smtk_task_Active_h +#define smtk_task_Active_h + +#include "smtk/task/Instances.h" +#include "smtk/task/Task.h" + +namespace smtk +{ +namespace task +{ + +/// This object provides applications a way to change and observe the active task. +/// +/// If passed an smtk::task::Manager::Instances object at construction, +/// only managed tasks may be active. +/// This ensures that before a task is destroyed this object +/// can notify observers the active task is becoming inactive. +/// +/// If not passed an smtk::task::Manager::Instances object at construction, +/// any task may become active but +/// unmanaged tasks might be deleted without any notification that the active +/// task changed. +/// You are strongly encouraged to pass Instances to the constructor. +class SMTKCORE_EXPORT Active +{ +public: + smtkTypeMacroBase(smtk::task::Active); + + /// The signature for observers of the active task. + /// Observers are passed the previously-active task and the soon-to-be-active task. + /// + /// Note that either task may be null (i.e., it is possible to have no active task). + using Observer = std::function; + /// The container for registered observers. + using Observers = smtk::common::Observers; + + /// Construct an active-task tracker. + Active(smtk::task::Instances* instances = nullptr); + virtual ~Active(); + + /// Return the active task (or nullptr if no task is active). + smtk::task::Task* task() const; + + /// Change the active task (or abandon the currently-active task by passing nullptr). + /// + /// This method returns true if the active task changed and false otherwise. + /// Passing a task that is not managed by \a instances passed to the constructor + /// will always return false. + /// Passing a task that is already active or unavailable will return false. + bool switchTo(smtk::task::Task*); + + /// Return the set of active-task observers (so you can insert yourself). + Observers& observers() { return m_observers; } + const Observers& observers() const { return m_observers; } + +private: + smtk::task::Instances* m_instances; + smtk::task::Instances::Observers::Key m_instancesObserver; + std::weak_ptr m_active; + smtk::task::Task::Observers::Key m_activeObserver; + Observers m_observers; +}; +} // namespace task +} // namespace smtk + +#endif // smtk_task_Active_h diff --git a/smtk/task/CMakeLists.txt b/smtk/task/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f6096393c2985a560772097fbf37c8df2ccfb412 --- /dev/null +++ b/smtk/task/CMakeLists.txt @@ -0,0 +1,32 @@ +set(taskSrcs + Active.cxx + Manager.cxx + Registrar.cxx + Task.cxx + TaskNeedsResources.cxx +) + +set(taskHeaders + Active.h + Instances.h + Manager.h + Registrar.h + Task.h + TaskNeedsResources.h +) + +if (SMTK_ENABLE_PYTHON_WRAPPING) + add_subdirectory(pybind11) +endif() + +#install the headers +smtk_public_headers(smtkCore ${taskHeaders}) + +if (SMTK_ENABLE_PARAVIEW_SUPPORT) + set_property(GLOBAL APPEND + PROPERTY _smtk_plugin_files "${CMAKE_CURRENT_SOURCE_DIR}/plugin/paraview.plugin") +endif() + +if (SMTK_ENABLE_TESTING) + add_subdirectory(testing) +endif() diff --git a/smtk/task/Instances.h b/smtk/task/Instances.h new file mode 100644 index 0000000000000000000000000000000000000000..5f362cd9492259c6e041a5bdffa4b7d7f518f02a --- /dev/null +++ b/smtk/task/Instances.h @@ -0,0 +1,38 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +/*! \file */ +#ifndef smtk_task_Instances_h +#define smtk_task_Instances_h + +#include "smtk/common/Instances.h" +#include "smtk/common/Managers.h" +#include "smtk/common/TypeName.h" + +#include "smtk/task/Task.h" + +namespace smtk +{ +namespace task +{ + +/// Track smtk::task::Task objects with smtk::common::Instances. +using Instances = smtk::common::Instances< + smtk::task::Task, + void, + std::tuple>, + std::tuple< + smtk::task::Task::Configuration&, + smtk::task::Task::PassedDependencies, + std::shared_ptr>>; + +} // namespace task +} // namespace smtk + +#endif // smtk_task_Instances_h diff --git a/CMake/InitializePlugins.h.in b/smtk/task/Manager.cxx similarity index 58% rename from CMake/InitializePlugins.h.in rename to smtk/task/Manager.cxx index d95795dfb7e0ab42740b80dfa135d87e02b3d849..f4ed4c6c289042e9a9a01642f8276e5f3a89d500 100644 --- a/CMake/InitializePlugins.h.in +++ b/smtk/task/Manager.cxx @@ -7,21 +7,20 @@ // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //========================================================================= -#ifndef __smtk_@PLUGIN_LIBRARY_TARGET@_InitializePlugins_h -#define __smtk_@PLUGIN_LIBRARY_TARGET@_InitializePlugins_h -#include "@PLUGIN_LIBRARY_TARGET@Export.h" +#include "smtk/task/Manager.h" namespace smtk { -namespace extension +namespace task { -namespace paraview + +Manager::Manager() + : m_active(&m_instances) { -@SMTK_PLUGIN_LIBRARY_EXPORT@ void initialize@PLUGIN_LIBRARY_TARGET@(); -@SMTK_PLUGIN_LIBRARY_EXPORT@ void load@PLUGIN_LIBRARY_TARGET@(); -} -} } -#endif +Manager::~Manager() = default; + +} // namespace task +} // namespace smtk diff --git a/smtk/task/Manager.h b/smtk/task/Manager.h new file mode 100644 index 0000000000000000000000000000000000000000..7e46c7aea7ac5029c48b5afc1d012de647c8ebd3 --- /dev/null +++ b/smtk/task/Manager.h @@ -0,0 +1,76 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#ifndef smtk_task_Manager_h +#define smtk_task_Manager_h + +#include "smtk/CoreExports.h" +#include "smtk/PublicPointerDefs.h" +#include "smtk/SharedFromThis.h" + +#include "smtk/common/Managers.h" +#include "smtk/common/TypeName.h" + +#include "smtk/task/Active.h" +#include "smtk/task/Instances.h" +#include "smtk/task/Task.h" + +#include +#include +#include +#include +#include + +namespace smtk +{ +namespace task +{ + +/// A task manager is responsible for creating new tasks. +/// +/// Eventually, the task manager will also hold an inventory +/// of created tasks and be a clearinghouse for task state transitions. +class SMTKCORE_EXPORT Manager : smtkEnableSharedPtr(Manager) +{ +public: + smtkTypeMacroBase(smtk::task::Manager); + smtkCreateMacro(smtk::task::Manager); + + virtual ~Manager(); + + /// Managed instances of Task objects (and a registry of Task classes). + using Instances = smtk::task::Instances; + + /// Return the set of managed task instances. + /// + /// This class also acts as a registrar for Task subclasses. + Instances& instances() { return m_instances; } + const Instances& instances() const { return m_instances; } + + /// Return a tracker for the active task. + Active& active() { return m_active; } + const Active& active() const { return m_active; } + + /// Return the managers instance that contains this manager, if it exists. + smtk::common::Managers::Ptr managers() const { return m_managers.lock(); } + void setManagers(const smtk::common::Managers::Ptr& managers) { m_managers = managers; } + +private: + Instances m_instances; + Active m_active; + std::weak_ptr m_managers; + +protected: + Manager(); +}; +} // namespace task +} // namespace smtk + +#endif // smtk_task_Manager_h diff --git a/smtk/task/Registrar.cxx b/smtk/task/Registrar.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7786ea78f695cd2a130412e00362554425d903e6 --- /dev/null +++ b/smtk/task/Registrar.cxx @@ -0,0 +1,65 @@ +//============================================================================= +// +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +// +//============================================================================= +#include "smtk/task/Registrar.h" +#include "smtk/task/Task.h" +#include "smtk/task/TaskNeedsResources.h" + +#include "smtk/plugin/Manager.h" + +#include + +namespace smtk +{ +namespace task +{ + +using TaskList = std::tuple; + +void Registrar::registerTo(const smtk::common::Managers::Ptr& managers) +{ + if (managers->insert(smtk::task::Manager::create())) + { + managers->get()->setManagers(managers); + + smtk::plugin::Manager::instance()->registerPluginsTo(managers->get()); + } +} + +void Registrar::unregisterFrom(const smtk::common::Managers::Ptr& managers) +{ + managers->erase(); +} + +void Registrar::registerTo(const smtk::resource::Manager::Ptr& resourceManager) +{ + (void)resourceManager; +} + +void Registrar::unregisterFrom(const smtk::resource::Manager::Ptr& resourceManager) +{ + (void)resourceManager; +} + +void Registrar::registerTo(const smtk::task::Manager::Ptr& taskManager) +{ + auto& instances = taskManager->instances(); + instances.registerTypes(); +} + +void Registrar::unregisterFrom(const smtk::task::Manager::Ptr& taskManager) +{ + auto& instances = taskManager->instances(); + instances.unregisterTypes(); +} + +} // namespace task +} // namespace smtk diff --git a/smtk/task/Registrar.h b/smtk/task/Registrar.h new file mode 100644 index 0000000000000000000000000000000000000000..31b18dcffd43b623872b1e2743aa28c58f93d6c9 --- /dev/null +++ b/smtk/task/Registrar.h @@ -0,0 +1,41 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +#ifndef smtk_task_Registrar_h +#define smtk_task_Registrar_h + +#include "smtk/CoreExports.h" + +#include "smtk/common/Managers.h" +#include "smtk/resource/Manager.h" +#include "smtk/resource/Registrar.h" +#include "smtk/task/Manager.h" + +namespace smtk +{ +namespace task +{ +class SMTKCORE_EXPORT Registrar +{ +public: + using Dependencies = std::tuple; + + static void registerTo(const smtk::common::Managers::Ptr&); + static void unregisterFrom(const smtk::common::Managers::Ptr&); + + static void registerTo(const smtk::resource::Manager::Ptr&); + static void unregisterFrom(const smtk::resource::Manager::Ptr&); + + static void registerTo(const smtk::task::Manager::Ptr&); + static void unregisterFrom(const smtk::task::Manager::Ptr&); +}; +} // namespace task +} // namespace smtk + +#endif // smtk_task_Registrar_h diff --git a/smtk/task/State.h b/smtk/task/State.h new file mode 100644 index 0000000000000000000000000000000000000000..2cd73a0d886ec8eaa96890c813710212048b6f92 --- /dev/null +++ b/smtk/task/State.h @@ -0,0 +1,82 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +/*! \file */ +#ifndef smtk_task_State_h +#define smtk_task_State_h + +#include "smtk/CoreExports.h" +#include "smtk/SharedFromThis.h" + +#include +#include +#include +#include +#include + +namespace smtk +{ +namespace task +{ + +/// The set of states that a task may take on. +enum class State +{ + Unavailable, //!< The task's dependencies are unmet. + Incomplete, //!< The task is available but its objective is not accomplished. + Completable, //!< The task is available and accomplished but has not been marked complete. + Completed //!< The task has been marked completed by the user. +}; + +/// A type-conversion operation to cast enumerants to strings. +inline std::string stateName(const State& s) +{ + static std::array names{ + { "unavailable", "incomplete", "completable", "completed" } + }; + return names[static_cast(s)]; +} + +/// A type-conversion operation to cast strings to enumerants. +inline State stateEnum(const std::string& s) +{ + std::string stateName(s); + std::transform(stateName.begin(), stateName.end(), stateName.begin(), [](unsigned char c) { + return std::tolower(c); + }); + if (stateName.substr(0, 7) == "state::") + { + stateName = stateName.substr(7); + } + if (stateName == "incomplete") + { + return State::Incomplete; + } + if (stateName == "completable") + { + return State::Completable; + } + if (stateName == "completed") + { + return State::Completed; + } + return State::Unavailable; +} + +/// States may be appended to streams. +inline std::ostream& operator<<(std::ostream& os, const State& s) +{ + os << stateName(s); + return os; +} + +} // namespace task +} // namespace smtk + +#endif // smtk_task_State_h diff --git a/smtk/task/Task.cxx b/smtk/task/Task.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d710b9badef350e40941fc20ab96fce937adf046 --- /dev/null +++ b/smtk/task/Task.cxx @@ -0,0 +1,253 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +#include "smtk/task/Task.h" + +#include + +namespace smtk +{ +namespace task +{ + +Task::Task() = default; + +Task::Task(const Configuration& config, const std::shared_ptr& managers) +{ + (void)managers; + this->configure(config); +} + +Task::Task( + const Configuration& config, + const PassedDependencies& dependencies, + const std::shared_ptr& managers) +{ + (void)managers; + this->configure(config); + for (const auto& dependency : dependencies) + { + m_dependencies.insert(std::make_pair( + (const std::weak_ptr)(dependency), + dependency->observers().insert([this](Task& dependency, State prev, State next) { + bool didChange = this->updateState(dependency, prev, next); + (void)didChange; + }))); + } +} + +void Task::configure(const Configuration& config) +{ + if (!config.is_object()) + { + throw std::logic_error("Invalid configuration passed to Task constructor."); + } + if (config.contains("title")) + { + m_title = config.at("title").get(); + } + if (config.contains("completed")) + { + m_completed = config.at("completed").get(); + } +} + +void Task::setTitle(const std::string& title) +{ + m_title = title; +} + +State Task::state() const +{ + State s = m_internalState; + for (const auto& dd : m_dependencies) + { + const auto& dependency(dd.first.lock()); + switch (dependency->state()) + { + case State::Unavailable: + case State::Incomplete: + s = State::Unavailable; + break; + case State::Completable: + case State::Completed: + break; + } + if (s == State::Unavailable) + { + break; + } + } + if (s == State::Completable && m_completed) + { + s = State::Completed; + } + return s; +} + +bool Task::markCompleted(bool completed) +{ + switch (this->state()) + { + case State::Unavailable: // fall through + case State::Incomplete: + return false; + case State::Completable: + if (!completed) + { + return false; + } + this->changeState(State::Completable, State::Completed); + break; + case State::Completed: + if (completed) + { + return false; + } + this->changeState(State::Completed, State::Completable); + } + return true; +} + +Task::PassedDependencies Task::dependencies() const +{ + PassedDependencies result; + for (const auto& dependency : m_dependencies) + { + if (auto task = dependency.first.lock()) + { + result.insert(task); + } + } + return result; +} + +bool Task::addDependency(const std::shared_ptr& dependency) +{ + if (!dependency) + { + return false; + } + auto it = m_dependencies.find(dependency); + if (it != m_dependencies.end()) + { + return false; + } + State prev = this->state(); + m_dependencies.insert(std::make_pair( + (const std::weak_ptr)(dependency), + dependency->observers().insert([this](Task& dependency, State prev, State next) { + bool didChange = this->updateState(dependency, prev, next); + (void)didChange; + }))); + // Now determine if this dependency changed the state. + State next = this->state(); + if (prev != next) + { + bool didChange = this->changeState(prev, next); + (void)didChange; + } + return true; +} + +bool Task::removeDependency(const std::shared_ptr& dependency) +{ + State prev = this->state(); + bool didRemove = m_dependencies.erase(dependency) > 0; + if (didRemove) + { + State next = this->state(); + if (prev != next) + { + this->changeState(prev, next); + } + return true; + } + return false; +} + +bool Task::changeState(State previous, State next) +{ + if (previous == next) + { + return false; + } + m_completed = next == State::Completed; + m_observers(*this, previous, next); + return true; +} + +bool Task::updateState(Task& dependency, State prev, State next) +{ + // If a dependent task becomes blocking or non-blocking, + // check other tasks and see if we should change our state + bool dependencyNowUnblocked = (prev < State::Completable && next > State::Incomplete); + bool dependencyNowBlocking = (prev > State::Incomplete && next < State::Completable); + + // No significant change to our dependency. + if (!dependencyNowUnblocked && !dependencyNowBlocking) + { + return false; + } + + if (dependencyNowUnblocked && dependencyNowBlocking) + { + throw std::logic_error("Impossible state."); + } + + bool remainingDepsUnblocked = true; + for (const auto& entry : m_dependencies) + { + if (auto remainingDep = entry.first.lock()) + { + if (remainingDep.get() == &dependency) + { + continue; + } + remainingDepsUnblocked &= remainingDep->state() > State::Incomplete; + } + } + if (!remainingDepsUnblocked) + { + // The dependent task would have caused a change, but other dependencies + // keep us in our current state. + return false; + } + if (dependencyNowUnblocked) + { + // All other tasks are also unblocked, we changed from Unavailable to Completable or Complete. + this->changeState(State::Unavailable, m_completed ? State::Completed : State::Completable); + } + else if (dependencyNowBlocking) + { + // All other tasks are also unblocked, we changed from Completable or Complete to Unavailable. + this->changeState(m_completed ? State::Completed : State::Completable, State::Unavailable); + } + return true; +} + +bool Task::internalStateChanged(State next) +{ + if (m_internalState == next) + { + return false; + } + State previousFinalState = this->state(); + m_internalState = next; + State nextFinalState = this->state(); + if (previousFinalState != nextFinalState) + { + this->changeState(previousFinalState, nextFinalState); + return true; + } + return false; +} + +} // namespace task +} // namespace smtk diff --git a/smtk/task/Task.h b/smtk/task/Task.h new file mode 100644 index 0000000000000000000000000000000000000000..5f31dd6ad7e26f709cdb09f77520874ba290c1fa --- /dev/null +++ b/smtk/task/Task.h @@ -0,0 +1,252 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +#ifndef smtk_task_Task_h +#define smtk_task_Task_h + +#include "smtk/CoreExports.h" +#include "smtk/SharedFromThis.h" +#include "smtk/SystemConfig.h" +#include "smtk/common/Managers.h" +#include "smtk/common/Observers.h" +#include "smtk/task/State.h" + +#include "nlohmann/json.hpp" + +#include +#include +#include +#include + +namespace smtk +{ +namespace task +{ + +/**\brief Task is a base class for all SMTK tasks. + * + * SMTK tasks are nodes in a graph whose arcs connect them to dependencies. + * The state of each task and its dependencies determine the set of available + * (or reachable) tasks. + * An application's user interface typically gets reconfigured when the active + * task changes to help direct users through a workflow, although tasks should + * not attempt to modify the user interface themselves. Instead, tasks should + * be solely focused on determining whether conditions are met for them to be + * (a) accessible to users and (b) marked completed by users. + * Once the first set of conditions is met, users are allowed to undertake the + * task. Once the second set of conditions is met, users are allowed to mark + * the task complete and thus gain access to those tasks which depend on it. + * + * Subclasses of Task are responsible for monitoring the application's state; + * the base class provides no methods to aid in this other than access to the + * application's managers at construction. + * Once the subclass has determined conditions are met, it should call + * the `internalStateChanged()` method. + * The base class will determine if this results in a state transition or not + * (based on dependencies blocking the change) and notify observers as needed. + */ +class SMTKCORE_EXPORT Task : smtkEnableSharedPtr(Task) +{ +public: + smtkTypeMacroBase(smtk::task::Task); + smtkCreateMacro(smtk::task::Task); + + /// A task's state changes may be observed. + using Observer = std::function; + /// The collection of all observers of this task instance. + using Observers = smtk::common::Observers; + /// A task's dependencies are other tasks stored as weak pointers. + using Dependencies = std::map>; + /// A task's dependencies are other tasks passed as shared pointers. + using PassedDependencies = std::set; + /// Tasks are configured with arbitrary JSON objects, though this may change. + using Configuration = nlohmann::json; + + Task(); + Task( + const Configuration& config, + const std::shared_ptr& managers = nullptr); + Task( + const Configuration& config, + const PassedDependencies& dependencies, + const std::shared_ptr& managers = nullptr); + + virtual ~Task() = default; + + /// A method called by all constructors passed Configuration information. + /// + /// In general, this method should set member variables directly + /// instead of calling set/get methods since those may invoke observers + /// with an uninitialized object. + /// + /// Depedendencies (if they were provided) will already have been added + /// when this method is called. + void configure(const Configuration& config); + + /// Return the title of the task (if one was provided). + const std::string& title() const { return m_title; } + + /// Set the title of the task to be presented to users. + /// This is not intended to be a unique identifier. + void setTitle(const std::string& title); + + /// Get the state. + /// + /// This state is a composition of \a m_internalState – updated by subclasses as + /// needed – and the state of any dependencies. + /// Because \a m_internalState is initialized to State::Completable, + /// the default behavior is to become Completable once all dependencies are met + /// (i.e., Completable or Completed) and Completed only if dependencies are met + /// **and** markCompleted(true) has been called. + /// Thus, the implementation in this base class will never return Incomplete. + /// If a subclass marks the internal state as Incomplete, then this method may + /// return Incomplete. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + ///
State "truth table" given internal and dependency states
Dependencies/
Internal
UnavailableIncomplete CompletableCompleted
User has not marked task completed
Unavailable UnavailableUnavailableUnavailableUnavailable
Incomplete Unavailable IncompleteIncomplete Incomplete
Completable Unavailable IncompleteCompletableCompletable
User has marked task completed
Unavailable UnavailableUnavailableUnavailableUnavailable
Incomplete Unavailable IncompleteIncomplete Incomplete
Completable Unavailable IncompleteCompletableCompleted
+ /// + /// Note that the internal state does not include State::Completed; only the user may mark a task + /// completed and the base class implements a method to handle user input. + /// A subclass that wishes to autocomplete might invoke the base-class method although this could + /// frustrate users. + virtual State state() const; + + /// This public method allows user-interface components to indicate + /// when the user marks a task complete (or unmarks it). + /// + /// This method has no effect and returns false if the task's current state + /// is unavailable or incomplete. + /// Returns true if the task's current state changes (from Completable to Completed + /// if \a completed is true or Completed to Completable if \a completed is false). + /// If true is returned, this method invoked its observers. + /// + /// Be aware that if this task transitions from State::Completed + /// to State::Incomplete or State::Unavailable, `m_completed` + /// will be reset to false and this method must be invoked again. + bool markCompleted(bool completed); + + /// Return the tasks which this task depends upon. + /// WARNING: The returned set is read-only (modifying it does not modify + /// this Task); however, modifying tasks in the returned set can affect + /// this Task's state. + PassedDependencies dependencies() const; + + /// Add a dependency. + /// + /// Returns true if the \a dependency was added, false if it already existed or is null. + /// This method will invoke observers if adding the dependency changes this task's state. + bool addDependency(const std::shared_ptr& dependency); + + /// Add a container of task-pointers as dependencies. + /// + /// Returns true if all \a dependencies were added, false if any already existed or were null. + /// This method will invoke observers if adding the dependencies changes this task's state. + template + bool addDependencies(const Container& tasks); + + /// Remove a dependency. + /// + /// Returns true if the \a dependency was removed, false if not. + /// This method will invoke observers if removing the dependency changes this task's state. + bool removeDependency(const std::shared_ptr& dependency); + + /// Remove a container of task-pointers as dependencies. + /// + /// Returns true if all \a dependencies were removed, false otherwise. + /// This method will invoke observers if removing the dependencies changes this task's state. + template + bool removeDependencies(const Container& tasks); + + /// Return this object's observers so other classes may insert themselves. + Observers& observers() { return m_observers; } + + /// Return the internal state of the task. + /// + /// This should not generally be used; instead, call `state()`. + /// This state does not include dependencies or user-completion; + /// it only reports whether the application has met conditions + /// inherent for the task itself. + State internalState() const { return m_internalState; } + +protected: + /// Indicate the state has changed. + /// This method invokes observers if and only if \a previous and \a next are different. + /// It will also update m_completed to match the new state. + /// + /// It returns false if \a previous == \a next and true otherwise. + bool changeState(State previous, State next); + + /// Update our state because a dependent task has changed state or + /// a subclass has marked the internal state as changed. + /// + /// Returns true if this task's state changed and false otherwise. + /// This method will invoke observers if it returns true. + virtual bool updateState(Task& dependency, State prev, State next); + + /// Update the internal state, possibly transitioning the task's final state. + /// + /// This method returns true if the task's final state changed and + /// false otherwise. + /// If true is returned, observers have been invoked. + bool internalStateChanged(State next); + + /// A task name to present to the user. + std::string m_title; + /// Whether the user has marked the task completed or not. + bool m_completed = false; + /// A set of dependent tasks and the keys used to observe their + /// state so that this task can update its state in response. + std::map> m_dependencies; + /// The set of observers of *this* task's state. + Observers m_observers; + +private: + /// The internal state of the task as provided by subclasses. + /// This is private so subclasses cannot alter it directly; + /// instead they should invoke `internalStateChanged()` so that + /// the Task's final state can be updated and observers invoked. + State m_internalState = State::Completable; +}; + +template +bool Task::addDependencies(const Container& tasks) +{ + bool addedAll = true; + for (const auto& task : tasks) + { + addedAll &= this->addDependency(task); + } + return addedAll; +} + +template +bool Task::removeDependencies(const Container& tasks) +{ + bool removedAll = true; + for (const auto& task : tasks) + { + removedAll &= this->removeDependency(task); + } + return removedAll; +} + +} // namespace task +} // namespace smtk + +#endif // smtk_task_Task_h diff --git a/smtk/task/TaskNeedsResources.cxx b/smtk/task/TaskNeedsResources.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4310d8d48422f74cc7b6d584612d5ccbab793ae0 --- /dev/null +++ b/smtk/task/TaskNeedsResources.cxx @@ -0,0 +1,208 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#include "smtk/task/TaskNeedsResources.h" + +#include "smtk/operation/Manager.h" +#include "smtk/operation/SpecificationOps.h" +#include "smtk/project/ResourceContainer.h" + +#include + +namespace smtk +{ +namespace task +{ + +void to_json(json& j, const TaskNeedsResources::Predicate& p) +{ + j = json{ { "role", p.m_role }, { "type", p.m_type } }; + if (p.m_minimumCount == 0 && p.m_maximumCount < 0) + { + // skip counts; any number of resources are allowed. + } + else + { + j["min"] = p.m_minimumCount; + j["max"] = p.m_maximumCount; + } + if (p.m_validator) + { + j["validator"] = "Cannot serialize validators yet."; + } +} + +void from_json(const json& j, TaskNeedsResources::Predicate& p) +{ + if (j.contains("role")) + { + j.at("role").get_to(p.m_role); + } + if (j.contains("type")) + { + j.at("type").get_to(p.m_type); + } + if (j.contains("min")) + { + j.at("min").get_to(p.m_minimumCount); + } + else + { + p.m_minimumCount = 1; + } + if (j.contains("max")) + { + j.at("max").get_to(p.m_maximumCount); + } + else + { + p.m_maximumCount = -1; + } + if (j.contains("validator")) + { + throw std::logic_error("todo"); // TODO + } + else + { + // Accept any resource + p.m_validator = nullptr; + /* + [](const smtk::resource::Resource&, const TaskNeedsResource::Predicate&) + { return true; }; + */ + } +} + +TaskNeedsResources::TaskNeedsResources() = default; + +TaskNeedsResources::TaskNeedsResources( + const Configuration& config, + const smtk::common::Managers::Ptr& managers) + : Task(config, managers) + , m_managers(managers) +{ + this->configure(config); +} + +TaskNeedsResources::TaskNeedsResources( + const Configuration& config, + const PassedDependencies& dependencies, + const smtk::common::Managers::Ptr& managers) + : Task(config, dependencies, managers) + , m_managers(managers) +{ + this->configure(config); +} + +void TaskNeedsResources::configure(const Configuration& config) +{ + if (config.contains("resources")) + { + auto rsrcSpecs = config.at("resources"); + if (rsrcSpecs.is_array()) + { + for (const auto& spec : rsrcSpecs) + { + if (!spec.contains("role")) + { + continue; + } + + Predicate predicate; + spec.get_to(predicate); + m_resourcesByRole[predicate.m_role] = spec.get(); + } + } + } + if (m_managers) + { + if (auto resourceManager = m_managers->get()) + { + m_observer = resourceManager->observers().insert( + [this](const smtk::resource::Resource& resource, smtk::resource::EventType event) { + this->updateResources(const_cast(resource), event); + }, + /* priority */ 0, + /* initialize */ true, + "TaskNeedsResources monitors results for resources and their roles."); + } + } + if (!m_resourcesByRole.empty()) + { + this->internalStateChanged(this->computeInternalState()); + } +} + +void TaskNeedsResources::updateResources( + smtk::resource::Resource& resource, + smtk::resource::EventType event) +{ + bool predicatesUpdated = false; + auto resourcePtr = resource.shared_from_this(); + switch (event) + { + case smtk::resource::EventType::ADDED: + { + // Add the resource to the appropriate entry: + const std::string& role = smtk::project::detail::role(resourcePtr); + auto it = m_resourcesByRole.find(role); + if (it != m_resourcesByRole.end()) + { + if (!it->second.m_validator || it->second.m_validator(resource, it->second)) + { + it->second.m_resources.insert(resourcePtr); + predicatesUpdated = true; + } + } + } + break; + case smtk::resource::EventType::REMOVED: + { + // Remove the resource from the appropriate entry. + const std::string& role = smtk::project::detail::role(resourcePtr); + auto it = m_resourcesByRole.find(role); + if (it != m_resourcesByRole.end()) + { + predicatesUpdated = it->second.m_resources.erase(resourcePtr) > 0; + } + } + break; + case smtk::resource::EventType::MODIFIED: + // TODO + break; + } + if (predicatesUpdated) + { + this->internalStateChanged(this->computeInternalState()); + } +} + +State TaskNeedsResources::computeInternalState() const +{ + State s = State::Completable; + for (const auto& entry : m_resourcesByRole) + { + const auto& predicate(entry.second); + if (predicate.m_resources.size() < static_cast(predicate.m_minimumCount)) + { + s = State::Incomplete; + } + else if ( + predicate.m_maximumCount >= 0 && + predicate.m_resources.size() > static_cast(predicate.m_maximumCount)) + { + s = State::Incomplete; + } + } + return s; +} + +} // namespace task +} // namespace smtk diff --git a/smtk/task/TaskNeedsResources.h b/smtk/task/TaskNeedsResources.h new file mode 100644 index 0000000000000000000000000000000000000000..06d261101e8bfddd331bcebd2a9a3c7a13ecd244 --- /dev/null +++ b/smtk/task/TaskNeedsResources.h @@ -0,0 +1,87 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +#ifndef smtk_task_TaskNeedsResources_h +#define smtk_task_TaskNeedsResources_h + +#include "smtk/resource/Manager.h" +#include "smtk/resource/Observer.h" +#include "smtk/resource/Resource.h" +#include "smtk/task/Task.h" + +namespace smtk +{ +namespace task +{ + +/**\brief TaskNeedsResources is a task that requires resources from a resource manager. + * + * Tasks of this type observe a resource manager for resources to be added and marked + * with a Role as specified (at construction time). When all the required resources + * are present with the required roles, then the task becomes completable. + */ +class SMTKCORE_EXPORT TaskNeedsResources : public Task +{ +public: + smtkTypeMacro(smtk::task::TaskNeedsResources); + smtkSuperclassMacro(smtk::task::Task); + smtkCreateMacro(smtk::task::Task); + + /// A predicate used to collect resources that fit a given role. + struct Predicate + { + using Entry = std::weak_ptr; + /// The required role. If empty, any role is allowed. + std::string m_role; + /// The minimum number of resources that must be collected to satisfy the requirement. + /// + /// If 0, then resources selected by the validator are not required (but *may* be accepted). + unsigned int m_minimumCount; + /// The maximum number of resources that can be collected while still satisfying the requirement. + /// + /// Note that if 0, the predicate is forcing the task to reject all resources + /// that the validator selects (i.e., no resources of the given type are allowed). + /// If negative, then there is no maximum number of validated resources. + int m_maximumCount; + /// The resource typename regex; typically just a resource typename. + std::string m_type; + /// A lambda used to determine whether the given resource is acceptable. + std::function m_validator; + /// The set of resources being managed that are selected by the validator. + std::set> m_resources; + }; + + TaskNeedsResources(); + TaskNeedsResources( + const Configuration& config, + const smtk::common::Managers::Ptr& managers = nullptr); + TaskNeedsResources( + const Configuration& config, + const PassedDependencies& dependencies, + const smtk::common::Managers::Ptr& managers = nullptr); + + ~TaskNeedsResources() override = default; + + void configure(const Configuration& config); + +protected: + /// Respond to resource changes that may change task state. + void updateResources(smtk::resource::Resource& resource, smtk::resource::EventType event); + + /// Check m_resourcesByRole to see if all requirements are met. + State computeInternalState() const; + + smtk::common::Managers::Ptr m_managers; + smtk::resource::Observers::Key m_observer; + std::map m_resourcesByRole; +}; +} // namespace task +} // namespace smtk + +#endif // smtk_task_TaskNeedsResources_h diff --git a/smtk/task/plugin/CMakeLists.txt b/smtk/task/plugin/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..2579d1a6987d010920e9909c5b7799c06760e546 --- /dev/null +++ b/smtk/task/plugin/CMakeLists.txt @@ -0,0 +1,7 @@ +smtk_add_plugin(smtkTaskPlugin + REGISTRAR smtk::task::Registrar + MANAGERS smtk::common::Managers + smtk::task::Manager + PARAVIEW_PLUGIN_ARGS + VERSION 1.0 +) diff --git a/smtk/task/plugin/paraview.plugin b/smtk/task/plugin/paraview.plugin new file mode 100644 index 0000000000000000000000000000000000000000..df07972f9c2c9810560b734d61c918d18862138c --- /dev/null +++ b/smtk/task/plugin/paraview.plugin @@ -0,0 +1,4 @@ +NAME + smtkTaskPlugin +DESCRIPTION + SMTK task plugin for ParaView diff --git a/smtk/task/pybind11/CMakeLists.txt b/smtk/task/pybind11/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..2075b7054c75824b482a9ddb795320f3cf6ac39e --- /dev/null +++ b/smtk/task/pybind11/CMakeLists.txt @@ -0,0 +1,30 @@ +set(library_name "_smtkPybindTask") +set(module_path "task") +set(build_path "${CMAKE_BINARY_DIR}/${SMTK_PYTHON_MODULEDIR}/smtk/${module_path}") +set(install_path "${SMTK_PYTHON_MODULEDIR}/smtk/${module_path}") + +pybind11_add_module(${library_name} PybindTask.cxx) +target_include_directories(${library_name} PUBLIC + $ +) +target_link_libraries(${library_name} LINK_PUBLIC smtkCore) +set_target_properties(${library_name} + PROPERTIES + CXX_VISIBILITY_PRESET hidden + COMPILE_FLAGS ${SMTK_PYBIND11_FLAGS} + LIBRARY_OUTPUT_DIRECTORY "${build_path}" +) + +# Install library +install(TARGETS ${library_name} DESTINATION "${install_path}") + +# Create and install module __init__.py +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py" + "${build_path}/__init__.py" @ONLY +) + +install( + FILES "${build_path}/__init__.py" + DESTINATION "${install_path}" +) diff --git a/smtk/task/pybind11/PybindManager.h b/smtk/task/pybind11/PybindManager.h new file mode 100644 index 0000000000000000000000000000000000000000..b276ddb0f7535a78df82e8756115f86ae995515d --- /dev/null +++ b/smtk/task/pybind11/PybindManager.h @@ -0,0 +1,36 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#ifndef pybind_smtk_task_Manager_h +#define pybind_smtk_task_Manager_h + +#include + +#include "smtk/task/Manager.h" + +namespace py = pybind11; + +inline PySharedPtrClass< smtk::task::Manager > pybind11_init_smtk_task_Manager(py::module &m) +{ + PySharedPtrClass< smtk::task::Manager > instance(m, "Manager"); + instance + .def_static("create", (std::shared_ptr (*)()) &smtk::task::Manager::create) + .def_static("create", (std::shared_ptr (*)(::std::shared_ptr &)) &smtk::task::Manager::create, py::arg("ref")) + .def("managers", &smtk::task::Manager::managers) + .def("setManagers", &smtk::task::Manager::setManagers, py::arg("managers")) + .def("instances", (smtk::task::Manager::Instances & (smtk::task::Manager::*)()) &smtk::task::Manager::instances) + .def("instances", (smtk::task::Manager::Instances const & (smtk::task::Manager::*)() const) &smtk::task::Manager::instances) + .def("typeName", &smtk::task::Manager::typeName) + .def_readonly_static("type_name", &smtk::task::Manager::type_name) + ; + return instance; +} + +#endif diff --git a/smtk/task/pybind11/PybindRegistrar.h b/smtk/task/pybind11/PybindRegistrar.h new file mode 100644 index 0000000000000000000000000000000000000000..d7503d26248343d3db251c2a4966f94b118505f0 --- /dev/null +++ b/smtk/task/pybind11/PybindRegistrar.h @@ -0,0 +1,37 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#ifndef pybind_smtk_task_Registrar_h +#define pybind_smtk_task_Registrar_h + +#include + +#include "smtk/task/Registrar.h" + +namespace py = pybind11; + +inline py::class_< smtk::task::Registrar > pybind11_init_smtk_task_Registrar(py::module &m) +{ + py::class_< smtk::task::Registrar > instance(m, "Registrar"); + instance + .def(py::init<>()) + .def(py::init<::smtk::task::Registrar const &>()) + .def("deepcopy", (smtk::task::Registrar & (smtk::task::Registrar::*)(::smtk::task::Registrar const &)) &smtk::task::Registrar::operator=) + .def_static("registerTo", (void (*)(::smtk::common::Managers::Ptr const &)) &smtk::task::Registrar::registerTo, py::arg("arg0")) + .def_static("registerTo", (void (*)(::smtk::resource::Manager::Ptr const &)) &smtk::task::Registrar::registerTo, py::arg("arg0")) + .def_static("registerTo", (void (*)(::smtk::task::Manager::Ptr const &)) &smtk::task::Registrar::registerTo, py::arg("arg0")) + .def_static("unregisterFrom", (void (*)(::smtk::common::Managers::Ptr const &)) &smtk::task::Registrar::unregisterFrom, py::arg("arg0")) + .def_static("unregisterFrom", (void (*)(::smtk::resource::Manager::Ptr const &)) &smtk::task::Registrar::unregisterFrom, py::arg("arg0")) + .def_static("unregisterFrom", (void (*)(::smtk::task::Manager::Ptr const &)) &smtk::task::Registrar::unregisterFrom, py::arg("arg0")) + ; + return instance; +} + +#endif diff --git a/smtk/task/pybind11/PybindState.h b/smtk/task/pybind11/PybindState.h new file mode 100644 index 0000000000000000000000000000000000000000..61a2bf020afee1db76ecdd6f4aafa7c2d4515b39 --- /dev/null +++ b/smtk/task/pybind11/PybindState.h @@ -0,0 +1,40 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#ifndef pybind_smtk_task_State_h +#define pybind_smtk_task_State_h + +#include + +#include "smtk/task/State.h" + +namespace py = pybind11; + +inline void pybind11_init_smtk_task_State(py::module &m) +{ + py::enum_(m, "State") + .value("Unavailable", smtk::task::State::Unavailable) + .value("Incomplete", smtk::task::State::Incomplete) + .value("Completable", smtk::task::State::Completable) + .value("Completed", smtk::task::State::Completed) + .export_values(); +} + +inline void pybind11_init_smtk_task_stateName(py::module &m) +{ + m.def("stateName", &smtk::task::stateName, "", py::arg("s")); +} + +inline void pybind11_init_smtk_task_stateEnum(py::module &m) +{ + m.def("stateEnum", &smtk::task::stateEnum, "", py::arg("s")); +} + +#endif diff --git a/smtk/task/pybind11/PybindTask.cxx b/smtk/task/pybind11/PybindTask.cxx new file mode 100644 index 0000000000000000000000000000000000000000..660f1096b8b3c52f6c95b3ba5d35bb8d02d6e755 --- /dev/null +++ b/smtk/task/pybind11/PybindTask.cxx @@ -0,0 +1,46 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#include +#include + +#include "nlohmann/json.hpp" + +namespace py = pybind11; + +template +using PySharedPtrClass = py::class_, Args...>; + +using namespace nlohmann; + +#include "PybindTaskNeedsResources.h" +#include "PybindTask.h" +#include "PybindManager.h" +#include "PybindRegistrar.h" +#include "PybindState.h" + +PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr); + +PYBIND11_MODULE(task, m) +{ + m.doc() = "SMTK tasks are portions of a workflow."; + py::module smtk = m.def_submodule("smtk", ""); + py::module task = smtk.def_submodule("task", ""); + + // The order of these function calls is important! It was determined by + // comparing the dependencies of each of the wrapped objects. + auto smtk_task_Manager = pybind11_init_smtk_task_Manager(task); + auto smtk_task_Registrar = pybind11_init_smtk_task_Registrar(task); + auto smtk_task_Task = pybind11_init_smtk_task_Task(task); + pybind11_init_smtk_task_State(task); + pybind11_init_smtk_task_stateEnum(task); + pybind11_init_smtk_task_stateName(task); + auto smtk_task_TaskNeedsResources = pybind11_init_smtk_task_TaskNeedsResources(task); +} diff --git a/smtk/task/pybind11/PybindTask.h b/smtk/task/pybind11/PybindTask.h new file mode 100644 index 0000000000000000000000000000000000000000..95cf400b7ff970c7090b1daf529174097fa6711d --- /dev/null +++ b/smtk/task/pybind11/PybindTask.h @@ -0,0 +1,47 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#ifndef pybind_smtk_task_Task_h +#define pybind_smtk_task_Task_h + +#include + +#include "smtk/task/Task.h" + +#include "smtk/task/State.h" + +namespace py = pybind11; + +inline PySharedPtrClass< smtk::task::Task > pybind11_init_smtk_task_Task(py::module &m) +{ + PySharedPtrClass< smtk::task::Task > instance(m, "Task"); + instance + .def(py::init<>()) + .def(py::init<::smtk::task::Task::Configuration const &, ::std::shared_ptr const &>()) + .def(py::init<::smtk::task::Task::Configuration const &, ::smtk::task::Task::PassedDependencies const &, ::std::shared_ptr const &>()) + .def("typeName", &smtk::task::Task::typeName) + .def_static("create", (std::shared_ptr (*)()) &smtk::task::Task::create) + .def_static("create", (std::shared_ptr (*)(::std::shared_ptr &)) &smtk::task::Task::create, py::arg("ref")) + .def("configure", &smtk::task::Task::configure, py::arg("config")) + .def("title", &smtk::task::Task::title) + .def("setTitle", &smtk::task::Task::setTitle, py::arg("title")) + .def("state", &smtk::task::Task::state) + .def("markCompleted", &smtk::task::Task::markCompleted, py::arg("completed")) + .def("dependencies", &smtk::task::Task::dependencies) + .def("addDependency", &smtk::task::Task::addDependency, py::arg("dependency")) + .def("removeDependency", &smtk::task::Task::removeDependency, py::arg("dependency")) + .def("observers", &smtk::task::Task::observers) + .def("internalState", &smtk::task::Task::internalState) + .def_readonly_static("type_name", &smtk::task::Task::type_name) + ; + return instance; +} + +#endif diff --git a/smtk/task/pybind11/PybindTaskNeedsResources.h b/smtk/task/pybind11/PybindTaskNeedsResources.h new file mode 100644 index 0000000000000000000000000000000000000000..2a76509d5e3bd30fdd60ddcfa0946abe0dbfa341 --- /dev/null +++ b/smtk/task/pybind11/PybindTaskNeedsResources.h @@ -0,0 +1,49 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= + +#ifndef pybind_smtk_task_TaskNeedsResources_h +#define pybind_smtk_task_TaskNeedsResources_h + +#include + +#include "smtk/task/TaskNeedsResources.h" + +#include "smtk/task/Task.h" + +namespace py = pybind11; + +inline PySharedPtrClass< smtk::task::TaskNeedsResources, smtk::task::Task > pybind11_init_smtk_task_TaskNeedsResources(py::module &m) +{ + PySharedPtrClass< smtk::task::TaskNeedsResources, smtk::task::Task > instance(m, "TaskNeedsResources"); + instance + .def(py::init<>()) + .def(py::init<::smtk::task::Task::Configuration const &, ::smtk::common::Managers::Ptr const &>()) + .def(py::init<::smtk::task::Task::Configuration const &, ::smtk::task::Task::PassedDependencies const &, ::smtk::common::Managers::Ptr const &>()) + .def("configure", &smtk::task::TaskNeedsResources::configure, py::arg("config")) + .def_static("create", (std::shared_ptr (*)()) &smtk::task::TaskNeedsResources::create) + .def_static("create", (std::shared_ptr (*)(::std::shared_ptr &)) &smtk::task::TaskNeedsResources::create, py::arg("ref")) + .def("typeName", &smtk::task::TaskNeedsResources::typeName) + .def_readonly_static("type_name", &smtk::task::TaskNeedsResources::type_name) + ; + py::class_< smtk::task::TaskNeedsResources::Predicate >(instance, "Predicate") + .def(py::init<::smtk::task::TaskNeedsResources::Predicate const &>()) + .def(py::init<>()) + .def("deepcopy", (smtk::task::TaskNeedsResources::Predicate & (smtk::task::TaskNeedsResources::Predicate::*)(::smtk::task::TaskNeedsResources::Predicate const &)) &smtk::task::TaskNeedsResources::Predicate::operator=) + .def_readwrite("m_role", &smtk::task::TaskNeedsResources::Predicate::m_role) + .def_readwrite("m_minimumCount", &smtk::task::TaskNeedsResources::Predicate::m_minimumCount) + .def_readwrite("m_maximumCount", &smtk::task::TaskNeedsResources::Predicate::m_maximumCount) + .def_readwrite("m_type", &smtk::task::TaskNeedsResources::Predicate::m_type) + .def_readwrite("m_validator", &smtk::task::TaskNeedsResources::Predicate::m_validator) + .def_readwrite("m_resources", &smtk::task::TaskNeedsResources::Predicate::m_resources) + ; + return instance; +} + +#endif diff --git a/smtk/task/pybind11/__init__.py b/smtk/task/pybind11/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..197de08efbd387d56799c60c82b98e6ccf27fcca --- /dev/null +++ b/smtk/task/pybind11/__init__.py @@ -0,0 +1,13 @@ +# ============================================================================= +# +# Copyright (c) Kitware, Inc. +# All rights reserved. +# See LICENSE.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even +# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the above copyright notice for more information. +# +# ============================================================================= + +from ._smtkPybindTask import * diff --git a/smtk/task/testing/CMakeLists.txt b/smtk/task/testing/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..2941d367a3cf5e1cbcdf5137f12b35096cd03df9 --- /dev/null +++ b/smtk/task/testing/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(cxx) + +# if(SMTK_ENABLE_PYTHON_WRAPPING) +# add_subdirectory(python) +# endif() diff --git a/smtk/task/testing/cxx/CMakeLists.txt b/smtk/task/testing/cxx/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..c2628128fd157741932c77ca0d5d34a8f049f5b5 --- /dev/null +++ b/smtk/task/testing/cxx/CMakeLists.txt @@ -0,0 +1,12 @@ +set(unit_tests + TestActive.cxx + TestTask.cxx +) + +find_package(Threads REQUIRED) + +smtk_unit_tests( + LABEL "Task" + SOURCES ${unit_tests} + LIBRARIES smtkCore +) diff --git a/smtk/task/testing/cxx/TestActive.cxx b/smtk/task/testing/cxx/TestActive.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9cea1a72e3622916b1d056daebf58371f6b24268 --- /dev/null +++ b/smtk/task/testing/cxx/TestActive.cxx @@ -0,0 +1,168 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +#include "smtk/attribute/Registrar.h" +#include "smtk/attribute/Resource.h" +#include "smtk/common/Managers.h" +#include "smtk/model/Registrar.h" +#include "smtk/model/Resource.h" +#include "smtk/operation/Manager.h" +#include "smtk/operation/Registrar.h" +#include "smtk/plugin/Registry.h" +#include "smtk/resource/Manager.h" +#include "smtk/resource/Registrar.h" +#include "smtk/task/Manager.h" +#include "smtk/task/Registrar.h" +#include "smtk/task/Task.h" +#include "smtk/task/TaskNeedsResources.h" + +#include "smtk/common/testing/cxx/helpers.h" + +namespace test_task +{ + +using namespace smtk::task; + +} // namespace test_task + +int TestActive(int, char*[]) +{ + using smtk::task::State; + using smtk::task::Task; + + // Create managers + auto managers = smtk::common::Managers::create(); + auto attributeRegistry = smtk::plugin::addToManagers(managers); + auto resourceRegistry = smtk::plugin::addToManagers(managers); + auto operationRegistry = smtk::plugin::addToManagers(managers); + auto taskRegistry = smtk::plugin::addToManagers(managers); + + auto resourceManager = managers->get(); + auto operationManager = managers->get(); + auto taskManager = managers->get(); + + auto attributeResourceRegistry = + smtk::plugin::addToManagers(resourceManager); + auto modelRegistry = smtk::plugin::addToManagers(resourceManager); + auto taskTaskRegistry = smtk::plugin::addToManagers(taskManager); + + std::cout << "Observing changes to active task\n"; + int count = 0; + smtk::task::Task* previousTask = nullptr; + smtk::task::Task* nextTask = nullptr; + auto ikey = taskManager->active().observers().insert( + [&count, &previousTask, &nextTask](smtk::task::Task* prev, smtk::task::Task* next) { + std::cout << " Active task switched " << (prev ? prev->title() : "(none)") << " ⟶ " + << (next ? next->title() : "(none)") << "\n"; + ++count; + previousTask = prev; + nextTask = next; + }, + /* priority */ 0, + /* initialize */ true, + "Observe active task for test"); + test(count == 1, "Expected observer to be initialized upon registration."); + test(previousTask == nullptr && nextTask == nullptr, "Unexpected initialization."); + + { + std::shared_ptr t1 = + taskManager->instances().create(Task::Configuration{ { "title", "Task 1" } }, managers); + std::cout << "Attempting to set active task:\n"; + taskManager->active().switchTo(t1.get()); + test(count == 2, "Expected to switch active task."); + test(previousTask == nullptr && nextTask == t1.get(), "Expected active switch null ⟶ t1."); + + { + std::cout << "Ensuring unmanaged tasks cannot become active.\n"; + std::shared_ptr tmp = Task::create(); + test(!!tmp, "Expected to create unmanaged task."); + tmp->configure(Task::Configuration{ { "title", "Unmanaged Task" } }); + taskManager->active().switchTo(tmp.get()); + test(count == 2, "Should not be able to switch to an unmanaged task."); + } + + bool success = t1->markCompleted(true); + test(count == 2, "Change in task state does not imply active task switch."); + success = t1->markCompleted(false); + + // Now add a task and switch to it. + std::shared_ptr t2 = + taskManager->instances().create(Task::Configuration{ { "title", "Task 2" } }, managers); + success = t1->addDependency(t2); + std::cout << "Switching to task 2:\n"; + taskManager->active().switchTo(t2.get()); + + // Test TaskNeedsResources + // I. Construction w/ configuration. + // The task is incomplete unless 1 or 2 model geometry resources + // and 1 or more simulation attribute resources are held by the + // resource manager. + Task::Configuration c4{ + { "title", "Task 4" }, + { "resources", + { { { "role", "model geometry" }, { "type", "smtk::model::Resource" }, { "max", 2 } }, + { { "role", "simulation attribute" }, { "type", "smtk::attribute::Resource" } } } } + }; + auto t4 = taskManager->instances().create(c4, managers); + t1->addDependency(t4); + std::cout << "Ensuring switches to unavailable tasks fail.\n"; + bool didSwitch = taskManager->active().switchTo(t1.get()); + test(!didSwitch, "Expected to fail switching to an unavailable task."); + test(count == 3, "Did not expect switch to unavailable task."); + + // II. State transitions + bool didAdd; + // Add 3 resources. Addition of the last should cause transition. + auto model1 = smtk::model::Resource::create(); + model1->properties().get()["project_role"] = "model geometry"; + didAdd = resourceManager->add(model1); + test(didAdd, "Expected to add model1 resource."); + auto model2 = smtk::model::Resource::create(); + model2->properties().get()["project_role"] = "model geometry"; + didAdd = resourceManager->add(model2); + test(didAdd, "Expected to add model2 resource."); + auto attr1 = smtk::attribute::Resource::create(); + attr1->properties().get()["project_role"] = "simulation attribute"; + didAdd = resourceManager->add(attr1); + test(didAdd, "Expected to add attr1 resource."); + + t4->markCompleted(true); // We'll test below that completion is reset. + + std::cout << "Ensuring switches to newly-available tasks succeed:\n"; + didSwitch = taskManager->active().switchTo(t1.get()); + test(didSwitch, "Expected to fail switching to an unavailable task."); + test(count == 4, "Expected switch to now-available task."); + test(previousTask == t2.get() && nextTask == t1.get(), "Expected active switch t2 ⟶ t1."); + + bool didRemove; + // Remove 2 resources. Removal of the last should cause active task to reset. + std::cout << "An active task becoming unavailable should reset the active task:\n"; + didRemove = resourceManager->remove(model1); + test(didRemove, "Expected to remove model resource."); + didRemove = resourceManager->remove(attr1); + test(didRemove, "Expected to remove attribute resource."); + test(count == 5, "Expected switch to null task when active task becomes unavailable."); + test(previousTask == t1.get() && nextTask == nullptr, "Expected active switch t1 ⟶ (none)."); + + // Test that user completion is reset by transitions "below" Completeable and back. + std::cout << "Switching to a now-available t1:\n"; + didAdd = resourceManager->add(attr1); + didSwitch = taskManager->active().switchTo(t1.get()); + test(didAdd && didSwitch, "Expected to succeed switching to a now-available task."); + test(count == 6, "Expected switch to now-available task."); + test(previousTask == nullptr && nextTask == t1.get(), "Expected active switch (none) ⟶ t1."); + + std::cout << "Unmanaging the active task should reset the active task:\n"; + taskManager->instances().clear(); + test(count == 7, "Expected switch to null task when a task is dropped from manager."); + test(previousTask == t1.get() && nextTask == nullptr, "Expected active switch t1 ⟶ (none)."); + } + + return 0; +} diff --git a/smtk/task/testing/cxx/TestTask.cxx b/smtk/task/testing/cxx/TestTask.cxx new file mode 100644 index 0000000000000000000000000000000000000000..04f0277c02b8fd7dfcb74bf4bed7bab6ab3b62e8 --- /dev/null +++ b/smtk/task/testing/cxx/TestTask.cxx @@ -0,0 +1,293 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//========================================================================= +#include "smtk/attribute/Registrar.h" +#include "smtk/attribute/Resource.h" +#include "smtk/common/Managers.h" +#include "smtk/model/Registrar.h" +#include "smtk/model/Resource.h" +#include "smtk/operation/Manager.h" +#include "smtk/operation/Registrar.h" +#include "smtk/plugin/Registry.h" +#include "smtk/resource/Manager.h" +#include "smtk/resource/Registrar.h" +#include "smtk/task/Manager.h" +#include "smtk/task/Registrar.h" +#include "smtk/task/Task.h" +#include "smtk/task/TaskNeedsResources.h" + +#include "smtk/common/testing/cxx/helpers.h" + +namespace test_task +{ + +using namespace smtk::task; + +static bool taskDestroyed = false; + +class UnavailableTask : public Task +{ +public: + smtkTypeMacro(test_task::UnavailableTask); + smtkCreateMacro(smtk::task::Task); + UnavailableTask() = default; + UnavailableTask( + const Configuration& config, + const smtk::common::Managers::Ptr& managers = nullptr) + : Task(config, managers) + { + this->internalStateChanged(State::Unavailable); + } + UnavailableTask( + const Configuration& config, + const Task::PassedDependencies& deps, + const smtk::common::Managers::Ptr& managers = nullptr) + : Task(config, deps, managers) + { + this->internalStateChanged(State::Unavailable); + } + ~UnavailableTask() override + { + std::cout << "Destroying " << this->title() << "\n"; + taskDestroyed = true; + } +}; + +} // namespace test_task + +int TestTask(int, char*[]) +{ + using smtk::task::State; + using smtk::task::Task; + using test_task::UnavailableTask; + + // Create managers + auto managers = smtk::common::Managers::create(); + auto attributeRegistry = smtk::plugin::addToManagers(managers); + auto resourceRegistry = smtk::plugin::addToManagers(managers); + auto operationRegistry = smtk::plugin::addToManagers(managers); + auto taskRegistry = smtk::plugin::addToManagers(managers); + + auto resourceManager = managers->get(); + auto operationManager = managers->get(); + auto taskManager = managers->get(); + + auto attributeResourceRegistry = + smtk::plugin::addToManagers(resourceManager); + auto modelRegistry = smtk::plugin::addToManagers(resourceManager); + auto taskTaskRegistry = smtk::plugin::addToManagers(taskManager); + + taskManager->instances().registerType(); + + auto ikey = taskManager->instances().observers().insert( + [](smtk::common::InstanceEvent event, const smtk::task::Task::Ptr& task) { + std::cout << (event == smtk::common::InstanceEvent::Managed ? "Manage" : "Unmanage") << " " + << task->title() << "\n"; + }); + + int count = 0; + auto countInstances = [&count](const std::shared_ptr& task) { + ++count; + std::cout << " " << task->title() << " " << task->state() << "\n"; + return smtk::common::Visit::Continue; + }; + + { + std::shared_ptr t1 = + taskManager->instances().create(Task::Configuration{ { "title", "Task 1" } }, managers); + test(!!t1, "Expecting to create a non-null task."); + test( + t1->state() == State::Completable, "Expected task without dependencies to be completable."); + + State from; + State to; + int called = 0; + auto callback = [&from, &to, &called](Task& task, State prev, State next) { + (void)task; + ++called; + from = prev; + to = next; + std::cout << " " << task.title() << " transitioned: " << prev << " ⟶ " << next << "\n"; + }; + auto okey = t1->observers().insert(callback); + + bool success = t1->markCompleted(true); + test(success, "Expected completion to be accepted."); + test(called == 1, "Expected observer to be invoked."); + test( + from == State::Completable && to == State::Completed, + "Expected state transition completable⟶completed."); + + called = 0; + success = t1->markCompleted(true); + test(!success, "Expected completion to be rejected on double-complete."); + test(called == 0, "Expected observer to be skipped on double-complete."); + + called = 0; + success = t1->markCompleted(false); + test(success, "Expected uncompletion to be accepted."); + test(called == 1, "Expected observer to be invoked."); + test( + from == State::Completed && to == State::Completable, + "Expected state transition completed⟶completable."); + + // Now add a dependent task that is unavailable. + test( + taskManager->instances().contains(), + "Expected UnavailableTask to be registered."); + std::shared_ptr t2 = taskManager->instances().create( + Task::Configuration{ { "title", "Task 2" } }, managers); + called = 0; + success = t1->addDependency(t2); + test(success, "Expected to add dependency to task."); + test(called == 1, "Expected observer to be invoked upon dependency insertion."); + test( + from == State::Completable && to == State::Unavailable, + "Expected state transition completable⟶unavailable."); + success = t1->addDependency(t2); + test(!success, "Expected failure when adding redundant dependency to task."); + + // Test construction with dependencies + Task::Configuration c3{ { "title", "Task 3" }, { "completed", true } }; + auto t3 = taskManager->instances().create( + c3, std::set>{ { t1, t2 } }, managers); + + // Test dependency removal and notification. + auto dokey = t3->observers().insert(callback); + called = 0; + success = t3->removeDependency(t2); + test(success, "Expected to remove dependency from Task 3."); + test(called == 0, "Did not expect state to change when removing first dependency."); + success = t1->removeDependency(t2); + test(success, "Expected to remove dependency from Task 1."); + test(called == 2, "Expected 2 tasks to change state."); + test( + from == State::Unavailable && to == State::Completed, + "Expected state transition unavailable⟶completed."); + success = t1->removeDependency(t2); + test(!success, "Expected removal of non-existent dependency to fail."); + + // Test TaskNeedsResources + // I. Construction w/ configuration. + // The task is incomplete unless 1 or 2 model geometry resources + // and 1 or more simulation attribute resources are held by the + // resource manager. + Task::Configuration c4{ + { "title", "Task 4" }, + { "resources", + { { { "role", "model geometry" }, { "type", "smtk::model::Resource" }, { "max", 2 } }, + { { "role", "simulation attribute" }, { "type", "smtk::attribute::Resource" } } } } + }; + auto t4 = taskManager->instances().create(c4, managers); + test(!!t4, "Could not create TaskNeedsResources."); + test(t4->state() == State::Incomplete, "Task with no resources should be incomplete."); + auto hokey = t4->observers().insert(callback); + + // II. State transitions + called = 0; + bool didAdd; + // Add 3 resources. Addition of the last should cause transition. + auto model1 = smtk::model::Resource::create(); + model1->properties().get()["project_role"] = "model geometry"; + didAdd = resourceManager->add(model1); + test(didAdd, "Expected to add model1 resource."); + test(called == 0, "Did not expect state to change when adding first model."); + auto model2 = smtk::model::Resource::create(); + model2->properties().get()["project_role"] = "model geometry"; + didAdd = resourceManager->add(model2); + test(didAdd, "Expected to add model2 resource."); + test(called == 0, "Did not expect state to change when adding first model."); + auto attr1 = smtk::attribute::Resource::create(); + attr1->properties().get()["project_role"] = "simulation attribute"; + didAdd = resourceManager->add(attr1); + test(didAdd, "Expected to add attr1 resource."); + test(called == 1, "Expected state to change when required resources present."); + test( + from == State::Incomplete && to == State::Completable, + "Expected state transition incomplete⟶completable."); + + t4->markCompleted(true); // We'll test below that completion is reset. + test(called == 2, "Expected state to change when user marks completed."); + test( + from == State::Completable && to == State::Completed, + "Expected state transition completable⟶completed."); + + called = 0; + bool didRemove; + // Remove 2 resources. Removal of the last should cause a transition. + didRemove = resourceManager->remove(model1); + test(didRemove, "Expected to remove model1 resource."); + test(called == 0, "Did not expect state to change when removing model1."); + didRemove = resourceManager->remove(attr1); + test(didRemove, "Expected to remove attr1 resource."); + test(called == 1, "Expected state to change when removing attr1 model."); + test( + from == State::Completed && to == State::Incomplete, + "Expected state transition completed⟶incomplete."); + + // Test that user completion is reset by transitions "below" Completeable and back. + called = 0; + didAdd = resourceManager->add(attr1); + test(didAdd, "Expected to add attr1 resource."); + test(called == 1, "Expected state to change when required resources present."); + test( + from == State::Incomplete && to == State::Completable, + "Expected state transition incomplete⟶completable."); + + // III. Verify that an empty role is allowed, as are empty resource types. + // This should also test initialization of TaskNeedsResources when + // resource manager is not empty. + Task::Configuration c5{ { "title", "Task 5" }, + { "resources", + { { { "type", "smtk::model::Resource" } }, + { { "role", "simulation attribute" } } } } }; + auto t5 = + taskManager->instances().createFromName("smtk::task::TaskNeedsResources", c5, managers); + test(!!t5, "Could not create TaskNeedsResources."); + auto pokey = t5->observers().insert(callback); + test(t5->state() == State::Completable, "Task 5 should be completable initially."); + called = 0; + didRemove = resourceManager->remove(attr1); + test(didRemove, "Expected to remove attr1 resource."); + // NB: called == 2 since both task 4 and 5 should transition: + test(called == 2, "Expected state to change when removing attr1 model."); + test( + from == State::Completable && to == State::Incomplete, + "Expected state transition completable⟶incomplete."); + + // Test task Instances methods: + + // Verify double-add fails. + didAdd = taskManager->instances().manage(t5); + test(!didAdd, "Should not return true when duplicate instance managed."); + + // Test visit() + std::cout << "Tasks:\n"; + taskManager->instances().visit(countInstances); + test(count == 5, "Expected 5 tasks."); + + // Test removal and addition. + didRemove = taskManager->instances().unmanage(t5); + test(didRemove, "Expected to unmanage task 5."); + test(!taskManager->instances().contains(t5), "Expected task 5 to be absent."); + didAdd = taskManager->instances().manage(t5); + test(didAdd, "Expected to manage task 5."); + test(taskManager->instances().contains(t5), "Expected task 5 to be present."); + + taskManager->instances().clear(); + test(!test_task::taskDestroyed, "Task 2 should still be alive while t2 in scope."); + } + test(test_task::taskDestroyed, "Task 2 should be dead once t2 is out of scope."); + + count = 0; + taskManager->instances().visit(countInstances); + test(count == 0, "Expected 0 tasks."); + + return 0; +} diff --git a/smtk/view/AssociationBadge.cxx b/smtk/view/AssociationBadge.cxx index 841eee758bf2ed99bcdebe094f97a183ce2fa4ff..51d555c7d19b43ba593fa400bb4b82f46990c391 100644 --- a/smtk/view/AssociationBadge.cxx +++ b/smtk/view/AssociationBadge.cxx @@ -32,10 +32,7 @@ namespace smtk namespace view { -AssociationBadge::AssociationBadge() - : m_parent(nullptr) -{ -} +AssociationBadge::AssociationBadge() = default; AssociationBadge::AssociationBadge(BadgeSet& parent, const Configuration::Component& config) : m_parent(&parent) diff --git a/smtk/view/AssociationBadge.h b/smtk/view/AssociationBadge.h index f6502c995645b57df5209b5e7a07bf852e75e453..9b7a617e6baf822031828af269a12ad3a055eede 100644 --- a/smtk/view/AssociationBadge.h +++ b/smtk/view/AssociationBadge.h @@ -77,7 +77,7 @@ protected: bool appliesToObject(const smtk::resource::PersistentObjectPtr& obj) const; std::set unmetRequirements(const smtk::resource::PersistentObjectPtr& obj) const; - const BadgeSet* m_parent; + const BadgeSet* m_parent{ nullptr }; std::string m_applyToResource; std::string m_applyToComponent; std::set m_requiredDefinitions; diff --git a/smtk/view/AvailableOperations.cxx b/smtk/view/AvailableOperations.cxx index f319fe5f015f00ba487b69ebf0a1410722f8b476..1dd3d35c831dd3ee2668b6ccbaa4963c72468440 100644 --- a/smtk/view/AvailableOperations.cxx +++ b/smtk/view/AvailableOperations.cxx @@ -24,11 +24,7 @@ using namespace smtk::view; AvailableOperations::AvailableOperations() - : m_selectionMask(1) - , m_selectionExact(true) - , m_useSelection(true) - , m_workflowFilter(nullptr) - + : m_workflowFilter(nullptr) { // For debugging: #if !defined(NDEBUG) && DEBUG_AVAILABLE_OPERATIONS diff --git a/smtk/view/AvailableOperations.h b/smtk/view/AvailableOperations.h index 116f31ef7e358abfa2f364ba7000739172740503..74d65ee62612eeaa9a571bc10ae14f5a5dfd952a 100644 --- a/smtk/view/AvailableOperations.h +++ b/smtk/view/AvailableOperations.h @@ -128,9 +128,9 @@ protected: smtk::operation::MetadataObservers::Key m_operationManagerObserverId; SelectionPtr m_selection; SelectionObservers::Key m_selectionObserverId; - int m_selectionMask; - bool m_selectionExact; - bool m_useSelection; + int m_selectionMask{ 1 }; + bool m_selectionExact{ true }; + bool m_useSelection{ true }; OperationFilterSort m_workflowFilter; smtk::workflow::OperationFilterSort::Observers::Key m_workflowFilterObserverId; OperationIndexSet m_workingSet; diff --git a/smtk/view/Badge.h b/smtk/view/Badge.h index 09ba4703feac8b4831fa2f611acb8ed536093452..9c793d34d850b6906a6fb02e331ef36e63fe3c6f 100644 --- a/smtk/view/Badge.h +++ b/smtk/view/Badge.h @@ -79,10 +79,7 @@ class SMTKCORE_EXPORT Badge : smtkEnableSharedPtr(Badge) { public: smtkTypeMacroBase(Badge); - Badge() - : m_isDefault(false) - { - } + Badge() = default; Badge(const Badge&) = delete; Badge& operator=(const Badge&) = delete; virtual ~Badge() = default; @@ -129,7 +126,7 @@ public: protected: /// Should this badge be invoked by non-specific user gestures when it is applicable? - bool m_isDefault; + bool m_isDefault{ false }; }; } // namespace view } // namespace smtk diff --git a/smtk/view/BadgeSet.h b/smtk/view/BadgeSet.h index 63e3d37b9ac1a8c58c07090ca01d2205cd3c1f9a..186d8a20f360a2bb97a4eeed72b62d16f9add370 100644 --- a/smtk/view/BadgeSet.h +++ b/smtk/view/BadgeSet.h @@ -31,10 +31,7 @@ class SMTKCORE_EXPORT BadgeSet { public: /// Remove this once view::Manager uses the new factory method to construct PhraseModel with arguments. - BadgeSet() - : m_phraseModel(nullptr) - { - } + BadgeSet() = default; /// Construct and configure a set of badges for a view. BadgeSet(const Configuration* viewSpec, const ManagerPtr& manager, PhraseModel* phraseModel) @@ -69,7 +66,7 @@ public: private: std::weak_ptr m_manager; - PhraseModel* m_phraseModel; + PhraseModel* m_phraseModel{ nullptr }; std::vector> m_badges; }; diff --git a/smtk/view/ComponentPhraseContent.cxx b/smtk/view/ComponentPhraseContent.cxx index e03d1a2e0ad82abbef2d6c1c084ba3a881518326..8921f0765b81462d2dd438b3bce09c427f517d49 100644 --- a/smtk/view/ComponentPhraseContent.cxx +++ b/smtk/view/ComponentPhraseContent.cxx @@ -18,6 +18,8 @@ #include "smtk/attribute/IntItem.h" #include "smtk/attribute/StringItem.h" +#include "smtk/graph/Component.h" + #include "smtk/mesh/core/CellSet.h" #include "smtk/mesh/core/Component.h" #include "smtk/mesh/core/MeshSet.h" @@ -27,6 +29,7 @@ #include "smtk/model/EntityRef.h" #include "smtk/operation/Manager.h" +#include "smtk/operation/groups/NamingGroup.h" #include "smtk/operation/operators/SetProperty.h" #include "smtk/resource/Resource.h" @@ -36,10 +39,7 @@ namespace smtk namespace view { -ComponentPhraseContent::ComponentPhraseContent() - : m_mutability(0) -{ -} +ComponentPhraseContent::ComponentPhraseContent() = default; ComponentPhraseContent::~ComponentPhraseContent() = default; @@ -80,8 +80,9 @@ bool ComponentPhraseContent::editable(ContentType contentType) const { auto modelComponent = dynamic_pointer_cast(component); auto meshComponent = dynamic_pointer_cast(component); - // Models and meshes may be assigned a name. - return !!modelComponent || !!meshComponent; + auto graphComponent = dynamic_pointer_cast(component); + // Models, meshes and graphs may be assigned a name. + return !!modelComponent || !!meshComponent || !!graphComponent; } } } @@ -205,30 +206,20 @@ bool ComponentPhraseContent::editStringValue(ContentType contentType, const std: if (contentType == TITLE) { smtk::operation::Operation::Ptr op; - if (auto meshComponent = std::dynamic_pointer_cast(component)) + if (opManager) { - if (opManager) + smtk::operation::NamingGroup nameSetter(opManager); + auto index = nameSetter.matchingOperation(*component); + op = opManager->create(index); + if (op) { - op = opManager->create(); + op->parameters()->findString("name")->setValue(val); } - if (!op) - { - op = smtk::mesh::SetMeshName::create(); - } - - op->parameters()->findString("name")->setValue(val); } - else + if (!op) { - if (opManager) - { - op = opManager->create(); - } - if (!op) - { - op = smtk::operation::SetProperty::create(); - } - + // Todo: Use component setName if no operation provided + op = smtk::operation::SetProperty::create(); op->parameters()->findString("name")->setValue("name"); op->parameters()->findString("string value")->appendValue(val); } diff --git a/smtk/view/ComponentPhraseContent.h b/smtk/view/ComponentPhraseContent.h index 3ed1894642b1f1a361ce68d94f7f395098dc842e..c486ed13b19917b23e64ba72d8dbac222feb4fe7 100644 --- a/smtk/view/ComponentPhraseContent.h +++ b/smtk/view/ComponentPhraseContent.h @@ -62,7 +62,7 @@ protected: ComponentPhraseContent(); std::weak_ptr m_component; - int m_mutability; + int m_mutability{ 0 }; }; } // namespace view diff --git a/smtk/view/DefaultOperationIcon.h b/smtk/view/DefaultOperationIcon.h index f40e746ee3e30e4adcde0d4475177cf6fb049385..152eb41315c9b2535051e357caddf8f17b3da33e 100644 --- a/smtk/view/DefaultOperationIcon.h +++ b/smtk/view/DefaultOperationIcon.h @@ -23,7 +23,7 @@ namespace smtk namespace view { -std::string SMTKCORE_EXPORT DefaultOperationIcon(const std::string& secondaryColor) +inline std::string SMTKCORE_EXPORT DefaultOperationIcon(const std::string& secondaryColor) { std::string svg = default_operation_opt_svg; std::array rgba; diff --git a/smtk/view/DescriptivePhrase.cxx b/smtk/view/DescriptivePhrase.cxx index 55118b57d1a9dba3a4fdc1e12c3bedf625a018b6..14ffad68288fc06648cc7f22a419e5ae6c30e314 100644 --- a/smtk/view/DescriptivePhrase.cxx +++ b/smtk/view/DescriptivePhrase.cxx @@ -31,8 +31,6 @@ namespace view unsigned int DescriptivePhrase::s_nextPhraseId = 0; DescriptivePhrase::DescriptivePhrase() - : m_type(DescriptivePhraseType::INVALID_DESCRIPTION) - , m_subphrasesBuilt(false) { m_phraseId = DescriptivePhrase::s_nextPhraseId++; } diff --git a/smtk/view/DescriptivePhrase.h b/smtk/view/DescriptivePhrase.h index 8dfcf2a6dbf24a958eb03949fc6cf9c8ecb9e53a..d8263aa69c17d00ed7e6599101384c8492225c5f 100644 --- a/smtk/view/DescriptivePhrase.h +++ b/smtk/view/DescriptivePhrase.h @@ -356,12 +356,12 @@ protected: int visitChildrenInternal(Visitor fn, std::vector& indices); WeakDescriptivePhrasePtr m_parent; - DescriptivePhraseType m_type; + DescriptivePhraseType m_type{ DescriptivePhraseType::INVALID_DESCRIPTION }; SubphraseGeneratorPtr m_delegate; PhraseContentPtr m_content; unsigned int m_phraseId; mutable DescriptivePhrases m_subphrases; - mutable bool m_subphrasesBuilt; + mutable bool m_subphrasesBuilt{ false }; private: static unsigned int s_nextPhraseId; diff --git a/smtk/view/ObjectIconBadge.cxx b/smtk/view/ObjectIconBadge.cxx index dcad956fff5d0f67666629339c461972d38c34e0..0726035e2bea0c4477361e0a96f7362d14432614 100644 --- a/smtk/view/ObjectIconBadge.cxx +++ b/smtk/view/ObjectIconBadge.cxx @@ -22,10 +22,7 @@ namespace smtk namespace view { -ObjectIconBadge::ObjectIconBadge() - : m_parent(nullptr) -{ -} +ObjectIconBadge::ObjectIconBadge() = default; ObjectIconBadge::ObjectIconBadge(BadgeSet& parent, const Configuration::Component&) : m_parent(&parent) diff --git a/smtk/view/ObjectIconBadge.h b/smtk/view/ObjectIconBadge.h index 5a477dd37c0779ac474687607de204b6f7a18ea9..036711524ae91e219ae4ca2175974a3cef49d43a 100644 --- a/smtk/view/ObjectIconBadge.h +++ b/smtk/view/ObjectIconBadge.h @@ -49,7 +49,7 @@ public: // void action(const DescriptivePhrase* phrase) const override { } protected: - const BadgeSet* m_parent; + const BadgeSet* m_parent{ nullptr }; }; } // namespace view } // namespace smtk diff --git a/smtk/view/PhraseListContent.cxx b/smtk/view/PhraseListContent.cxx index b9ee2b0a5214fb1eb3888e99a96b2f8f9bcaf135..97fa73893289a9a0b0da095c079cdc094596423c 100644 --- a/smtk/view/PhraseListContent.cxx +++ b/smtk/view/PhraseListContent.cxx @@ -20,13 +20,8 @@ namespace smtk namespace view { -PhraseListContent::PhraseListContent() - : m_mutability(0) - , m_commonFlags(smtk::model::INVALID) - , m_unionFlags(0) -{ - // only color is mutable -} +// only color is mutable +PhraseListContent::PhraseListContent() = default; PhraseListContent::Ptr PhraseListContent::setup( DescriptivePhrase::Ptr parent, diff --git a/smtk/view/PhraseListContent.h b/smtk/view/PhraseListContent.h index e4ae45480149f271dfd566a53e2760f8f33a5799..b90f5f174877aabde87db7eba39e9e7dbb3ebcc6 100644 --- a/smtk/view/PhraseListContent.h +++ b/smtk/view/PhraseListContent.h @@ -132,9 +132,9 @@ protected: std::string generateTitle(smtk::model::BitFlags& flagCommon, smtk::model::BitFlags& flagUnion) const; - int m_mutability; - mutable smtk::model::BitFlags m_commonFlags; - mutable smtk::model::BitFlags m_unionFlags; + int m_mutability{ 0 }; + mutable smtk::model::BitFlags m_commonFlags{ smtk::model::INVALID }; + mutable smtk::model::BitFlags m_unionFlags{ 0 }; mutable std::string m_title; }; diff --git a/smtk/view/PhraseModel.cxx b/smtk/view/PhraseModel.cxx index 676faa58941014a2897af6902b8204daa56d7a66..80e6aa2458fbea7be8d9d5711ad78a057d291d0d 100644 --- a/smtk/view/PhraseModel.cxx +++ b/smtk/view/PhraseModel.cxx @@ -34,37 +34,6 @@ namespace view namespace { -// Sort paths from deepest to shallowest, then rear-most to front-most. -// Doing these things keeps us from invalidating paths when items are removed. -struct PathComp -{ - bool operator()(const std::vector& a, const std::vector& b) const - { - if (a.size() < b.size()) - { - return false; - } - else if (a.size() > b.size()) - { - return true; - } - std::size_t ii = 0; - for (auto ai : a) - { - if (ai < b[ii]) - { - return false; - } - else if (ai > b[ii]) - { - return true; - } - ++ii; - } - return false; // a == b... neither is less than other. - } -}; - void notifyRecursive( PhraseModel::Observer obs, DescriptivePhrasePtr parent, @@ -96,10 +65,6 @@ void notify(PhraseModel::Observer obs, DescriptivePhrasePtr parent) } } // namespace -class PhraseDeltas : public std::set, PathComp> -{ -}; - // Returns the operation manager - right now it assumes the first source // TODO: figure out the proper behavior when there is more // than one source @@ -114,14 +79,12 @@ smtk::operation::ManagerPtr PhraseModel::operationManager() const PhraseModel::PhraseModel() : m_observers(std::bind(notify, std::placeholders::_1, this->root())) - , m_mutableAspects(PhraseContent::EVERYTHING) { } PhraseModel::PhraseModel(const Configuration* config, Manager* manager) : m_observers(std::bind(notify, std::placeholders::_1, this->root())) , m_badges(config, manager->shared_from_this(), this) - , m_mutableAspects(PhraseContent::EVERYTHING) , m_manager(manager->shared_from_this()) { } @@ -198,69 +161,6 @@ std::multimap PhraseModel::configureFilterStrings( return result; } -bool PhraseModel::addSource( - smtk::resource::ManagerPtr rsrcMgr, - smtk::operation::ManagerPtr operMgr, - smtk::view::ManagerPtr viewMgr, - smtk::view::SelectionPtr seln) -{ - for (const auto& source : m_sources) - { - if ( - ((!rsrcMgr && !source.m_managers.contains()) || - (source.m_managers.contains() && - source.m_managers.get() == rsrcMgr)) && - ((!operMgr && !source.m_managers.contains()) || - (source.m_managers.contains() && - source.m_managers.get() == operMgr)) && - ((!viewMgr && !source.m_managers.contains()) || - (source.m_managers.contains() && - source.m_managers.get() == viewMgr)) && - ((!seln && !source.m_managers.contains()) || - (source.m_managers.contains() && - source.m_managers.get() == seln))) - { - return false; // Do not add what we already have - } - } - std::ostringstream description; - description << "PhraseModel " << this << ": "; - auto rsrcHandle = rsrcMgr ? rsrcMgr->observers().insert( - [this](const Resource& rsrc, const resource::EventType& event) { - this->handleResourceEvent(rsrc, event); - return 0; - }, - 0, // assign a neutral priority - true, // observeImmediately - description.str() + "Update phrases when resources change.") - : smtk::resource::Observers::Key(); - auto operHandle = operMgr - ? operMgr->observers().insert( - [this](const Operation& op, operation::EventType event, const Operation::Result& res) { - this->handleOperationEvent(op, event, res); - return 0; - }, - description.str() + "Update phrases based on operation results.") - : smtk::operation::Observers::Key(); - auto selnHandle = seln ? seln->observers().insert( - [this](const std::string& src, smtk::view::SelectionPtr seln) { - this->handleSelectionEvent(src, seln); - }, - 0, // assign a neutral priority - true, // observeImmediately - description.str() + "Update phrases when selection changes.") - : smtk::view::SelectionObservers::Key(); - m_sources.emplace_back( - rsrcMgr, - operMgr, - viewMgr, - seln, - std::move(rsrcHandle), - std::move(operHandle), - std::move(selnHandle)); - return true; -} - bool PhraseModel::addSource(const smtk::common::TypeContainer& managers) { const auto& rsrcMgr = @@ -327,27 +227,6 @@ bool PhraseModel::addSource(const smtk::common::TypeContainer& managers) return true; } -bool PhraseModel::removeSource( - smtk::resource::ManagerPtr rsrcMgr, - smtk::operation::ManagerPtr operMgr, - smtk::view::ManagerPtr viewMgr, - smtk::view::SelectionPtr seln) -{ - for (auto it = m_sources.begin(); it != m_sources.end(); ++it) - { - if ( - it->m_managers.get() == rsrcMgr && - it->m_managers.get() == operMgr && - it->m_managers.get() == viewMgr && - it->m_managers.get() == seln) - { - m_sources.erase(it); - return true; - } - } - return false; -} - bool PhraseModel::removeSource(const smtk::common::TypeContainer& managers) { const auto& rsrcMgr = diff --git a/smtk/view/PhraseModel.h b/smtk/view/PhraseModel.h index a898bc2303c9a3b12c31f5f085c4c84e62a2fd76..8850fa8e2206d2a3790cfec77fdf8b89ab2741a5 100644 --- a/smtk/view/PhraseModel.h +++ b/smtk/view/PhraseModel.h @@ -17,6 +17,7 @@ #include "smtk/common/TypeContainer.h" #include "smtk/view/BadgeSet.h" +#include "smtk/view/PhraseContent.h" #include "smtk/view/PhraseModelObserver.h" #include "smtk/view/Selection.h" @@ -35,6 +36,41 @@ namespace smtk namespace view { +// Sort paths from deepest to shallowest, then rear-most to front-most. +// Doing these things keeps us from invalidating paths when items are removed. +struct PathComp +{ + bool operator()(const std::vector& a, const std::vector& b) const + { + if (a.size() < b.size()) + { + return false; + } + else if (a.size() > b.size()) + { + return true; + } + std::size_t ii = 0; + for (auto ai : a) + { + if (ai < b[ii]) + { + return false; + } + else if (ai > b[ii]) + { + return true; + } + ++ii; + } + return false; // a == b... neither is less than other. + } +}; + +class PhraseDeltas : public std::set, PathComp> +{ +}; + /**\brief Hold and maintain a descriptive phrase hierarchy. * * This class holds the root descriptive phrase in a hierarchy and @@ -97,21 +133,9 @@ public: * the phrase hierarcy as required. */ ///@{ - /// Indicate a resource and operation manager that should be monitored for changes. - [[deprecated("PhraseModel::addSource now accepts const smtk::common::TypeContainer&")]] bool - addSource( - smtk::resource::ManagerPtr rsrcMgr, - smtk::operation::ManagerPtr operMgr, - smtk::view::ManagerPtr viewMgr, - smtk::view::SelectionPtr seln); + /// Indicate the managers that should be monitored for changes. virtual bool addSource(const smtk::common::TypeContainer& managers); - /// Indicate a resource and operation manager that should no longer be monitored for changes. - [[deprecated("PhraseModel::removeSource now accepts const smtk::common::TypeContainer&")]] bool - removeSource( - smtk::resource::ManagerPtr rsrcMgr, - smtk::operation::ManagerPtr operMgr, - smtk::view::ManagerPtr viewMgr, - smtk::view::SelectionPtr seln); + /// Indicate managers that should no longer be monitored for changes. virtual bool removeSource(const smtk::common::TypeContainer& managers); /// Stop listening for changes from all sources. virtual bool resetSources(); @@ -273,7 +297,7 @@ protected: BadgeSet m_badges; - int m_mutableAspects; + int m_mutableAspects{ PhraseContent::EVERYTHING }; WeakManagerPtr m_manager; }; diff --git a/smtk/view/ResourcePhraseContent.cxx b/smtk/view/ResourcePhraseContent.cxx index 89d10f2af11fb74cf954aa34b88ee396d1bd77d6..e990a9330f2f4b3e1649e88fdb101eb7c39ffcbc 100644 --- a/smtk/view/ResourcePhraseContent.cxx +++ b/smtk/view/ResourcePhraseContent.cxx @@ -27,10 +27,7 @@ namespace smtk namespace view { -ResourcePhraseContent::ResourcePhraseContent() - : m_mutability(0) -{ -} +ResourcePhraseContent::ResourcePhraseContent() = default; ResourcePhraseContent::~ResourcePhraseContent() = default; diff --git a/smtk/view/ResourcePhraseContent.h b/smtk/view/ResourcePhraseContent.h index 4a477281236a0893836fc430f25c47459eb681e0..e8206c681b82af9fdcc5675bcf3df0b30fbaf487 100644 --- a/smtk/view/ResourcePhraseContent.h +++ b/smtk/view/ResourcePhraseContent.h @@ -64,7 +64,7 @@ protected: ResourcePhraseContent(); std::weak_ptr m_resource; - int m_mutability; + int m_mutability{ 0 }; }; } // namespace view diff --git a/smtk/view/ResourcePhraseModel.cxx b/smtk/view/ResourcePhraseModel.cxx index 24c922b91ff3648424bf6b58fd9653ffb7df4f61..779e9096da618da297ec1a4fa3bf13d0828133ff 100644 --- a/smtk/view/ResourcePhraseModel.cxx +++ b/smtk/view/ResourcePhraseModel.cxx @@ -73,7 +73,7 @@ bool ResourcePhraseModel::setResourceFilters( const std::multimap& resourceFilters) { auto filter = [resourceFilters](const smtk::resource::Resource& resource) -> bool { - bool acceptable = false; + bool acceptable = resourceFilters.empty(); for (const auto& filter : resourceFilters) { if (resource.isOfType(filter.first)) @@ -82,7 +82,7 @@ bool ResourcePhraseModel::setResourceFilters( break; } } - return !acceptable; + return acceptable; }; return setFilter(filter); } diff --git a/smtk/view/Selection.cxx b/smtk/view/Selection.cxx index bf8a96b0d153f5f007c2110136c863596472c3c9..b9be39742dcde805e7ce002da1c55be767cd98f2 100644 --- a/smtk/view/Selection.cxx +++ b/smtk/view/Selection.cxx @@ -35,8 +35,7 @@ static bool defaultFilter( static Selection* g_instance = nullptr; Selection::Selection() - : m_defaultAction(SelectionAction::FILTERED_REPLACE) - , m_observers( + : m_observers( [this](Selection::Observer& fn) { fn(g_selectionManagerSource, this->shared_from_this()); }) , m_filter(defaultFilter) { diff --git a/smtk/view/Selection.h b/smtk/view/Selection.h index fee7e5797ca958028476b3d477e8a8f5a1595aa9..6b82006eeace41f3190bdd41a3a4fa48db199f46 100644 --- a/smtk/view/Selection.h +++ b/smtk/view/Selection.h @@ -339,7 +339,7 @@ protected: bool bitwise); bool refilter(const std::string& source); - SelectionAction m_defaultAction; + SelectionAction m_defaultAction{ SelectionAction::FILTERED_REPLACE }; //smtk::model::BitFlags m_modelEntityMask; bool m_meshSetMask; std::set m_selectionSources; diff --git a/smtk/view/SelectionPhraseModel.cxx b/smtk/view/SelectionPhraseModel.cxx index f99d45ff9acd33201775c72971553e73d5828fa1..c72c4c86d313ac410759e41ff078e117a8f683ba 100644 --- a/smtk/view/SelectionPhraseModel.cxx +++ b/smtk/view/SelectionPhraseModel.cxx @@ -32,8 +32,6 @@ using namespace smtk::view; SelectionPhraseModel::SelectionPhraseModel() : m_root(DescriptivePhrase::create()) , m_selectionBit(~0) - , m_componentMutability(0) - , m_resourceMutability(0) { // By default, do not show children of selected objects. auto generator = smtk::view::EmptySubphraseGenerator::create(); @@ -44,8 +42,6 @@ SelectionPhraseModel::SelectionPhraseModel(const Configuration* config, Manager* : Superclass(config, manager) , m_root(DescriptivePhrase::create()) , m_selectionBit(~0) - , m_componentMutability(0) - , m_resourceMutability(0) { auto generator = PhraseModel::configureSubphraseGenerator(config, manager); m_root->setDelegate(generator); diff --git a/smtk/view/SelectionPhraseModel.h b/smtk/view/SelectionPhraseModel.h index 3c4976d2cce23d9b30adf8841395bfa6d6f65cbd..79071b8647242d6310715e73af34e932399a8a18 100644 --- a/smtk/view/SelectionPhraseModel.h +++ b/smtk/view/SelectionPhraseModel.h @@ -50,8 +50,8 @@ protected: smtk::view::DescriptivePhrasePtr m_root; smtk::view::SelectionPtr m_selection; int m_selectionBit; - int m_componentMutability; - int m_resourceMutability; + int m_componentMutability{ 0 }; + int m_resourceMutability{ 0 }; }; } // namespace view } // namespace smtk diff --git a/smtk/view/SubphraseGenerator.cxx b/smtk/view/SubphraseGenerator.cxx index cd29d8b6d229a6ed29d63478d5063b447bfdd1ae..d58047283dbc1aa94022ae86d49346ec63089317 100644 --- a/smtk/view/SubphraseGenerator.cxx +++ b/smtk/view/SubphraseGenerator.cxx @@ -219,7 +219,8 @@ void SubphraseGenerator::subphrasesForCreatedObjects( for (const auto& obj : objects) { DescriptivePhrasePtr actualParent(parent); - Path childPath = this->indexOfObjectInParent(obj, actualParent, parentPath); + Path childPath = + actualParent->findDelegate()->indexOfObjectInParent(obj, actualParent, parentPath); if (childPath.empty()) { continue; @@ -248,31 +249,6 @@ void SubphraseGenerator::subphrasesForCreatedObjects( } return 0; // 0 => continue iterating, 1 => skip children of parent, 2 => terminate }); - - smtk::attribute::AttributePtr attr; - smtk::model::EntityPtr ment; - smtk::mesh::ComponentPtr mcmp; - for (const auto& obj : objects) - { - auto comp = obj->as(); - if (!comp) - { - continue; - } - - int rsrcIdx = this->findResourceLocation(comp->resource(), localRoot); - if (rsrcIdx < 0) - { - continue; - } - - Path path{ rsrcIdx, -1 }; - - DescriptivePhrasePtr parent = localRoot->subphrases()[rsrcIdx]; - DescriptivePhrasePtr phr; - } - /* - */ } int SubphraseGenerator::directLimit() const diff --git a/smtk/view/pybind11/PybindDescriptivePhrase.h b/smtk/view/pybind11/PybindDescriptivePhrase.h index 53e91ada89c672482daa7c789b472e171eee2945..6b66a473b34ae16e57e8659400b0003f9b9289f5 100644 --- a/smtk/view/pybind11/PybindDescriptivePhrase.h +++ b/smtk/view/pybind11/PybindDescriptivePhrase.h @@ -24,7 +24,7 @@ namespace py = pybind11; -void pybind11_init_smtk_view_DescriptivePhraseType(py::module &m) +inline void pybind11_init_smtk_view_DescriptivePhraseType(py::module &m) { py::enum_(m, "DescriptivePhraseType") .value("RESOURCE_LIST", smtk::view::DescriptivePhraseType::RESOURCE_LIST) @@ -39,7 +39,7 @@ void pybind11_init_smtk_view_DescriptivePhraseType(py::module &m) .export_values(); } -PySharedPtrClass< smtk::view::DescriptivePhrase > pybind11_init_smtk_view_DescriptivePhrase(py::module &m) +inline PySharedPtrClass< smtk::view::DescriptivePhrase > pybind11_init_smtk_view_DescriptivePhrase(py::module &m) { PySharedPtrClass< smtk::view::DescriptivePhrase > instance(m, "DescriptivePhrase"); instance diff --git a/smtk/view/pybind11/PybindSelection.h b/smtk/view/pybind11/PybindSelection.h index 3fd650abdd8dd01bbd9ef083a552cf00c56e810e..4a1acf7c80612d01d0357b992511a4310bfc07a0 100644 --- a/smtk/view/pybind11/PybindSelection.h +++ b/smtk/view/pybind11/PybindSelection.h @@ -27,7 +27,7 @@ SMTK_THIRDPARTY_POST_INCLUDE namespace py = pybind11; -void pybind11_init_smtk_view_SelectionAction(py::module &m) +inline void pybind11_init_smtk_view_SelectionAction(py::module &m) { py::enum_(m, "SelectionAction") .value("FILTERED_REPLACE", smtk::view::SelectionAction::FILTERED_REPLACE) @@ -40,7 +40,7 @@ void pybind11_init_smtk_view_SelectionAction(py::module &m) .export_values(); } -PySharedPtrClass< smtk::view::Selection > pybind11_init_smtk_view_Selection(py::module &m) +inline PySharedPtrClass< smtk::view::Selection > pybind11_init_smtk_view_Selection(py::module &m) { PySharedPtrClass< smtk::view::Selection > instance(m, "Selection"); instance diff --git a/smtk/view/pybind11/PybindSelectionObserver.h b/smtk/view/pybind11/PybindSelectionObserver.h index 7c02995640101cf5a87658a461cb8215a92aa743..4b76ff59e79d0557d71f6a026014a7ded2480607 100644 --- a/smtk/view/pybind11/PybindSelectionObserver.h +++ b/smtk/view/pybind11/PybindSelectionObserver.h @@ -19,7 +19,7 @@ namespace py = pybind11; -py::class_< smtk::view::SelectionObservers > pybind11_init_smtk_view_SelectionObservers(py::module &m) +inline py::class_< smtk::view::SelectionObservers > pybind11_init_smtk_view_SelectionObservers(py::module &m) { py::class_< smtk::view::SelectionObservers > instance(m, "SelectionObservers"); instance diff --git a/smtk/view/pybind11/PybindSubphraseGenerator.h b/smtk/view/pybind11/PybindSubphraseGenerator.h index f829571582323b4840dd15bfbf188348f0457ab4..fa10c2539f923f7df16c6a0212543941d7b7261b 100644 --- a/smtk/view/pybind11/PybindSubphraseGenerator.h +++ b/smtk/view/pybind11/PybindSubphraseGenerator.h @@ -19,7 +19,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::view::SubphraseGenerator > pybind11_init_smtk_view_SubphraseGenerator(py::module &m) +inline PySharedPtrClass< smtk::view::SubphraseGenerator > pybind11_init_smtk_view_SubphraseGenerator(py::module &m) { PySharedPtrClass< smtk::view::SubphraseGenerator > instance(m, "SubphraseGenerator"); instance diff --git a/smtk/view/pybind11/PybindView.h b/smtk/view/pybind11/PybindView.h index 9d8d456e25a332b4a91eaa0ac57a27241c15b1f4..6b7ab293238c9ccac09d4f6b075bcb318045872f 100644 --- a/smtk/view/pybind11/PybindView.h +++ b/smtk/view/pybind11/PybindView.h @@ -17,7 +17,7 @@ namespace py = pybind11; -PySharedPtrClass< smtk::view::Configuration > pybind11_init_smtk_view_View(py::module &m) +inline PySharedPtrClass< smtk::view::Configuration > pybind11_init_smtk_view_View(py::module &m) { PySharedPtrClass< smtk::view::Configuration > instance(m, "View"); instance diff --git a/smtk/view/testing/cxx/CMakeLists.txt b/smtk/view/testing/cxx/CMakeLists.txt index 62c4a711a8dfd756da0c95d4a7b7985232646cd9..d5b0856006290730c944405a110a8af97af95f58 100644 --- a/smtk/view/testing/cxx/CMakeLists.txt +++ b/smtk/view/testing/cxx/CMakeLists.txt @@ -17,7 +17,7 @@ set(helper_srcs if (SMTK_ENABLE_POLYGON_SESSION) smtk_unit_tests( - Label "View" + LABEL "View" SOURCES ${unit_tests} SOURCES_REQUIRE_DATA ${unit_tests_which_require_data} EXTRA_SOURCES ${helper_srcs} diff --git a/smtk/view/testing/cxx/unitBadge.cxx b/smtk/view/testing/cxx/unitBadge.cxx index d693abb20652a48ad2a2022f1d1f7629f88d4fce..99857d3a50d7295913ca2e1c028c7a2e073d5e02 100644 --- a/smtk/view/testing/cxx/unitBadge.cxx +++ b/smtk/view/testing/cxx/unitBadge.cxx @@ -27,6 +27,8 @@ #include "smtk/io/Logger.h" +#include "smtk/plugin/Registry.h" + #include "smtk/view/json/jsonView.h" #include "smtk/common/testing/cxx/helpers.h" @@ -154,7 +156,7 @@ int unitBadge(int argc, char* argv[]) // badgeSet.configure(viewConfig, viewManager); auto resource = phraseModel->root()->subphrases()[0]->relatedResource(); auto resourceManager = resource->manager(); - smtk::attribute::Registrar::registerTo(resourceManager); + auto registry = smtk::plugin::addToManagers(resourceManager); auto attRsrc = resourceManager->create(); auto defBC = attRsrc->createDefinition("BoundaryCondition"); auto assoc = defBC->createLocalAssociationRule(); diff --git a/smtk/view/testing/cxx/unitOperationIcon.cxx b/smtk/view/testing/cxx/unitOperationIcon.cxx index 8e2ee4910914a20f204e1d660aa881e17afa99ac..fde1de7ee9b938441ca614eb2e243320e81b1236 100644 --- a/smtk/view/testing/cxx/unitOperationIcon.cxx +++ b/smtk/view/testing/cxx/unitOperationIcon.cxx @@ -21,6 +21,8 @@ #include "smtk/operation/Metadata.h" #include "smtk/operation/MetadataContainer.h" +#include "smtk/plugin/Registry.h" + #include "smtk/io/Logger.h" #include "smtk/common/testing/cxx/helpers.h" @@ -32,9 +34,9 @@ int unitOperationIcon(int, char*[]) auto viewManager = smtk::view::Manager::create(); auto resourceManager = smtk::resource::Manager::create(); auto operationManager = smtk::operation::Manager::create(); - smtk::attribute::Registrar::registerTo(resourceManager); - smtk::attribute::Registrar::registerTo(operationManager); - smtk::view::Registrar::registerTo(viewManager); + auto attributeRegistry = + smtk::plugin::addToManagers(resourceManager, operationManager); + auto viewRegistry = smtk::plugin::addToManagers(viewManager); std::string color = "dark"; // Create some "icon constructor" functors that really just increment counters: diff --git a/smtk/view/testing/cxx/unitPhraseModel.cxx b/smtk/view/testing/cxx/unitPhraseModel.cxx index 2d90e40662876aa5cfefd7e12da037073361b32a..1890287da33102dcf63c5ac1de4d40561a647ed0 100644 --- a/smtk/view/testing/cxx/unitPhraseModel.cxx +++ b/smtk/view/testing/cxx/unitPhraseModel.cxx @@ -21,6 +21,8 @@ #include "smtk/model/SessionRef.h" +#include "smtk/plugin/Registry.h" + #include "smtk/operation/Manager.h" #include "smtk/resource/Manager.h" @@ -213,7 +215,7 @@ int unitPhraseModel(int argc, char* argv[]) { { { "Name", "SubphraseGenerator" }, { "Attributes", { { "Type", "default" } } } } } } } } } } } }; auto viewManager = smtk::view::Manager::create(); - smtk::view::Registrar::registerTo(viewManager); + auto registry = smtk::plugin::addToManagers(viewManager); viewManager->phraseModelFactory().registerType(); smtk::view::ConfigurationPtr viewConfig = j; auto phraseModel = viewManager->phraseModelFactory().createFromConfiguration(viewConfig.get()); diff --git a/smtk/view/testing/cxx/utility.cxx b/smtk/view/testing/cxx/utility.cxx index 4fcdbf8557e08420914ccac6729c864581103715..892b1deb8e71714ac080b2b9189b3bbd3f6b27ae 100644 --- a/smtk/view/testing/cxx/utility.cxx +++ b/smtk/view/testing/cxx/utility.cxx @@ -64,10 +64,9 @@ PhraseModel::Ptr loadTestData( auto operMgr = smtk::operation::Manager::create(); operMgr->registerResourceManager(rsrcMgr); - auto registry = smtk::plugin:: - Registry( - rsrcMgr, operMgr); - smtk::view::Registrar::registerTo(viewManager); + auto polygonRegistry = + smtk::plugin::addToManagers(rsrcMgr, operMgr); + auto viewRegistry = smtk::plugin::addToManagers(viewManager); auto phraseModel = viewManager->phraseModelFactory().createFromConfiguration(&viewConfig); // auto phraseModel = smtk::view::ResourcePhraseModel::create(); phraseModel->addSource({ rsrcMgr, operMgr }); diff --git a/smtk/workflow/testing/cxx/CMakeLists.txt b/smtk/workflow/testing/cxx/CMakeLists.txt index a4a1e434e30f32835e0dbfc536ff45f861368c84..5dab0340e88ed8f23a60093ae30d04b10d235e8f 100644 --- a/smtk/workflow/testing/cxx/CMakeLists.txt +++ b/smtk/workflow/testing/cxx/CMakeLists.txt @@ -7,7 +7,7 @@ set(unit_tests_which_require_data if (SMTK_ENABLE_POLYGON_SESSION) smtk_unit_tests( - Label "workflow" + LABEL "Workflow" SOURCES ${unit_tests} SOURCES_REQUIRE_DATA ${unit_tests_which_require_data} LIBRARIES diff --git a/utilities/python/cpp_to_pybind11.py b/utilities/python/cpp_to_pybind11.py index 35dc23558621e9d35b28ef0f5479b99140a68a5a..dc2ad1053369afcb6fed04a4b07bc6c3c3f4e83a 100644 --- a/utilities/python/cpp_to_pybind11.py +++ b/utilities/python/cpp_to_pybind11.py @@ -339,7 +339,7 @@ def parse_free_enumeration(enum, stream): Write bindings for a free enumeration """ init_function_name = "pybind11_init_" + mangled_name(enum) - stream("void %s(py::module &m)" % init_function_name) + stream("inline void %s(py::module &m)" % init_function_name) stream("{") full_enum_name = full_class_name(enum) stream(" py::enum_<%s>(m, \"%s\")" % @@ -358,7 +358,7 @@ def parse_free_function(func, overloaded, stream): """ init_function_name = "pybind11_init_" + \ (func.mangled if overloaded else mangled_name(func)) - stream("void %s(py::module &m)" % init_function_name) + stream("inline void %s(py::module &m)" % init_function_name) stream("{") if overloaded: stream(" m.def(\"%s\", (%s (*)(%s)) &%s, \"\", %s);" % @@ -409,8 +409,8 @@ def parse_class(class_, stream, top_level=True): init_function_name = "pybind11_init_" + mangled_name(class_) if top_level: - stream("%s %s(py::module &m)" % (bind_class_name(class_), - init_function_name)) + stream("inline %s %s(py::module &m)" % (bind_class_name(class_), + init_function_name)) stream("{") stream(" %s instance(m, \"%s\");" % (bind_class_name(class_), diff --git a/version.txt b/version.txt index 2b2dbfd3c88f7c72f61b2160ae0514e299de64b9..16406cd4a7122de27ee90b9bd92eb168edf50afb 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -21.05.0 +21.07.0